slides

advertisement
On Finding an Optimal TCAM
Encoding Scheme
for Packet Classification
Ori Rottenstreich (Technion, Israel)
Joint work with
Isaac Keslassy (Technion, Israel)
Avinatan Hassidim (Google Israel & Bar-Ilan Univ.)
Haim Kaplan (Tel Aviv Univ.)
Ely Porat (Bar-Ilan Univ.)
Network Structure
Accept?
2
Packet Classification
H
E
A
D
E
R
Incoming
Packet
Switch
Forwarding Engine
Packet Classification
Action
Policy Database (classifier)
Rule
Action
----------------
---3
TCAM Architecture
1
2
3
4
5
6
7
8
9
111001001
0011100
1010
11111111111
 
0
deny
deny
0
0
1
0
0
1
Encoder
0
TCAM Array
001110111111
Each entry is a
1000000110
word in {0,1,}W
1001011001000
001110
11100100
row 3
1
0
1
accept
deny
accept
deny
deny
accept
deny
accept
Match lines
Source Port
0011101000011100
Packet Header
Width W
4
Range Rules
•
•
Rule
Source
address
Source
port
Dest.
address
Dest.
Port
Prot
ocol
Action
Rule 1
123.25.0.0/16
80
255.2.3.4/32
80
TCP
Accept
Rule 2
13.24.35.0/24
>1023
255.2.127.4/31
5556
TCP
Deny
Rule 3
16.32.223.14
20-50
255.2.3.4/31
50-70
UDP
Accept
Rule 4
22.2.3.4
1-6
255.2.3.0/21
20-22
TCP
Deny
Range rule = rule that contains range field
 Usually source-port or destination-port
How many entries are required to represent one range
field?
5
TCAM Encoding Example
•
•
Reducing number of TCAM entries by exploiting TCAM
properties
Example: R=[1,6]
Basic encoding
with 6 entries
0
000
2
1
001
010
3
4
011
100
6
5
101
110
7
111
6
TCAM Encoding Example
•
•
Reducing number of TCAM entries by exploiting TCAM
properties
Example: R=[1,6]
Shorter encoding
with 4 entries
0
000
3
2
1
001
001
010
01*
011
6
5
4
100
10*
101
110
7
111
110
6
TCAM Encoding Example
•
•
Reducing number of TCAM entries by exploiting TCAM
properties
Example: R=[1,6]
Improved encoding
with only 3 entries
0
000
2
1
001
010
3
4
011
000
100
6
5
101
110
7
111
111
6
***
Past Work: Prefix Encoding
• Definition: An encoding in which in all entries “*”-s appear only as a
suffix
• Example: Encoding of the range R = [0,2]
Prefix encoding
Non-prefix encoding
• Property: For a general function F, it is easy to find an optimal prefix
encoding [Suri et al. ’03]
• TCAM enables non-prefix encoding
• Can we use this TCAM property to do better than past algorithms?
7
Outline
 Introduction
 Optimal Encoding of Extremal Ranges
 Average Expansion of Extremal Ranges
 Bounds on the Worst-Case Expansion
8
General Functions
Given a function F, we define
•
•
- The size of a smallest encoding of F.
- The size of a smallest prefix encoding of F.
• Property: For a general function F, the equality
does not necessarily hold.
• Example:
0
000
2
1
001
010
Optimal prefix
encoding
3
Optimal
encoding
011
9
Range Functions
Given a range R, does necessarily
?
• Extremal ranges = Ranges that start or end a sub-tree
(e.g. [0,2] or [4,6] in tree [0,7])
• Real life database: 97% of all rules are extremal ranges
• Theorem: For an extremal range R,
• Corollary: Finding an optimal encoding of extremal ranges is easy
6
3
2Non–extremal
5
4 ranges?
1
• Open0Question:
000
001
010
011
100
101
110
7
111
10
Optimal Encoding
Given a subtree T and a range R, we define
•
- The size of a smallest encoding of R∩T with a last entry of
•
- The size of a smallest encoding of R∩T with a last entry of
• Example: If
and
•
•
• Property:
then
and
D
11
Algorithm Illustration
• Illustration of the algorithm for the extremal range R=[0,22]
• Values are calculated recursively for T0,…,T5
• The range R can be encoded in
entries:
T0 :[22,22]
TW=5:(3,4)
1
T4:(3,3)
0
T1 :[22,23]
T3:(2,3)
1
T2 :(2,3)
1
0
T2 :[20,23]
T1 :(2,2)
T0 :(1,2)
22
0
31
R = [0,22]
12
Another Way to Look at it…
• For simplicity, let’s focus on the simple extremal ranges [0,y]
TW=5:(3,4)
1
T4:(3,3)
0
1
0
0
0
T3:(2,3)
1
start
A
B
C
(a,a+1)
(b,b)
(c+1,c)
T2 :(2,3)
1
T1 :(2,2)
0
1
1
Deterministic Finite Automaton (DFA)
0
T0 :(1,2)
22
31
R = [0,22]=[00000,10110]
13
Another Way to Look at it…
• For simplicity, let’s focus on the simple extremal ranges [0,y]
1
0
0
0
start
A
B
C
(a,a+1)
(b,b)
(c+1,c)
1
1
Deterministic Finite Automaton (DFA)
•
Theorem: For a range
transitions of the DFA in the processing of
Then,
.
, let
.
be the number of blue
14
Another Way to Look at it…
• For simplicity, let’s focus on the simple extremal ranges [0,y]
1
0
0
0
1/2
1/2 1/2
1/2
start
A
B
C
A
B
C
(a,a+1)
(b,b)
(c+1,c)
(a,a+1)
(b,b)
(c+1,c)
1
1
Deterministic Finite Automaton (DFA)
•
Theorem: For a range
transitions of the DFA in the processing of
Then,
.
•
1/2
1/2
Corresponding Markov Chain
, let
.
be the number of blue
Corollary:
is affected by the average number of blue
transitions (among the first W transitions) in the Markov Chain derived from the DFA.
14
Average Expansion of
Simple Extremal Ranges
• Theorem: The average range expansion
of simple extremal ranges [0,y] satisfies:
• Corollary:
15
Outline
 Introduction
 Optimal Encoding of Extremal Ranges
 Average Expansion of Extremal Ranges
 Bounds on the Worst-Case Expansion
16
Bounds on the Worst-Case
Expansion
- Worst-case expansion over all ranges of W bits:
Known
1-D
Ranges
2-D
Ranges
Our Contribution
=
Optimality over all coding schemes
=
for 1-D ranges
Optimality over all coding schemes
for 2-D ranges
17
Concluding Remarks
• Optimal encoding of extremal ranges
• Formula for the average range expansion
of simple extremal ranges
• Tight worst-case bounds
 r(W) (1-D ranges, all coding schemes)
 r2(W) (2-D ranges, all coding schemes)
18
Thank You
Download