Skip to content
Rakesh Kumar T edited this page May 4, 2020 · 11 revisions

Ip-Model

About

Ip-model is a light-weight Data structure to perform operations on IP's efficiently. We can add & remove Ip's, especially check the presence in O(1) time.

Implementation

The DS is designed by leveraging the advantages of Radix Tree.

For IPv4:

Steps for adding, removing and checking Individual IP's:

  • Convert IP in binary form, append the 4 8-bits as a single 32bit unit
  • Insert/Remove the 32bit number into/from Radix tree

Time Complexity: O(1)

For CIDR:

Steps to adding and removing CIDR's

  • Covert the given CIDR into list of IP's
  • Iterate over the list & follow the same Steps for adding/removing Ipv4
Clone this wiki locally