in reply to Algorithom to find overlaping subnets (Internet IPv4)
If speed is a concern, then I would go with your "build a tree of up to 32 levels" idea. Such a tree is called a prefix trie, and it is often used in IP routing tables. You can code your own or choose something from CPAN (say, Net::IPTrie or Tree::Trie).
Note, however, that checking overlaps is more difficult than your "inserting a network I find the space taken, I would have found an overlap" idea, because not just the node itself, but all its parents must be checked as well. In particular, you have an overlap either if the node corresponding to your subnet is taken or any of its parents is taken.
|Replies are listed 'Best First'.|
Re^2: Algorithom to find overlaping subnets (Internet IPv4)
by chrestomanci (Priest) on Sep 20, 2011 at 13:47 UTC