1
Hubs, Switches, and
Routers, Oh My!
Mike Freedman
COS 461: Computer Networks
http://www.cs.princeton.edu/courses/archive/spr20/cos461/
Today: Hubs, Switches, and
Routers, Oh My!
2
HTTP
TCP
IP
Ethernet
interface
HTTP
TCP
IP
Ethernet
interface
IP IP
Ethernet
interface
Ethernet
interface
SONET
interface
SONET
interface
host host
router router
HTTP message
TCP segment
IP packet IP packet
IP packet
Application
Transport
Network
Link
3
Layer 7
Layer 4
Layer 3
Layer 2
Developed in
late 1970s / early 1980s
Terminology
• Hubs and Repeaters
– Connect machines on same “layer 2” LAN
– Broadcast: All frames are sent out all physical ports
• Switches and Bridges
– Connect machines on same “layer 2” LAN
– Only send frames to selected physical port based on
destination MAC address
• Routers
– Connect between LANs at “layer 3”, e.g., wide area
– Only send packet to selected physical port based on
destination IP address 4
2
“Layer 2”
Hubs and Switches
5
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
6
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
7
Limitations of Repeaters and Hubs
• One large shared link
– Each bit is sent everywhere
– So, aggregate throughput is limited
• Cannot support multiple LAN technologies
– Does not buffer or interpret frames
– Can’t interconnect between different rates/formats
• Limitations on maximum nodes and distances
– Shared medium imposes length limits
– E.g., cannot go beyond 2500 meters on Ethernet
8
3
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 host host host host
host
host
Bridge
9
Link Layer: Switches
• Typically connects individual computers
– A switch is essentially the same as a bridge
– … though typically used to connect hosts
• Supports concurrent communication
– Host A can talk to C, while B talks to D
switch
A
B
C
D
10
Bridges/Switches: Traffic Isolation
• Switch filters packets
– Frame only forwarded to the necessary segments
– Segments can support separate transmissions
hub hub
hub
switch/bridge
segment segment
segment
11
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
A
B
C
D
Switch learns how
to reach A
12
4
Self Learning: Handling Misses
• When frame arrives with unfamiliar destination
– Forward the frame out all of the interfaces
– … except for the one where the frame arrived
– Hopefully, this case won’t happen very often!
When in
doubt,
shout!
13
A
B
C
D
Switches vs. Hubs
• Compared to hubs, Ethernet switches support
(Y) Larger geographic span
(M) Similar span
(C) Smaller span
• Compared to hubs, switches provides
(Y) Higher load on links
(M) Less privacy
(C) Heterogenous communication technologies
14
Looking closer…
15
Basic Router Architecture
• Each switch/router has a forwarding table
– Maps destination address to outgoing interface
16
• 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
5
• 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
17
Lookup
Address
Data Hdr
Basic Router Architecture
Address
Table
Update
Header
Queue
Addr Next Hop
Line Card (I/O)
Router
Switching
Fabric
Processor
Line Card
Line Card
Line Card
Line Card
Line Card
Line Card
data plane
control plane
18
Router
Switching
Fabric
Processor
Line Card
Line Card
Line Card
data plane
19
1. Placement, behavior
of lookup tables
2. Design of switching
fabric
Lookup algorithm depends on protocol
20
Protocol Mechanism Techniques
Ethernet (48 bits)
MPLS
ATM
Exact Match
• Direct lookup
• Associative lookup
• Hashing
• Binary tree
IPv4 (32 bits)
IPv6 (128 bits)
Longest-Prefix Match
• Radix trie
• Compressed trie
• TCAM
6
Longest Prefix Match
• Each packet has destination IP address
• Router looks up table entry that matches address
21
Prefix Output
68.208.0.0/12 1
68.211.0.0/17 1
68.211.128.0/19 2
68.211.160.0/19 2
68.211.192.0/18 1
68.211.6.120
Longest Prefix Match
• Each packet has destination IP address
• Router looks up table entry that matches address
• Benefit of CIDR allocation and LPR
– Efficiency: Prefixes can be allocated at much finger granularity
– Hierarchical aggregation: Upstream ISP can aggregate 2
contiguous prefixes from downstream ISPs to shorter prefix
22
How? Address lookup using trie
• Prefixes “spelled out” by following path from root
• To find the best prefix spell out address in trie
23
Prefixes
A 111*
B 10*
C 1010*
D 10101
1
1
1
0
1
0
1
A
B
C
D
How? Address lookup using trie
• Prefixes “spelled out” by following path from root
• To find the best prefix spell out address in trie
24
1
1
1
0
1
0
1
A
B
C
D
• 1 per / lvl = max 32 lookups!
• Too slow:
– E.g., “Optical Carrier 48” line
(2.5 Gbps) requires 160ns
lookup … or 4 memory
accesses
7
K-ary trie (k=2)
25
11
11
10
10
Prefixes
A 111*
B 10*
C 1010*
D 10101
10
B
A A
11
10
C
D D
Alternatives to trie for LPM
• Content-Address Memory (CAM)
– Input: tag (address)
– Output: value (port
– Exact match, but O(1) in hardware
• Ternary CAM
– 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
26
Alternatives to trie for LPM
27
Decision: Forwarding table per line card
Switching
Fabric
Processor
Line Card
Line Card
Line Card
data plane
28
1. Each line card has
own forwarding
table copy
2. Prevents central
table bottleneck
(vs. early routers
had table across
shared bus)
8
Decision: Crossbar switch
????
Processor
Line Card
Line Card
Line Card
Line Card
Line Card
Line Card
data plane
control plane
29
Decision: Crossbar switch
• Shared bus
– Only one input can speak to one output at a time
• Crossbar switch / switched backplane
– Input / output pairs that don’t compete can send
in same timeslot
30
Crossbar switching
• Every input port has connection to every output port
• In each timeslot, each input connected to zero or
more outputs
31
1
2
3
4
5
6
Crossbar switching
• Every input port has connection to every output port
• In each timeslot, each input connected to zero or
more outputs
32
1
2
3
4 5 6
• Good parallelism
• Needs scheduling
9
Everything gets complicated…
33
1
2
3
4
5
6
• 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
Everything gets complicated…
34
1
2
3
4
5
6
• Solution: Virtual output queues
– One queue at input per output port
– So avoids head-of-line blocking during crossbar scheduling
Data Control Management
Time-
scale
Packet (ns)
Event
(10 ms to sec)
Human
(min to hours)
Tasks
Forwarding,
buffering,
filtering,
scheduling
Routing,
signaling
Analysis,
configuration
Location
Line-card
hardware
Router
software
Humans or
scripts
Data, Control, & Management Planes
35
Switching
Fabric
Processor
36
Cisco 8000 Series Routers
• Up to 648 400 GbE
• 260 Tbps backplane
10
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
37

routerrouterrouterrouterrouterrouterrouter

  • 1.
    1 Hubs, Switches, and Routers,Oh My! Mike Freedman COS 461: Computer Networks http://www.cs.princeton.edu/courses/archive/spr20/cos461/ Today: Hubs, Switches, and Routers, Oh My! 2 HTTP TCP IP Ethernet interface HTTP TCP IP Ethernet interface IP IP Ethernet interface Ethernet interface SONET interface SONET interface host host router router HTTP message TCP segment IP packet IP packet IP packet Application Transport Network Link 3 Layer 7 Layer 4 Layer 3 Layer 2 Developed in late 1970s / early 1980s Terminology • Hubs and Repeaters – Connect machines on same “layer 2” LAN – Broadcast: All frames are sent out all physical ports • Switches and Bridges – Connect machines on same “layer 2” LAN – Only send frames to selected physical port based on destination MAC address • Routers – Connect between LANs at “layer 3”, e.g., wide area – Only send packet to selected physical port based on destination IP address 4
  • 2.
    2 “Layer 2” Hubs andSwitches 5 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 6 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 7 Limitations of Repeaters and Hubs • One large shared link – Each bit is sent everywhere – So, aggregate throughput is limited • Cannot support multiple LAN technologies – Does not buffer or interpret frames – Can’t interconnect between different rates/formats • Limitations on maximum nodes and distances – Shared medium imposes length limits – E.g., cannot go beyond 2500 meters on Ethernet 8
  • 3.
    3 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 host host host host host host Bridge 9 Link Layer: Switches • Typically connects individual computers – A switch is essentially the same as a bridge – … though typically used to connect hosts • Supports concurrent communication – Host A can talk to C, while B talks to D switch A B C D 10 Bridges/Switches: Traffic Isolation • Switch filters packets – Frame only forwarded to the necessary segments – Segments can support separate transmissions hub hub hub switch/bridge segment segment segment 11 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 A B C D Switch learns how to reach A 12
  • 4.
    4 Self Learning: HandlingMisses • When frame arrives with unfamiliar destination – Forward the frame out all of the interfaces – … except for the one where the frame arrived – Hopefully, this case won’t happen very often! When in doubt, shout! 13 A B C D Switches vs. Hubs • Compared to hubs, Ethernet switches support (Y) Larger geographic span (M) Similar span (C) Smaller span • Compared to hubs, switches provides (Y) Higher load on links (M) Less privacy (C) Heterogenous communication technologies 14 Looking closer… 15 Basic Router Architecture • Each switch/router has a forwarding table – Maps destination address to outgoing interface 16 • 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
  • 5.
    5 • 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 17 Lookup Address Data Hdr Basic Router Architecture Address Table Update Header Queue Addr Next Hop Line Card (I/O) Router Switching Fabric Processor Line Card Line Card Line Card Line Card Line Card Line Card data plane control plane 18 Router Switching Fabric Processor Line Card Line Card Line Card data plane 19 1. Placement, behavior of lookup tables 2. Design of switching fabric Lookup algorithm depends on protocol 20 Protocol Mechanism Techniques Ethernet (48 bits) MPLS ATM Exact Match • Direct lookup • Associative lookup • Hashing • Binary tree IPv4 (32 bits) IPv6 (128 bits) Longest-Prefix Match • Radix trie • Compressed trie • TCAM
  • 6.
    6 Longest Prefix Match •Each packet has destination IP address • Router looks up table entry that matches address 21 Prefix Output 68.208.0.0/12 1 68.211.0.0/17 1 68.211.128.0/19 2 68.211.160.0/19 2 68.211.192.0/18 1 68.211.6.120 Longest Prefix Match • Each packet has destination IP address • Router looks up table entry that matches address • Benefit of CIDR allocation and LPR – Efficiency: Prefixes can be allocated at much finger granularity – Hierarchical aggregation: Upstream ISP can aggregate 2 contiguous prefixes from downstream ISPs to shorter prefix 22 How? Address lookup using trie • Prefixes “spelled out” by following path from root • To find the best prefix spell out address in trie 23 Prefixes A 111* B 10* C 1010* D 10101 1 1 1 0 1 0 1 A B C D How? Address lookup using trie • Prefixes “spelled out” by following path from root • To find the best prefix spell out address in trie 24 1 1 1 0 1 0 1 A B C D • 1 per / lvl = max 32 lookups! • Too slow: – E.g., “Optical Carrier 48” line (2.5 Gbps) requires 160ns lookup … or 4 memory accesses
  • 7.
    7 K-ary trie (k=2) 25 11 11 10 10 Prefixes A111* B 10* C 1010* D 10101 10 B A A 11 10 C D D Alternatives to trie for LPM • Content-Address Memory (CAM) – Input: tag (address) – Output: value (port – Exact match, but O(1) in hardware • Ternary CAM – 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 26 Alternatives to trie for LPM 27 Decision: Forwarding table per line card Switching Fabric Processor Line Card Line Card Line Card data plane 28 1. Each line card has own forwarding table copy 2. Prevents central table bottleneck (vs. early routers had table across shared bus)
  • 8.
    8 Decision: Crossbar switch ???? Processor LineCard Line Card Line Card Line Card Line Card Line Card data plane control plane 29 Decision: Crossbar switch • Shared bus – Only one input can speak to one output at a time • Crossbar switch / switched backplane – Input / output pairs that don’t compete can send in same timeslot 30 Crossbar switching • Every input port has connection to every output port • In each timeslot, each input connected to zero or more outputs 31 1 2 3 4 5 6 Crossbar switching • Every input port has connection to every output port • In each timeslot, each input connected to zero or more outputs 32 1 2 3 4 5 6 • Good parallelism • Needs scheduling
  • 9.
    9 Everything gets complicated… 33 1 2 3 4 5 6 •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 Everything gets complicated… 34 1 2 3 4 5 6 • Solution: Virtual output queues – One queue at input per output port – So avoids head-of-line blocking during crossbar scheduling Data Control Management Time- scale Packet (ns) Event (10 ms to sec) Human (min to hours) Tasks Forwarding, buffering, filtering, scheduling Routing, signaling Analysis, configuration Location Line-card hardware Router software Humans or scripts Data, Control, & Management Planes 35 Switching Fabric Processor 36 Cisco 8000 Series Routers • Up to 648 400 GbE • 260 Tbps backplane
  • 10.
    10 Conclusions • Physical devicessharing 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 37