Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Jun 2012 15:43:42 +0300
From:      Gleb Kurtsou <gleb.kurtsou@gmail.com>
To:        enrico d'urso <e.durso@live.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: [Hash function Ipv4]
Message-ID:  <20120603124342.GA1225@reks>
In-Reply-To: <DUB116-W41324220EB6A5F7FD8B06A97090@phx.gbl>
References:  <DUB116-W41324220EB6A5F7FD8B06A97090@phx.gbl>

next in thread | previous in thread | raw e-mail | index | archive | help
On (02/06/2012 20:14), enrico d'urso wrote:
> 
> Hi,
> I'm looking for an Hash function for Ipv4 addresses.
> 
> What are good ones?

Have you tried good general purpose hash functions like murmur3 or
cityhash?

Another option is to use "hash" function that is bijection on integers
and exploit this fact in data structure, e.g. by using hash array mapped
trie or another prefix tree.

The easiest way to build such function is Feistel network on top of
general purpose hash function as round function. Li and Ri will be most
and less significant 16 bits of ipv4 address accordingly. At least 3
Fiestel rounds required. Play with function to achieve better
performance/distribution.

https://en.wikipedia.org/wiki/Feistel_cipher

Reduced round and block size RC5 also looks very attractive, but it's
patented :(

Thanks,
Gleb.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120603124342.GA1225>