UDP

UDP protocol layer

Constructor

new UDP()

Properties
NameTypeDescription
srcnumberSource UDP port.
dstnumberDestination UDP port.
totalLengthnumberThis field specifies the length in bytes of the UDP datagram (the header fields and Data field) in octets.
checksumnumberThe 16-bit checksum field is used for error-checking of the header and data.
Implements

Members

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 UDP 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 UDP layer.
Implements
Returns:
The UDP layer fields as an object.
Type: 
Object
Example
udp.toObject();
// {
//   src: 52622,
//   dst: 24043,
//   seq: 3994458414,
//   totalLength: 2048,
//   checksum: 3346,
// }