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
- Wireshark filter
ip- Encrypted
- no
Packet structure
Select a field to see what it does.
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
| Range | Meaning |
|---|---|
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 | Private (RFC 1918), not routed on the internet |
100.64.0.0/10 | Carrier-grade NAT (shared address space) |
127.0.0.0/8 | Loopback |
169.254.0.0/16 | Link-local (APIPA): no DHCP answer received |
224.0.0.0/4 | Multicast (224.0.0.0/24 stays on the local link) |
255.255.255.255 | Limited 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/24 | Documentation only; should never appear in real traffic |
240.0.0.0/4 | Reserved |
In Wireshark
| Filter | Shows |
|---|---|
ip.addr == 192.0.2.10 | Traffic from or to a host |
ip.src == 10.0.0.0/8 | Traffic from a subnet (CIDR works) |
ip.proto == 17 | Only UDP inside IPv4 (same as udp && ip) |
ip.ttl < 5 | Low TTL: traceroute, routing loops, or IDS evasion (packets that reach the sensor but expire before the target) |
ip.flags.mf == 1 || ip.frag_offset > 0 | All fragments |
ip.flags.df == 0 && ip.len > 1400 | Large packets that may be fragmented |
ip.hdr_len > 20 | Packets with IP options |
ip.flags.rb == 1 | Reserved bit set: always crafted |
ip.dsfield.dscp != 0 | Traffic 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
- Spoofing: the source address is not authenticated. Spoofed sources are used in reflection/amplification DDoS (DNS, NTP, memcached) and in blind attacks. Ingress filtering (BCP 38) is the fix at network edges.
- Fragmentation attacks: overlapping fragments (Teardrop) and tiny fragments split the TCP header across fragments to evade firewalls and IDS that do not reassemble. Fragmented traffic on a modern network is rare enough to look at.
- TTL as a fingerprint: the starting TTL reveals the OS family (64 vs 128 vs 255); a TTL that does not fit the claimed host hints at spoofing or a middlebox.
- IP ID side channel: hosts with a global, incrementing IP ID can be used as a “zombie” for idle scans (
nmap -sI), and leak how much traffic they send. - Options: Loose/Strict Source Route lets the sender choose the path and can bypass filtering. Packets with these options should be dropped and are worth an alert.
- Broadcast abuse: ICMP echo to a directed broadcast address (Smurf attack). Disabled on modern routers by default.
- Covert channels: unused or loosely checked fields (IP ID, reserved bit, DSCP, options) can carry hidden data.
Versions and related
- IPv6 is the successor: 128-bit addresses, fixed 40-byte header, no router fragmentation, extension headers instead of options.
- ICMP carries IPv4’s error and diagnostic messages (protocol 1).
- ARP maps IPv4 addresses to MAC addresses on the local network.
- IPsec (ESP, AH) adds encryption and authentication on top of IP.