1
CS 168, Spring 2025 @ UC Berkeley
Slides credit: Sylvia Ratnasamy, Rob Shakir, Peyrin Kao
IP Routers
Lecture 8 (Routing 4)
SP25 announcement:
No live lecture on Wed Feb 26 and Mon Mar 3.
Videos will be posted on the website instead.
IP Routers in Real Life
Lecture 8, CS 168, Spring 2025
IP Routers
Routers – Conceptually
Recall:
Today: What do routers actually look like in real life?
R2
R1
A
R3
R4
B
C
D
0
1
2
R2's Table | |
Destination | Port |
A | 0 |
B | 1 |
C | 1 |
D | 2 |
Colocation Facilities
Colocation facility (aka carrier hotel): A building where multiple ISPs install routers.
Allows for high-performance connections between networks.
In our diagrams, these routers would live in carrier hotels.
Routers in Real Life
A router is just a computer specialized for forwarding packets.
Measuring Router Size
Different dimensions for measuring the size of a router:
Example:
Modern Router Capacity
Modern router:
Next-generation router:
Innovation is focused on improving line rate, since we're running out of physical space to add more ports.
Evolution of Router Capacity
Modern routers are facing physical constraints: size, power, cooling, etc.
Rate of growth is slowing: 10G → 100G → 400G → 800G.
2010
2011
2012
2015
2016
2017
2014
2018
2019
2013
Juniper MX3D
1.76T
Brocade MLXe
2.56T
Juniper PTX5000
3.84T
Cisco ASR9000
16T
Juniper MX2020
8T
Arista 7500R
28T
Juniper/Cisco/
Arista lean core
50T+
Juniper/Cisco/
Arista lean core
200T+
Juniper/Cisco/
Arista lean core
100T+
10G
100G
400G
Router Components (Planes)
Lecture 8, CS 168, Spring 2025
IP Routers
Router Planes
The components of a router can be split into 3 planes:
Each plane is optimized for its tasks and its time scale.
What's Inside a Router? – View of Components
Chassis
Controller Card
Chassis: The metal box holding the hardware.
Linecard
CPU
Linecard
CPU
Linecard
CPU
CPU
Control processor: Runs routing protocols and puts forwarding tables on linecards.
Also handles management plane.
Removable linecards gives us flexibility in scaling the router. 1–20 linecards per chassis.
Each linecard has several ports.�A port can be used for both input/output.
Each linecard has some hardware to control its functionality.
What's Inside a Router? – View of Links
Chassis
Fabric
Linecard
Linecard
Linecard
Linecard
Linecard
Linecard
Controller Card
Controller card is connected to the linecards.
Each linecard is connected to the fabric: A bunch of wires providing high-bandwidth, fault-tolerant interconnection between linecards.
What's Inside a Router? – View of a Linecard
Linecard
CPU
Forwarding Chip
Forwarding Chip
Fabric Chip(s)
To Fabric
Specialized hardware optimized to forward packets.
Sends packets into the fabric, to other ports on the router.
What's Inside a Router? – Full View
Local CPU (x86)
Control Processor (x86)
Local CPU (x86)
Linecard
Linecard
Controller Card
Chassis
Forwarding Chip(s)
Fabric Chip(s)
Fabric
Fabric Chip(s)
Fabric
Fabric
Forwarding Chip(s)
What's Inside a Router? – Data Plane
Data: Packet travels from port to port, via forwarding chips and fabric.
Local CPU (x86)
Control Processor (x86)
Local CPU (x86)
Linecard
Linecard
Controller Card
Chassis
Forwarding Chip(s)
Fabric Chip(s)
Fabric
Fabric Chip(s)
Fabric
Fabric
Forwarding Chip(s)
What's Inside a Router? – Control Plane
Control: Controller card talks with other routers, and programs linecards with routes.
Linecard
Linecard
Chassis
Forwarding Chip(s)
Fabric Chip(s)
Fabric
Fabric Chip(s)
Fabric
Fabric
Forwarding Chip(s)
Control Processor (x86)
Controller Card
Local CPU (x86)
Local CPU (x86)
Other Routers
Routing Protocol
What's Inside a Router? – Management Plane
Management: Controller card talks with operator.
Linecard
Linecard
Chassis
Forwarding Chip(s)
Fabric Chip(s)
Fabric
Fabric Chip(s)
Fabric
Fabric
Forwarding Chip(s)
Control Processor (x86)
Controller Card
Local CPU (x86)
Local CPU (x86)
Monitoring System
Diagnostics
Configuration System
Configuration
What's in a Router?
A router is really a cluster of computers specialized for forwarding packets.
Linecard
Controller Card
Fan Tray
"06" = 6 slots:
2 controllers,�4 linecards
Packet Types
Lecture 8, CS 168, Spring 2025
IP Routers
Types of Packets
3 types of packets can arrive at a router.
Types of Packets – User Traffic
User packet: Forward according to installed routes.
Local CPU (x86)
Control Processor (x86)
Local CPU (x86)
Linecard
Linecard
Controller Card
Chassis
Forwarding Chip(s)
Fabric Chip(s)
Fabric
Fabric Chip(s)
Fabric
Fabric
Forwarding Chip(s)
Types of Packets – Control Plane Traffic
Control plane traffic: Packets destined for this router (e.g. routing advertisement).
Local CPU (x86)
Control Processor (x86)
Local CPU (x86)
Linecard
Linecard
Controller Card
Chassis
Forwarding Chip(s)
Fabric Chip(s)
Fabric
Fabric Chip(s)
Fabric
Fabric
Forwarding Chip(s)
Types of Packets – Punt Traffic
Punt traffic: User packets that need extra processing (e.g. TTL expired).
Local CPU (x86)
Control Processor (x86)
Local CPU (x86)
Linecard
Linecard
Controller Card
Chassis
Forwarding Chip(s)
Fabric Chip(s)
Fabric
Fabric Chip(s)
Fabric
Fabric
Forwarding Chip(s)
Scaling Routers
Why build routers like this? Why not just use a general-purpose CPU?
Reason: Scale.
We can't achieve this scale in software.
Router functionality must be implemented directly on hardware.
Forwarding in Hardware
Lecture 8, CS 168, Spring 2025
IP Routers
Forwarding Pipeline (1/3)
When a packet arrives, what does the input linecard need to do?
1. Receive the packet from other systems.
PHY
MAC
Hardware
Forwarding Pipeline (2/3)
When a packet arrives, what does the input linecard need to do?
2. Process the packet.
PHY
MAC
Parse
Lookup
Actions
Hardware
Forwarding Chip
Forwarding Pipeline (3/3)
When a packet arrives, what does the input linecard need to do?
3. Send the packet onwards.
PHY
MAC
Parse
Lookup
Actions
Fabric Interconnect
To other linecards
Hardware
Forwarding Chip
Fabric Chip
Forwarding Pipeline – Queuing
Many possible queuing approaches: We'll assume the simplest one.
Alternate complex approaches can be used to implement business objectives.
PHY
MAC
Parse
Lookup
Actions
Fabric Interconnect
To other linecards
Hardware
Forwarding Chip
Fabric Chip
Queuing
Scaling Forwarding Hardware
Main challenge: Speed.
Network processors are specialized to perform forwarding quickly.
Scaling Forwarding Hardware
How hard is it to implement operations in hardware?
PHY
MAC
Parse
Lookup
Actions
Fabric Interconnect
To other linecards
Hardware
Forwarding Chip
Fabric Chip
Doing efficient lookup is our challenge!
Efficient Forwarding with Tries
Lecture 8, CS 168, Spring 2025
IP Routers
Efficient Forwarding
The forwarding table is a map (key-value pairs).
How do we do fast lookups?
Challenges:
Naive solution: Write out the whole range.
R2's Table | |
Destination | Port |
2.1.1.0/24 | 5 |
R2's Table | |
Destination | Port |
2.1.1.0 | 5 |
2.1.1.1 | 5 |
2.1.1.2 | 5 |
2.1.1.3 | 5 |
2.1.1.4 | 5 |
... | ... |
2.1.1.252 | 5 |
2.1.1.253 | 5 |
2.1.1.254 | 5 |
2.1.1.255 | 5 |
Longest Prefix Match
We want a fast implementation of longest prefix match.
R2's Table | |
Destination | Port |
11101000 01100101 111..... ........ | 5 |
11101000 01100... ........ ........ | 9 |
11101100 01100101 111..... ........ | 7 |
11111... ......... ........ ........ | 2 |
11101000 01100101 11101011 11000110
Destination:
These two prefixes match. The first one is longer.
Longest Prefix Match
Naive longest prefix match implementation:
Requires scanning every entry. O(N) runtime for table with N entries.
R2's Table | |
Destination | Port |
11101000 01100101 111..... ........ | 5 |
11101000 01100... ........ ........ | 9 |
11101100 01100101 111..... ........ | 7 |
11111... ......... ........ ........ | 2 |
11101000 01100101 11101011 11000110
Destination:
These two prefixes match. The first one is longer.
Tries – Conceptual
Is there a map data structure that supports efficient longest prefix match?
Maybe familiar if you've taken UC Berkeley CS 61B.
s
a
m
d
p
e
a
w
l
s
1
7
12
2
5
9
Key | Value |
a | 5 |
awls | 9 |
sa | 7 |
sad | 1 |
sam | 8 |
same | 2 |
sap | 12 |
8
Tries – Conceptual
Longest prefix matching on a trie:
s
a
m
d
p
e
a
w
l
s
1
12
2
5
9
7
8
Key | Value |
a | 5 |
awls | 9 |
sa | 7 |
sad | 1 |
sam | 8 |
same | 2 |
sap | 12 |
Longest prefix of "sample" is "sam".
Efficient IP Lookup with Tries
Longest prefix matching on a trie:
...
0..
1..
00.
001
Key | Value |
0.. | 1 |
100 | 2 |
101 | 3 |
11. | 4 |
001 | 5 |
10.
11.
100
101
5
2
3
4
1
Longest prefix of 00100 is 001.
Efficient IP Lookup with Tries
Longest prefix matching on a trie:
...
0..
1..
001
10.
11.
100
101
5
2
3
4
1
00.
Key | Value |
0.. | 1 |
100 | 2 |
101 | 3 |
11. | 4 |
001 | 5 |
Longest prefix of 00000 is 0.
Efficient IP Lookup with Tries
Longest prefix matching also works with default route.
0..
11.
100
4
1
3
2
Key | Value |
... | 1 |
0.. | 2 |
11. | 3 |
100 | 4 |
Longest prefix of 10100 is default.
...
1..
10.
Efficient IP Lookup with Tries
Runtime of longest prefix matching in a trie is constant: O(1).
All routers have efficient longest prefix matching functionality.
Some use more complex solutions with heuristics and optimizations.
Summary: IP Routers
Routers have different planes.
Data plane leverages tradeoffs in software vs. hardware packet processing.
Data plane challenges: Speed!