1 of 36

Discussion 9

1

CS 168, Summer 2025 @ UC Berkeley

Slides credit: Sylvia Ratnasamy, Rob Shakir, Peyrin Kao, Iuniana Oprescu

DHCP, ARP, NAT 🚚

2 of 36

Logistics

  • Project 3A: Transport
    • Deadline: Tuesday, July 29th
  • Project 3B: Transport
    • Deadline: Tuesday, August 5th
  • Final exam is on Wednesday, August 13th, 3-6PM
    • The final accommodations form is open. If you need any exam accommodations (DSP, online, left handed desk, etc.), please fill this form out by Wednesday, August 9th.
    • For the midterm, a lot of requests came in for changes after the deadline, and while we were lenient, we may not be for the final, so please make sure to fill this out.

3 of 36

Addressing

  • DHCP (Application)
  • ARP (Datalink)
  • NAT

Transport

Network

Datalink

Physical

Application

4 of 36

Addressing

  • DHCP (Application)
  • ARP (Datalink)
  • NAT

Transport

Network

Datalink

Physical

Application

5 of 36

DHCP - Dynamic Host Configuration Protocol

  • Enables a host to learn about its….
    • Own IP Address
    • Network Mask
    • First-hop router’s IP Address
    • DNS Server(s) IP Address(es)

INTERNET

?

?

?

?

?

?

?

6 of 36

DHCP Discovery

  • DHCP server(s) located on same local network as host
  • Host initially broadcasts discover message
  • “Can anyone give me a configuration?”

Local Network

DHCP Server

IP Address: ???

Subnet Mask: ???

First-hop Router IP Address: ???

DNS IP Address: ???

7 of 36

DHCP Offer

  • DHCP server(s) responds by broadcasting offer message
  • Message includes assigned IP address, network mask, first-hop router address, DNS server addresses

Local Network

DHCP Server

IP Address: 212.0.0.0 (tentative)

Subnet Mask: /8 (tentative)

First-hop Router IP Address: 212.2.3.0 (tentative)

DNS IP Address: 212.4.7.8 (tentative)

IP Address: ???

Subnet Mask: ???

First-hop Router IP Address: ???

DNS IP Address: ???

8 of 36

DHCP Request

  • Host responds by broadcasting request message
  • This message identifies which offer was accepted (helps when there are multiple local DHCP servers)

Local Network

DHCP Server

IP Address: 212.0.0.0 (tentative)

Subnet Mask: /8 (tentative)

First-hop Router IP Address: 212.2.3.0 (tentative)

DNS IP Address: 212.4.7.8 (tentative)

9 of 36

DHCP Acknowledgement

  • Host responds by broadcasting request message
  • This message identifies which offer was accepted (helps when there are multiple local DHCP servers)

Local Network

IP Address: 212.0.0.0 (tentative)

Subnet Mask: /8 (tentative)

First-hop Router IP Address: 212.2.3.0 (tentative)

DNS IP Address: 212.4.7.8 (tentative)

IP Address: 212.0.0.0 (confirmed!)

Subnet Mask: /8 (confirmed!)

First-hop Router IP Address: 212.2.3.0 (confirmed!)

DNS IP Address: 212.4.7.8 (confirmed!)

DHCP Server

10 of 36

DHCP Summary

  1. Client Discover: The client broadcasts a request for a configuration.
  2. DHCP Offer: One or more DHCP servers respond with a configuration offer.�Offer includes subnet mask, router's IP address, DNS resolver, and IP for client.
  3. Client Request: The client broadcasts which configuration it has chosen.�If multiple DHCP servers made offers, the ones that were not chosen discard their offer.
  4. DHCP Acknowledgement: The chosen server confirms that its configuration has been given to the client.

source: lecture 18 slide 20

11 of 36

A Couple Questions…

1. Dealing with failures?

  • Hosts have a lease periods for their IP addresses
  • Hosts must refresh before lease period ends

2. Why do we need the first-hop router’s IP address and the subnet mask?

  • Answered when we talk about ARP.

12 of 36

Addressing

  • DHCP (Application)
  • ARP (Datalink)
  • NAT

Transport

Network

Datalink

Physical

Application

13 of 36

ARP (Overview)

  • When host sends packet, specify dest Ethernet (MAC) address so packet can traverse local networks
  • Each host has ARP table, which maps IP to Ethernet
  • If mapping unknown, ask (solicit) local network by broadcasting “Who has IP address x?”
  • Host with IP x responds “My Ethernet address is y

Local Network

Dest Host

IP: a.b.c.d

Ethernet address: 40:11:11:11:11:11

IP Addr.

Ethernet Addr.

a.b.c.d

40:11:11:11:11:11

a.b.c.a

50:37:11:11:11:11

ARP Table

14 of 36

ARP (Within local network)

Destination is in the same local network

  • Use ARP table to lookup Ethernet address of dest
  • Specify Ethernet address when sending packet

Local Network

Dest Host

IP: a.b.c.d

Ethernet address: 40:11:11:11:11:11

IP Addr.

Ethernet Addr.

a.b.c.d

40:11:11:11:11:11

a.b.c.a

50:37:11:11:11:11

ARP Table

Src Host

15 of 36

ARP (Across local networks)

Destination is NOT in the same local network

  • How can we tell?
    • Use subnet mask to check destination network address

Local Network 1

Dest Host

IP: a.b.c.d

Ethernet address: 40:11:11:11:11:11

Src Host

Local Network 1

Src’s First Hop Router

IP: d.c.b.a

Ethernet address: 50:11:11:11:11:11

IP Addr.

Ethernet Addr.

d.c.b.a

50:11:11:11:11:11

d.c.b.c

60:37:11:11:11:11

ARP Table

Router 2

16 of 36

ARP (Across local networks)

  • Use ARP table to lookup Ethernet address of first-hop-router (which is in same local network)
    • We know router’s IP address through DHCP!
  • Specify first-hop router’s Ethernet address in packet and send packet

Local Network 1

Dest Host

IP: a.b.c.d

Ethernet address: 40:11:11:11:11:11

Src Host

Local Network 1

Src’s First Hop Router

IP: d.c.b.a

Ethernet address: 50:11:11:11:11:11

IP Addr.

Ethernet Addr.

d.c.b.a

50:11:11:11:11:11

d.c.b.c

60:37:11:11:11:11

ARP Table

Router 2

17 of 36

ARP (Across local networks)

  • First-hop router will route packet to router 2 using dest IP address
    • Dest IP address is a.b.c.d. in this example

Local Network 1

Dest Host

IP: a.b.c.d

Ethernet address: 40:11:11:11:11:11

Src Host

Local Network 1

Src’s First Hop Router

IP: d.c.b.a

Ethernet address: 50:11:11:11:11:11

IP Addr.

Ethernet Addr.

d.c.b.a

50:11:11:11:11:11

d.c.b.c

60:37:11:11:11:11

ARP Table

Router 2

18 of 36

ARP (Across local networks)

  • Router 2 will use its ARP table to set packet’s dest Ethernet address to actual dest host’s Ethernet address:
    • Router 2 then sends packet to dest host

Local Network 1

Dest Host

IP: a.b.c.d

Ethernet address: 40:11:11:11:11:11

Src Host

Local Network 1

Src’s First Hop Router

IP: d.c.b.a

Ethernet address: 50:11:11:11:11:11

IP Addr.

Ethernet Addr.

d.c.b.a

50:11:11:11:11:11

d.c.b.c

60:37:11:11:11:11

ARP Table

IP Addr.

Ethernet Addr.

a.b.c.d

40:11:11:11:11:11

a.b.c.c

70:33:33:33:11:11

ARP Table

Router 2

19 of 36

Putting everything together

Laptop

DHCP

server

DNS

Server

Gateway

Router

google

Server

DHCP: get IPlaptop

UDP: port 67, 68

IP: broadcast

Ethernet: ..

DNS: resolve google.com

UDP: port 53

IP: IPDNS_server

Ethernet,ARP: ..

IP: IPlaptop ↔ IPgoogle

Ethernet, ARP: ..

The realm of routing protocols..

OSPF, BGP..

HTTP: GET “cat”

IP, NAT: IPGW ↔ IPgoogle

Ethernet: ..

..in the Datacenter!

HTTP: OK “=^.^=”

TCP

*Gateway router: the first- and last-hop router of the laptop, e.g., a router at home

20 of 36

Addressing

  • DHCP (Application)
  • ARP (Datalink)
  • NAT

Transport

Network

Datalink

Physical

Application

21 of 36

Network Address Translation (NAT)

  • Only have 2^32 IP addresses
  • Goal: use single public IP address to represent many hosts
  • Have a gateway to convert private to public when going in and convert public to private when going out

22 of 36

Network Address Translation (NAT)

23 of 36

Network Address Translation (NAT)

  • Use logical ports to resolve ambiguities
  • If A and B choose same ports, router notes down fake port

24 of 36

Worksheet

  • Multiple Choice
  • Host-to-Host
  • Network Address Translation

25 of 36

Question 1: Multiple Choice

26 of 36

Question 1: Multiple Choice

27 of 36

Question 1: Multiple Choice

28 of 36

Worksheet

  • Multiple Choice
  • Host-to-Host
  • Network Address Translation

29 of 36

Question 2: Host-to-Host

30 of 36

Question 2: Host-to-Host

31 of 36

Question 2: Host-to-Host

32 of 36

Question 2: Host-to-Host

33 of 36

Question 2: Host-to-Host

34 of 36

Worksheet

  • Multiple Choice
  • Host-to-Host
  • Network Address Translation

35 of 36

Question 3: Network Address Translation

36 of 36

Questions?

Feedback Form: https://tinyurl.com/cs168-su25-disc-feedback