Hi,
I did some tests with some subnets Ip /24  and I will share the results.


I got very good results with this configuration:

Hash table's size: 
Let x be the number of ip.
Y = x*2, then 
size_table = 'The power of 2 closest to Y, and greater than or equal to Y'.

Hash Function: 

return Ip_in_network_byte_order % size_table;

Collision's case:

In this case i have used research quadratic:
((unsigned int)( hash_function + 0.5*k + 0.5*k*k )) % size_table ;

----------------------------------
on the other hand

When I have used Random Ip, that does not belong to the same subnet ip:


unsigned int HASH = 2039;
  uint32_t  h; 
    h = key % HASH;
    key /= HASH;
    h ^= key % HASH;
    h ^= key / HASH; 

Suggested to me by Poul-Henning Kamp (thanks) works much better.

That's all.

Bye

Enrico 




                                          
_______________________________________________
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