Skip to Main Content
Internet (IP) packet forwarding is typically done by finding the longest prefix in a router table that matches the packet's destination address. For W-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≪2W 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(logn). These three operations can be done with O(logn) cache misses using a B-tree data structure [S. Suri et al., (2001)]. However, the runtime (including operation cost and cost of cache misses) is not O(logn). In this paper, we develop a data structure in which prefix matching, prefix insertion, and deletion can each be done in O(logn) 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.