Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need a hash function to create 32 bit value out of ipv6 16 Byte address and TCP 2 Byte port numbers

I want to create a hash value of 32 bit. I have 16 byte source and destination ipv6 addresses and 2 byte source and destination port numbers.

32 bit Output = (Src IP,Dst Ip,Src Port,Dest Port)

It would be better if the hash function distribute the entities well along the 32 bit space. I want to use the result as an index.

Resit

like image 982
Mustafa Sahin Avatar asked Jun 30 '11 07:06

Mustafa Sahin


1 Answers

Another, may be useful references:

General Purpose Hash Function Algorithms

CityHash by Google

Note that, it is very hard to make a no collision guaranteed hash function (no different input result in the same hash code). There are many solutions to this problem, most simple one is the open addressing.

Open Addressing

like image 167
9dan Avatar answered Sep 27 '22 17:09

9dan