Constructor
new IPv4(data, opts)
Parameters:
PropertiesName | Type | Description |
---|---|---|
data | Buffer | | Input buffer or object with protocol fields. |
opts | Object | Options for the layer. |
Name | Type | Description |
---|---|---|
headerLength | number | IP header length, has the value of 5 for IPv4. |
version | number | IP version number, has the value of 4 for IPv4. |
typeOfService | number | type of service, same as Differentiated Services Code Point (DSCP) |
totalLength | number | Entire packet (fragment) size, including header and data, in bytes |
id | number | Identification field. Primarily used for uniquely identifying the group of fragments of a single IP datagram |
fragmentOffsetRaw | number | Fragment offset field, measured in units of eight-byte blocks (64 bits) @LE |
timeToLive | number | An eight-bit time to live field helps prevent datagrams from persisting (e.g. going in circles) on an internet. In practice, the field has become a hop count |
protocol | number | Defines the protocol used in the data portion of the IP datagram. Must be one of ::IPProtocolTypes |
checksum | number | Error-checking of the header |
src | string | IPv4 address of the sender of the packet |
dst | string | IPv4 address of the receiver of the packet |
- Source
Members
dst :string
The destination IP address in human-readable format.
Type:
- string
- Source
fragmentOffsetFlags :number
Type:
- number
- Source
fragmentOffsetValue :number
Type:
- number
- Source
isFirstFragment :boolean
Type:
- boolean
- Source
isFragment :boolean
Type:
- boolean
- Source
isLastFragment :boolean
Type:
- boolean
- Source
length :number
Number of bytes occupied by the layer.
Type:
- number
- Implements
- Source
osi :OsiModelLayers
Respective protocol OSI layer.
Type:
- Implements
- Source
src :string
The source IP address in human-readable format.
Type:
- string
- Source
Methods
calculateChecksum()
Calculates and updates the checksum for the IPv4 layer. This method mutates the object by setting the `checksum` property based on the current state of the `buffer`.
- Source
toObject() → {Object}
Returns an object with all protcol fields without owning the underlying buffer. Useful to read all the data and use it without having to deal with binary representation.
- Implements
- Source
Returns:
- All protocol fields
- Type:
- Object