That's actually not true - there is hundreds if not thousands of ranges which differ in the
last part (even across countries, not only companies).
Example from RIPE: (all ranges share the first part: 37.59.223.___)
IT ->
https://apps.db.ripe.net/search/quer...t=37.59.223.39
NL ->
https://apps.db.ripe.net/search/quer...t=37.59.223.47
PL ->
https://apps.db.ripe.net/search/quer...t=37.59.223.63
CZ ->
https://apps.db.ripe.net/search/quer...t=37.59.223.79
GB ->
https://apps.db.ripe.net/search/quer...t=37.59.223.95
DE ->
https://apps.db.ripe.net/search/quer...=37.59.223.127
FR ->
https://apps.db.ripe.net/search/quer...=37.59.223.191
Or to give another example from ARIN:
The US-RangeSite here:
http://lite.ip2location.com/united-s...address-ranges
lists e.g. the range: 23.239.183.32 to 23.247.128.255 ...
But in reality there is a whole lot of Sub-Ranges in there, which were re-assigned,
as e.g. the range 23.246.198.192 to 23.246.198.223 belonging to CL (Chile) now.
https://whois.arin.net/rest/customer/C05314851.html
So these more detailed infos can be found over the registrars (of the appropriate region) directly,
or by using more recent (and more "fine-granular") DataBases...
The one I've found among the free available ones, is this one here (CC-licensed):
https://db-ip.com/db/download/country
It contains nearly half a Million range-records - and was the most detailed one
(there's other free, liberally licensed DBs, but the next one which came close had only about 250,000 records).
The advantage with those larger DBs is, that they cover all countries *and*:
- that they leave no gaps!
That means, the format within the CSV above (IPfrom, IPto, ...) is not really
needed, because any "IPto-Value" is equal to the "IPfrom-Value minus one" from the next line.
That makes it quite easy for much more efficient storage - and for a fast binary search.
So I've re-formatted the above CSV in a Binary-Format, which takes this "gapelessness" into account,
storing a single range-record in only 6 Bytes, which reduces the Raw-Binary-File to about 2.5MB
(432616 Records * 6 Bytes-per-Record = 2,595,696).
Further LZMA-compressing reduces these ~2.5MB to about 500kByte (something one can ship-along easily with ones App).
... since you called ... ;)
Though the US-DB is a bit small (any algo would probably feel "fast enough").
So I'd suggest to use the Data from the link I've posted above (the one with the 432616 Records)
and use that...
I've done that in the following Demo (which does not include the original CSV, but the 512KB LZMA-Raw-Binary-Data):
http://vbRichClient.com/Downloads/IPRangesByCountry.zip
Which needs some time to load (about 300msec, mostly due to the LZMA-decompression):
http://www.vbforums.com/images/ieimages/2017/08/1.png
But after the 0.5Mio Records sit in the Dictionary, the (Binary) search goes quite fast:
http://www.vbforums.com/images/ieimages/2017/08/1.png
My 0.02$...
Olaf