A 4,000-byte datagram (20-byte header, no options) must cross a link with MTU 1,500. List each fragment's data size, total length, offset and MF flag. Then the second fragment meets a link with MTU 620 — how is it re-fragmented?
IP is the Internet's connectionless, best-effort delivery service. Master the IPv4 header, fragmentation, classful and CIDR addressing, subnetting, NAT, the helpers ARP, DHCP and ICMP, and IPv6 — together the most heavily tested networking topic.
IPv4 (RFC 791, 1981) moves datagrams from a source host to a destination host across many networks. Its service is connectionless (no setup; each datagram is routed independently) and best effort (datagrams may be lost, duplicated, delayed or reordered with no notice). Reliability is left to TCP above it; error reporting is left to its companion, ICMP.
| Field | Bits | Meaning |
|---|---|---|
| Version | 4 | 4 for IPv4 |
| IHL (header length, HLEN) | 4 | Header size in 32-bit words: 5 (20 bytes) to 15 (60 bytes) |
| DSCP + ECN (old 'type of service') | 6 + 2 | DiffServ priority class; explicit congestion notification bits |
| Total length | 16 | Header + data in bytes; maximum 65,535 |
| Identification | 16 | Same value in every fragment of one datagram |
| Flags | 3 | Reserved (0), DF = don't fragment, MF = more fragments follow |
| Fragment offset | 13 | Where this fragment's data starts in the original, in units of 8 bytes |
| TTL (time to live) | 8 | Hop limit; each router subtracts 1 and discards the datagram at 0 (sending ICMP time exceeded) |
| Protocol | 8 | Payload type: 1 ICMP, 2 IGMP, 6 TCP, 17 UDP, 41 IPv6-in-IPv4, 50 ESP, 51 AH, 89 OSPF |
| Header checksum | 16 | One's-complement checksum of the header only; recomputed at every hop because TTL changes |
| Source address | 32 | Sender's IPv4 address |
| Destination address | 32 | Final receiver's IPv4 address |
| Options + padding | 0–320 | Record route, source routing, timestamp, security; padded to a 4-byte boundary |
A router therefore changes only a few fields: it decrements TTL, recomputes the header checksum, and — if it must fragment or NAT is involved — updates the length, flags, offset or addresses. The checksum covers only the header because the transport layer checks the data itself.
Every link has a maximum transmission unit (MTU) — the largest payload its frames can carry (1,500 bytes for Ethernet). When an IPv4 datagram is larger than the next link's MTU, the router (or the source) splits it into fragments, each a complete datagram with its own header. Fragments may be fragmented again further along; they are reassembled only at the final destination.
If DF = 1 and the datagram is too big, the router discards it and returns ICMP destination unreachable — fragmentation needed and DF set (type 3, code 4). Hosts use this for Path MTU Discovery: they send full-sized datagrams with DF set and shrink them when such errors come back, avoiding fragmentation altogether. Fragmentation is costly — losing one fragment loses the whole datagram — so modern stacks avoid it.
An IPv4 address is 32 bits, written in dotted decimal (four bytes, each 0–255), e.g. 192.168.1.10 = 11000000.10101000.00000001.00001010. It has two parts: a network (prefix) part shared by every host on the same network, and a host part. Originally the split was fixed by classes identified from the leading bits.
| Class | Leading bits | First octet | Default mask | Networks | Hosts per network |
|---|---|---|---|---|---|
| A | 0 | 1–126 (0 and 127 reserved) | 255.0.0.0 (/8) | 2⁷ − 2 = 126 | 2²⁴ − 2 = 16,777,214 |
| B | 10 | 128–191 | 255.255.0.0 (/16) | 2¹⁴ = 16,384 | 2¹⁶ − 2 = 65,534 |
| C | 110 | 192–223 | 255.255.255.0 (/24) | 2²¹ = 2,097,152 | 2⁸ − 2 = 254 |
| D | 1110 | 224–239 | — | Multicast groups | — |
| E | 1111 | 240–255 | — | Reserved / experimental | — |
| Address / block | Meaning |
|---|---|
| Host bits all 0 (e.g. 192.168.1.0/24) | Network address — names the network, not a host |
| Host bits all 1 (e.g. 192.168.1.255/24) | Directed broadcast to every host on that network |
| 255.255.255.255 | Limited broadcast — this local network only; routers never forward it |
| 0.0.0.0 | 'This host' (source address before DHCP); as 0.0.0.0/0, the default route |
| 127.0.0.0/8 | Loopback (127.0.0.1 = localhost); never leaves the host |
| 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 | Private addresses (RFC 1918) — not routed on the Internet; reach it through NAT |
| 169.254.0.0/16 | Link-local / APIPA — self-assigned when no DHCP server answers |
| 100.64.0.0/10 | Shared address space for carrier-grade NAT (RFC 6598) |
| 224.0.0.0/4 | Multicast (224.0.0.1 all hosts, 224.0.0.2 all routers, 224.0.0.5 OSPF, 224.0.0.9 RIPv2) |
| 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 | Reserved for documentation and examples |
Classful addressing wasted addresses (a firm needing 300 hosts had to take a whole class B of 65,534) and could not split a network internally. Subnetting borrows high-order host bits as subnet bits; a subnet mask (or prefix length /n) marks which bits are network+subnet. CIDR (Classless Inter-Domain Routing, 1993) drops classes entirely: any prefix length from /0 to /32 is allowed, written a.b.c.d/n.
VLSM (variable-length subnet masking) gives each subnet just the size it needs: allocate the largest requirement first so that every block stays aligned on its own size, then fit smaller ones into the gaps — for example a /30 (2 hosts) for each point-to-point router link.
Supernetting (route aggregation, summarization) goes the other way: several contiguous networks are advertised as one shorter prefix, shrinking routing tables. A set of 2ᵏ networks can be summarized only if they are contiguous and the first one is aligned (divisible by 2ᵏ in the relevant octet): 192.168.0.0/24 – 192.168.3.0/24 become 192.168.0.0/22, but 192.168.1.0 – 192.168.4.0 cannot form a single /22.
Network Address Translation (NAT) lets hosts with private addresses share a few public ones. The NAT router rewrites the source address of outgoing packets to its public address and keeps a translation table so it can rewrite replies back. Static NAT maps one private address to one public address permanently (for servers); dynamic NAT draws public addresses from a pool; PAT/NAPT (port address translation, 'NAT overload') maps many private hosts onto one public address by also rewriting port numbers.
| Inside (private) address:port | Outside (public) address:port | Remote server |
|---|---|---|
| 192.168.1.10:51000 | 203.0.113.5:62001 | 198.51.100.7:443 |
| 192.168.1.11:51000 | 203.0.113.5:62002 | 198.51.100.7:443 |
| 192.168.1.11:51744 | 203.0.113.5:62003 | 192.0.2.53:53 |
IP addresses are logical, but a frame on a LAN must carry the next hop's MAC address. ARP (Address Resolution Protocol, RFC 826) finds it. A host that wants to send to 192.168.1.20 broadcasts an ARP request — 'who has 192.168.1.20? tell 192.168.1.10' — in a frame to FF:FF:FF:FF:FF:FF. Only the owner answers, with a unicast ARP reply carrying its MAC. Both sides store the mapping in an ARP cache whose entries expire after a timeout (typically minutes), so stale mappings disappear.
| Field | Bytes | Value |
|---|---|---|
| Hardware type | 2 | 1 = Ethernet |
| Protocol type | 2 | 0x0800 = IPv4 |
| Hardware / protocol address lengths | 1 + 1 | 6 and 4 |
| Operation | 2 | 1 = request, 2 = reply |
| Sender MAC, sender IP | 6 + 4 | The asker's addresses |
| Target MAC, target IP | 6 + 4 | Unknown MAC (zeros) in a request; filled in by the reply |
ICMP (RFC 792) is IP's reporting protocol. ICMP messages travel inside IP datagrams (protocol 1), but ICMP is considered part of the network layer. Each message starts with a type, a code and a checksum. Error messages carry the original IP header plus the first 8 bytes of its payload, enough for the source to identify the TCP or UDP ports involved.
| Type | Message | Typical cause or use |
|---|---|---|
| 0 | Echo reply | Answer to ping |
| 3 | Destination unreachable | Code 0 network, 1 host, 2 protocol, 3 port unreachable, 4 fragmentation needed but DF set, 13 administratively prohibited |
| 4 | Source quench | Old 'slow down' signal for congestion — deprecated (RFC 6633) |
| 5 | Redirect | A router tells a host that a better first-hop router exists on the same network |
| 8 | Echo request | Sent by ping |
| 11 | Time exceeded | Code 0: TTL reached 0 in transit (used by traceroute); code 1: fragment reassembly timed out |
| 12 | Parameter problem | Bad header field |
| 13 / 14 | Timestamp request / reply | Clock comparison (rarely used) |
IPv4's 2³² ≈ 4.3 billion addresses ran out (IANA's free pool was exhausted in 2011). IPv6 (RFC 8200) uses 128-bit addresses — about 3.4 × 10³⁸ — written as eight groups of four hex digits separated by colons, e.g. 2001:0db8:0000:0000:0008:0800:200c:417a.
| Field | Bits | Notes |
|---|---|---|
| Version | 4 | 6 |
| Traffic class | 8 | Priority (DSCP + ECN), like IPv4's ToS |
| Flow label | 20 | Marks packets of one flow for special handling |
| Payload length | 16 | Bytes after the base header (extension headers + data) |
| Next header | 8 | Type of the following header: 6 TCP, 17 UDP, 58 ICMPv6, 0 hop-by-hop, 43 routing, 44 fragment, 50 ESP, 51 AH, 60 destination options |
| Hop limit | 8 | Replaces TTL |
| Source / destination address | 128 + 128 |
IPv6 deliberately removed work from routers: there is no header checksum (links and transport protocols already check), no fragmentation by routers (only the source fragments, using a Fragment extension header, after Path MTU Discovery; every link must carry at least 1,280 bytes), and options moved to extension headers chained by the Next Header field. There is no broadcast: addresses are unicast (global 2000::/3, link-local fe80::/10, unique-local fc00::/7), multicast (ff00::/8, e.g. ff02::1 all nodes) or anycast (delivered to the nearest member of a group). Loopback is ::1 and the unspecified address is ::.
Hosts can configure themselves with SLAAC (stateless address autoconfiguration): form a link-local address, check it is unique (duplicate address detection), send a Router Solicitation, and combine the prefix from the Router Advertisement with an interface ID — random, or modified EUI-64 (insert FFFE into the middle of the MAC and flip the universal/local bit). NDP (Neighbor Discovery, carried in ICMPv6) replaces ARP, router discovery and redirects; DHCPv6 is available for stateful configuration.
| Feature | IPv4 | IPv6 |
|---|---|---|
| Address size | 32 bits, dotted decimal | 128 bits, colon hexadecimal |
| Header | 20–60 bytes, variable | 40 bytes fixed + extension headers |
| Header checksum | Yes | No |
| Fragmentation | Source and routers | Source only |
| Broadcast | Yes | No — multicast and anycast instead |
| Address configuration | Manual or DHCP | SLAAC, DHCPv6 or manual |
| Address resolution | ARP | NDP (ICMPv6 neighbor solicitation/advertisement) |
| QoS fields | DSCP/ToS | Traffic class + flow label |
| IPsec | Optional add-on | Designed in (extension headers AH/ESP) |
| DNS record | A | AAAA |
| Loopback | 127.0.0.1 | ::1 |
The two protocols are not compatible on the wire, so the Internet moves over gradually. Dual stack runs both on hosts and routers (DNS returns A and AAAA records and the host prefers IPv6). Tunnelling carries IPv6 packets inside IPv4 datagrams (protocol 41: 6in4, 6to4, Teredo over UDP) across IPv4-only regions. Translation — NAT64 with DNS64 — lets IPv6-only clients reach IPv4-only servers by mapping addresses into 64:ff9b::/96.
Try the problem first, then reveal the working one step at a time.
A 4,000-byte datagram (20-byte header, no options) must cross a link with MTU 1,500. List each fragment's data size, total length, offset and MF flag. Then the second fragment meets a link with MTU 620 — how is it re-fragmented?
(a) For host 172.16.45.200/27 find the mask, network address, broadcast address and usable host range. (b) Split 192.168.10.0/24 into four equal subnets.
Allocate 192.168.1.0/24 to LANs needing 100, 50 and 20 hosts and to two point-to-point WAN links, wasting as little space as possible.
(a) Compress 2001:0db8:0000:0000:0008:0800:200c:417a. (b) Expand fe80::1. (c) Build the link-local address of an interface with MAC 00:1A:2B:3C:4D:5E using modified EUI-64.
An IPv4 header begins (hex) 45 00 05 DC 1C 46 40 00 40 11 …. Decode the version, header length, total length, identification, flags, fragment offset, TTL and protocol, and give the payload size.
Summarize the eight networks 200.10.16.0/24 to 200.10.23.0/24 into one route. Is 200.10.24.0/24 covered?
Network 172.20.0.0 is subnetted with mask 255.255.240.0. How many subnets and usable hosts per subnet are there? Which subnet contains 172.20.141.200, and what is its broadcast address?
A fragment arrives with offset 100, HLEN 5 and total length 500. Which bytes of the original datagram does it carry? What can you say if MF = 1? What if MF = 0 and the offset were 0?
Classify each address: (a) 172.15.12.28 (b) 172.31.200.5 (c) 100.70.1.1 (d) 169.254.10.20 (e) 224.0.0.9 (f) 127.0.0.53 (g) 192.168.1.255 in 192.168.1.0/24.
12 questions. 70 % passes the topic quiz (+30 XP, +20 more for 100 %). Exam scoring: +1 correct, −⅓ wrong.
Modelled on real KPSC questions (reworded) with the same concept and answer; each links to its original paper.