7 · Network layer overview and router architecture ★
Slides 4-1 → 4-31 · HW5 P1, P2, P3 · Textbook 4.1–4.2
What the network layer does (4-2, 4-3)
- Sender encapsulates transport segments into datagrams and passes them to the link layer. Receiver delivers the segments up to transport (4-2).
- The network layer runs in every host and every router. A router examines header fields in every IP datagram passing through it (4-2).
- Forwarding: move a packet from a router's input link to the right output link. Analogy: getting through one interchange (4-3).
- Routing: determine the route packets take from source to destination, using routing algorithms. Analogy: planning the whole trip (4-3).
Data plane vs control plane (4-4 → 4-6)
| Data plane | Control plane | |
|---|---|---|
| Scope | Local, per-router | Network-wide logic |
| Job | How a datagram arriving on an input port is forwarded to an output port | How a datagram is routed among routers along the end-to-end path |
| Speed (4-11) | Nanoseconds, in hardware | Milliseconds, in software |
- Per-router control plane (traditional): a routing algorithm component runs in each and every router, and they interact with each other to build the forwarding tables (4-5).
- SDN control plane: a remote controller (in servers) computes and installs forwarding tables in the routers. Each router runs only a small control agent (CA) (4-6).
Network service model (4-7 → 4-9)
- Possible services for individual datagrams: guaranteed delivery; guaranteed delivery with less than 40 ms delay (4-7).
- Possible services for a flow: in-order delivery; guaranteed minimum bandwidth; limits on changes in inter-packet spacing (jitter) (4-7).
- The Internet gives best effort: no guarantees on (i) successful delivery, (ii) timing or order of delivery, (iii) bandwidth available to the flow (4-8).
| Architecture | Service model | Bandwidth | Loss | Order | Timing |
|---|---|---|---|---|---|
| Internet | best effort | none | no | no | no |
| ATM | Constant Bit Rate | constant rate | yes | yes | yes |
| ATM | Available Bit Rate | guaranteed min | no | yes | no |
| Internet | Intserv (RFC 1633) | yes | yes | yes | yes |
| Internet | Diffserv (RFC 2475) | possible | possibly | possibly | no |
"Loss: no" in the best-effort row means no guarantee against loss.
Router architecture (4-11)
- Input ports: terminate the line, run the link layer, look up the output port, queue.
- Switching fabric: moves packets from input ports to output ports.
- Output ports: queue (buffer), run the link layer, transmit on the line.
- Routing processor: runs the routing protocols and management (control plane, software, milliseconds). Ports + fabric are the data plane (hardware, nanoseconds).
Input port functions (4-12 → 4-16)
- Three stages: line termination (physical layer, bit-level reception) → link layer protocol (e.g., Ethernet) → lookup, forwarding, queueing (4-12).
- Decentralized switching: each input port has its own copy of the forwarding table and does the lookup itself ("match plus action"). Goal: finish input processing at line speed (4-12).
- Input port queueing happens if datagrams arrive faster than the forwarding rate into the fabric (4-12).
- Destination-based forwarding: forward based only on the destination IP address (traditional). Generalized forwarding: forward on any set of header fields (4-13).
- Longest prefix match: use the longest table prefix that matches the destination address (4-15). Worked in detail on page 8.
- TCAM (ternary content addressable memory): present the address and get the entry back in one clock cycle, regardless of table size. Cisco Catalyst: ~1M entries (4-16).
Switching fabrics (4-17 → 4-21)
- Switching rate: rate packets move from inputs to outputs, measured as a multiple of line rate. With N inputs at rate R, a switching rate of N·R is desirable (4-17).
| Fabric | How | Limit | Two packets at once? |
|---|---|---|---|
| Memory (first generation) | Traditional computer, CPU copies the packet into system memory then out | Memory bandwidth; 2 bus crossings per datagram | No: one memory read/write at a time |
| Bus | Input port memory → output port memory over a shared bus | Bus contention: speed limited by bus bandwidth (Cisco 5600: 32 Gbps bus) | No: one packet on the bus at a time |
| Interconnection network (crossbar, Clos, multistage) | Grid of buses; multistage switches built from smaller switches; datagrams cut into fixed-length cells, reassembled at exit | Parallel; Cisco CRS up to 100s of Tbps | Yes if they go to different outputs; no if same output |
Input port queueing and HOL blocking (4-22)
- If the fabric is slower than the input ports combined, packets queue at the inputs. Result: queueing delay and loss from input buffer overflow.
- Head-of-the-line (HOL) blocking: the datagram at the front of an input queue is waiting (its output is busy), so packets behind it wait too, even if their own output port is free.
- Slide picture: two red packets at the front of two inputs both want the same output. Only one goes. The green packet behind the blocked red one wants an idle output but is stuck.
Output port queueing (4-23 → 4-25)
- Buffering is needed when datagrams arrive from the fabric (rate up to N·R) faster than the link rate R (4-23, 4-24).
- Result: queueing delay and loss from output buffer overflow (4-24).
- Drop policy: which datagrams to drop when no buffers are free. Scheduling discipline: which queued datagram to send next (4-23).
- How much buffering? RFC 3439 rule of thumb: buffer = typical RTT (say 250 ms) × link capacity C. Example: C = 10 Gbps → 2.5 Gbit (4-25).
- Newer rule with N flows: buffer =
RTT · C / √N(4-25). - Too much buffering hurts: longer delays (especially home routers), poor real-time performance, sluggish TCP. "Keep the bottleneck link just full enough, but no fuller" (4-25).
Buffer management (4-26)
- Drop: which packet to drop when buffers are full. Tail drop: drop the arriving packet. Priority: drop/remove by priority.
- Marking: which packets to mark to signal congestion: ECN, RED (random early detection).
Packet scheduling (4-27 → 4-30)
- FCFS / FIFO: send packets in order of arrival at the output port (4-27).
- Priority: classify arrivals into classes (by any header fields), send from the highest-priority queue that has a packet; FCFS within a class. A packet already being sent is not interrupted (non-preemptive) (4-28).
- Round robin (RR): cyclically scan the class queues, sending one complete packet from each class (if it has one) in turn (4-29).
- Weighted fair queueing (WFQ): generalized RR. Class i has weight wi and gets fraction
wi / Σj wjof the link each cycle. Gives a minimum bandwidth guarantee per class (4-30). - Net neutrality (4-31): 2015 FCC rules were no blocking, no throttling, no paid prioritization; rolled back in 2017; the rollback was itself reversed in 2024.
HW5 P1: forwarding is by destination only
Q (HW5 P1): Consider the network in the figure. Router A has interfaces 1 (to H1), 2 (to H2), 3 (to B), 4 (to C). H3 sits behind D.
- (a) Show the forwarding table in router A such that all traffic destined to host H3 is forwarded through interface 3.
- (b) Can you write a forwarding table in router A such that all traffic from H1 destined to H3 is forwarded through interface 3, while all traffic from H2 destined to H3 is forwarded through interface 4? (Hint: this is a trick question.)
- a) Table in A:
destination H3 → interface 3. - b) No. Forwarding uses only the destination address. Packets from H1 and from H2 to H3 have the same destination, so they hit the same entry and leave on the same interface.
HW5 P2: two packets at the same time? (official answers)
Q (HW5 P2): Two packets arrive at two different input ports of a router at exactly the same time. There are no other packets anywhere in the router.
- (a) The two packets go to two different output ports. Can they be forwarded through the switch fabric at the same time if the fabric is a shared bus?
- (b) The two packets go to two different output ports. Can they be forwarded through the switch fabric at the same time if the fabric uses switching via memory?
- (c) The two packets go to the same output port. Can they be forwarded through the switch fabric at the same time if the fabric is a crossbar?
- a) Shared bus, different outputs: No. Only one packet can cross a shared bus at a time.
- b) Memory, different outputs: No. Only one memory read/write at a time over the shared system bus.
- c) Crossbar, same output: No. Both packets would have to use the same output bus at the same time. (A crossbar can do it for different outputs.)
How to solve: scheduling departure order (HW5 P3)
- Write down what arrives at each time t. Each packet takes one slot to send.
- At the start of each slot, list the packets waiting (include the ones that arrive exactly at that instant).
- Pick one by the policy. FIFO: earliest arrival (ties: lower number). Priority: highest class first, FIFO inside the class. RR: alternate classes, skip an empty class. WFQ (weights 2:1): class 1 gets two slots, then class 2 gets one; skip an empty class.
- A packet that starts at slot t leaves at t+1. Delay (HW definition in a, b) = slot start − arrival. Arrival-to-departure = that + 1.
- Sum and divide by 11.
Q (HW5 P3): Packets 1 to 12 arrive at a single output queue at the times in the figure (table below). Each packet takes one slot to transmit, and packet 1 is in service first.
- (a) Assuming FIFO service, give the time at which packets 2 through 12 each leave the queue. For each packet, what is the delay between its arrival and the beginning of the slot in which it is transmitted? What is the average of this delay over all 11 packets?
- (b) Now assume priority service: odd-numbered packets are high priority, even-numbered packets are low priority. Give the time each of packets 2 through 12 leaves the queue, the delay from arrival to the beginning of its transmit slot, and the average of this delay over all 11 packets.
- (c) Now assume round robin. Packets 1, 2, 3, 6, 11, 12 are class 1; packets 4, 5, 7, 8, 9, 10 are class 2. Give the time each of packets 2 through 12 leaves the queue, the delay between its arrival and its departure, and the average delay over all 11 packets.
- (d) Now assume WFQ. Odd-numbered packets are class 1 (weight 2), even-numbered packets are class 2 (weight 1). An idealized WFQ schedule may not be possible, so say why you chose the packet that goes into service in each slot. For each packet, what is the delay between its arrival and its departure? What is the average delay over all 11 packets?
- (e) What do you notice about the average delay in all four cases (FIFO, RR, priority, WFQ)?
The problem's arrivals (from the figure)
| Time | t=0 | t=1 | t=2 | t=3 | t=4 | t=5 | t=6 | t=7 | t=8 |
|---|---|---|---|---|---|---|---|---|---|
| Arrive | 1, 2 | 3, 4 | 6 | 5, 7 | – | 8, 9 | – | 10 | 11, 12 |
Packet 1 is in service during [0, 1] and leaves at t = 1 in every part. Note that 6 arrives before 5.
a) FIFO
| Slot start | Waiting | Send | Leaves | Arrived | Delay |
|---|---|---|---|---|---|
| 1 | 2, 3, 4 | 2 | 2 | 0 | 1 |
| 2 | 3, 4, 6 | 3 | 3 | 1 | 1 |
| 3 | 4, 6, 5, 7 | 4 | 4 | 1 | 2 |
| 4 | 6, 5, 7 | 6 | 5 | 2 | 2 |
| 5 | 5, 7, 8, 9 | 5 | 6 | 3 | 2 |
| 6 | 7, 8, 9 | 7 | 7 | 3 | 3 |
| 7 | 8, 9, 10 | 8 | 8 | 5 | 2 |
| 8 | 9, 10, 11, 12 | 9 | 9 | 5 | 3 |
| 9 | 10, 11, 12 | 10 | 10 | 7 | 2 |
| 10 | 11, 12 | 11 | 11 | 8 | 2 |
| 11 | 12 | 12 | 12 | 8 | 3 |
order: 1, 2, 3, 4, 6, 5, 7, 8, 9, 10, 11, 12 sum = 1+1+2+2+2+3+2+3+2+2+3 = 23 average = 23/11 ≈ 2.09 slots
b) Priority (odd = high, even = low, non-preemptive)
| Slot start | Waiting (H | L) | Send | Leaves | Arrived | Delay |
|---|---|---|---|---|---|
| 1 | 3 | 2, 4 | 3 | 2 | 1 | 0 |
| 2 | – | 2, 4, 6 | 2 | 3 | 0 | 2 |
| 3 | 5, 7 | 4, 6 | 5 | 4 | 3 | 0 |
| 4 | 7 | 4, 6 | 7 | 5 | 3 | 1 |
| 5 | 9 | 4, 6, 8 | 9 | 6 | 5 | 0 |
| 6 | – | 4, 6, 8 | 4 | 7 | 1 | 5 |
| 7 | – | 6, 8, 10 | 6 | 8 | 2 | 5 |
| 8 | 11 | 8, 10, 12 | 11 | 9 | 8 | 0 |
| 9 | – | 8, 10, 12 | 8 | 10 | 5 | 4 |
| 10 | – | 10, 12 | 10 | 11 | 7 | 3 |
| 11 | – | 12 | 12 | 12 | 8 | 3 |
order: 1, 3, 2, 5, 7, 9, 4, 6, 11, 8, 10, 12 sum = 0+2+0+1+0+5+5+0+4+3+3 = 23 average = 23/11 ≈ 2.09 slots
c) Round robin (class 1 = 1, 2, 3, 6, 11, 12; class 2 = 4, 5, 7, 8, 9, 10)
Packet 1 (class 1) went first, so class 2 has the next turn. An empty class is skipped.
| Slot start | Waiting (C1 | C2) | Turn | Send | Leaves | Arrived | Delay to slot start |
|---|---|---|---|---|---|---|
| 1 | 2, 3 | 4 | C2 | 4 | 2 | 1 | 0 |
| 2 | 2, 3, 6 | – | C1 | 2 | 3 | 0 | 2 |
| 3 | 3, 6 | 5, 7 | C2 | 5 | 4 | 3 | 0 |
| 4 | 3, 6 | 7 | C1 | 3 | 5 | 1 | 3 |
| 5 | 6 | 7, 8, 9 | C2 | 7 | 6 | 3 | 2 |
| 6 | 6 | 8, 9 | C1 | 6 | 7 | 2 | 4 |
| 7 | – | 8, 9, 10 | C2 | 8 | 8 | 5 | 2 |
| 8 | 11, 12 | 9, 10 | C1 | 11 | 9 | 8 | 0 |
| 9 | 12 | 9, 10 | C2 | 9 | 10 | 5 | 4 |
| 10 | 12 | 10 | C1 | 12 | 11 | 8 | 2 |
| 11 | – | 10 | C2 | 10 | 12 | 7 | 4 |
order: 1, 4, 2, 5, 3, 7, 6, 8, 11, 9, 12, 10 sum (to slot start) = 0+2+0+3+2+4+2+0+4+2+4 = 23 average ≈ 2.09 arrival → departure = each +1: sum 34, average 34/11 ≈ 3.09
d) WFQ (odd = class 1, weight 2; even = class 2, weight 1)
Cycle: class 1 gets two slots, then class 2 gets one. If a class has nothing waiting, its turn passes to the other class (the link never sits idle). Packet 1 used class 1's first slot.
| Slot start | Waiting (C1 | C2) | Why | Send | Leaves | Delay to slot start |
|---|---|---|---|---|---|
| 1 | 3 | 2, 4 | C1's 2nd slot | 3 | 2 | 0 |
| 2 | – | 2, 4, 6 | C2's slot | 2 | 3 | 2 |
| 3 | 5, 7 | 4, 6 | new cycle, C1 1st | 5 | 4 | 0 |
| 4 | 7 | 4, 6 | C1 2nd | 7 | 5 | 1 |
| 5 | 9 | 4, 6, 8 | C2's slot | 4 | 6 | 4 |
| 6 | 9 | 6, 8 | new cycle, C1 1st | 9 | 7 | 1 |
| 7 | – | 6, 8, 10 | C1 2nd, but C1 empty → C2 | 6 | 8 | 5 |
| 8 | 11 | 8, 10, 12 | new cycle, C1 1st | 11 | 9 | 0 |
| 9 | – | 8, 10, 12 | C1 empty → C2 | 8 | 10 | 4 |
| 10 | – | 10, 12 | only C2 left | 10 | 11 | 3 |
| 11 | – | 12 | only C2 left | 12 | 12 | 3 |
order: 1, 3, 2, 5, 7, 4, 9, 6, 11, 8, 10, 12 sum (to slot start) = 0+2+0+1+4+1+5+0+4+3+3 = 23 average ≈ 2.09 arrival → departure: sum 34, average ≈ 3.09
e) Official answer
The average delay is the same for all four policies (23/11 ≈ 2.09 slots to slot start). Every packet takes one slot and the link is never idle while packets wait, so the set of departure times (2, 3, …, 12) is fixed. The policy only changes which packet gets which time, which moves delay between packets but not the total.
• Forwarding vs routing: forwarding is local (one router, input → output). Routing is network-wide (the whole path). Don't swap them.
• Data plane = nanoseconds, hardware. Control plane = milliseconds, software.
• Best effort guarantees nothing: not delivery, not order, not timing, not bandwidth.
• HW5 P2: memory and bus are No even for different outputs. Crossbar is No only because both want the same output.
• HOL blocking is an input queue problem. Output queueing is caused by arrivals from the fabric faster than the link rate.
• Buffer rule:
RTT·C/√N, square root of N, not N.• Priority is non-preemptive: a low-priority packet already on the wire finishes.
• In P3, packet 6 arrives at t=2, before 5 (t=3). FIFO sends 6 before 5.
• Read which delay the question wants: "to the beginning of the slot" (a, b) vs "arrival to departure" (c, d). They differ by 1 per packet.
Quick check
1. Forwarding vs routing in one line each.
Forwarding: move a packet from a router's input link to the right output link (local, data plane). Routing: compute the source-to-destination path (network-wide, control plane).2. Per-router control plane vs SDN control plane?
Per-router: a routing algorithm runs in every router and the routers talk to each other. SDN: a remote controller computes forwarding tables and installs them in the routers.3. Name four things the Internet's best-effort service does NOT guarantee.
Delivery (no loss guarantee), order, timing (delay), bandwidth.4. Which switching fabric can forward two packets to two different outputs at the same time?
Only the interconnection network (crossbar). Memory and bus move one packet at a time.5. Why is switching via memory slow?
The CPU copies each packet into memory and back out: 2 bus crossings per datagram, limited by memory bandwidth.6. What is head-of-line blocking?
The packet at the front of an input queue waits for a busy output, so packets behind it wait too, even if their outputs are free.7. RTT = 200 ms, C = 40 Gbps. Buffer by the RFC 3439 rule? With N = 400 flows?
RTT·C = 0.2 s × 40×10⁹ b/s = 8×10⁹ bits = 8 Gbit with N = 400: 8 Gbit / √400 = 8 / 20 = 0.4 Gbit = 400 Mbit
8. WFQ with weights 3, 2, 5 on a 100 Mbps link. Minimum rate for each class?
Σw = 3 + 2 + 5 = 10 class 1: 3/10 × 100 = 30 Mbps class 2: 2/10 × 100 = 20 Mbps class 3: 5/10 × 100 = 50 Mbps
9. Six one-slot packets. Arrivals: t=0: 1, 2; t=1: 3; t=2: 4, 5; t=3: 6. Odd = high priority. Departure order and average delay (to slot start) under FIFO and priority?
FIFO: order 1,2,3,4,5,6 starts 0,1,2,3,4,5
delays 0,1,1,1,2,2 = 7 average 7/6 ≈ 1.17
Priority: t=0 send 1 (waiting 1,2)
t=1 waiting 2(L),3(H) → 3
t=2 waiting 2,4(L),5(H) → 5
t=3 waiting 2,4,6 (all L) → 2
t=4 → 4, t=5 → 6
order 1,3,5,2,4,6
delays 1:0, 3:0, 5:0, 2:3, 4:2, 6:2 = 7 average ≈ 1.17
Same average, as in HW5 P3e.10. Same six packets, round robin with class A = {1, 2, 3} and class B = {4, 5, 6}, A goes first. Order?
t=0 A: 1 (B empty) t=1 B empty → A: 2 t=2 B: 4 (turn to B) t=3 A: 3 t=4 B: 5 t=5 B: 6 (A empty) order 1, 2, 4, 3, 5, 6 delays 1:0, 2:1, 4:0, 3:2, 5:2, 6:2 = 7 average ≈ 1.17Packet 3 arrived at t=1 and started at t=3, so its delay is 2. Total 7, the same as FIFO.
11. HW5 P1b: can router A send H1→H3 traffic on interface 3 and H2→H3 traffic on interface 4?
No. Destination-based forwarding looks only at the destination address. Both flows go to H3, so they match the same entry.12. What do tail drop, ECN and RED have in common?
All are buffer management. Tail drop drops the arriving packet when full. ECN and RED mark (or drop early) to signal congestion before the buffer is full.13. What does a TCAM give you?
Longest prefix match lookup in one clock cycle regardless of table size.← prev · all topics · next →