#Why this matters
In earlier lessons, you ran shell commands and saw how computers encode data into binary and hexadecimal bytes. Once those bytes leave your network card, they cross Wi-Fi links, cables, and dozens of independent networks before reaching a remote server.
When a service times out, guessing wastes effort. Knowing how packets are addressed, handed between providers, and guided by routers lets you pinpoint where traffic breaks.
#Packets and network layers
Networks do not send an entire file in one unbroken burst, because one large transfer would block everyone else on a shared wire. Instead, the Internet uses packet switching: data is split into small packets, each holding a header (delivery metadata) and a payload (a slice of your message), so links stay shared and lost pieces can be resent individually.
Each network layer adds its own header before passing the packet downward:
- 4ApplicationHTTP, DNS, SSH (your data)
- 3TransportTCP, UDP (ports, reliability)
- 2InternetIP (source and destination IP)
- 1LinkEthernet, Wi-Fi (local MAC addresses)
This wrapping is encapsulation. Your destination IP address stays unchanged end-to-end (unless a gateway rewrites it), while the Link-layer header changes at every hop to address the next device on that physical link.
#IP addresses, ISPs, and Autonomous Systems
Every networked device needs an IP address:
- IPv4 uses 32-bit addresses written as four decimal numbers, such as
192.0.2.50. - IPv6 uses 128-bit hexadecimal addresses, such as
2001:db8::50, solving IPv4 address exhaustion.
Home and lab networks use private IPv4 ranges (10.0.0.0/8, 192.168.0.0/16) internally. When traffic leaves for the public Internet, the router applies Network Address Translation (NAT) to share a public address assigned by an ISP (Internet Service Provider).
The Internet is a network of networks. Each ISP or large university operates an Autonomous System (AS) with its own routing policy. Providers exchange traffic at peering points and Internet Exchange Points (IXPs), using the Border Gateway Protocol (BGP) to announce reachable IP prefixes.
- Host10.10.10.5 creates IP packet
- Gateway10.10.10.1 applies NAT and forwards
- Access ISProutes across regional backbone
- Peering IXPhands packet to destination AS
- Server192.0.2.50 receives payload
#How routing and TTL work
A router reads each packet's destination IP, checks its routing table for the best matching prefix, and forwards the packet one hop closer.
To stop misconfigured routing loops from looping forever, IPv4 headers carry a TTL (Time to Live) counter (called Hop Limit in IPv6), typically starting at 64 or 128. Each router subtracts 1. If TTL hits 0, the router drops the packet and returns an ICMP "Time Exceeded" message.
Two standard tools rely on ICMP and TTL:
| Tool | What it sends | What it reveals |
|---|---|---|
ping |
ICMP Echo Requests | Reachability, round-trip latency, and loss |
traceroute |
Probes with TTL 1, 2, 3... | Each router hop on the forward path |
$ ping -c 2 192.0.2.50
PING 192.0.2.50 (192.0.2.50) 56(84) bytes of data.
64 bytes from 192.0.2.50: icmp_seq=1 ttl=61 time=12.4 ms
64 bytes from 192.0.2.50: icmp_seq=2 ttl=61 time=12.1 ms
--- 192.0.2.50 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss
$ traceroute -n 192.0.2.50
traceroute to 192.0.2.50 (192.0.2.50), 30 hops max, 60 byte packets
1 10.10.10.1 1.120 ms 1.050 ms 0.990 ms
2 198.51.100.1 4.810 ms 4.790 ms 4.750 ms
3 * * *
4 192.0.2.50 12.310 ms 12.190 ms 12.140 msThe -n flag prints raw IP addresses instead of resolving hostnames (on Windows, use tracert -d). At hop 3, * * * means three probes timed out; because hop 4 (192.0.2.50) still answered, hop 3 forwarded the packets and only suppressed ICMP Time Exceeded replies.
#Common mistakes
- Treating every
* * *as packet loss: Routers often rate-limit ICMP Time Exceeded replies while still forwarding traffic; always check later hops. - Assuming failed
pingmeans offline: Firewalls frequently block ICMP Echo Requests even when web or SSH ports are open. - Expecting symmetric paths: Return traffic can take a different ISP path than outbound probes.
- Confusing private and public IPs:
10.x.x.xand192.168.x.xaddresses require NAT to cross the public Internet.
#Summary
- Networks break data into packets so many hosts can share links and recover from errors one chunk at a time.
- Every packet carries IP addresses across an interconnected web of ISPs and Autonomous Systems, while Link-layer headers change at every hop.
- Routers forward packets using routing tables and decrement the TTL field so misconfigured loops expire.
pingtests reachability and latency, whiletraceroutemaps the forward hop-by-hop path when read carefully.