What are some good algorithms to compute the hash from (192.168.0.1, 34829, 80.229.161.151, 80, 6) which I can use to lookup the connection in a hash table?
192.168.0.1:34829 -> 80.229.161.151:80
(3232235521, 34829, 1357226391, 80, 6)
I read in this article that a popular way to do this, is to sum the integers then mod N, were N is the maximum number of connections.
3232235521 + 34829 + 1357226391 + 80 + 6 = 4589496827 mod 65536 = 10747
However this would collide with the following:
3232235521 + 34818 + 1357226391 + 80 + 17 = 4589496827 mod 65536 = 10747
Would it be better to do this?
3232235521 ⊕ 34829 ⊕ 1357226391 ⊕ 80 ⊕ 6 mod 65536
Just to make sure, the following TCP connection isn't possible because the source port 80 isn't available, as it's already in listening mode on that host?
80.229.161.151:80 ->192.168.0.1:34829
(1357226391, 80, 3232235521, 34829, 6)
Could I use the toeplitz hash or is that just for load balancing packets to cpu cores?