Constructor
new TCP()
Properties| Name | Type | Description | 
|---|---|---|
| src | number | Source TCP port. | 
| dst | number | Destination TCP port. | 
| seq | number | Sequence number. | 
| ack | number | Acknowledgment number. | 
| windowSize | number | The size of the receive window, which specifies the number of window size units (by default, bytes). | 
| checksum | number | The 16-bit checksum field is used for error-checking of the header and data. | 
| urgentPointer | number | If the URG flag is set, then this 16-bit field is an offset from the sequence number indicating the last urgent data byte. | 
| flags | TCPFlags | TCP flags. | 
- Implements
- Source
Members
flags :TCPFlags
Get the flags object. Changes to this object will update the associated buffer.
Type:
- Source
length :number
Number of bytes occupied by the layer.
Type:
- number
- Implements
- Source
options :Iterable.<TLVOption>
TLV options;
Type:
- Iterable.<TLVOption>
- Source
osi :OsiModelLayers
Respective protocol OSI layer.
Type:
- Implements
- Source
Methods
calculateChecksum()
Calculates and updates the checksum for the TCP layer. This method mutates the object by setting the `checksum` property based on the current state of the `buffer` and `prev` field.
- Source
toObject() → {Object}
Retrieves all fields of the TCP layer.
- Implements
- Source
Returns:
The TCP layer fields as an object.
- Type:
- Object
Example
tcp.toObject();
// {
//   src: 52622,
//   dst: 24043,
//   seq: 3994458414,
//   ack: 3198720281,
//   dataOffset: 8,
//   windowSize: 2048,
//   checksum: 3346,
//   urgentPointer: 0,
//   flags: {
//     reserved: 0,
//     cwr: 0,
//     ece: 0,
//     urg: 0,
//     ack: 1,
//     psh: 0,
//     rst: 0,
//     syn: 0,
//     fin: 0
//   },
//   options: [
//     { type: 1 },
//     { type: 1 },
//     { type: 8, recLength: 10, value: Buffer.from([0x52, 0xd3, 0xc6, 0x50, 0xdd, 0x04, 0xcd, 0xd6]) }
//   ],
// }