Chapter 3 · Hands-on labs
Six small, beginner-friendly labs using only built-in Linux commands. Type the command, read the output. Each maps to a Chapter 3 idea — finishing with the one that ties the whole chapter together: IP end-to-end, MAC hop-to-hop.
Show the frame header on live traffic (-e prints the Layer-2 part):
sudo tcpdump -i any -e -c 5 -nn
6c:f0:49:68:95:68 > 52:54:00:aa:bb:cc, ethertype IPv4 (0x0800), length 74
Every frame starts with dst MAC > src MAC, then the ethertype. Both MACs are on your local link — the link layer just moves the frame to the next device.
List your one-hop neighbours — devices you can reach directly (their IP and MAC):
ip neigh
192.168.1.1 dev eth0 lladdr 9c:1c:12:aa:bb:cc REACHABLE 192.168.1.42 dev eth0 lladdr 3c:5a:b4:11:22:33 STALE
ip neigh lists exactly those reachable neighbours — the nodes the link layer can hand a frame to directly.Your card’s error counters — how many frames failed their checks:
ip -s link show eth0
2: eth0: <BROADCAST,MULTICAST,UP> ...
RX: bytes packets errors dropped missed mcast
12345678 9876 0 0 0 12
TX: bytes packets errors dropped carrier collsns
2345678 4321 0 0 0 0The errors column counts frames that failed the FCS / CRC check — the link layer’s error detection. On a healthy link it’s 0; a bad cable makes it climb.
Watch a checksum being verified. Capture with -vv and look for “cksum … (correct)”:
sudo tcpdump -i any -vv -c 3 -nn icmp
# in another terminal, generate one ping:
ping -c 1 8.8.8.8
errors counter), and IP/TCP carry their own checksum that tcpdump can re-check as “(correct).”Check speed & duplex on a wired link:
sudo ethtool eth0 | grep -E 'Speed|Duplex'
Speed: 1000Mb/s Duplex: Full
Full duplex means you can send and receive at the same time — modern switched Ethernet, so there are no collisions and CSMA/CD isn’t needed. (Old shared “bus” Ethernet was half-duplex and used CSMA/CD.)
On Wi-Fi instead? Wireless can’t hear collisions, so it uses CSMA/CA (avoidance). Check your wireless link:
iwconfig
Look at the ARP table (IP ↔ MAC pairs your machine has learned):
ip neigh
Start watching ARP in Terminal A (-e shows the MACs):
sudo tcpdump -i any -e -nn arp
Clear the cache & ping your gateway in Terminal B — this forces a fresh ARP lookup:
sudo ip neigh flush all ping -c 1 192.168.1.1
... 6c:f0:49:68:95:68 > ff:ff:ff:ff:ff:ff, Request who-has 192.168.1.1 tell 192.168.1.23 ... 9c:1c:12:aa:bb:cc > 6c:f0:49:68:95:68, Reply 192.168.1.1 is-at 9c:1c:12:aa:bb:cc
Confirm it was cached — the gateway’s MAC is now stored:
ip neigh
Your MAC — the fixed “name” of your card (link/ether):
ip link show eth0
Your IP — your “address”, which depends on this network:
ip -br addr show eth0
Your gateway — the router that is your door to other networks:
ip route | grep default
default via 192.168.1.1 dev eth0
Note your gateway’s MAC (from Lab 4/5) — keep it handy:
ip route | grep default
ip neigh | grep "$(ip route | awk '/default/{print $3}')"Capture one packet to a far host in Terminal A:
sudo tcpdump -i any -e -c 1 -nn 'icmp and dst 8.8.8.8'
Ping that far host in Terminal B:
ping -c 1 8.8.8.8
6c:f0:49:68:95:68 > 9c:1c:12:aa:bb:cc, ethertype IPv4 (0x0800)
192.168.1.23 > 8.8.8.8: ICMP echo requestLook closely: the destination MAC (9c:1c:12:…) is your gateway — the next hop — but the destination IP is 8.8.8.8, the final target. The MAC is local; the IP is end-to-end.
See the IP stay constant across many hops:
traceroute -n 8.8.8.8
Lab 1. Both MACs are on your own network — a frame only travels one hop, between two local devices. (Even traffic bound for the Internet shows your gateway’s local MAC, not a far one — that’s Lab 6.)
Lab 2. Yes, the packet counts rise as your machine sends/receives traffic. If errors stays 0, your link is clean; a climbing errors count points to a bad cable or interference.
Lab 3. No collisions on a full-duplex switched link (send & receive happen on separate paths). A Wi-Fi card would use CSMA/CA (collision avoidance).
Lab 4. The request is a broadcast (all F’s) because A doesn’t yet know who owns the IP — everyone must hear it. The reply is unicast because B now knows exactly who asked (A’s MAC), so it answers just A.
Lab 5. The IP changes on a new network; the MAC stays the same (it’s burned into the card).
Lab 6. For a device on your own LAN, the destination MAC would be that device itself (it’s one hop away). The gateway’s MAC only appears when the destination is on a different network.
| This lab’s tool | Returns in… |
|---|---|
| ip neigh / ARP (Lab 1, 4) | Chapter 4 & 5 — addressing & how packets find their way |
| tcpdump dissection (Lab 1, 6) | Chapter 4 & 5 — the IP header, TTL, ICMP |
| ip route / gateway (Lab 5, 6) | Chapter 4–6 — routing, IP addressing & subnetting |
| error counters (Lab 2) | Any troubleshooting — your first check for a flaky link |