Unit 2: The Internet · Routing with redundancy

Article

How routers move packets

6 min read

When you open a video from a server far away, your request may pass through ten or more machines before it arrives. Nobody planned that exact journey in advance. Each machine along the way made a small decision. This article is about those machines and the decisions they make.

Routers pass packets along

A router is a device that receives packets and sends each one on toward its destination. The Internet is made of millions of routers joined by cables and wireless links.

A router does not need to know the whole journey. It reads the destination address in the packet's header and chooses the next device that is closer to that destination. The next router does the same. Each step from one router to the next is called a hop.

Look at this small network:

A small network

LaptopR1R2R3R4R5Server
One possible route is highlighted. From R1, a packet could just as well go through R4.

A packet from the laptop reaches R1. R1 can send it toward R2 or toward R4. Both ways end at R5 and then at the server. R1 picks one, based on what looks best at that moment, for example which link is less busy.

Check your understanding

A packet arrives at a router. What does the router do with it?

Different packets, different routes

R1 makes a new decision for every packet. So the packets of one message do not have to follow the same route. Packet 1 might go through R2 and R3, while packet 2 goes through R4 because the first link became busy.

This has an important result: the packets may arrive in a different order than they were sent. A packet that took a short, quiet route can overtake one that took a long, busy route.

The receiving computer is ready for this. It uses the packet numbers to put the pieces back in the right order.

Routes can also change when something breaks. If the link between R1 and R2 stops working, R1 simply sends packets the other way. The sender and receiver may never notice.

The link from R1 to R2 breaks

LaptopR1R2R3R4R5Server
R1 sends the next packets through R4 instead. They still reach the server.

Check your understanding

Packet 3 of a message arrives at the receiver before packet 2. What is the most likely reason?

Worked example

The laptop sends four packets to the server, using the network above. This is what happened:

PacketRoute takenArrived
1R1, R2, R3, R52nd
2R1, R4, R51st
3R1, R4, R53rd
4R1, R2, R3, R54th

Packets 2 and 3 took the shorter route through R4, so packet 2 arrived before packet 1. The server receives the pieces in the order 2, 1, 3, 4. It looks at the packet numbers and puts them in the order 1, 2, 3, 4. The message is complete and correct.

Notice what did not happen: no router decided the whole route, and no one made the packets arrive in order. Order was fixed at the end, by the receiver.

Common mistakes

  • "A router knows the whole route." No. Each router only chooses the next hop.
  • "All packets of a message use the same route." Not necessarily. Each packet is routed on its own.
  • "Packets always arrive in the order they were sent." The Internet does not promise this.
  • "The router puts the message back together." No. Routers only forward packets. The receiving computer rebuilds the message.

On the exam

The key facts are: routers forward packets using the destination address; the route is not fixed in advance; and the route can change, even in the middle of a message. If a question says that packets arrived in a different order, the usual reason is that they took different routes.

Key words

Router: a device that receives packets and forwards them toward their destination.

Hop: one step of a packet's journey, from one router to the next.

Route (or path): the list of devices and links a packet passes through on its way.

Routing: choosing which way to send each packet next.

AP® is a trademark registered by the College Board, which is not affiliated with, and does not endorse, this site. All lessons and questions here are written by JrCodex.