Local delivery and gateway delivery
On this page
You saw the link header change in Following one exchange. Now explain why. Web is outside laptop’s subnet, and a home broadcast cannot ask web for its MAC address. Laptop still needs a link destination before it can send the packet.
Before you start
Section titled “Before you start”Finish Finding a neighbor with ARP. Use the starting lab, modes off. Leave machine shells and run netlab reset at the VM prompt if needed. Open two terminals on laptop with netlab shell laptop. Keep the local decision from Same subnet or gateway in mind: laptop uses its own prefix.
Reach a local interface directly
Section titled “Reach a local interface directly”In terminal 1 start sudo tcpdump -n -e -i eth0 arp or icmp, answering sudo’s password question. In terminal 2 clear laptop’s neighbors with sudo ip neigh flush dev eth0, then ping phone and web once each. Read ip neigh. Return to terminal 1 and stop with Ctrl+C. The two replays below show this whole experiment.
Phone is local under laptop’s prefix. Laptop asks ARP for phone’s own IP address, learns its MAC address, and puts that address on the frame. Both the packet and its surrounding frame name phone, using their different address types.
Hand a remote packet to a neighbor
Section titled “Hand a remote packet to a neighbor”A gateway is a router used to reach another network. A next hop is the next device to which a packet is handed. For a local destination, that device is the destination itself. For web, laptop’s next hop is router’s home interface.
Laptop asks who has 10.77.10.1, rather than who has web’s address. Router answers with 02:77:10:00:00:01. That MAC address becomes the frame’s destination. The packet inside still names 10.77.20.80. These fields answer different questions: who receives this frame, and where the packet is going.
Predict: after reaching web, does laptop’s neighbor table contain web’s address or router’s address?
learner@laptop:~$ sudo tcpdump -n -e -i eth0 arp or icmp[sudo] password for learner: tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes15:08:04.817294 02:77:10:00:00:10 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.77.10.11 tell 10.77.10.10, length 28
15:08:04.817353 02:77:10:00:00:11 > 02:77:10:00:00:10, ethertype ARP (0x0806), length 42: Reply 10.77.10.11 is-at 02:77:10:00:00:11, length 28
15:08:04.817355 02:77:10:00:00:10 > 02:77:10:00:00:11, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.10.11: ICMP echo request, id 176, seq 1, length 64
15:08:04.817384 02:77:10:00:00:11 > 02:77:10:00:00:10, ethertype IPv4 (0x0800), length 98: 10.77.10.11 > 10.77.10.10: ICMP echo reply, id 176, seq 1, length 64
15:08:05.320955 02:77:10:00:00:10 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.77.10.1 tell 10.77.10.10, length 28
15:08:05.321022 02:77:10:00:00:01 > 02:77:10:00:00:10, ethertype ARP (0x0806), length 42: Reply 10.77.10.1 is-at 02:77:10:00:00:01, length 28
15:08:05.321024 02:77:10:00:00:10 > 02:77:10:00:00:01, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.20.80: ICMP echo request, id 177, seq 1, length 64
15:08:05.321100 02:77:10:00:00:01 > 02:77:10:00:00:10, ethertype IPv4 (0x0800), length 98: 10.77.20.80 > 10.77.10.10: ICMP echo reply, id 177, seq 1, length 64^C8 packets captured
8 packets received by filter
0 packets dropped by kernellearner@laptop:~$ Steps (10)
- Type
sudo tcpdump -n -e -i eth0 arp or icmp - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes - Terminal 2 finished its tests. Return here and stop the listener with Ctrl+C.
- Output:
15:08:04.817294 02:77:10:00:00:10 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.77.10.11 tell 10.77.10.10, length 28 15:08:04.817353 02:77:10:00:00:11 > 02:77:10:00:00:10, ethertype ARP (0x0806), length 42: Reply 10.77.10.11 is-at 02:77:10:00:00:11, length 28 15:08:04.817355 02:77:10:00:00:10 > 02:77:10:00:00:11, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.10.11: ICMP echo request, id 176, seq 1, length 64 15:08:04.817384 02:77:10:00:00:11 > 02:77:10:00:00:10, ethertype IPv4 (0x0800), length 98: 10.77.10.11 > 10.77.10.10: ICMP echo reply, id 176, seq 1, length 64 15:08:05.320955 02:77:10:00:00:10 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.77.10.1 tell 10.77.10.10, length 28 15:08:05.321022 02:77:10:00:00:01 > 02:77:10:00:00:10, ethertype ARP (0x0806), length 42: Reply 10.77.10.1 is-at 02:77:10:00:00:01, length 28 15:08:05.321024 02:77:10:00:00:10 > 02:77:10:00:00:01, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.20.80: ICMP echo request, id 177, seq 1, length 64 15:08:05.321100 02:77:10:00:00:01 > 02:77:10:00:00:10, ethertype IPv4 (0x0800), length 98: 10.77.20.80 > 10.77.10.10: ICMP echo reply, id 177, seq 1, length 64 - Press Ctrl + C
- Output:
8 packets captured 8 packets received by filter 0 packets dropped by kernel
learner@laptop:~$ sudo ip neigh flush dev eth0[sudo] password for learner: learner@laptop:~$ ping -c 1 10.77.10.11PING 10.77.10.11 (10.77.10.11) 56(84) bytes of data.
64 bytes from 10.77.10.11: icmp_seq=1 ttl=64 time=0.178 ms
--- 10.77.10.11 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.178/0.178/0.178/0.000 mslearner@laptop:~$ ping -c 1 10.77.20.80PING 10.77.20.80 (10.77.20.80) 56(84) bytes of data.
64 bytes from 10.77.20.80: icmp_seq=1 ttl=63 time=0.217 ms
--- 10.77.20.80 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.217/0.217/0.217/0.000 mslearner@laptop:~$ ip neigh10.77.10.1 dev eth0 lladdr 02:77:10:00:00:01 REACHABLE
10.77.10.11 dev eth0 lladdr 02:77:10:00:00:11 REACHABLE learner@laptop:~$ Steps (14)
- Type
sudo ip neigh flush dev eth0 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Type
ping -c 1 10.77.10.11 - Press Enter
- Output:
PING 10.77.10.11 (10.77.10.11) 56(84) bytes of data. 64 bytes from 10.77.10.11: icmp_seq=1 ttl=64 time=0.178 ms --- 10.77.10.11 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.178/0.178/0.178/0.000 ms - Type
ping -c 1 10.77.20.80 - Press Enter
- Output:
PING 10.77.20.80 (10.77.20.80) 56(84) bytes of data. 64 bytes from 10.77.20.80: icmp_seq=1 ttl=63 time=0.217 ms --- 10.77.20.80 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.217/0.217/0.217/0.000 ms - Type
ip neigh - Press Enter
- Output:
10.77.10.1 dev eth0 lladdr 02:77:10:00:00:01 REACHABLE 10.77.10.11 dev eth0 lladdr 02:77:10:00:00:11 REACHABLE
Check your answer
Router’s 10.77.10.1 appears beside phone’s 10.77.10.11. Web’s IP address is absent. Laptop learned a local next hop for that remote destination.
Compare the listener’s two cases side by side here. Read the MAC address immediately after > separately from the packet’s destination later on that line.
| phone | web | |
|---|---|---|
| Local or remote | Local | Remote |
| ARP asked for | 10.77.10.11 |
10.77.10.1 |
| Frame destination MAC address | 02:77:10:00:00:11 |
02:77:10:00:00:01 |
| Packet destination IP address | 10.77.10.11 |
10.77.20.80 |
Repeat the decision at router
Section titled “Repeat the decision at router”Predict which destination address changes when router sends onto site. Step through the same captured echo request at all four points. The stage matches that packet across the points; it does not join packets from separate pings.
Use the neighbor learned on each network
- laptopmachine
- sw-homeswitch
- routerrouter
- sw-siteswitch
- webserver
In the capture4 capture points
- laptop:eth0
15:08:05.321024 02:77:10:00:00:10 > 02:77:10:00:00:01, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.20.80: ICMP echo request, id 177, seq 1, length 64 - router:eth0
15:08:05.321032 02:77:10:00:00:10 > 02:77:10:00:00:01, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.20.80: ICMP echo request, id 177, seq 1, length 64 - router:eth1
15:08:05.321071 02:77:20:00:00:01 > 02:77:20:00:00:80, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.20.80: ICMP echo request, id 177, seq 1, length 64 - web:eth0
15:08:05.321072 02:77:20:00:00:01 > 02:77:20:00:00:80, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.20.80: ICMP echo request, id 177, seq 1, length 64
ping -c 1 10.77.20.80, on Ubuntu 24.04.5 LTS, netlab 1.0, tcpdump 4.99.4. The values are the capture's; what each device reads is the model. The routed request uses the ARP result on each local link. Switch actions are modeled from the adjacent captures; the four capture points observe the same packet.Steps (6)
- laptop sends. ARP for router’s home address supplied this frame’s destination MAC address. The packet still names web.
15:08:05.321024 02:77:10:00:00:10 > 02:77:10:00:00:01, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.20.80: ICMP echo request, id 177, seq 1, length 64 - sw-home. The home switch reads the destination MAC address and forwards the frame unchanged. Its action is modeled from the capture after it. Read: Destination MAC address.
15:08:05.321032 02:77:10:00:00:10 > 02:77:10:00:00:01, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.20.80: ICMP echo request, id 177, seq 1, length 64 - router in. Router accepts its home link address and reads web’s destination IP address to choose site. Read: Destination MAC address and Destination address.
15:08:05.321032 02:77:10:00:00:10 > 02:77:10:00:00:01, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.20.80: ICMP echo request, id 177, seq 1, length 64 - router out. Router’s separate site ARP question learned web’s MAC address. It builds this link header from that answer. Rewritten: Source MAC address 02:77:10:00:00:10 to 02:77:20:00:00:01, Destination MAC address 02:77:10:00:00:01 to 02:77:20:00:00:80 and Time to live 64 to 63.
15:08:05.321071 02:77:20:00:00:01 > 02:77:20:00:00:80, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.20.80: ICMP echo request, id 177, seq 1, length 64 - sw-site. The site switch reads the destination MAC address and forwards the frame unchanged. Its action is modeled from the capture after it. Read: Destination MAC address.
15:08:05.321072 02:77:20:00:00:01 > 02:77:20:00:00:80, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.20.80: ICMP echo request, id 177, seq 1, length 64 - web receives. web accepts the frame addressed to its interface and the packet addressed to its machine. Read: Destination MAC address and Destination address.
15:08:05.321072 02:77:20:00:00:01 > 02:77:20:00:00:80, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.20.80: ICMP echo request, id 177, seq 1, length 64
Check your answer
The link destination changes to web’s 02:77:20:00:00:80. The packet destination stays web’s IP address. Router can ask for web directly because its site interface shares web’s network.
Router receives a frame addressed to its home interface. It reads the carried destination, selects its site interface, resolves web there, and builds a link header for that network. Its source MAC address also changes to the site interface’s address.
The switches pass these frames within their own networks. They do not replace the headers. The ARP questions on home and site are separate local exchanges, each supplying the address needed for that link. Neither question travels through router to the other network.
Mistakes to recognize
Section titled “Mistakes to recognize”“The frame carries the final destination’s MAC address.” Laptop’s frame for web names router instead. Compare the remote row with the stage after router.
“The gateway’s IP address is written in the packet.” The captured request keeps web’s destination IP address. The gateway setting chooses a handoff; it does not replace that destination.
Good to know
Section titled “Good to know”One gateway entry can serve many remote destinations. A neighbor table records local associations, not a list of every remote server contacted. Read the state promptly; timing and ping identifiers vary, so your number will differ.
Try it yourself
Section titled “Try it yourself”Predict phone’s neighbors after reaching web and laptop. Enter phone, clear its neighbors, run ping -c 1 10.77.20.80, then ping -c 1 10.77.10.10, then ip neigh. Compare the addresses with your prediction and explain each handoff.
Solution
learner@phone:~$ sudo ip neigh flush dev eth0[sudo] password for learner: learner@phone:~$ ping -c 1 10.77.20.80PING 10.77.20.80 (10.77.20.80) 56(84) bytes of data.
64 bytes from 10.77.20.80: icmp_seq=1 ttl=63 time=0.153 ms
--- 10.77.20.80 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.153/0.153/0.153/0.000 mslearner@phone:~$ ping -c 1 10.77.10.10PING 10.77.10.10 (10.77.10.10) 56(84) bytes of data.
64 bytes from 10.77.10.10: icmp_seq=1 ttl=64 time=0.116 ms
--- 10.77.10.10 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.116/0.116/0.116/0.000 mslearner@phone:~$ ip neigh10.77.10.1 dev eth0 lladdr 02:77:10:00:00:01 REACHABLE
10.77.10.10 dev eth0 lladdr 02:77:10:00:00:10 REACHABLE learner@phone:~$ Steps (14)
- Type
sudo ip neigh flush dev eth0 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Type
ping -c 1 10.77.20.80 - Press Enter
- Output:
PING 10.77.20.80 (10.77.20.80) 56(84) bytes of data. 64 bytes from 10.77.20.80: icmp_seq=1 ttl=63 time=0.153 ms --- 10.77.20.80 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.153/0.153/0.153/0.000 ms - Type
ping -c 1 10.77.10.10 - Press Enter
- Output:
PING 10.77.10.10 (10.77.10.10) 56(84) bytes of data. 64 bytes from 10.77.10.10: icmp_seq=1 ttl=64 time=0.116 ms --- 10.77.10.10 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.116/0.116/0.116/0.000 ms - Type
ip neigh - Press Enter
- Output:
10.77.10.1 dev eth0 lladdr 02:77:10:00:00:01 REACHABLE 10.77.10.10 dev eth0 lladdr 02:77:10:00:00:10 REACHABLE
Phone learns 10.77.10.1 at 02:77:10:00:00:01 and 10.77.10.10 at 02:77:10:00:00:10. It needs no web entry.
- Resolve the local destination itself for direct delivery.
- Resolve the gateway for a remote packet.
- Keep the remote packet destination through the handoff.
Next, Reading routes and default routes explains the choice of interface and next hop.