Download presentation
Presentation is loading. Please wait.
1
IP Routers – internal view
Lecture 11: IP Routers – internal view
6
Unlike standard computer memory (eg
Unlike standard computer memory (eg. RAM) in which the user supplies a memory address and the RAM returns the data word stored at that address, a CAM is designed such that the user supplies a data word and the CAM searches its entire memory to see if that data word is stored anywhere in it. If the data word is found, the CAM returns a list of one or more storage addresses where the word was found Thus, a CAM is the hardware embodiment of what in software terms would be called an associative array.
9
Longest Prefix Match Harder than Exact Match
destination address of arriving packet does not carry information to determine length of longest matching prefix need to search space of all prefix lengths; as well as space of prefixes of given length
10
LPM in IPv4: exact match Use 32 exact match algorithms Network Address
against prefixes of length 1 Network Address Exact match against prefixes of length 2 Priority Encode and pick Port Exact match against prefixes of length 32
11
IP Address Lookup routing tables contain (prefix, next hop) pairs address in packet compared to stored prefixes, starting at left prefix that matches largest number of address bits is desired match packet forwarded to specified next hop routing table next hop prefix 10* 7 01* 5 110* 3 1011* 5 0001* 0101 1* 7 0001 0* 1 * 2 * 3 * 5 * 6 * 4 * 8 * 10 * 9 Problem - large router may have 100,000 prefixes in its list address:
12
Address Lookup Using Tries
next-hop-ptr (if prefix) left-ptr right-ptr Trie node P1 111* H1 P2 10* H2 P3 1010* H3 P4 10101 H4 A 1 B prefixes “spelled” out by following path from root to find best prefix, spell out address in tree last green node marks longest matching prefix Lookup 10111 adding prefix easy 1 C add P5=1110* I P5 D P2 1 1 F E P1 G P3 1 H P4
13
Binary Tries For W-bit prefixes: O(W) lookup,
O(NW) storage, N number of entries (at the worst case for each entry has different prefix, disjoint path in a trie) O(W) update Advantages Simplicity Extensible to wider fields Disadvantages Worst case lookup slow Wastage of storage space in chains
14
Leaf-pushed Binary Trie
Trie node A left-ptr or next-hop right-ptr or next-hop 1 B 1 C D P1 111* H1 P2 10* H2 P3 1010* H3 P4 10101 H4 P2 P1 1 E P2 G P3 P4
15
PATRICIA Patricia tree internal node bit-position left-ptr right-ptr PATRICIA (Practical Algorithm To Retrieve Coded Information in Alphanumeric) A 2 1 B C P1 P2 3 1 E Bitpos 12345 5 P1 111* H1 P2 10* H2 P3 1010* H3 P4 10101 H4 1 F G P3 P4
16
Bitpos 12345 P1 111* H1 P2 10* H2 P3 1010* H3 P4 10101 H4 111* Lookup: follow the key according to the bit position if can not proceed and the node is “filled”: this is the output if can not proceed and the node is not “filled”: lookup failed if can proceed and arrived to a leaf: this is the output
17
Bitpos 12345 P1 111* H1 P2 10* H2 P3 1010* H3 P4 10101 H4 2 1 10* 111* Lookup: follow the key according to the bit position if can not proceed and the node is “filled”: this is the output if can not proceed and the node is not “filled”: lookup failed if can proceed and arrived to a leaf: this is the output
18
Bitpos 12345 P1 111* H1 P2 10* H2 P3 1010* H3 P4 10101 H4 2 1 111* 3 10* 1 1010* Lookup: follow the key according to the bit position if can not proceed and the node is “filled”: this is the output if can not proceed and the node is not “filled”: lookup failed if can proceed and arrived to a leaf: if the leaf corresponds to the prefix, then this is the output
19
Bitpos 12345 P1 111* H1 P2 10* H2 P3 1010* H3 P4 10101 H4 2 1 111* 10* 3 1 5 1 1010* 10101 Lookup: follow the key according to the bit position if can not proceed and the node is “filled”: this is the output if can not proceed and the node is not “filled”: lookup failed if can proceed and arrived to a leaf: this is the output
20
Example: lookup 10111 111* 10* 1010* 10101 P1 111* H1 P2 10* H2 P3
1 111* 3 10* 1 5 1 1010* 10101 Let’s lookup for ‘10111’ … We can't proceed to check from the 5’th bit. Backtrack to bit 3
21
(Example cont.) Inserting Operation
111* H1 P2 10* H2 P3 1010* H3 P4 10101 H4 P5 10111 H5 2 1 111* 3 10* 1 4 1 5 10111 1 10101 1010*
22
PATRICIA W-bit prefixes: O(W2) lookup O(N) storage
O(W) update complexity Advantages decreased storage extensible to wider fields Disadvantages worst case lookup slow backtracking makes implementation complex
23
Path-compressed Tree A C B D E Lookup 10111
1, , 2 A B C 1 10,P2,4 P4 P1 E D 1010,P3,5 P1 111* H1 P2 10* H2 P3 1010* H3 P4 10101 H4 Lookup 10111 bit-position left-ptr right-ptr variable-length bitstring next-hop (if prefix present) Path-compressed tree node structure
24
Path-compressed Tree W-bit prefixes: O(W) lookup, O(N) storage and O(W) update complexity Advantages decreased storage Disadvantages worst case lookup slow
25
Multi-bit Tries Binary trie W Multi-ary trie W/k Depth = W Degree = 2
Stride = 1 bit Depth = W/k Degree = 2k Stride = k bits Multi-ary trie W/k
26
Prefix Expansion with Multi-bit Tries
If stride = k bits, prefix lengths that are not a multiple of k need to be expanded Prefix Expanded prefixes 0* 00*, 01* 11* E.g., k = 2: Maximum number of expanded prefixes corresponding to one non-expanded prefix = 2k-1
27
4-ary Trie (k=2) A four-ary trie node A B C Lookup 10111 P2 D E F P3
next-hop-ptr (if prefix) A ptr00 ptr01 ptr10 ptr11 11 10 B C Lookup 10111 P2 11 10 D E F 10 P3 P11 P12 10 11 H G P41 P42 P1 111* H1 P2 10* H2 P3 1010* H3 P4 10101 H4
28
Prefix Expansion Increases Storage Consumption
replication of next-hop ptr greater number of unused (null) pointers in a node Time ~ W/k Storage ~ NW/k * 2k-1
29
Generalization: Different Strides at Each Trie Level
split split 24-8 split split In future, use cartoons esp. with questions like ‘optional exercise’…
30
Choice of Strides: Controlled Prefix Expansion
Given forwarding table and desired number of memory accesses in worst case (i.e., maximum tree depth, D) A dynamic programming algorithm to compute optimal sequence of strides that minimizes storage requirements: runs in O(W2D) time Advantages Optimal storage under these constraints Disadvantages Updates lead to sub-optimality anyway Hardware implementation difficult
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.