In message <dub116-w41324220eb6a5f7fd8b06a97...@phx.gbl>, enrico d'urso writes:
>

>I'm looking for an Hash function for Ipv4 addresses.
>
>What are good ones?

They are generally very hard to hash well, for all sorts of reasons
related to how we use them.

One way that used to work reasonably well for me:

        uint32_t ipv4, h;

        h = ipv4 % HASH;
        ipv4 /= HASH;
        h ^= ipv4 % HASH;
        h ^= ipv4 / HASH;

Where HASH was a prime number near to 2^11

However, I cannot rule out that the good results I saw was a result
if RIPE's allocation policy at the time.


-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
p...@freebsd.org         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to