Lec04 Routers
Lec04 Routers
Kyle Jamieson
Fall 2020
Today: Hubs, Switches, and
Routers, Oh My!
host host
HTTP message
HTTP HTTP Application
TCP segment
TCP TCP Transport
router router
IP packet IP packet IP packet
IP IP IP IP Network
Ethernet
interface
Ethernet
interface
SONET
interface
SONET
interface
Ethernet
interface
Ethernet
interface Link
2
Terminology
• Hubs and Repeaters
– Connect machines on same “layer 2” LAN
– Broadcast: All frames are sent out all physical ports
• Routers
– Connect between LANs at “layer 3”, e.g., wide area
– Only send packet to selected physical port based on
destination IP address 3
“Layer 2”
Hubs and Switches
4
Physical Layer: Repeaters
• Distance limitation in local-area networks
– Electrical signal becomes weaker as it travels
– Imposes a limit on the length of a LAN
• Repeaters join LANs together
– Analog electronic device
– Continuously monitors electrical signals
– Transmits an amplified copy
Repeater
5
Physical Layer: Hubs
• Joins multiple input lines electrically
– Designed to hold multiple line cards
– Do not necessarily amplify the signal
• Very similar to repeaters
– Also operates at the physical layer
hub
hub
hub hub
6
Limitations of Repeaters and Hubs
• One large shared link
– Each bit is sent everywhere
– So, aggregate throughput is limited
7
Link Layer: Bridges
• Connects two or more LANs at the link layer
– Extracts destination address from the frame
– Looks up the destination in a table
– Forwards the frame to the appropriate segment
• Each segment can carry its own traffic
host host host host host host
Bridge
A C
switch
D
9
Bridges/Switches: Traffic Isolation
• Switch filters packets
– Frame only forwarded to the necessary segments
– Segments can support separate transmissions
switch/bridge
segment
hub
hub hub
segment segment
10
Self Learning: Building the Table
• When a frame arrives
– Inspect the source MAC address
– Associate the address with the incoming interface
– Store the mapping in the switch table
– Use a timer to eventually forget the mapping
B
A C
When in
doubt, A C
shout!
D
12
Switches vs. Hubs
• Compared to hubs, Ethernet switches support
(Y) Larger geographic span
(M) Similar span
(C) Smaller span
13
Routers: Looking closer…
14
Basic Router Architecture
• Each switch/router has a forwarding table
– Maps destination address to outgoing interface
• Basic operation
1. Receive packet
2. Look at header to determine destination address
3. Look in forwarding table to determine output interface
4. Modify packet header (e.g., decr TTL, update chksum)
5. Send packet to output interface
15
Basic Router Architecture
Data Hdr
Lookup Update
Queue
Address Header
Addr Next Hop
Address
Table
control plane
data plane Processor
Switching
Line Card Line Card
Fabric
17
Router
18
Lookup algorithm depends on protocol
• Direct lookup
Ethernet (48 bits)
• Associative lookup
MPLS Exact Match
• Hashing
ATM
• Binary tree
• Radix trie
IPv4 (32 bits)
Longest-Prefix Match • Compressed trie
IPv6 (128 bits)
• TCAM
19
Longest Prefix Match (LPM)
• Each packet has destination IP address
• Router looks up table entry that matches address
Prefix Output
68.208.0.0/12 1
68.211.0.0/17 1
68.211.6.120
68.211.128.0/19 2
68.211.160.0/19 2
68.211.192.0/18 1
20
LPM: Motivation
• Each packet has destination IP address
• Router looks up table entry that matches address
21
Software LPM lookup using trie
• Prefixes “spelled out” by following path from root
• To find the best prefix spell out address in trie
1
Prefixes
A 111* 0 1
B 10* B
1 1
C 1010*
A
0
D 10101
C 1
D 22
Software LPM lookup using trie
• Prefixes “spelled out” by following path from root
• To find the best prefix spell out address in trie
1
• 1 lookup per level à max 32
lookups/address! 0 1
• Too slow: B
– E.g., “Optical Carrier 48” line 1 1
(2.5 Gbps) requires 160ns A
lookup … or 4 memory 0
accesses C 1
D 23
Software LPM lookup: k-ary trie (k=2)
Prefixes
A 111*
B 10*
10 11
C 1010* B
10 10 11
D 10101
C A A
10 11
D D
24
Hardware for LPM lookup
• Content-Address Memory (CAM)
– Input: tag (address)
– Output: value (port
– Exact match, but O(1) in hardware
• Ternary CAM
– Can have wildcards: 0, 1, *
– “value” memory cell and “mask” (care / don’t care) cell
• LPM via TCAM
– In parallel, search all prefixes for all matches
– Then choose longest match
• Trick: choose first match, but already sorted by prefix length
25
Example: LPM with a TCAM
control plane
data plane Processor
28
Decision: Crossbar switch
• Shared bus
– Only one input can speak to one output at a time
29
Crossbar switching
• Every input port has connection to every output port
• In each timeslot, each input connected to zero or
more outputs
1 4
2 5
3 6
30
Crossbar switching
• Every input port has connection to every output port
• In each timeslot, each input connected to zero or
more outputs
1
2
• Good parallelism
3
• Needs scheduling
4 5 6
31
Everything gets complicated…
• Problem: Head-of-line blocking
– The packet in front of queue blocks packets behind it from
being processed
– Say first packet at input 1 wants to go to output 5;
second packet at 1 that wants 4 is still blocked
1 4
2 5
3 6
32
Everything gets complicated…
• Solution: Virtual output queues
– One queue at input, per output port (for all inputs)
– So avoids head-of-line blocking during crossbar
scheduling
1 4
2 5
3 6
33
Data, Control, & Management Planes
Processor
Switching
Fabric
35
Conclusions
• Physical devices sharing L2 & L3 networks have many
common features
– Forward table lookups
– Queueing and backplane switching
– Fast vs. slow paths
• Switches and routers separate routing decisions (control
plane) from forwarding actions (data plane)
• High speed necessitates innovation
– Specialized hardware
– Software algorithms
36