3 ms·
for ipv4 you can do with with just a single lookup, so real O(1) store the entire thing in one big array, indexed by the uint24 value of the /24 so ASN for 0.
by blibble 2y ago
for ipv4 you can do with with just a single lookup, so real O(1)
store the entire thing in one big array, indexed by the uint24 value of the /24
so ASN for 0.0.0.0 stored in position 0, ASN for 0.0.1.0 stored in position 1, etc
and you can drop 0.0.0.0/8, 10.0.0.0/8, 127.0.0.0/8, 224.0.0.0/4, 240.0.0.0/24 to save 35 /8s
(256-16-16-3)256256*4 bytes needed -> 55mb
mmap it if necessary
- zamadatix 2y agoIf you do it this way I think you lose all of the prefix size info I.e. every match will claim to be part of a /24 match. Depends if you care showing that portion or not if that matters though.