On the Code Length of TCAM Coding Schemes Ori Rottenstreich (Technion, Israel) Joint work with Isaac Keslassy (Technion, Israel) 1
Network Structure 2
Packet Classification Action ---- RuleAction Policy Database (classifier) Packet Classification Forwarding Engine Incoming Packet HEADERHEADER 3 Switch
The TCAM Architecture Encoder Match lines deny accept deny accept deny accept 1 00 10 1110 010 0 11 01 1010 row 3 Each entry is a word in {0,1, } W Packet Header TCAM Array Source Port 4 Width W
Range Rules RuleSource address Source port Dest- address Dest- port Prot ocol Action Rule / /32 80TCP Accept Rule /24> / TCP Deny Rule / UDP Accept Rule / TCP Limit Rule ICMP Log Range rule = rule that contains range field Usually source-port or dest-port 5 How many TCAM entries are required for representing one range field?
Range Rule Representation in TCAM Coding objective: minimize the number of TCAM entries needed to code the range More TCAM entries represent more power consumption Some ranges are easy to represent Example: W=3: [4, 7] = {100,101,110,111} = 1 But what about [1,6] ? 6
Range [1,6] in tree of all elements with W=3 bits: (Internal) Coding of [1,6] Known result: expansion in 2W-2 TCAM entries Here: 2W-2=4 TCAM entries 7
Upper Bounds on the TCAM Range Expansion 2W-2 (Srinivasan et al., 1998) 2W-4 (Bremler-Barr et al., 2007) 2W-5 (Roth, 2009) W (Rottenstreich et al., 2010; Cohen et al., 2010) ??? 8 Is W also the lower bound?
External Coding Reduced number of TCAM entries: exploiting TCAM entry order by coding range complimentary as well Recent result: expansion in W TCAM entries Here: W=3 TCAM entries (instead of 4) Is this new coding scheme optimal? 9
Basic Definitions Let be the number of TCAM entries required for representing the range R using the coding scheme. We define the range code length f(W) as the best achievable code length for W-bit ranges given all coding schemes Likewise, we define f p (W) as the minimal code length given all prefix coding schemes. 10
Basic Definitions (2) We define the range code length g(W) as the best achievable code length for extremal W-bit ranges given all coding schemes R=[0,0]R=[0,1]R=[0,2]R=[0,3]R=[0,7] 11
Results KnownOur Contribution Optimality over all coding schemes 12 Optimality over prefix coding schemes which are the most common coding schemes
Optimality Proof Intuition a1a1 a2a2 a3a3 Assume W = 2 and R = [0,2]. If a 1 (01), a 3 (10) R are encoded in the same TCAM entry, it must be **. Therefore, a 2 (11) R also matches this entry R 13 The range R = [0,2] cannot be coded in a single TCAM entry.
Hull Property We define the hull of a set of W -bit strings in the W - dimensional string space: Definition (Hull): Let (n, W) N 2, and consider n strings a 1, …, a n of W bits each, with a i = (a i 1, …, a i W ) for each i [1,n]. Then the hull of (a 1, …, a n ), denoted H(a 1, …, a n ), is the smallest cuboid containing a 1, …, a n in the W-dimensional string space, and is defined as 14 H(a 1, a 3 ) = H(10, 01) = {00, 01, 10, 11} R a1a1 a2a2 a3a3
Alternating Path and Independent Set Let n and W be positive integers and let α:{0,1} W →{0,1} be a classifier function. A n = (a 1, …, a 2n-1 ) is an alternating path if it satisfies the following conditions: Alternation: For i [1,2n-1], α(a 1 ) = α(a 3 ) = … = α(a 2n-1 ) = 1 α(a 2 ) = α(a 4 ) = … = α(a 2n-2 ) = 0 Hull: For any i 1, i 2, i 3 such that i 1 ≤ i 2 ≤ i 3 ≤2n-1, a i2 H(a i1, a i3 ) 15 In such an alternating path (a 1, a 3, a 5, …, a 2n-3, a 2n-1 ) is an independent set
Example a1a1 a2a2 a3a3 W = 2 and R = [0,2]. Alternation: α(a 1 ) = α(a 3 ) = 1, α(a 2 )=0. Hull: a 2 H(a 1, a 3 ). (a 1, a 2, a 3 ) is an alternating path and (a 1, a 3 ) is an independent set R 16
Alternating Path and Independent Set Theorem: A classifier function with an independent set of size n cannot be coded in less than n TCAM entries. 17
Extremal Range Code-Length Optimality Assume W=4. Let R = [0, c] = [0, {1010}]. Define: a 1 = 0101 a 2 = 1101 a 3 = 1001, a 4 = 1011 a 5 = c = Observe: a 1, a 3, a 5 ≤ c = 1010, a 2, a 4 > c = Alternation: α(a 1 ) = α(a 3 ) = α(a 5 )= 1, α(a 2 ) = α(a 4 )= 0. Hull: a i2 H(a i1, a i3 ) for i 1 ≤ i 2 ≤ i 3. (a 1, a 3, a 5 ) is an independent set. The range R = [0,{1010}] cannot be coded in less than 3 TCAM entries. 18
Extremal Range Code-Length Optimality We showed optimality for g(W) with W=2 and W=4, let’s show it for any even W. Let R = [0, c] = [0, {10} W ] = [0,2/3(2 W -1)]. Define: a 1 = {01} W/2, a 2 = 11{01} W/2-1, a 3 = 10{01} W/2-1, a 4 = 1011{01} W/2-2, a 5 = 1010{01} W/2-2, …, a W+1 = c = {10} W/2 Observe: a 2k+1 ≤ c a 2k ≥ c. Alternation: α(a 2k+1 ) = 1, α(a 2k ) = 0. Hull: a i2 H(a i1, a i3 ) for i 1 ≤ i 2 ≤ i 3. (a 1, a 2, …, a W+1 ) is an alternating path and (a 1, a 3, …, a W+1 ) is an independent set. The upper bound of g(W) is tight. 19
General Range Code-Length Optimality In this paper, we present a range R that cannot be coded in less than W prefix TCAM entries, whether the first TCAM entry encodes the range R (internal coding) or its complementary (external coding). Future Direction: Coding scheme optimality over all coding schemes 20
Summary TCAM coding optimality g(W) (Extremal ranges, all coding schemes) f p (W) (All ranges, prefix coding schemes) New tools for TCAM: Independent sets and alternating paths 21
Thank You 22