0
u_int
mkhash (u_int src, u_short sport, u_int dest, u_short dport)
{
u_int res = 0;
int i;
u_char data[12];
u_int *stupid_strict_aliasing_warnings=(u_int*)data;
*stupid_strict_aliasing_warnings = src;
*(u_int *) (data + 4) = dest;
*(u_short *) (data + 8) = sport;
*(u_short *) (data + 10) = dport;
for (i = 0; i < 12; i++)
res = ((res << 8) + (data[perm[i]]^xor[i])) % 0xff100f;
return res;
}
這裏是上面的libnids哈希算法。當表大小爲65536時,兩個不同的tuple4可以獲得相同的散列值嗎?將libnids哈希算法得到衝突?
輸入大小大於哈希值,所以是的,根據[pidgeonhole原理](http://en.wikipedia.org/wiki/Pigeonhole_principle)您的哈希函數不能是內射 –