the ip data plane: packets and routersee122/fa13/lectures/lec8.pdf · the ip layer ! so far,...

79
The IP Data Plane: Packets and Routers EE 122, Fall 2013 Sylvia Ratnasamy http://inst.eecs.berkeley.edu/~ee122/ Material thanks to Ion Stoica, Scott Shenker, Jennifer Rexford, Nick McKeown, and many other colleagues

Upload: others

Post on 19-Apr-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

The IP Data Plane: Packets and Routers

EE 122, Fall 2013 Sylvia Ratnasamy

http://inst.eecs.berkeley.edu/~ee122/

Material thanks to Ion Stoica, Scott Shenker, Jennifer Rexford, Nick McKeown, and many other colleagues

Page 2: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

The IP layer

l  So far, we’ve focused mostly on routing protocols l  how routers discover and select end-to-end paths l  part of a network’s control plane

l  Today: the data plane l  what data packets look like at the IP layer (the IP header) l  how routers forward these IP packets

Page 3: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Recall from Lecture#3:Layer Encapsulation"

transport

network

link

application

User A User B

Page 4: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

What is Designing IP?

l  Syntax: format of packet l  Nontrivial part: packet “header” l  Rest is opaque payload (why opaque?)

l  Semantics: meaning of header fields

l  Required processing

Header Opaque Payload

Page 5: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Packet Headers

l  Think of packet header as interface l  Only way of passing information from packet to switch

l  Designing interfaces l  What task are you trying to perform? l  What information do you need to accomplish it?

l  Header reflects information needed for basic tasks

Page 6: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

What Tasks Do We Need to Do?

l  Read packet correctly l  Get packet to the destination; responses back to

the source l  Carry data l  Tell host what to do with packet once arrived l  Specify any special network handling of the

packet l  Deal with problems that arise along the path

Page 7: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

IP Packet Structure"4-bit

Version 4-bit

Header Length

8-bit Type of Service

(TOS) 16-bit Total Length (Bytes)

16-bit Identification 3-bit Flags 13-bit Fragment Offset

8-bit Time to Live (TTL) 8-bit Protocol 16-bit Header Checksum

32-bit Source IP Address

32-bit Destination IP Address

Options (if any)

Payload

Page 8: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

20 Bytes of Standard Header, then Options"4-bit

Version 4-bit

Header Length

8-bit Type of Service

(TOS) 16-bit Total Length (Bytes)

16-bit Identification 3-bit Flags 13-bit Fragment Offset

8-bit Time to Live (TTL) 8-bit Protocol 16-bit Header Checksum

32-bit Source IP Address

32-bit Destination IP Address

Options (if any)

Payload

Page 9: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Fields for Reading Packet Correctly"4-bit

Version 4-bit

Header Length

8-bit Type of Service

(TOS) 16-bit Total Length (Bytes)

16-bit Identification 3-bit Flags 13-bit Fragment Offset

8-bit Time to Live (TTL) 8-bit Protocol 16-bit Header Checksum

32-bit Source IP Address

32-bit Destination IP Address

Options (if any)

Payload

Page 10: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Reading Packet Correctly"l  Version number (4 bits)

l  Indicates the version of the IP protocol l  Necessary to know what other fields to expect l  Typically “4” (for IPv4), and sometimes “6” (for IPv6)

l  Header length (4 bits) l  Number of 32-bit words in the header l  Typically “5” (for a 20-byte IPv4 header) l  Can be more when IP options are used

l  Total length (16 bits)

l  Number of bytes in the packet l  Maximum size is 65,535 bytes (216 -1) l  … though underlying links may impose smaller limits

Page 11: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Fields for Reaching Destination and Back"4-bit

Version 4-bit

Header Length

8-bit Type of Service

(TOS) 16-bit Total Length (Bytes)

16-bit Identification 3-bit Flags 13-bit Fragment Offset

8-bit Time to Live (TTL) 8-bit Protocol 16-bit Header Checksum

32-bit Source IP Address

32-bit Destination IP Address

Options (if any)

Payload

Page 12: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Telling End-Host How to Handle Packet"4-bit

Version 4-bit

Header Length

8-bit Type of Service

(TOS) 16-bit Total Length (Bytes)

16-bit Identification 3-bit Flags 13-bit Fragment Offset

8-bit Time to Live (TTL) 8-bit Protocol 16-bit Header Checksum

32-bit Source IP Address

32-bit Destination IP Address

Options (if any)

Payload

Page 13: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Telling End-Host How to Handle Packet"

l  Protocol (8 bits) l  Identifies the higher-level protocol l  Important for demultiplexing at receiving host

Application

Transport

Network

Data link

Physical L1

L2

L3

L4

L7 SMTP HTTP DNS NTP

TCP UDP

IP

Ethernet FDDI PPP

optical copper radio PSTN

Page 14: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Telling End-Host How to Handle Packet"

l  Protocol (8 bits) l  Identifies the higher-level protocol l  Important for demultiplexing at receiving host

l  Most common examples l  E.g., “6” for the Transmission Control Protocol (TCP) l  E.g., “17” for the User Datagram Protocol (UDP)

IP header IP header TCP header UDP header

protocol=6 protocol=17

Page 15: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Potential Problems

l  Header Corrupted: Checksum

l  Loop: TTL

l  Packet too large: Fragmentation

Page 16: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Checksum, TTL and Fragmentation Fields"4-bit

Version 4-bit

Header Length

8-bit Type of Service

(TOS) 16-bit Total Length (Bytes)

16-bit Identification 3-bit Flags 13-bit Fragment Offset

8-bit Time to Live (TTL) 8-bit Protocol 16-bit Header Checksum

32-bit Source IP Address

32-bit Destination IP Address

Options (if any)

Payload

Page 17: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Header Corruption (Checksum)

l  Checksum (16 bits) l  Particular form of checksum over packet header

l  If not correct, router discards packets l  So it doesn’t act on bogus information

l  Checksum recalculated at every router l  Why? l  Why include TTL? l  Why only header?

Page 18: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Preventing Loops (TTL)"l  Forwarding loops cause packets to cycle for a looong time

l  As these accumulate, eventually consume all capacity

l  Time-to-Live (TTL) Field (8 bits) l  Decremented at each hop, packet discarded if reaches 0 l  …and “time exceeded” message is sent to the source

Page 19: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Fragmentation "

l  Fragmentation: when forwarding a packet, an Internet router can split it into multiple pieces (“fragments”) if the packet is too big for next hop link l  too big à exceeds the link’s “Max Transmission Unit” (MTU)

l  Must reassemble to recover original packet l  Need fragmentation information (32 bits) l  Packet identifier, flags, and fragment offset

l  Details in Section

Page 20: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Fields for Special Handling"4-bit

Version 4-bit

Header Length

8-bit Type of Service

(TOS) 16-bit Total Length (Bytes)

16-bit Identification 3-bit Flags 13-bit Fragment Offset

8-bit Time to Live (TTL) 8-bit Protocol 16-bit Header Checksum

32-bit Source IP Address

32-bit Destination IP Address

Options (if any)

Payload

Page 21: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Special Handling"

l  “Type of Service”, or “Differentiated Services Code Point (DSCP)” (8 bits) l  Allow packets to be treated differently based on needs l  E.g., low delay for audio, high bandwidth for bulk transfer l  Has been redefined several times, will cover later in class

l  Options (not often used) l  details in Section

Page 22: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Examples of Options

l  Record Route l  Strict Source Route l  Loose Source Route l  Timestamp l  Traceroute l  Router Alert l  …..

Page 23: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Let’s take a quick look at the IPv6 header…"

Page 24: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

IPv6

l  Motivated (prematurely) by address exhaustion l  Addresses four times as big

l  Steve Deering focused on simplifying IP l  Got rid of all fields that were not absolutely necessary l  “Spring Cleaning” for IP

Page 25: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Summary of Changes"

l  Eliminated fragmentation (why?) l  Eliminated checksum (why?) l  New options mechanism (next header) (why?) l  Eliminated header length (why?) l  Expanded addresses (why?) l  Added Flow Label (why?)

Page 26: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

IPv4 and IPv6 Header Comparison"

Version IHL Type of Service Total Length

Identification Flags Fragment Offset

Time to Live Protocol Header Checksum

Source Address

Destination Address

Options Padding

Version Traffic Class Flow Label

Payload Length Next Header Hop Limit

Source Address

Destination Address

IPv4 IPv6

Field name kept from IPv4 to IPv6 Fields not kept in IPv6

Name & position changed in IPv6 New field in IPv6

Page 27: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Philosophy of Changes"

l  Don’t deal with problems: leave to ends l  Eliminated fragmentation l  Eliminated checksum l  Why retain TTL?

l  Simplify handling: l  New options mechanism (uses next header approach) l  Eliminated header length

l  Why couldn’t IPv4 do this?

l  Provide general flow label for packet l  Not tied to semantics l  Provides great flexibility

Page 28: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Comparison of Design Philosophy"

Version IHL Type of Service Total Length

Identification Flags Fragment Offset

Time to Live Protocol Header Checksum

Source Address

Destination Address

Options Padding

Version Traffic Class Flow Label

Payload Length Next Header Hop Limit

Source Address

Destination Address

IPv4 IPv6

To Destination and Back (expanded) Deal with Problems (greatly reduced)

Read Correctly (reduced) Special Handling (similar)

Page 29: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

IP Routers

l  Core building block of the Internet infrastructure

l  $120B+ industry

l  Vendors: Cisco, Huawei, Juniper, Alcatel-Lucent (account for >90%)

Page 30: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Lecture#2: Routers Forward Packets

to MIT

to UW

UCB

to NYU

Destination Next Hop

UCB 4

UW 5

MIT 2

NYU 3

Forwarding Table 111010010 MIT

switch#2

switch#5

switch#3

switch#4

Page 31: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Router definitions

1

2

3

4 5

N-1

N

•  N = number of external router “ports” •  R = speed (“line rate”) of a port •  Router capacity = N x R

R bits/sec

Page 32: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Networks and routers

AT&T BBN

NYU

UCB

core

core

edge (ISP)

edge (enterprise)

home, small business

Page 33: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Examples of routers (core)

72 racks, 1MW

Cisco CRS •  R=10/40/100 Gbps •  NR = 322 Tbps

Juniper T4000 •  R= 10/40 Gbps •  NR = 4 Tbps

Page 34: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Examples of routers (edge)

Cisco ASR 1006 •  R=1/10 Gbps •  NR = 40 Gbps

Juniper M120 •  R= 2.5/10 Gbps •  NR = 120 Gbps

Page 35: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Examples of routers (small business)

Cisco 3945E •  R = 10/100/1000 Mbps •  NR < 10 Gbps

Page 36: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

What’s inside a router?

1

2

N

1

2

N

Linecards (input)

Interconnect (Switching)

Fabric

Route/Control Processor

Linecards (output)

Processes packets on their way in

Processes packets before they leave

Transfers packets from input to output ports

Input and Output for the same port are on one

physical linecard

Page 37: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

What’s inside a router?

1

2

N

1

2

N

Linecards (input)

Interconnect (Switching)

Fabric

Route/Control Processor

Linecards (output)

(1) Implement IGP and BGP protocols;

compute routing tables (2) Push forwarding

tables to the line cards

Page 38: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

What’s inside a router?

1

2

N

1

2

N

Linecards (input)

Interconnect Fabric

Route/Control Processor

Linecards (output)

Constitutes the data plane

Constitutes the control plane

Page 39: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Input Linecards

l  Tasks l  Receive incoming packets (physical layer stuff) l  Update the IP header

Version Header Length

Type of Service (TOS) Total Length (Bytes)

16-bit Identification Flags Fragment Offset

Time to Live (TTL) Protocol Header Checksum

Source IP Address

Destination IP Address

Options (if any)

Payload

Page 40: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Input Linecards

l  Tasks l  Receive incoming packets (physical layer stuff) l  Update the IP header

l  TTL, Checksum, Options (maybe), Fragment (maybe) l  Lookup the output port for the destination IP address l  Queue the packet at the switch fabric

l  Challenge: speed! l  100B packets @ 40Gbps à new packet every 20 nano secs!

l  Typically implemented with specialized hardware l  ASICs, specialized “network processors” l  “exception” processing often done at control processor

Page 41: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

IP Lookup

l  Recall IP addressing and BGP routing l  For scalability, multiple IP addresses are aggregated l  BGP operates on IP address prefixes (recall “/n” notation) l  IP routing tables maintain a mapping from IP prefixes to

output interfaces

l  Route lookup à find the longest prefix in the table that matches the packet destination address l  Longest Prefix Match (LPM) lookup

Page 42: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Longest Prefix Match Lookup l  Packet with destination address 12.82.100.101 is sent

to interface 2, as 12.82.100.xxx is the longest prefix matching packet’s destination address

1

2 128.16.120.111

12.82.100.101

… …

3 12.82.xxx.xxx

1 128.16.120.xxx

12.82.100.xxx 2

Page 43: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Longest Prefix Match is NOT… l  Check an address against all destination prefixes and

select the prefix it matches with on the most bits

… …

3 1**.***.xxx.xxx(/1)

1 101.xx.xxx.xxx (/3)

… ..

l  To which port should we send a packet with destination address 100.5.6.7?

Page 44: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Example #1: 4 Prefixes, 4 Ports"

Prefix Port

201.143.0.0/22 Port 1 201.143.4.0.0/24 Port 2 201.143.5.0.0/24 Port 3 201.143.6.0/23 Port 4

201.143.0.0/22 201.143.4.0/24 201.143.5.0/24 201.143.6.0/23

ISP Router Port 1

Port 2 Port 3

Port 4

Page 45: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Finding the Match"

l  Consider 11001001100011110000010111010010 l  First 21 bits match 4 partial prefixes l  First 22 bits match 3 partial prefixes l  First 23 bits match 2 partial prefixes l  First 24 bits match exactly one full prefix

11001001 10001111 000000−− −−−−−−− 11001001 10001111 00000100 −−−−−−− 11001001 10001111 00000101 −−−−−−− 11001001 10001111 0000011− −−−−−−−

201.143.0.0/22

201.143.4.0/24

201.143.5.0/24

201.143.6.0/23

Page 46: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Finding Match Efficiently

l  Testing each entry to find a match scales poorly l  On average: O(number of entries)

l  Leverage tree structure of binary strings l  Set up tree-like data structure

l  Return to example:

Prefix Port 1100100110001111000000********** 1 110010011000111100000100******** 2 110010011000111100000101******** 3 11001001100011110000011********* 4

Prefix Port 1100100110001111000000********** 1 110010011000111100000100******** 2 110010011000111100000101******** 3 11001001100011110000011********* 4

Page 47: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Consider four three-bit prefixes

l  Just focusing on the bits where all the action is….

l  0** è Port 1 l  100 è Port 2 l  101 è Port 3 l  11* è Port 4

Page 48: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

48

Tree Structure"

00*

000 001

0 1 01*

010 011

0 1 11*

110 111

0 1 10*

100 101

0 1

0** 0 1

1** 0 1

*** 0 1

0** è Port 1 100 è Port 2 101 è Port 3 11* è Port 4

Page 49: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Walk Tree: Stop at Prefix Entries"

00*

000 001

0 1 01*

010 011

0 1 11*

110 111

0 1 10*

100 101

0 1

0** 0 1

1** 0 1

*** 0 1

0** è Port 1 100 è Port 2 101 è Port 3 11* è Port 4

Page 50: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Walk Tree: Stop at Prefix Entries"

00*

000 001

0 1 01*

010 011

0 1 11*

110 111

0 1 10*

100 101

0 1

0** 0 1

1** 0 1

*** 0 1

P1

P2 P3

P4

0** è Port 1 100 è Port 2 101 è Port 3 11* è Port 4

Page 51: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Slightly Different Example

l  Several of the unique prefixes go to same port

l  0** è Port 1 l  100 è Port 2 l  101 è Port 1 l  11* è Port 1

Page 52: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Prefix Tree"

00*

000 001

0 1 01*

010 011

0 1 11*

110 111

0 1 10*

100 101

0 1

0** 0 1

1** 0 1

*** 0 1

P1

P2 P1

P1

0** è Port 1 100 è Port 2 101 è Port 1 11* è Port 1

Page 53: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

More Compact Representation"

10*

100

0

1** 0

*** 1

P2

P1

Record port associated with latest match, and only over-ride when it matches

another prefix during walk down tree

If you ever leave path, you are done, last matched

prefix is answer

Page 54: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

LPM in real routers

l  Real routers use far more advanced/complex solutions than the approaches I just described l  but what we discussed is their starting point

l  With many heuristics and optimizations that leverage real-world patterns l  Some destinations more popular than others l  Some ports lead to more destinations l  Typical prefix granularities

Page 55: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Recap: Input linecards

l  Main challenge is processing speeds l  Tasks involved:

l  Update packet header (easy) l  LPM lookup on destination address (harder)

l  Mostly implemented with specialized hardware

Page 56: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Output Linecard

l  Packet classification: map each packet to a “flow” l  Flow (for now): set of packets between two particular endpoints

l  Buffer management: decide when and which packet to drop l  Scheduler: decide when and which packet to transmit

1

2

Scheduler

flow 1

flow 2

flow n

Classifier

Buffer management

Page 57: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Output Linecard

l  Packet classification: map each packet to a “flow” l  Flow (for now): set of packets between two particular endpoints

l  Buffer management: decide when and which packet to drop l  Scheduler: decide when and which packet to transmit

l  Used to implement various forms of policy l  Deny all e-mail traffic from ISP-X to Y (access control) l  Route IP telephony traffic from X to Y via PHY_CIRCUIT (policy) l  Ensure that no more than 50 Mbps are injected from ISP-X (QoS)

Page 58: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Simplest: FIFO Router

l  No classification l  Drop-tail buffer management: when buffer is full drop the

incoming packet l  First-In-First-Out (FIFO) Scheduling: schedule packets in

the same order they arrive

1

2

Scheduler Buffer

Page 59: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Packet Classification

l  Classify an IP packet based on a number of fields in the packet header, e.g., l  source/destination IP address (32 bits) l  source/destination TCP port number (16 bits) l  Type of service (TOS) byte (8 bits) l  Type of protocol (8 bits)

l  In general fields are specified by range l  classification requires a multi-dimensional range search!

1

2 Scheduler

flow 1 flow 2

flow n

Classifier

Buffer management

Page 60: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Scheduler l  One queue per “flow” l  Scheduler decides when and from which queue to send a

packet l  Goals of a scheduling algorithm:

l  Fast! l  Depends on the policy being implemented (fairness, priority, etc.)

1

2

Scheduler

flow 1 flow 2

flow n

Classifier

Buffer management

Page 61: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Priority Scheduler

Example: Priority Scheduler

l  Priority scheduler: packets in the highest priority queue are always served before the packets in lower priority queues

High priority

Medium priority

Low priority

Page 62: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Example: Round Robin Scheduler

l  Round robin: packets are served from each queue in turn

Fair Scheduler

High priority

Medium priority

Low priority

Page 63: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Switching

1

2

N

1

2

N

Linecards (input)

Interconnect Fabric

Route/Control Processor

Linecards (output)

Page 64: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Shared Memory (1st Generation) Route Table CPU

Buffer Memory

Line Interface

MAC

Line Interface

MAC

Line Interface

MAC

Limited by rate of shared memory

Shared Backplane

(* Slide by Nick McKeown, Stanford Univ.)

Page 65: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Shared Bus (2nd Generation) Route Table CPU

Line Card

Buffer Memory

Line Card

MAC

Buffer Memory

Line Card

MAC

Buffer Memory

Fwding Cache

Fwding Cache

Fwding Cache

MAC

Buffer Memory

Limited by shared bus

(* Slide by Nick McKeown)

Page 66: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Point-to-Point Switch (3rd Generation)

Line Card

MAC

Local Buffer

Memory

CPU Card

Line Card

MAC

Local Buffer

Memory

Switched Backplane

Fwding Table

Routing Table

Fwding Table

(*Slide by Nick McKeown)

Page 67: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

© Nick McKeown 2006

NxR

3rd Gen. Router: Switched Interconnects

This is called an “output queued” switch

Page 68: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

© Nick McKeown 2006

3rd Gen. Router: Switched Interconnects

This is called an “input queued” switch

Page 69: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Two challenges with input queuing

1) Need an internal fabric scheduler!

Page 70: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

© Nick McKeown 2006

1 x R

Fabric Scheduler

3rd Gen. Router: Switched Interconnects

Page 71: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Two challenges with input queuing

1)  Need an internal fabric scheduler! 2)  Must avoid “head-of-line” blocking

Page 72: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Head of Line Blocking

HoL blocking limits throughput to approximately

58% of capacity

Page 73: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

“Virtual Output Queues”

Page 74: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

© Nick McKeown 2006

1 x R

Fabric Scheduler

3rd Gen. Router: Switched Interconnects

Page 75: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Reality is more complicated

l  Commercial (high-speed) routers use l  combination of input and output queuing l  complex multi-stage switching topologies (Clos, Benes) l  distributed, multi-stage schedulers (for scalability)

l  We’ll consider one simpler context l  de-facto architecture for a long time and still used in

lower-speed routers

Page 76: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Scheduling

l  Context l  crossbar fabric l  centralized scheduler

l  Goals

l  Work conserving (100% throughput) l  Fast

Page 77: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Scheduling

l  Context l  crossbar fabric l  centralized scheduler

l  Goal: 100% throughput, fast l  optimal solution: maximum matching on a bipartite graph l  problem: too slow l  practical solution: a good maximal matching l  multiple fast algorithms exist for computing a good

and fair maximal matching [PIM, iSlip]

Page 78: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

In Summary

l  IP header formats l  not as boring as one might imagine

l  IP routers l  core building block of the infrastructure l  needs simple, fast implementations for longest-prefix

matching, multi-dimensional search, switch and output scheduling

Page 79: The IP Data Plane: Packets and Routersee122/fa13/lectures/lec8.pdf · The IP layer ! So far, we’ve focused mostly on routing protocols ! how routers discover and select end-to-end

Administrivia

l  All but one of you should now have an instructional account l  email apanda@cs and sylvia@cs if you haven’t ! l  don’t wait until 5 minutes before HW1 is due

l  HW1 is due Oct 4, 5pm l  Check the course website for other adjustments

l  Next lecture will start with a 5minute Q&A with Gautam/Kaifei/Radhika on Project#1