Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

IPv4 (ipv4)

Reached from

Lower layerSelectorValue
ethernet2ethertype2048 (0x0800)
dot1qethertype2048 (0x0800)
dot1adethertype2048 (0x0800)
snappid2048 (0x0800)
ipv4protocol4 (0x04)
ipv6next_header4 (0x04)
ipv6_hopoptsnext_header4 (0x04)
ipv6_routenext_header4 (0x04)
ipv6_srhnext_header4 (0x04)
ipv6_fragnext_header4 (0x04)
ipv6_dstoptsnext_header4 (0x04)
pppprotocol33 (0x0021)
greprotocol_type2048 (0x0800)
mplsFirst 4 bits of the payload when s = 14
gtpuFirst 4 bits of the payload when message_type = 255 (0xff)4
geneveprotocol_type2048 (0x0800)
pim_registerFirst 4 bits of the payload when type = 14

Fields

FieldTypeDefaultAutoDescription
versionuint(4)4IP version, always 4.
ihluint(4)Length of the header in 32-bit wordsHeader length in 32-bit words, 5 to 15 (Auto, includes the options).
dscpuint(6)0Differentiated services code point (QoS class, 0 to 63).
ecnuint(2)0Explicit congestion notification (0 = not ECT, 1 / 2 = ECT, 3 = CE).
total_lengthuint(16)Length of the header and payload in octetsTotal length of header and payload in octets (Auto).
identificationuint(16)0Identification shared by the fragments of one datagram.
flagsflags(3)0x0Flags: DF (don’t fragment) and MF (more fragments); the top bit is reserved.
frag_offsetuint(13)0Offset of this fragment in 8-octet units.
ttluint(8)64Time to live; decremented at every router, 0 is never sent.
protocolenum(8)253 (experimental)Protocol number of the next layer (see Next layer)Protocol number of the next layer (Auto; 253 = experimental when none is known).
header_checksumuint(16)Internet checksum over the headerInternet checksum over the header (Auto).
srcipv4192.0.2.1Source IPv4 address.
dstipv4192.0.2.2Destination IPv4 address.
optionstlv — ihl * 4 - 20 octetsIPv4 options as TLVs (EOL, NOP, security, record route, timestamp…).
paddingpadding(4)Zero padding of the options to a 32-bit boundary (Auto).

flags

BitMaskName
24reserved
12df
01mf

protocol

ValueName
1 (0x01)icmp
2 (0x02)igmp
4 (0x04)ipip
6 (0x06)tcp
17 (0x11)udp
41 (0x29)ipv6
46 (0x2e)rsvp
47 (0x2f)gre
50 (0x32)esp
51 (0x33)ah
58 (0x3a)ipv6_icmp
88 (0x58)eigrp
89 (0x59)ospf
103 (0x67)pim
112 (0x70)vrrp
115 (0x73)l2tp
132 (0x84)sctp
253 (0xfd)experimental

options

  • Type 8 bits, length 8 bits.
  • The length counts the type and length fields too.
  • Unknown types are kept as raw value octets.
TypeNameValue fieldsDescription
0 (0x00)eol(type only, no length or value)
1 (0x01)nop(type only, no length or value)
148 (0x94)router_alertvalue

options › router_alert

FieldTypeDefaultAutoDescription
valueuint(16)

Next layer

The next layer is selected by protocol; when the field is Auto the builder writes the value of the protocol stacked above.

ValueProtocolNote
1 (0x01)icmpv4
2 (0x02)igmp
4 (0x04)ipv4
6 (0x06)tcp
17 (0x11)udp
41 (0x29)ipv6
46 (0x2e)rsvp
47 (0x2f)gre
88 (0x58)eigrp
89 (0x59)ospfv2
103 (0x67)pim
103 (0x67)pim_register
112 (0x70)vrrpv3
112 (0x70)vrrpv2
115 (0x73)l2tpv3
132 (0x84)sctp

Constraints

LevelRule
warningversion = 4
errorihl within 5..15
warningttl ≠ 0

Sample templates