Internet Protocol
Table of Contents
The network-layer protocol responsible for addressing and routing packets between hosts across interconnected networks. IP provides logical addressing (IP addresses) and packet forwarding — it is connectionless and best-effort, with reliability left to upper layers (TCP).
Related: IP Address CIDR ICMP Networking MOC
Versions
| Version | Address size | Space | Status |
|---|---|---|---|
| IPv4 | 32-bit | ~4.3 billion addresses | Dominant, exhausted |
| IPv6 | 128-bit | 2¹²⁸ addresses | Growing adoption |
See IP Address for addressing, subnetting, and CIDR detail.
IPv4 Header Fields
| Field | Size | Purpose |
|---|---|---|
| Version | 4 bits | IPv4 (4) or IPv6 (6) |
| IHL | 4 bits | Header length in 32-bit words |
| DSCP / ToS | 8 bits | Quality of service priority |
| Total length | 16 bits | Total packet size (header + data) in bytes |
| Identification | 16 bits | Identifies fragments belonging to same datagram |
| Flags | 3 bits | DF (don't fragment), MF (more fragments) |
| Fragment offset | 13 bits | Position of fragment in original datagram |
| TTL | 8 bits | Decremented at each hop — packet dropped at 0 |
| Protocol | 8 bits | Upper-layer protocol (6=TCP, 17=UDP, 1=ICMP) |
| Header checksum | 16 bits | Error detection for the header only |
| Source address | 32 bits | Sending host IP |
| Destination address | 32 bits | Receiving host IP |
TTL
Time To Live is decremented by 1 at each router hop. When it
reaches 0, the packet is dropped and an ICMP Time Exceeded
message is sent back to the source. Prevents packets circulating
indefinitely and is used by traceroute to map network paths.
Default TTL values vary by OS — see Ping for OS fingerprinting via TTL.
Routing
Routers maintain routing tables mapping destination networks to next-hop addresses. Routing protocols automate table population:
| Protocol | Type | Use |
|---|---|---|
| OSPF | Link-state IGP | Internal routing within an organisation |
| BGP | Path-vector EGP | Inter-AS routing — the internet backbone |
| RIP | Distance-vector IGP | Legacy, small networks |
| EIGRP | Hybrid IGP | Cisco proprietary |
Fragmentation
When a packet exceeds the MTU (Maximum Transmission Unit) of a link, IP fragments it. Each fragment has the same identification field; the destination reassembles them using the fragment offset. IPv6 does not fragment at routers — fragmentation is the sender's responsibility.
Security Relevance
— IP spoofing: source address is not verified by IP itself — an attacker can set any source IP. Ingress filtering (BCP38) at ISPs mitigates this. — TTL fingerprinting: default TTL reveals OS (64=Linux, 128=Windows) See: Ping note — Fragmentation attacks: overlapping fragments can confuse stateful inspection devices or IDS/IPS — Protocol field: useful in firewall rules and packet filters — block ICMP (1), allow TCP (6) and UDP (17) as needed