A router controls each packet's route

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

A router controls each packet's route

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does a router read in a packet's header to decide where to send the packet next?
A The destination address
B The payload data
2. Which statement about routing is correct?
A A router decides the route for each packet separately
B A router decides one route for the whole message before any packet is sent
3. After a router reads a packet's header, what does it do with the packet?
A Keeps it until all the other packets arrive
B Forwards it to the next router on the way to the destination
4. Which part of a packet does the router use to choose the next router?
A Header
B Trailer
5. Two packets from the same file reach a router. Which is true?
A The router must send them to the same next router
B The router can send them to different next routers

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1routing Afor packet in packets: route = router.choose(packet)
2next_hop = router.read(packet.header.destination) Brouter2.forward(packet, router3)
3A router decides the route for each packet separately, so two packets from the same file can be sent different ways. CThe router uses the payload to choose the route. The payload is just the data being carried. The router must read the header, which holds the destination address.
4A router does not plan the whole journey. It only forwards the packet to the next router, which then makes its own decision. DThe router reads the destination address in the packet header to decide which router to forward the packet to next.
5router.read(packet.payload) # to find the route EA router reads each packet's destination address in its header and picks the next router to send it to, so every packet's route is decided one step at a time.
6route = router.choose(all_packets) # one route for the whole message FA router does not pick one route for the whole message. It decides the route for each packet separately, so packets may take different routes.

Definitions

routing

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
address ← packet.header.___________
2.
address ← packet.header.destination next ← router.___________(address)
3.
next ← router.chooseRoute(address) router._______(packet, next)
4.
FOR ____ packet IN message router.route(packet)
5.
address ← packet.header.destination next ← router.chooseRoute(_______) router.forward(packet, next)

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A dest <- packet.packet_number
B next <- LOOKUP(dest)
C SEND packet TO next
Question 2
A FOR EACH packet IN arrived
B dest <- packet.destination
C next <- PICK_ROUTE(source)
D SEND packet TO next
Question 3
A RECEIVE packet
B dest <- packet.trailer.dest
C next <- BEST_ROUTER(dest)
D FORWARD packet TO next
Question 4
A packet <- RECEIVE()
B dest <- packet.destination
C next <- LOOKUP(dest)
D SEND payload TO next_router
Question 5
A FOR EACH packet IN message
B dest <- packet.destination
C next <- LOOKUP(dest)
D SEND message TO next

Answer Key

A router controls each packet's route
Section A: Quick Questions
Q1
A — The destination address
Q2
A — A router decides the route for each packet separately
Q3
B — Forwards it to the next router on the way to the destination
Q4
A — Header
Q5
B — The router can send them to different next routers
Section B: Match the Pairs
Q1
routing → A router reads each packet's destination address in its header and picks the next router to send it to, so every packet's route is decided one step at a time.
Q2
next_hop = router.read(packet.header.destination) → The router reads the destination address in the packet header to decide which router to forward the packet to next.
Q3
A router decides the route for each packet separately, so two packets from the same file can be sent different ways. → for packet in packets: route = router.choose(packet)
Q4
A router does not plan the whole journey. It only forwards the packet to the next router, which then makes its own decision. → router2.forward(packet, router3)
Q5
router.read(packet.payload) # to find the route → The router uses the payload to choose the route. The payload is just the data being carried. The router must read the header, which holds the destination address.
Q6
route = router.choose(all_packets) # one route for the whole message → A router does not pick one route for the whole message. It decides the route for each packet separately, so packets may take different routes.
Section C: Definitions
Q1
routing — A router reads each packet's destination address in its header and picks the next router to send it to, so every packet's route is decided one step at a time.
Section D: Fill in the Blanks
Q1
address ← packet.header.destination
Q2
address ← packet.header.destination next ← router.chooseRoute(address)
Q3
next ← router.chooseRoute(address) router.forward(packet, next)
Q4
FOR EACH packet IN message router.route(packet)
Q5
address ← packet.header.destination next ← router.chooseRoute(address) router.forward(packet, next)
Section E: Spot the Error
Q1
A — The router must read the destination address from the header to choose a route. The packet number is only used to reorder packets at the end. It should be dest <- packet.destination.
Q2
C — The next router is chosen using the destination address, not the originator's address. The line should be next <- PICK_ROUTE(dest).
Q3
B — The destination address is stored in the packet header, not the trailer. The trailer only marks the end of the packet. It should be packet.header.dest.
Q4
D — The router must forward the whole packet, including its header. If only the payload is sent, the next router cannot read the destination address. It should be SEND packet TO next_router.
Q5
D — Routing is decided packet by packet, so each packet is sent on its own route. The whole message must not be sent together. It should be SEND packet TO next.