networking, updated

IPv4

Internet Protocol version 4 carries almost every packet on the internet from host to host across networks, without delivery guarantees or authentication.

OSI layer
3 Network
Carried in
Ethernet / any link layer
Identified by
EtherType 0x0800
Specs
RFC 791, RFC 1122, RFC 2474, RFC 3168, RFC 6890
Wireshark filter
ip
Encrypted
no

Packet structure

IPv4 header20 bytes + variable

Select a field to see what it does.

RFC 791. 20 bytes without options; options are rare and often dropped by firewalls.

The header is 20 bytes unless options are present (IHL > 5). Everything after the header is the payload, handed to the protocol named in the Protocol field.

How it works

IPv4 is connectionless and best effort: each packet is routed on its own, may be dropped, duplicated or reordered, and nothing in IP notices. Reliability is TCP’s job.

Per hop, a router looks up the destination address in its routing table (longest prefix wins), decrements the TTL, recalculates the header checksum and forwards the packet. At TTL 0 it drops the packet and sends ICMP time exceeded to the source.

Fragmentation happens when a packet is bigger than the next link’s MTU. The router (or sender) splits the payload into fragments that share the same Identification; each carries its Fragment Offset, and all but the last have MF set. Only the destination reassembles. If DF is set, the router drops the packet and sends ICMP fragmentation needed with the MTU instead; this is how Path MTU Discovery works, and why blocking all ICMP breaks it.

sequenceDiagram
    participant H as Host (MTU 1500)
    participant R as Router
    participant S as Server
    H->>R: 1500 bytes, DF=1
    Note over R: next link MTU 1400
    R-->>H: ICMP type 3 code 4 (fragmentation needed, MTU 1400)
    H->>R: 1400 bytes, DF=1
    R->>S: 1400 bytes, TTL - 1

Special address ranges

RangeMeaning
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16Private (RFC 1918), not routed on the internet
100.64.0.0/10Carrier-grade NAT (shared address space)
127.0.0.0/8Loopback
169.254.0.0/16Link-local (APIPA): no DHCP answer received
224.0.0.0/4Multicast (224.0.0.0/24 stays on the local link)
255.255.255.255Limited broadcast
0.0.0.0/8“This host”; 0.0.0.0 as source in DHCP Discover
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24Documentation only; should never appear in real traffic
240.0.0.0/4Reserved

In Wireshark

FilterShows
ip.addr == 192.0.2.10Traffic from or to a host
ip.src == 10.0.0.0/8Traffic from a subnet (CIDR works)
ip.proto == 17Only UDP inside IPv4 (same as udp && ip)
ip.ttl < 5Low TTL: traceroute, routing loops, or IDS evasion (packets that reach the sensor but expire before the target)
ip.flags.mf == 1 || ip.frag_offset > 0All fragments
ip.flags.df == 0 && ip.len > 1400Large packets that may be fragmented
ip.hdr_len > 20Packets with IP options
ip.flags.rb == 1Reserved bit set: always crafted
ip.dsfield.dscp != 0Traffic with QoS marking

What normal looks like: IHL 5, no options, DF set on most TCP traffic, TTL close to 64 or 128 minus a few hops, DSCP 0 on internet traffic. Wireshark flagging the header checksum on outgoing packets of the capturing host is usually checksum offloading, not corruption.

Security notes

References

§ home
~/knubertus/home/
1,1 Top