IPv4 operations

1. Has IPv4 datagram

Description

Checks if a packet has or not an IPv4 datagram.

Format

hasip4(arg_1) → result

  • arg_1 : Packet
  • result : Boolean

Examples

  Example 1

 pkt → packet field name

hasip4(pkt), where pkt is a packet with an IPv4 datagram

  • arg_1 : pkt
  • result : true
  Example 2

 pkt → packet field name

 hasip4(pkt), where pkt is a packet without an IPv4 datagram

  • arg_1 : pkt
  • result : false

2. IPv4 header checksum

Description

Returns the header checksum of an IPv4 datagram. This checksum is calculated only for the header bytes and protects the header of IPv4 data packages against data corruption.

Format

ip4cs(arg_1) → result

  • arg_1 : Packet
  • result : Integer

Examples

  Example 1

pkt → packet field name

ip4cs(pkt)

  • arg_1 : pkt
  • result : 17220
  Example 2

pkt → packet field name

 ip4cs(pkt)

  • arg_1 : pkt
  • result : 25767
 The result of this operation is a decimal number (base 10).

3. IPv4 differentiated services

Description

Returns the differentiated services value (DSCP) of an IPv4 datagram.

Format

 ip4ds(arg_1) → result

  • arg_1 : Packet
  • result : Integer

Examples

  Example 1

 pkt → packet field name

ip4ds(pkt)

  • arg_1 : pkt
  • result : 46
  Example 2

 pkt → packet field name

 ip4ds(pkt), with no IPv4 datagram

  • arg_1 : pkt
  • result : null

This operation specifies a mechanism for classifying and managing network traffic and providing quality of service on IP networks, such as low latency to a critical network, while providing best-effort service to non-critical services. It is also known as DiffServ,but originally defined as Type of Service (TOS). Here are some examples:

  • Best effort → 0
  • High priority expedited forwarding → 46
The result of this operation will be a decimal number (base 10).

4. IPv4 destination address

Description

Returns the destination IPv4 address of the packet receiver.

Format

ip4dst(arg_1) → result

  • arg_1 : Packet
  • result : IPv4 address

Examples

  Example 1

pkt → packet field name

ip4dst(pkt)

  • arg_1 : pkt
  • result : 8.254.34.124
  Example 2

 pkt → packet field name

 ip4dst(pkt)

  • arg_1 : pkt
  • result : 192.168.16.131

5. IPv4 explicit congestion notification

Description

Returns the ECN (explicit congestion notification) value of an IPv4 datagram.

Format

ip4ds(arg_1) → result

  • arg_1 : Packet
  • result : Integer

Examples

  Example 1

pkt → packet field name

ip4ds(pkt)

  • arg_1 : pkt
  • result : 0
  Example 2

pkt → packet field name

 ip4ds(pkt)

  • arg_1 : pkt
  • result : 3

This is an optional file that allows end-to-end notification of network congestion without dropping packets between two endpoints which infrastructure supports it. These are the ECN values:

  • 0 (00) → Non ECN-capable transport, Non-ECT
  • 2 (10) → ECN capable transport, ECT(0)
  • 1 (01) → ECN capable transport, ECT(1)
  • 3 (11) → Congestion Encountered, CE

The result of this operation is a decimal number (base 10).

6. IPv4 flags

Description

Returns the flags value of an IPv4 datagram.It is a 3 bit field used to control and identify all the fragments.

  Check here the bits definitions
  • bit 0 → Reserved. Must be 0
  • bit 1 → Don't fragment (DF)
  • bit 2 → More fragments (MF)

Format

ip4flags(arg_1) → result

  • arg_1 : Packet
  • result : Integer

Examples

  Example 1

pkt → packet field name

ip4flags(pkt)

  • arg_1 : pkt
  • result : 0
  Example 2

 pkt → packet field name

 ip4flags(pkt)

  • arg_1 : pkt
  • result : 2

7. IPv4 fragment offset

Returns the fragment offset value of an IPv4 datagram.

8. IPv4 header length

Description

Returns the Internet header length (IHL) field value of an IPv4 datagram.

Format

ip4hl(arg_1) → result

  • arg_1 : Packet
  • result : Integer

Examples

  Example 1

pkt → packet field name

ip4hl(pkt)

  • arg_1 : pkt
  • result : 5 (20 bytes)
  Example 2

 pkt → packet field name

 ip4hl(pkt)

    • arg_1 : pkt
    • result : 6 (24 bytes)

This 4-bit field is a number of 32-bit words in the header that specifies the size of the header, which also coincides with the offset to the data. As a 4-bit field, it has the following values:

  • Minimum value: 5 → 5 × 32 bits  = 160 bits = 20 bytes
  • Maximum value: 15 → 15 × 32 bits  = 480 bits = 60 bytes

9. IPv4 identification

Description

Returns the identification field value of an IP datagram. This field is used for uniquely identifying the group of fragments of a single IPv4 datagram.

Format

ip4ident(arg_1) → result

  • arg_1 : Packet
  • result : Integer

Examples

  Example 1

pkt → packet field name

ip4ident(pkt)

  • arg_1 : pkt
  • result : 3149
  Example 2

 pkt → packet field name

 ip4ident(pkt)

  • arg_1 : pkt
  • result : 20012

10. IPv4 total length

Description

Returns the total length field value of an IP datagram.

Format

ip4len(arg_1) → result

  • arg_1 : Packet
  • result : Integer

Examples

  Example 1

pkt → packet field name

ip4len(pkt)

  • arg_1 : pkt
  • result : 44

  Example 2

pkt → packet field name.

 ip4len(pkt)

  • arg_1 : pkt
  • result : 658

This field defines the entire packet size in bytes, including header and data. As a 4-bit field, it has the following values:

  • Minimum length: 20 bytes → 20 bytes header + 0 bytes data
  • Maximum length 65535 bytes → max value of a 16-bit word

11. IPv4 payload 

Description

Returns the payload of an IP datagram.

Format

ip4payload(arg_1) → result

  • arg_1 : Packet
  • result : Byte array 

Examples

  Example 1

pkt → packet field name

ip4payload(pkt)

  • arg_1 : pkt
  • result : DAE86989093F77C6FD83154080100FF9 9D2800000101080A33F09A6217391144
  Example 2

pkt → packet field name

 ip4payload(pkt)

  • arg_1 : pkt
  • result : DAE86989093F778CFD83147E80181000D736000001010 80A33F09A2B173907713A0000004403000000000000D4 0700000000000061646D696E2E24636D640000000000F FFFFFFF130000001069736D6173746572000100

12. IPv4 protocol

Description

Returns the protocol field value of an IP datagram, which is the protocol used in the data portion. These are the most common protocol values:

  • 1 (0x01) → ICMP
  • 6 (0x06) → TCP
  • 17 (0x11) → UDP

Format

ip4proto(arg_1) → result

  • arg_1 : Packet
  • result : Integer

Examples

  Example 1

pkt → packet field name

ip4proto(pkt), where pkt contains a TCP segment

  • arg_1 : pkt
  • result : 6
  Example 2

pkt → packet field name

 ip4proto(pkt), where pkt contains an UDP datagram

  • arg_1 : pkt
  • result : 17

13. IPv4 source address 

Description

Returns the source IPv4 address of the receiver of the packet receiver.

Format

ip4src(arg_1) → result

  • arg_1 : Packet
  • result : IPv4 address

Examples

  Example 1

pkt → packet field name

ip4src(pkt)

  • arg_1 : pkt
  • result : 192.168.16.127
  Example 2

pkt → packet field name

 ip4src(pkt)

  • arg_1 : pkt
  • result : 52.51.245.49

14. IPv4 status

Description

Returns the status of an IPv4 packet.

  Check here the packet status codes
  • OK → The packet has been parsed without problems
  • UNPARSED → Unparded packet
  • UNDERFLOW → The packet is smaller than its outer payload
  • OVERFLOW → The packet is bigger than the payload
  • CRC_UNAVAILABLE → CRC cannot be declared due to the lack of data
  • BAD_CRC → CRC does not match
  • HEADER_BAD → Header has inconsistent values
  • TOO_SHORT → There is not enough data to fill the header

Format

ip4status(arg_1) → result

  • arg_1 : Packet
  • result : String

Examples

  Example 1

 pkt → packet field name

ip4status(pkt)

  • arg_1 : pkt
  • result : OK
  Example 2

pkt → packet field name

 ip4status(pkt)

  • arg_1 : pkt
  • result : OVERFLOW

15. IPv4 type of service

Description

Returns the type of service field value of an IP datagram.This field has been redefined as Differentiated Service Code Point (DSCP).

Format

ip4tos(arg_1) → result

  • arg_1 : Packet
  • result : Integer

Examples

  Example 1

pkt → packet field name

ip4tos(pkt)

  • arg_1 : pkt
  • result : 0 - Best effort
  Example 2

pkt → packet field name

 ip4tos(pkt)

  • arg_1 : pkt
  • result : 56 - Network control

16. IPv4 time to live

Description

Returns the time to live (TTL) value in seconds of an IP datagram.TTL is a mechanism that limits the lifetime of data, preventing datagrams from persisting on a network

Format

ip4ttl(arg_1) → result

  • arg_1 : Packet
  • result : Integer

Examples

  Example 1

pkt → packet field name

ip4ttl(pkt)

  • arg_1 : pkt
  • result : 64
  Example 2

pkt → packet field name

 ip4ttl(pkt)

  • arg_1 : pkt
  • result : 241

Have we answered your question?

If not, please contact our technical support team via email by clicking the button below.

CONTACT US