An O(log n) dynamic router-table design
Internet (IP) packet forwarding is typically done by finding the longest prefix in a router table that matches the packet's destination address. For Vi-bit destination addresses, the use of binary tries enables us to determine the longest matching prefix in O(W) time, independent of the number n of prefixes in the router table. New prefixes may be inserted and old ones deleted in O(W) time also. Since n much less than 2(W) in real router tables, it is desirable to develop a data structure that permits longest prefix matching as well as the insertion and deletion of prefixes in O(log n). These three operations can be done with O(log n) cache misses using a B-tree data structure [19]. However, the runtime (including operation cost and cost of cache misses) is not O(log n). In this paper, we develop a data structure in which prefix matching, prefix insertion, and deletion can each be done in O(log n) time. Experiments using real IPv4 routing databases indicate that, although the proposed data structure is slower than optimized variable-stride tries for longest prefix matching, the proposed data structure is considerably faster for the insert and delete operations.
longest matching prefix packet routing red-black trees