CMPT 471/771: Computer Networks��Router Design and QoS Support
Instructor: Mohamed Hefeeda
1
School of Computing Science �Simon Fraser University
Outline
2
Router Architecture Overview
3
CPU: Routing Processor
Switching Fabric
1
2
N
.
.
.
Input Ports
1
2
N
.
.
.
Output Ports
Control Plane
Data Plane
Insert forwarding rules
Packet Path Through a Router
4
Input port
Switching fabric
Output port
Lookup
output port
Classify
class
Police
rate check
ingress match-action pipeline
Queue
buffer, early drops
Schedule
which packet next
Send
to link
traffic manager (buffer, queues, scheduler)
Input Port Functions
5
Line termination
bits in
Link layer (receive)
frame (e.g., Ethernet)
Lookup
output port (longest prefix match)
Classify
class (DSCP, headers)
Police
rate check: pass, mark, drop
one match-action pipeline, at line speed
Input queue
waits if fabric busy
fabric
Destination-based Forwarding
6
src: 200.33.22.111
dst: 142.58.228.150
data
Forwarding Table
IP Packet
Match
Uses longest prefix matching algorithm 🡺 costly operation
142.0.0.0/8
142.58.0.0/16
……
Longest Prefix and TCAM
7
CAM: Brief Intro
8
CAM
1
0
1
0
1
1
0
0
1
1
1
1
Entry 2
Entry 3
Entry 4
Search for
1
0
1
0
Entry 1
1
1
1
0
0
0
1
0
TCAM: Brief Intro
9
TCAM: Example
10
TCAM
1
0
X
X
1
1
0
X
X
X
X
X
Entry 2
Entry 3
Entry 4
Search for
1
0
1
0
Entry 1
1
1
X
X
0
0
1
1
Highest Priority
TCAM Limitations
11
TCAM Limits in Practice: 512k Day (2014)
12
512k
768k
1.05M
512k limit
2012
2026
IPv4 routes in global table
Longest Prefix Match in SRAM: Tries
13
Prefixes:
0* → port A
10* → port B
101* → port C
11* → port D
Lookup: 1011…
0
1
0
1
1
0*
A
10*
B
11*
D
101*
C
bit 1: go right
bit 0: 10* matches, remember B
bit 1: 101* matches, remember C
bit 1: no child: answer C (101*)
Switching Fabric
14
memory
memory
bus
crossbar
Input Port Queuing
15
Switching fabric
only one red packet can be transferred at the same time 🡺 lower red packet is blocked 🡺 Green packet must wait (unnecessarily)
blocked
HOL Solution: Virtual Output Queue
16
Switching fabric
Blocked (ok)
Output Ports
17
fabric
class 1
class 2
class 3
per-class queues (buffer)
Scheduler
SP + DWRR
class 1 first;
others by weight
Link layer (send)
frame (e.g., Ethernet)
Line termination
bits out
link
AQM: drop early
Buffer Sizing
18
C
buffer of B bits
drain time B / C
C: link rate (bits/s)
B: buffer size (bits)
Buffer Sizing: One TCP Flow
B ≥ RTT × C
19
buffer full: RTT × C + B
link full: RTT × C
up to B
queued
window
time
Buffer Sizing: Many TCP Flows
20
1 flow: swing = RTT × C
10 flows: swing ≈ ⅓ of it
100 flows: swing ≈ 1/10 of it
total window over time (mean = 1)
Buffer Sizing: Examples
21
| Internet backbone link | Datacenter switch port |
Link rate C | 10 Gb/s | 100 Gb/s |
RTT | 250 ms | 20 µs |
Flows n | 50,000 | 100 |
One flow: RTT × C | 2.5 Gbit (312 MB) | 2 Mbit (250 KB) |
Many flows: RTT × C / √n̅ | ≈ 11 Mbit (1.4 MB) | 200 kbit (25 KB) |
Real buffers | deep routers: GBs (off-chip) | chip: ≈ 500 KB per port |
Packet Losses and their Impact
P(k packets all arrive) = (1 − p)k
22
Full output queue
link
dropped
p = 1% per packet:
(0.99)100 ≈ 0.37
Active Queue Management (AQM)
23
input port
output port
Lookup
Classify
Police
Queue
how big? what to drop?
Schedule
which packet next? (later)
Send
fabric
Random Early Detection (RED)
24
Random Early Detection (RED)
25
link
arrivals
departures
AvgLen
MinThresh
MaxThresh
P(drop)
AvgLen
1.0
MaxP
AvgLen < MinThresh:
no drops
between thresholds:
drop with P rising to MaxP
AvgLen > MaxThresh:
drop every arrival
Probability of dropping grows with average queue length
RED: Drop Probability
p = MaxP × (AvgLen − MinThresh) / (MaxThresh − MinThresh)
26
Random Early Detection (RED)
27
Packet Path: From Queuing to Scheduling
28
Input port
Switching fabric
Output port
Lookup
output port
Classify
class
Police
rate check
ingress match-action pipeline
Queue
buffer, RED (done)
Schedule
which packet next (now)
Send
to link
traffic manager (buffer, queues, scheduler)
Scheduling Policy
29
link
(server)
queue
(waiting area)
packet
arrivals
packet
departures
Switching fabric
Output queue
Scheduling Policy: Priority
30
high priority queue
(waiting area)
low priority queue
(waiting area)
arrivals
classify
departures
link
(server)
Switching fabric
Output queue
Scheduling Policy: Other Policies
31
Output queue
Switching fabric
Round Robin: Packets vs. Bytes
32
One round of round robin
A
1,500 B
B
64 B
Same number of packets,
very different bytes
Packet Scheduling Policy: WFQ
33
WFQ: Picking the Next Packet
34
FIFO queues (F of each packet)
A
21
16
12
B
14
10
5
C
18
13
9
min-heap of heads
B: 5
C: 9
A: 12
send B (F = 5)
after: insert B's next (F = 10)
C: 9
B: 10
A: 12
WFQ: Guaranteed Rates
Ri = R × wi / Σj wj
35
12 Mb/s link, weights 3 : 2 : 1
All busy
6
4
2
Class 3 idle
7.2
4.8
Class 1 red, class 2 green, class 3 blue
(Mb/s inside each bar)
Deficit Round Robin (DRR)
36
Example: Q = 500 B per round
credit after
round 1 / 2
A
200
750
300 / 0
B
500
500
0 / 0
C
1,000
500 / 0
head
sent in round 1
in round 2
Each queue sends 950–1,000 B
in two rounds: fair in bytes
Weighted DRR (DWRR)
Ri ≈ R × Qi / Σj Qj
37
One DWRR round: 9,000 B
4,500 B
3,000
1,500
On 12 Mb/s link
6 Mb/s
4
2
queue 1 red, 2 green, 3 blue:
same 3 : 2 : 1 shares as WFQ
Scheduler Comparison
38
Scheduler | Sends next | Good at | Weak at | Work per packet |
FIFO | oldest packet | simple | no isolation: one burst delays all | O(1) |
Strict priority | from highest busy class | lowest delay for top class | starves others unless top class is policed | O(1) |
Round robin | one packet per busy queue, in turn | isolates queues | fair in packets, not bytes | O(1) |
WFQ | packet that would finish first bit by bit | byte-fair, weighted; guaranteed rates | must sort finish times | O(log n) |
DRR, DWRR | head packets while credit lasts | byte-fair over a few rounds; weighted (DWRR) | bursts of up to one quantum | O(1) |
Switch chips combine them: strict priority for a few classes, DWRR for the rest
Think About It: Choosing the DRR Quantum
Think: how often does A send? Best Q?
39
A's credit each round (Q = 500 B)
packet
1,500 B
1
2
3
send
4
5
6
send
round
QoS Motivation: Voice Meets File Transfer
40
voice
1 Mb/s
file transfer
router queue (FIFO, 100 packets)
1.5 Mb/s link
Internet
voice packet waits 0.8 s
QoS Motivation: More Examples
41
Datacenter: storage meets bulk copy
RDMA storage traffic needs no loss
Bulk copy fills switch buffer:
RDMA packets dropped, slow recovery
QoS: own lossless class (PFC), own queue
Same pattern: one link, traffic with different needs
5G cell: voice, video, web on one radio
Voice: guaranteed rate, 100 ms budget
Web, e-mail: best effort, 300 ms
Network marks each flow's class
QoS: scheduler serves classes by need
QoS Needs: Classify, Police, Share, Admit
42
voice
1 Mb/s
file
transfer
router
1.5 Mb/s
Four needs: classify, police,
share, admit
QoS and Router Mechanisms
43
input port
output port
Lookup
Classify
DSCP marks (DiffServ)
Police
token bucket (next)
Queue
buffer, AQM (done)
Schedule
SP, WFQ, DRR (done)
Send
fabric
QoS in IP Networks: Two Models
44
Policing Mechanisms
Goal: limit traffic so that it does not exceed declared parameters
Three commonly-used criteria:
45
Policing Mechanisms: Token Bucket (aka Leaky Bucket)
Token Bucket: controls Burst Size and Average Rate
(aka Leaky Bucket)
46
Token bucket limits max burst size. How can we control delay?
Exercise: extend token bucket to also control peak rate.
Hint: use two buckets and adjust their parameters.
Token Bucket: Policing vs. Shaping
47
Shaper: packets wait in queue for tokens
Policer: no queue; packet without token
is dropped or marked
Token Bucket + WFQ
48
Token Bucket + WFQ
49
Example: Delay Guarantee (Token Bucket + WFQ)
dmax ≤ b/Ri + K × L/Ri
50
b / Ri
arrivals:
at most b + r·t
service:
Ri·t
b
time
Think About It: What Rate for 20 ms?
Think: what rate must WFQ reserve for 20 ms delay bound?
51
Scheduling in Practice: Strict Priority + DWRR
52
voice
police
video w = 3
data w = 2
bulk w = 1
strict
priority,
then
DWRR
link
Voice goes first (policed);
others share by weight
Delay Bound with DWRR
dmax ≤ b/Ri + K × (extra wait per hop)
53
Integrated Services (IntServ)
54
IntServ: Session Admission
Arriving session must:
Signaling protocol:
55
IntServ: Resource Reservation Protocol (RSVP)
56
request/
reply
Concerns with IntServ
57
Differentiated Services (DiffServ)
58
Marking
Scheduling
Edge Router: Logical Architecture
59
Classifier
Marker
Shaper/
Dropper
Meter
forward
drop
Packet is marked in Type of Service (TOS) field in IPv4, and Traffic Class field in IPv6
6 bits used for Differentiated Service Code Point (DSCP) and determine Per-Hop Behavior (PHB) that packet will receive
Core Router: Forwarding
60
IntServ vs. DiffServ
61
| IntServ | DiffServ |
Unit of service | each flow | class of traffic |
State in core routers | per flow | per class only (few queues) |
Setup | RSVP reserves along path | none: edge marks DSCP |
Promise | hard delay bound per flow | relative: better than other classes |
Scales to backbones | no: 39,000 flows on one 2.5 Gb/s link | yes |
Used today | few long-term reservations in ISPs; per-flow ideas in 5G, DetNet | inside enterprise, datacenter and access networks |
DiffServ and IntServ in Practice
62
QoS in Practice Today
63
Summary
64
Readings
65