TCP

TCP protocol layer

Constructor

new TCP()

Properties
NameTypeDescription
srcnumberSource TCP port.
dstnumberDestination TCP port.
seqnumberSequence number.
acknumberAcknowledgment number.
windowSizenumberThe size of the receive window, which specifies the number of window size units (by default, bytes).
checksumnumberThe 16-bit checksum field is used for error-checking of the header and data.
urgentPointernumberIf the URG flag is set, then this 16-bit field is an offset from the sequence number indicating the last urgent data byte.
flagsTCPFlagsTCP flags.
Implements

Members

flags :TCPFlags

Get the flags object. Changes to this object will update the associated buffer.

length :number

Number of bytes occupied by the layer.
Type:
  • number
Implements

options :Iterable.<TLVOption>

TLV options;
Type:

osi :OsiModelLayers

Respective protocol OSI layer.
Implements

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.

toObject() → {Object}

Retrieves all fields of the TCP layer.
Implements
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]) }
//   ],
// }