← all topics

9 · DHCP, NAT, IPv6 and tunnelling ★

Slides 4-43 → 4-51, 4-56 → 4-68 · HW5 P7 · Sample midterm 1.2 · Book 4.3.3 – 4.3.5

Getting an IP address: two questions (4-43)

DHCP: Dynamic Host Configuration Protocol (4-44)

The four messages (4-44, 4-46)

Slide scenario: server 223.1.2.5, arriving client gets 223.1.2.4.

#MessageSource (IP, port)Dest (IP, port)yiaddrTrans. IDMeaning
1DISCOVER0.0.0.0, 68255.255.255.255, 670.0.0.0654"Is there a DHCP server out there?"
2OFFER223.1.2.5, 67255.255.255.255, 68223.1.2.4654"I'm a DHCP server! Here's an IP address you can use." Lifetime 3600 s
3REQUEST0.0.0.0, 68255.255.255.255, 67223.1.2.4655"OK. I would like to use this IP address!" Lifetime 3600 s
4ACK223.1.2.5, 67255.255.255.255, 68223.1.2.4655"OK. You've got that IP address!" Lifetime 3600 s

DHCP returns more than an address (4-47)

Encapsulation (4-48, 4-49)

NAT: network address translation (4-56 → 4-60)

Why NAT (4-57)

What the NAT router does (4-58)

  1. Outgoing: replace (source IP, port #) with (NAT IP address, new port #). Remote hosts reply to that pair.
  2. Remember: store every (source IP, port #) ↔ (NAT IP, new port #) pair in the NAT translation table.
  3. Incoming: replace (NAT IP, new port #) in the destination fields with the stored (source IP, port #).

Slide walk-through (4-59)

StepWhereSourceDestination
1Host 10.0.0.1 → router (LAN)10.0.0.1, 3345128.119.40.186, 80
2Router → Internet (WAN), table updated138.76.29.7, 5001128.119.40.186, 80
3Reply arrives at router128.119.40.186, 80138.76.29.7, 5001
4Router → host (LAN)128.119.40.186, 8010.0.0.1, 3345

Table row: WAN 138.76.29.7, 5001 ↔ LAN 10.0.0.1, 3345.

Controversies (4-60)

How to solve: build a NAT translation table

  1. Assign LAN addresses: give each host and the router's LAN interface a distinct address inside the private prefix. Skip the network address (.0) and the broadcast address (.255).
  2. The router has two addresses: the ISP-given public one on the WAN side, a private one on the LAN side.
  3. LAN side of each row: (host's private IP, source port the host picked). Two connections from the same host need two different source ports.
  4. WAN side of each row: (router's public IP, a new port the router picked). Every WAN port must be unique. The public IP is the same in every row.
  5. The remote server (IP, port 80) does not go in the table.

Worked example: HW5 P7

Q (HW5 P7): Consider the network setup in Figure 4.25 (3 hosts on a home LAN behind one NAT router). Suppose the ISP instead assigns the router the address 24.34.112.235 and the network address of the home network is 192.168.1/24.

  1. (a) Assign addresses to all interfaces in the home network.
  2. (b) Suppose each host has two ongoing TCP connections, all to port 80 at host 128.119.40.86. Provide the six corresponding entries in the NAT translation table.

(a) Hosts 192.168.1.1, 192.168.1.2, 192.168.1.3; router LAN interface 192.168.1.4. (Official answer. Any distinct addresses in 192.168.1.1–192.168.1.254 also work.)

(b) Official table:

WAN sideLAN side
24.34.112.235, 4000192.168.1.1, 3345
24.34.112.235, 4001192.168.1.1, 3346
24.34.112.235, 4002192.168.1.2, 3445
24.34.112.235, 4003192.168.1.2, 3446
24.34.112.235, 4004192.168.1.3, 3545
24.34.112.235, 4005192.168.1.3, 3546
3 hosts × 2 connections = 6 rows
WAN IP   : always 24.34.112.235 (the one public address)
WAN port : 4000..4005, one new port per connection, all different
LAN side : (host address, the source port that host chose)
dest     : 128.119.40.86, 80 for all six, not stored in this table

Sample midterm 1.2

Q (sample midterm 1.2): Suppose I run NAT at home and use Comcast cable service. Suppose my IP address is 10.0.0.1. What protocol did I run to get this IP address? Will this address be used to access the Internet directly? Why?

DHCP (the home NAT router's DHCP server handed it out). No. 10.0.0.1 is in the private range 10/8, which is only meaningful inside the local network and is not routable on the Internet. The NAT router replaces the source (10.0.0.1, port) with its Comcast-assigned public address and a new port, and translates replies back.

IPv6 (4-61 → 4-62)

Motivation

Header: 40 bytes, fixed

|<-------------------- 32 bits -------------------->|
| ver(4) | pri(8) |        flow label (20)          |
|   payload len (16)   | next hdr (8) | hop limit (8)|
|            source address (128 bits)              |
|          destination address (128 bits)           |
|                 payload (data)                    |
32 + 32 + 128 + 128 = 320 bits = 40 bytes

What's missing compared with IPv4 (4-62)

IPv4 → IPv6 transition: tunnelling (4-63 → 4-66)

Slide 4-66: A → F, IPv4 routers C and D in the middle

LinkWhat's on the wire
A → BPlain IPv6: Flow X, Src A, Dest F, data
B → C, C → D, D → EIPv4 header src B, dest E, payload = the untouched IPv6 datagram (Flow X, Src A, Dest F, data)
E → FPlain IPv6 again: Flow X, Src A, Dest F, data

Adoption (4-67, 4-68)

About 40% of Google clients use IPv6 (2023); NIST: 1/3 of US government domains are IPv6-capable; deployment has taken 25 years and counting. Network-layer changes are hard because every router must change, while apps (WWW, social media, streaming) changed fast.

Traps
• Ports: server 67, client 68. Don't swap them.
• The REQUEST is still from 0.0.0.0 and still broadcast. The client has no address until the ACK.
• OFFER/ACK go to 255.255.255.255, not to the offered yiaddr.
• The four messages are D-O-R-A: DISCOVER, OFFER, REQUEST, ACK.
• NAT table: the WAN IP is the same in every row; the WAN ports must all differ. LAN ports may repeat across different hosts.
• Don't give a host the .0 network address or the .255 broadcast address, and don't forget the router's own LAN interface.
• The remote server's address and port 80 don't go in the NAT table.
• A private address (10/8, 172.16/12, 192.168/16) never appears on the public Internet.
• IPv6 header is 40 bytes fixed (IPv4 is 20+ bytes). Addresses are 128 bits, flow label 20 bits.
• IPv6 routers don't fragment. Fragmentation isn't gone entirely: only the endpoints do it.
• Tunnel: IPv6 sits inside IPv4. The outer IPv4 destination is the tunnel exit (E), not the final host F.

Quick check

1. A DHCP server at 192.168.10.1 offers 192.168.10.23 to a new laptop with lease 7200 s. DISCOVER uses transaction ID 88 and REQUEST uses 89. Write the four messages with src/dst IP and port, yiaddr and ID.
MsgSrcDstyiaddrID
DISCOVER0.0.0.0, 68255.255.255.255, 670.0.0.088
OFFER192.168.10.1, 67255.255.255.255, 68192.168.10.23 (lifetime 7200 s)88
REQUEST0.0.0.0, 68255.255.255.255, 67192.168.10.23 (lifetime 7200 s)89
ACK192.168.10.1, 67255.255.255.255, 68192.168.10.23 (lifetime 7200 s)89
2. Why is the DHCP REQUEST sent from 0.0.0.0 to 255.255.255.255? The client doesn't own the address until the ACK, so it can't use it as a source. Broadcasting tells every server that sent an offer which offer was accepted.
3. Besides the IP address, what three things does DHCP give the host? The first-hop router address, the DNS server name and address, and the subnet mask.
4. How is a DHCP REQUEST encapsulated, and what is the Ethernet destination? DHCP in UDP (dst port 67) in IP (dst 255.255.255.255) in Ethernet with dest MAC FF:FF:FF:FF:FF:FF (link-layer broadcast).
5. Name three goals of DHCP. Plug-and-play (get an address on joining), lease renewal, reuse of addresses (held only while connected), and support for mobile users joining and leaving.
6. NAT, new numbers: the ISP gives the router 71.58.9.200; the home network is 10.0.0/24. Three hosts each have two TCP connections to port 443 at 52.10.3.7. Assign addresses and build the NAT table, using WAN ports starting at 6000. Addresses: hosts 10.0.0.2, 10.0.0.3, 10.0.0.4; router LAN interface 10.0.0.1. Hosts pick source ports (here 5100/5101 on each host; reuse across hosts is fine).
WAN sideLAN side
71.58.9.200, 600010.0.0.2, 5100
71.58.9.200, 600110.0.0.2, 5101
71.58.9.200, 600210.0.0.3, 5100
71.58.9.200, 600310.0.0.3, 5101
71.58.9.200, 600410.0.0.4, 5100
71.58.9.200, 600510.0.0.4, 5101
Same public IP in every row, six different WAN ports. 52.10.3.7:443 is not in the table.
7. NAT router 138.76.29.7. Host 10.0.0.3 sends from port 4100 to 93.184.216.34 port 80; the router picks 5007. Give source and destination for all four legs.
1 LAN out : S 10.0.0.3, 4100      D 93.184.216.34, 80
2 WAN out : S 138.76.29.7, 5007   D 93.184.216.34, 80
3 WAN in  : S 93.184.216.34, 80   D 138.76.29.7, 5007
4 LAN in  : S 93.184.216.34, 80   D 10.0.0.3, 4100
Table row: 138.76.29.7, 5007 ↔ 10.0.0.3, 4100.
8. (Sample 1.2) My home IP is 10.0.0.1 behind NAT on Comcast. Which protocol gave it to me? Is it used on the Internet directly? DHCP. No: 10.0.0.1 is a private address (10/8), not routable on the Internet. The NAT router rewrites it to Comcast's public address plus a new port on the way out and reverses that on replies.
9. Why can one NAT address support about 60,000 simultaneous connections? Connections are told apart by WAN-side port, and the port field is 16 bits: 216 = 65,536 values, minus reserved ones, gives about 60,000.
10. Give three arguments against NAT. Routers should only process up to layer 3 (NAT touches ports); the address shortage should be fixed by IPv6; it violates the end-to-end argument. Also, an outside client can't reach a server behind NAT without NAT traversal.
11. ISP holds 200.23.16.0/20 and splits it into 8 equal blocks. What is Organization 5's block and its address range?
/20 → 8 blocks: 20 + 3 = /23 (each /23 spans 2 values of the third octet)
Org k third octet = 16 + 2k → Org 5 = 16 + 10 = 26
block: 200.23.26.0/23
range: 200.23.26.0 – 200.23.27.255  (2^9 = 512 addresses)
12. List the IPv6 header fields and show that the header is 40 bytes. Version (4 bits), priority (8), flow label (20), payload length (16), next header (8), hop limit (8), source (128), destination (128).
4+8+20 = 32;  16+8+8 = 32;  32+32+128+128 = 320 bits = 40 bytes
13. What three IPv4 features are gone from IPv6, and what happens when a datagram is too big for the next link? No checksum, no fragmentation/reassembly at routers, no options. The router drops the datagram and sends an ICMPv6 "Packet Too Big" message to the source, which resends smaller datagrams.
14. A (IPv6) sends to F (IPv6) via B (v6/v4), C and D (IPv4 only), E (v6/v4). What do the IPv4 and IPv6 headers say between C and D? Outer IPv4: src B, dest E. Its payload is the unchanged IPv6 datagram: src A, dest F (flow X) plus data. E strips the IPv4 header and forwards the IPv6 datagram to F.
15. A 1000-byte TCP payload (20-byte TCP header) crosses that tunnel. How many bytes is the IPv4 datagram between B and E?
TCP segment   = 1000 + 20 = 1020
IPv6 datagram = 1020 + 40 = 1060   (payload length field = 1020)
IPv4 datagram = 1060 + 20 = 1080 bytes

← prev · all topics · next →