Part I Equivalent Transformation Techniques
4.1 Multi-dimensional TCAM Minimization: The Basics
In this section, we present TCAM Razor, our algorithm for minimizing multi- dimensional pre¿x packet classi¿ers. A key idea behind TCAM Razor is processing one dimension at a time using the weighted one-dimensional TCAM minimization algorithm in Section 2.2 to greedily identify a local minimum for the current dimen- sion. Although TCAM Razor is not guaranteed to achieve a global minimum across all dimensions, it does signi¿cantly reduce the number of pre¿x rules in real-life packet classi¿ers.
4.1.1 Conversion to Firewall Decision Diagrams
To facilitate processing a packet classi¿er one dimension at a time, we¿rst convert a given packet classi¿er to an equivalent reducedFirewall Decision Diagram(FDD)
31 C. R. Meiners et al., Hardware Based Packet Classification for High Speed Internet Routers, DOI 10.1007/978-1-4419-6700-8_4, © Springer Science+Business Media, LLC 2010
32 4 TCAM Razor
[Gouda and Liu(2007)]. Given a packet classi¿erf1, we can construct an equivalent FDD f2using the FDD construction algorithm in [Liu and Gouda(2004)].
Fig. 4.1 A¿rewall decision diagram
4.1.2 Multi-dimensional TCAM Minimization
We start the discussion of our greedy solution by examining the reduced FDD in Figure 4.1. We¿rst look at the subgraph rooted at nodev2. This subgraph can be seen as representing a one-dimension packet classi¿er over¿eldF2. We can use the weighted one-dimensional TCAM minimization algorithm in Section 2.2 to mini- mize the number of pre¿x rules for this one-dimensional packet classi¿er. The algo- rithm takes the following 3 pre¿xes as input:
10∗ ∗ (with decision accept and cost 1), 0∗ ∗∗ (with decision discard and cost 1), 11∗ ∗ (with decision discard and cost 1).
The one-dimensional TCAM minimization algorithm will produce a minimum (one- dimensional) packet classi¿er of two rules as shown in Table 4.1.
Rule # F1 Decision
1 10** accept
2 **** discard
Table 4.1 A minimum packet classi¿er corresponding tov2in Fig. 4.1
Similarly, from the subgraph rooted at nodev3, we can get a minimum packet classi¿er of one rule as shown in Table 4.2.
4.1 Multi-dimensional TCAM Minimization: The Basics 33 Rule # F1 Decision
1 **** discard
Table 4.2 A minimum packet classi¿er corresponding tov3in Fig. 4.1
Next, we look at the root v1. As shown in Figure 4.2, we view the subgraph rooted atv2as a decision with a multiplication factor or cost of 2, and the subgraph rooted atv3as another decision with a cost of 1. Thus, the graph rooted atv1can be thought of as a “virtual” one-dimensional packet classi¿er over¿eldF1where each child has a multiplicative cost.
1000
0***
1001
F
11**
1F
2ę10**ėaccept
F
2ę****ėdiscard
F
2ę****ėdiscard
101*
Fig. 4.2 “Virtual” one-dimensional packet classi¿er
Now we are ready to use the one-dimensional TCAM minimization algorithm in Section 2.2 to minimize the number of rules for this “virtual” one-dimensional packet classi¿er. The algorithm takes the following 5 pre¿xes and associated costs as input:
1000 (with decisionv2and cost 2), 101∗ (with decisionv2and cost 2), 0∗ ∗∗ (with decisionv3and cost 1), 1001 (with decisionv3and cost 1), 11∗ ∗ (with decisionv3and cost 1),
Running the weighted one-dimensional TCAM minimization algorithm on the above input will produce the “virtual” one-dimensional packet classi¿er of three rules as shown in Table 4.3.
Combining the “virtual” packet classi¿er in Table 4.3 and the two packet clas- si¿ers in Table 4.1 and 4.2, we get a packet classi¿er of 4 rules as shown in Table 4.4.
34 4 TCAM Razor Rule # F1 Decision
1 1001 go to nodev3 2 10** go to nodev2 3 **** go to nodev3 Table 4.3 A minimum packet classi¿er corresponding tov1in Fig. 4.1
Rule # F1 F2 Decision 1 1001 **** discard
2 10** 10** accept
3 10** **** discard 4 **** **** discard Table 4.4 Packet classi¿er generated from the FDD in Figure 4.1
4.1.3 Removing Redundant Rules
Next, we observe that ruler3in the packet classi¿er in Table 4.4 is redundant. If we remove ruler3, all the packets that used to be resolved byr3(that is, all the packets that matchr3but do not matchr1andr2) are now resolved by ruler4, andr4has the same decision asr3. Therefore, removing ruler3does not change the semantics of the packet classi¿er. Redundant rules in a packet classi¿er can be removed using the algorithms in [Liu and Gouda(2005)] or the algorithm in the next chapter. Finally, after removing redundant rules, we get a packet classi¿er of 3 rules from the FDD in Figure 4.1.
4.1.4 The Algorithm
To summarize, TCAM Razor, our multi-dimensional TCAM minimization algo- rithm, consists of the following four steps:
1. Convert the given packet classi¿er to an equivalent FDD.
2. Use the FDD reduction algorithm described in the next section to reduce the size of the FDD. This step will be explained in more detail in the next section. 3. Generate a packet classi¿er from the FDD in the following bottom up fashion.
For every terminal node, assign a cost of 1. For a non-terminal nodevwithz
outgoing edges{e1,⋅⋅⋅,ez}, formulate a one-dimensional TCAM minimization
problem as follows. For every pre¿xPin the label of edgeej, (1≤j≤z), we set
the decision ofPto bej, and the cost ofPto be the cost of the node that edgeej
points to. For nodev, we use the weighted one-dimensional TCAM minimization algorithm in Section 2.2 to compute a one-dimensional pre¿x packet classi¿er with the minimum cost. We then assign this minimum cost to the cost of nodev. After the root node is processed, generate a packet classi¿er using the pre¿xes