How a packet finds its way across the internet

· 2 min read

#how-it-works#networking

A packet crossing the internet passes through a series of routers, and each router decides only the next step. The idea to keep: every hop is a table lookup, and a counter makes sure a wrong turn cannot go on forever.

The short version

The packet is passed from one network to the next through routers. Each router looks in its own route database and forwards the packet. When several routes match the destination, the most specific one wins: the longest matching network prefix. Meanwhile a time-to-live field is lowered wherever the packet is processed. When it reaches zero, the packet is destroyed.

How a packet is forwarded from router to router A packet goes from the sender through router 1 and router 2 to the receiver. Each router looks up the next hop in its routing table, where the longest matching prefix wins, and lowers the time-to-live. If the time-to-live reaches zero, the packet is dropped. Sender sends the packet Router 1 TTL lowered Router 2 TTL lowered Receiver packet arrives Routing table longest prefix wins Packet dropped TTL reached 0 1 2 3 look up look up TTL 0
Arrows 1 to 3 follow the packet. Each router looks up its table and lowers the time-to-live (TTL); the dashed path is what happens at zero.

Step by step

  1. The sender hands the packet to the first router.
  2. The router looks up the destination in its route database.
  3. If more than one route matches, it uses the longest matching network prefix.
  4. It lowers the time-to-live field and forwards the packet to the next router.
  5. This repeats until the receiver is reached. If the time-to-live hits zero first, the packet is dropped.

Why it matters

A wrong turn between two routers cannot make a packet circle forever, because the counter runs out. My reading, not a quoted line: no single router needs to know the whole path, only the next hop. Simplified: one path, no error messages, no routing protocols.

Sources