Presentation is loading. Please wait.

Presentation is loading. Please wait.

IP Address Lookup Masoud Sabaei Assistant professor

Similar presentations


Presentation on theme: "IP Address Lookup Masoud Sabaei Assistant professor"— Presentation transcript:

1 IP Address Lookup Masoud Sabaei Assistant professor
Computer Engineering and Information Technology Department, Amirkabir University of Technology

2 Outlines Overview, Trie-based Algorithms, Hardware-based Schemes,
IPV6 Lookup

3 Trie-based Algorithms
Binary Trie, Path Compressed Trie, Multi-Bit Trie Level Compression, Lulea Algorithm, Tree Bitmap Algorithm Tree-Based Pipelined Search, Binary Search on Prefix Lengths, Binary Search on Prefix Range.

4 Binary Trie Represents prefixes of different lengths 1-bit trie
Left link: 0 Right link: 1 Search Start from root, move to left or right if the current bit of the address is 0 or 1 respectively If a node containing a prefix mark (*) is seen, store it somewhere as the longest match up to now Addition Follow the path and create new nodes if needed and finally mark the last node as a prefix Deletion Follow the path and delete the last node and its parents until a marked node or a node with another child is seen يکی از ساختارهای داده‌ی شناخته شده برای جستجو بر اساس طولانی‌ترين تطبيق، Trie می‌باشد. در ساده‌ترين حالت، يک Trie يک درخت دودويی است که اطلاعات پيشوند‌ها در يال‌های آن ذخيره شده‌اند و نام پيشوندها در نودها قرار دارند. با شروع از نود ريشه‌ی Trie، و با شروع از پر ارزش‌ترين بيت پيشوند، بسته به صفر يا يک بودن اين بيت، يک انشعاب به فرزند چپ يا فرزند راست داريم. پس از رسيدن به آخرين بيت، نام پيشوند در نود فعلی قرار دارد. شکل، يک مثال در اين مورد نشان می‌دهد. در اين شکل تعدادی پيشوند و Trie متناظر با آن‌ها مشاهده می‌شود. همان طور که در شکل مشاهده می‌شود، نام پيشوندها می‌تواند درنودهای غير برگ هم وجود داشته باشد و اين به خاطر اين است که يک پيشوند می‌تواند خود، پيشوندی از ديگری باشد. مثلا پيشوند b در اين شکل، پيشوندی از e است. به همين خاطر است که امکان تطبيق يک آدرس مورد جستجو با چند پيشوند وجود دارد و در اين موارد طولانی‌ترين پيشوند به عنوان نتيجه‌ی جستجو بازگردانده می‌شود. جستجودر Trie خيلی ساده است. با شروع از نود ريشه و با توجه به صفر يا يک بودن بيت‌های آدرس مورد جستجو، پس از چک کردن هر بيت‌، به فرزند سمت چپ يا راست آن نود منتقل می‌شويم. در حين اين انتقال، هر جا که نودی حاوی نام پيشوند مشاهده کنيم، آن را به عنوان طولانی‌ترين تطبيق يافته شده تا به حال به خاطر می‌سپاريم. وقتی که به يک نود برگ برسيم، و يا اين که ادامه‌ی حرکت امکان‌پذير نباشد، جستجو پايان يافته‌است. به عنوان مثال فرض کنيد بخواهيم در Trie شکل بالا برای آدرس جستجو انجام شود. برای سادگی کار، آدرس را 5 بيتی در نظر گرفته‌ايم. با شروع از نود ريشه، با توجه به اولين بيت آدرس که يک است به فرزند سمت راست منتقل می‌رويم. در آن‌جا با مشاهده‌ی پيشوند a آن را به عنوان طولانی‌ترين تطبيق مشاهده شده تا به حال به خاطر می‌سپاريم. سپس با توجه به بيت بعدی آدرس که يک است، به فرزند سمت راست نود a حرکت می‌کنيم. در آن جا نام پيشوندی مشاهده نمی‌شود. بنابراين a هنوز طولانی‌ترين تطبيق يافته شده تا به حال است. سپس با توجه به صفر بودن بيت بعدی آدرس، به فرزند سمت چپ نود فعلی می‌رويم. در آن جا d را مشاهده می‌کنيم و اين بار d به عنوان طولانی‌ترين تطبيق يافته شده تا به حال، جای a را می‌گيرد. سپس با توجه به صفر بودن بيت بعدی آدرس مورد جستجو، بايد به فرزند سمت چپ نود d حرکت کنيم. اما با توجه به عدم وجود چنين فرزندی اين کار امکان ندارد و به همين خاطر جستجو پايان يافته است و d بهترين تطبيق يافته شده برای آدرس است. وقتی که يک مدخل جديد به جدول مسيريابی افزوده می‌شود، بايد پيشوند جديد در Trie وارد شود. برای انجام اين کار ابتدا مثل اين که بخواهيم يک جستجو برای آن پيشوند انجام دهيم، مسير موجود بر روی Trie را تا جايی که وجود دارد ادامه می‌دهيم. اگر اين مسير به طور کامل وجود داشت، فقط کافی است نام پيشوند را در نود پايانی ثبت کنيم. در غير اين صورت بايد ادامه‌ی مسير مربوط به آن نود را در Trie ايجاد کنيم و سپس نام پيشوند را در نود پايانی ذخيره کنيم. در مورد حذف يک پيشوند از Trie، ابتدا مسير مربوط به آن پيشوند را تا انتها بر روی Trie مرور می‌کنيم. سپس اگر آخرين نود مربوط به اين مسير دارای فرزندی باشد، مثل پيشوند c در شکل بالا، بايد فقط نام پيشوند را از نود حذف کنيم و نمی‌توانيم خود نود را حذف کنيم. مثلا برای حذف پيشوند c از Trie شکل بالا، بايد نام آن را از نود مربوط به آن حذف کنيم. اما در صورتی که فرزندی نداشته‌باشد، بايد خود نود را حذف کنيم و نيز والد‌های نود هم تا جايی که حاوی پيشوند نباشند و فقط يک فرزند داشته باشند، بايد حذف شوند. مثلا برای حذف پيشوند h از Trie شکل بالا، بايد نود h و نود والد آن حذف شوند.

5 Data Structure of a 1-bit Binary Trie

6 Performance of Binary Trie
The Number of Memory Accesses in The Worst Case is 32 for IPv4. To Add a Prefix to The Trie, In The Worst Case It Needs to Add 32 Nodes. In This Case, The Storing Complexity is 32N · S, The Lookup Complexity is O(W), The Storagecomplexity is O(NW)

7 Variants of Binary Tries
Disjoint-prefix binary trie

8 Path-Compressed Trie

9 Example of Path-Compressed Trie with N Leaves

10 Performance of Path-compressed Tire
Path compression reduces the height of a sparse binary trie. When the tree is full and there is no compression possible, a path-compressed trie looks the same as a regular binary trie. Thus, its lookup and update complexity (the worst case) is the same as a binary trie, O(W). Considering a path-compressed trie as a full binary trie with N leaves, there can be N − 1 internal nodes between the root and each leaf node (including the root node), Since the path can be significantly compressed to reduce the internal nodes, the space complexity becomes O(N), independent of W.

11 Multi-Bit Trie

12 Multi-Bit Trie Example With Each Entry a Prefix or a Pointer to Save Memory Space

13 Performance of Multi-Bit Trie
The advantage of the k-bit trie structure is that it improves the lookup by k times. The disadvantage is that a large memory space is required. One way to reduce the memory space is to use a scheme called ‘leaf pushing’. The lookup is performed in strides of k bits. The lookup complexity is the number of bits in the prefix divided by k bits, O(W/k). For example, if W is 32 and k is 4, then 8 lookups in the worst case are required to access that node. An update requires a search through W/k lookup iterations plus access to each child node (2k ). The update complexity is O(W/k + 2k). In the worst case, each prefix would need an entire path of length (W/k) and each node would have 2k entries. The space complexity would then be O((2k ∗ N ∗ W)/k).

14 Level Compression Trie
One-bit trie; Path-compressed trie; LC-trie.

15 Performance of Level Compression Trie
An LC-trie searches in strides of k bits, and thus the lookup complexity of a k-stride LC-trie is O(W/k). To update a particular node, we would have to go through W/k lookups and then access each child of the node (2k ). Thus, the update complexity is O(W/k + 2k). The memory consumption increases exponentially as the stride size (k) increases. In the worst case, each prefix would need an entire path of length (W/k) and each node has 2k entries. The space complexity would then be O((2k ∗ N ∗ W)/k).

16 Lulea Algorithm Example of a Lulea Trie

17 Lulea Algorithm Three Levels of the Data Structure

18 Lulea Algorithm Part of cut with corresponding bit-vector

19 Lulea Algorithm Bit-masks versus code words and base indices

20 Lulea Algorithm Finding the pointer index

21 Lulea Algorithm Performance. The Lulea algrorithm provides a very compact data structure and fast lookups. The data structure has 150–160 kbytes for the largest forwarding tables with 40,000 routing entries, which is small enough to fit in the cache of a conventional general-purpose processor. A 200MHz Pentium Pro or a 333MHz Alpha with the table in the cache can perform a few million IP lookups per second without special hardware and no traffic locality is assumed. Lulea does not support incremental updates because of the algorithm’s tight coupling property. In many cases, the whole table should be reconstructed. Thus, routing protocols that require frequent updates make this algorithm unsuitable. The Lulea trie uses the k-bit stride multi-bit method. The lookup complexity is the same as a multi-bit trie, O(W/k). The bitmap compression technique applied to the multi-bit trie makes it almost impossible to perform incremental updates. The data structure may need to be completely rebuilt. The memory consumption is the same as the k-bit stride multi-bit trie. Thus, the space complexity is O((2k ∗ N ∗ W)/k).

22 Tree Bitmap Algorithm

23 Tree Bitmap Algorithm Example of route lookup

24 Tree-Based Pipelined Search

25 Tree-Based Pipelined Search
Random ring pipeline architecture with two data paths

26 Binary Search on Prefix Lengths

27 Binary Search on Prefix Lengths

28 Binary Search on Prefix Lengths
Performance. The algorithm requiresO(log2 W) hashed memory accesses for one lookup operation, taking no account of the hash collision. So does the update complexity. This data structure has storage complexity of O(NW) since there could be up to W markers for a prefix-each internal node in the trie on the path from the root node to the prefix. However, not all the markers need to be kept. Only the log2 W markers that would be probed by the binary search algorithm need be stored in the corresponding hash tables. For instance, an IPv4 prefix of length 22 needs markers only for prefix lengths 16 and 20. This decreases the storage complexity to O(N log2 W).

29 Binary Search on Prefix Range

30 Binary Search on Prefix Lengths
Performance. There should be 2N segment points for a prefix database size of N when each prefix generates two endpoints. If a k-way search is used, the search time in the worst case will be logk 2N. Once a prefix is added or deleted, the range sequence is changed and the content of N memory locations storing the original N ranges need to be updated. The update complexity and memory space are both O(N). It has been reported that by using a 200-MHz Pentium Pro-based machine and a practical forwarding table with over 32,000 route entries, the worst-case time of 490 ns and an average time of 100 ns for IP route lookups were obtained. Only a 0.7-Mbyte memory was used. A drawback of this algorithm is that it does not support incremental updates.


Download ppt "IP Address Lookup Masoud Sabaei Assistant professor"

Similar presentations


Ads by Google