13
1 Algorithms for Routing Lookups and Packet Classification Pankaj Gupta Department of Computer Science Stanford University [email protected] http://www.stanford.edu/~pankaj October 3, 2000 2 High Level Outline Part I. Routing Lookups - Two lookup algorithms Part II. Packet Classification - One classification algorithm 3 Routing Lookups: Outline • Introduction – Background – Motivation – Definition of the problem • Algorithm #1 • Algorithm #2 • Conclusions of Part I 4 Internet: Mesh of Routers The Internet Core IP Core router IP Edge Router A C 5 Inside an IP Router 1. Accept packet arriving on an incoming link. 2. Lookup packet destination address in the forwarding table, to identify outgoing port(s). 3. Manipulate packet header: e.g., decrement TTL, update header checksum. 4. Send packet to the outgoing port(s). 5. Buffer packet in the queue. 6. Transmit packet onto outgoing link. 6 Part I of the Talk Fast and efficient algorithms that an IP router uses to lookup the destination address in order to decide where to forward the packets next.

Algorithms for High Level Outline Routing Lookups and

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Algorithms for High Level Outline Routing Lookups and

1

Algorithms forRouting Lookups andPacket Classification

Pankaj GuptaDepartment of Computer Science

Stanford [email protected]

http://www.stanford.edu/~pankaj

October 3, 2000

2

High Level Outline

Part I. Routing Lookups- Two lookup algorithms

Part II. Packet Classification- One classification algorithm

3

Routing Lookups: Outline

• Introduction– Background– Motivation– Definition of the problem

• Algorithm #1• Algorithm #2• Conclusions of Part I

4

Internet: Mesh of Routers

The Internet Core

IP Core router

IP EdgeRouter

A

C

5

Inside an IP Router1. Accept packet arriving on an incoming link.2. Lookup packet destination address in the

forwarding table, to identify outgoingport(s).

3. Manipulate packet header: e.g., decrementTTL, update header checksum.

4. Send packet to the outgoing port(s).5. Buffer packet in the queue.6. Transmit packet onto outgoing link.

6

Part I of the Talk

Fast and efficient algorithms that an IProuter uses to lookup the destinationaddress in order to decide where toforward the packets next.

Page 2: Algorithms for High Level Outline Routing Lookups and

2

7

Forwarding Engineheaderpayload

Packet

Router

Destination Address

OutgoingPort

Dest-network PortForwarding Table

Routing LookupData Structure

65.0.0.0/8128.9.0.0/16

149.12.0.0/19

31

78

The Search Operation is not aDirect Lookup

(Incoming port, label)

Address

Memory

Data

(Outgoing port, label)

IP addresses: 32 bits long ⇒ 4G entries

9

The Search Operation is alsonot an Exact Match Search

• Hashing• Balanced binary search trees

Exact match search: search for a key ina collection of keys of the same length.

Relatively well studied data structures:

10

0 224 232-1

128.9.0.0/16

65.0.0.0

142.12.0.0/19

65.0.0.0/8

65.255.255.255

Example Forwarding Table

7142.12.0.0/191128.9.0.0/16365.0.0.0/8Outgoing PortDestination IP Prefix

IP prefix: 0-32 bits

Prefix length

128.9.16.14

11

Prefixes can Overlap

128.9.16.0/21 128.9.172.0/21

128.9.176.0/24

Routing lookup: Find the longest matchingprefix (aka the most specific route) among allprefixes that match the destination address.

0 232-1

128.9.0.0/16142.12.0.0/1965.0.0.0/8

128.9.16.14

Longestmatching prefix

12

8

32

24

Prefixes

Pref

ix Le

ngth

0 232-1

128.9.0.0/16142.12.0.0/19

65.0.0.0/8

Difficulty of Longest PrefixMatch

128.9.16.14

128.9.172.0/21

128.9.176.0/24

128.9.16.0/21

Page 3: Algorithms for High Level Outline Routing Lookups and

3

13

Metrics for Lookup Algorithms

• Preprocessing time• Storage requirements• Lookup rate• Update time

14

Lookup Rate Required

12540.0OC768c2002-0331.2510.0OC192c2000-017.812.5OC48c1999-001.940.622OC12c1998-99

40Bpackets(Mpps)

Line-rate(Gbps)

LineYear

DRAM: 50-80 ns, SRAM: 5-10 ns

31.25 Mpps ⇒ 33 ns

15

0100002000030000400005000060000700008000090000

100000

Size of the Forwarding Table

Source: http://www.telstra.net/ops/bgptable.html

95 96 97 98 99 00Year

Numb

er of

Pref

ixes

10,000/year

Superlinear

16

Routing Lookups: Outline

• Introduction• Algorithm #1

– Motivation– Details– Performance

• Algorithm #2• Conclusions

17

Binary Search on PrefixIntervals1

0000 11110010 0100 0110 1000 11101010 1100

P1

P4P3

P5P2

1101…11011101/4P41000…11111/1P3

P5

P2P1

0010…0011001/3

0000…001100/20000…1111/0IntervalPrefix

1001

1. [Lampson et al., Proc. Infocom, 1998]

I1 I3 I4 I5 I6I2

18

I1

I3

I2 I4 I5

I6

0111

0011 1101

11000001

≤ >Alphabetic Tree

1/2 1/4

1/8

1/16 1/32

1/32≤

≤≤

>

>

>

>

0000 11110010 0100 0110 1000 11101010 1100

P1

P4P3

P5P2

1001I1 I3 I4 I5 I6I2

Page 4: Algorithms for High Level Outline Routing Lookups and

4

19

0001

Another Alphabetic Tree

I1

I2

I5

I3

I4

I6

0111

0011

1100

1101

1/2

1/4

1/8

1/161/32 1/32 20

0001

Yet Another Alphabetic Tree

I1

I2

I5I3 I4 I6

0111

0011

11001101

1/2

1/4

1/8 1/321/16 1/32

21

I1

I3

I2 I4 I5

I6

0111

0011 1101

11000001

≤ >Original

AlphabeticTree

1/2 1/4

1/8

1/16 1/32

1/32

0000 11110010 0100 0110 1000 11101010 1100

P1P4

P3P5P2

I1 I3 I4 I5 I6I21001

≤≤

>

>

>

>

Avgtime = 2.85Maxtime = 3

22

0001

Optimal Alphabetic Tree

I1

I2

I5

I3

I4

I6

0111

0011

1100

1101

1/2

1/4

1/8

1/161/32 1/32

Avgtime = 1.94Maxtime = 5

23

0001

I1

I2

I5I3 I4 I6

0111

0011

11001101

1/2

1/4

1/8 1/321/16 1/32

Optimal Depth-constrainedAlphabetic Tree

Avgtime = 2Maxtime = 4

Depth Constraint = 4

24

Expected Result

Maximum Lookup Time

Aver

age L

ooku

p Tim

e

logN

logN

Page 5: Algorithms for High Level Outline Routing Lookups and

5

25

Problem Statement

• Depth-constrained Huffman trees• Optimal solutions

Minimize Average Lookup Time = ∑ i lipi s.t. l i ≤ D ∀ i

access time toreach leaf i

probability ofaccessing leaf i

Depthconstraint

Previous Work:

[Larmore and Przytycka94] O(nDlogn) with largeconstant factors.

26

Goal: Near-optimal Depth-constrained Alphabetic Tree

• Simpler to find than an optimalsolution.

• Probabilities are approximate.

Why near-optimal ?

27

Algorithm MinDPQFact [Yeung91]: Given {pk}, can choose {lk}such that: H(p) ≤ C < H(p) + 2

Dlp kD

k >⇒< −2

But:Depth constraint(D) violated

<<+−=−

=nkp

nkpl

k

kk 11log

,1log

2

2

∑−=

=

iii pppH

imeavgLookupTC

log)(

28

Algorithm MinDPQ (contd.)Originaldistribution {pk},possibly pmin< 2-D

Transformeddistribution{qk}, qmin ≥ 2-DTransform

Probabilities

1* s.t. is where2,max* =∑

−=

kkqDkp

kq µµ

µ can be found in O(nlogn) time and O(n) space

ExplicitSolution

22)()(** +≤++≤=∑ optk

kk CpHqpDlpC

Within 2 memory accessesof optimal!

29

Algorithm MinDPQ:Experimental Results

Maximum mem-accesses

Aver

age m

em-a

cces

ses

30

Summary of AlgorithmMinDPQ

• A practical algorithm to minimizeaverage lookup time whilesimultaneously keeping maximumlookup time bounded.

• Provably within two memory accessesof the optimal algorithm.

Page 6: Algorithms for High Level Outline Routing Lookups and

6

31

Routing Lookups: Outline• Introduction• Algorithm #1• Algorithm #2

– Motivation– Previous Work– Details– Performance

• Conclusions32

What if we are simplyinterested in the fastest

worst-case lookup algorithm?

33

Previous Work• K. Sklower. “A tree-based packet routing table for

Berkeley unix,” Proc. Usenix, pp 93-9, 1991.• W. Doeringer, G. Karjoth and M. Nassehi. “Routing

on longest-matching prefixes,” IEEE/ACMTransactions on Networking, vol. 4, no. 1, pp 86-97,1996.

• M. Degermark, A. Brodnik, S. Carlsson, S. Pink.“Small forwarding tables for fast routing lookups,”Proc. Sigcomm, pp 3-14, 1997.

• M. Waldvogel, G. Varghese, J. Turner, B. Plattner.“Scalable high-speed IP routing lookups,” Proc.Sigcomm, pp 25-36, 1997.

34

Previous Work (contd.)• B. Lampson, V. Srinivasan, G. Varghese. “IP lookups

using multiway and multicolumn search,” Proc.Infocom, vol. 3, pp 1248-56, 1998.

• V. Srinivasan, G.Varghese. “Fast IP lookups usingcontrolled prefix expansion”, Sigmetrics, 1998.

• S. Nilsson, G. Karlsson. “IP-address lookup usingLC-tries,” IEEE JSAC, vol. 17, no. 6, pp 1083-92,1999.

Fastest: 298 ns (3.3 Mpps) with 2 MB forforwarding table with 38K prefixes (300 MHzPentium-II with 512 KB cache)

35

ProsØFast: 15-20 nsØSimple to understand

Cons

ØHigh power: 6-8 WØExpensive (low density): 0.25MB at 50 MHz costs $30-$75.Biggest TCAM in productiontoday holds 64K 32-bitentries.

Lookups with Ternary CAM

Memory array

1.23.11.3

10.x.x.x P8

TCAM0123

M

P32

P31

DestinationAddress

36

Motivation: Speed andSimplicity

Optimized for implementation indedicated hardware:

• Routing lookup function fairly well-defined

• Seems necessary for highestperformance anyway

Goal: One routing lookup every memoryaccess

Page 7: Algorithms for High Level Outline Routing Lookups and

7

37

Key Idea #1

MAE-EAST routing table (source: www.merit.edu)

Numb

er of

Pref

ixes 10000

0

1000

100000

100

10

248 16Prefix Length 32

< 0.04%

38

Key Idea #2• Memory is cheap (approx $1/MByte),

and getting cheaper– Makes sense to use memory inefficiently

to gain speed

39

Routing Lookups in Hardware

102.19.6.14

102.19.6

Prefixes expanded to 24-bits

1 Port

24

Port

102.19.6

224 = 16M entries

210.12/16210.12.255

210.12.0

40

Prefixes up to 24-bits

1 Port

128.3.72

24

128.3.72.14

128.3.72 0 Pointer

Routing Lookups in Hardware

offs

etba

se

8

Prefixes longerthan 24-bits

Next Hop

Port

Port

14

(when pipelined) Throughputof one routing lookup everymemory access.

(24,8) split

41

Routing Lookups in HardwarePros

ØSimple hardwareimplementationØ20 Mpps with 50ns DRAMØUnlimited number ofprefixes less than or equalto 24 bits long

Cons

ØLarge memory required (7-33MB)ØDepends on prefix-lengthdistributionØSlow worst-case updates

42

Routing Lookups: Outline

• Introduction• Algorithm #1• Previous work• Algorithm #2• Conclusions

Page 8: Algorithms for High Level Outline Routing Lookups and

8

43

Summary of Contributions• Algorithm to minimize average lookup

time while keeping worst casebounded: of independent interest ininformation theory.

• Hardware lookup algorithm: firstproposed algorithm that performs arouting lookup in one memory access.

44

High Level Outline

Part I. Routing Lookups- Two lookup algorithms

Part II. Packet Classification- One classification algorithm

45

Packet Classification: Outline

• Introduction– Background– Motivation– Problem definition

• Previous work• Proposed algorithm• Conclusions

46

Background

The Internet Core

IP Core router

IP EdgeRouter

A

C

R

Traditional Internet provides a “best-effort” service, and treats all packetsgoing to the same destination identically

47

Motivation: Desire forAdditional Services

ISP1NAP

E1

ISP2

ISP3X

Deny all web traffic from ISP3 at interface X.Packet FilteringEnsure that all web traffic from ISP3 is sent viainterface Z.

Policy-basedrouting

Ensure that traffic from ISP2 is given higher priorityover traffic from ISP3.

DifferentiatedService

ExampleService Src IP address

Transport LayerProtocol

Y

Z

48

Packet Header Fields

L3-SA L2-DAL2-SAL3-DA L3-PROTL4-PROTL4-DPL4-SP

Transport layer header Network layer header MAC header

DA = Destination addressSA = Source addressPROT = ProtocolSP = Source portDP = Destination port

L2 = layer 2 (e.g., Ethernet)L3 = layer 3 (e.g., IP)L4 = layer 4 (e.g., TCP)

Page 9: Algorithms for High Level Outline Routing Lookups and

9

49

Multi-field Packet Classification

Packet Classification: Find the action associated with thehighest priority rule matching an incoming packet header.

ANANY…152.0.0.0/85.168.0.0/16Rule N

………………

A2TCP…152.133.0.0/16

5.168.3.0/24Rule 2

A1UDP…2.13.8.11/325.3.40.0/21Rule 1ActionField k…Field 2Field 1

Example: packet (5.168.3.32, 152.133.171.71, … , TCP)

50

Routing Lookup: Instance of 1DClassification

• One-dimension (destination address)• Forwarding table ≡ classifier• Routing table entry ≡ rule• Outgoing port ≡ action• Prefix-length ≡ priority

Example of multi-dimensional classification:Firewall for packet-filtering

51

R5

Geometric Interpretation

R4

R3

R2R1

R7

Dimension 1

Dim

ensio

n 2

R6

e.g. (128.16.46.23, *)e.g. (144.24/16, 64/24)

P2 P1

Packet classification problem: Findthe highest priority rectanglecontaining an incoming point

52

Goal: Packet ClassificationAlgorithms

• Small preprocessing time• Low storage requirements• High speed• Scale to multiple header fields

53

Packet Classification: Outline

• Introduction• Previous work• Proposed algorithm• Conclusions

54

Previous Work• T.V. Lakshman, D. Stiliadis. “High-speed

policy-based packet forwarding usingefficient multi-dimensional rangematching,” Proc. Sigcomm, pp 191-202,1998.

• V. Srinivasan, S. Suri, G. Varghese and M.Waldvogel. “Fast and scalable layer fourswitching,” Proc. Sigcomm, pp 203-214,1998.

• V. Srinivasan, G. Varghese, S. Suri. “Packetclassification using tuple space search”,Proc. Sigcomm, pp 135-146, 1999.

Page 10: Algorithms for High Level Outline Routing Lookups and

10

55

Previous Work (contd.)• M. M. Buddhikot, S. Suri, and M. Waldvogel.

“Space decomposition techniques for fastlayer-4 switching,” PfHSN ’99, pp 25-41,1999.

• A. Feldmann and S. Muthukrishnan.“Tradeoffs for packet classification,” Proc.Infocom, vol. 3, pp 1193-202, 2000.

• T. Woo, “A modular approach to packetclassification: algorithms and resuts,” Proc.Infocom, vol. 3, pp 1203-22, 2000.

56

Previous Algorithms: Summary• Good for two fields, but do not scale

to more than two fields, OR• Good for very small classifiers (< 50

rules) only, OR• Have non-deterministic classification

time, OR• Either too slow or consume too much

storage

57

Classification Algorithms:Speed vs Storage Tradeoff

O(log N) time with O(Nd) storage, orO(logd-1N) time with O(N) storage

Point Location: Lower bounds for N regionsin d dimensions.

N = 100, d = 4, Nd = 100 MBytes andlogd-1N = 350 memory accesses

58

Recursive Flow Classification:Motivation

• Lower bounds are achieved by pathologicalclassifier datasets.

• Real-life datasets have structure andredundancy.

• Good heuristics may do better than worst-case bounds for real-life datasets.

Goal: A practical algorithm that exploits thestructure of real-life datasets to achieve bothhigh speed and low storage requirements.

59

Packet Classification: Outline• Introduction• Previous work• Algorithm Recursive Flow Classification

– Motivation– Real-life datasets: characteristics and

structure– Algorithm details– Performance– Pros and cons

• Conclusions60

Classifier Dataset• 793 classifiers from 101 ISP and

enterprise networks with a total of 41,505rules

• 40 classifiers: more than 100 rules. Biggestclassifier had 1733 rules

• Maximum of 4 fields per rule: source IPaddress, destination IP address, protocoland destination transport port number

Page 11: Algorithms for High Level Outline Routing Lookups and

11

61

Structure of the Classifiers

R1

R2

R34 regions

Dimension 1

Dime

nsion

2

62

Structure of the Classifiers

R1

R2

R3

{R1, R2}

{R2, R3}

{R1, R2, R3}

7 regions

dataset: 1733 rule classifier = 4316 distinctregions (worst case is 1011 !)

63

Recursive Flow Classification(RFC): Basic Idea

2S = 2128 2T = 212

One-step

2S = 2128 2T = 212232264

Multi-step

S = header widthT = log2(#actions)

64

RFC: Packet Flow

Phase 0 Phase 1 Phase 2 Phase 3

action

Header

Combination

16128 64 32 16

16 8

16 8

16 8 Reduction

128 12

8

16 8

16

16

65

RFC: Classification Speed

Pipelined hardware: 31 Mpps (worst caseOC192) using two 0.5Mbyte SRAMs and two8Mbyte SDRAMs at 125MHz.

66

RFC: Storage Requirements

Number of Rules

Stor

age i

n Mby

tes Three Phases

Four Phases

Page 12: Algorithms for High Level Outline Routing Lookups and

12

67

Two Phase RFC ≡Crossproducting [Srini98]

Two PhasesThree PhasesFour Phases

Number of Rules

Stor

age i

n Mby

tes

68

RFC: Pros and Cons

Pros

ØExploits structure ofreal-life datasetsØScales to multiple fieldsØFast classification(designed for parallel andpipelined accesses)

Cons

ØDepends on structure ofclassifiersØLarge pre-processing timeØSlow incremental insertions

69

Packet Classification: Outline• Introduction• Previous work• Proposed algorithm

– Motivation– Real-life classifiers: characteristics and

structure– Algorithm details– Performance– Pros and cons

• Conclusions70

Summary of Contributions onPacket Classification

Recursive Flow Classification: Firstproposed algorithm that achieves fastmulti-field classification and lowstorage requirements, by deliberatelyexploiting the structure of real-lifedatasets.

71

Other Contributions on PacketClassification

• P. Gupta and N. McKeown. “Packetclassification using hierarchical intelligentcuttings,” Proc. Hot Interconnects VII,August 99. Also in IEEE Micro, pp 34-41,vol. 20, no. 1, Jan/Feb 2000.

• P. Gupta and N. McKeown. “Dynamicalgorithms with worst-case performancefor packet classification,” Proc. IFIPNetworking, May 2000.

72

Publications for AlgorithmsDiscussed Here

• P. Gupta, B. Prabhakar, and S. Boyd. “Near-optimalrouting lookups with bounded worst caseperformance,” Proc. Infocom, vol. 3, pp 1184-92,March 2000.

• P. Gupta, S. Lin, and N. McKeown. “Routing lookupsin hardware at memory access speeds,” Proc.Infocom, vol. 3, pp 1241-8, April 1998.

• P. Gupta and N. McKeown. “Packet Classification onMultiple Fields,” Proc. Sigcomm, vol. 29, pp 147-60,September 1999.

Page 13: Algorithms for High Level Outline Routing Lookups and

13

73

Unrelated Contributions• P. Gupta and N. McKeown. “Design and

implementation of a fast crossbarscheduler,” Proc. Hot Interconnects VI,August 98. Also in IEEE Micro, pp 20-28,vol. 19, no. 1, Jan/Feb 1999.

• D. Shah and P. Gupta, “Fast updates onternary CAMs for packet lookups andclassification,” Proc. Hot InterconnectsVIII, August 2000.