Skip to contentSkip to conversation

Hash Function to Seperate Flows

DISCUSSION Srinivas Krishnan 3 participants 3 messages May 2, 2006 – May 4, 2006 netfilter

lore
Share & tools
lore
#0 lore raw

hi,

i am trying to separate different flows, and was wondering if there is a standard hash function with low collisions i can use to hash based on src ip, dest ip, src port, dest port and protocol.

there seems to be as hash fn in freeBSD's dummynet code but I do not know if it can be directly applied, as it does some bit fiddling with flow_mask.

any help/thoughts would be greatly appreciated

-srinivas

--
*********************************
Srinivas Krishnan

Graduate Student
Dept. Of Computer Science
UNC-Chapel Hill
++++++++++++++++++++++++++++++++
Phone:
**Office: (919) 962-1920
**Cell: (585)295-3359
Email: [email protected], [email protected]
++++++++++++++++++++++++
Web: www.cs.unc.edu/~krishnan
**************************************

#1 lore raw
Quoted 11 lines · Srinivas Krishnan

hi,

i am trying to separate different flows, and was wondering if there is a standard hash function with low collisions i can use to hash based on src ip, dest ip, src port, dest port and protocol.

there seems to be as hash fn in freeBSD's dummynet code but I do not know if it can be directly applied, as it does some bit fiddling with flow_mask.

any help/thoughts would be greatly appreciated

I suggest you read a few times through all kernel source files with "conntrack" in the name.

I did, and it did me a world of good.

jhash is probably the hash function you want. Look out for it, and happy reading.

Sam

#2 lore raw

I suggest to refer the net/ipv4/netfilter/ip_conntrack_core.c

Thehe is a example using jhash for reference.

static u_int32_t __hash_conntrack(const struct ip_conntrack_tuple *tuple,
unsigned int size, unsigned int rnd)

{
        return (jhash_3words(tuple->src.ip,
                             (tuple->dst.ip ^ tuple->dst.protonum),
                             (tuple->src.u.all | (tuple->dst.u.all <<
16)),
                             rnd) % size);
}

Vincent

Quoted 34 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Amin Azez
Sent: Wednesday, May 03, 2006 5:35 PM
To: [email protected]
Subject: Re: Hash Function to Seperate Flows

Quoted 3 lines · Srinivas Krishnan

hi,

i am trying to separate different flows, and was wondering

if there is

Quoted 5 lines

a standard hash function with low collisions i can use to hash based on src ip, dest ip, src port, dest port and protocol.

there seems to be as hash fn in freeBSD's dummynet code but I do not know if it can be directly applied, as it does some bit

fiddling with

Quoted 3 lines

flow_mask.

any help/thoughts would be greatly appreciated

I suggest you read a few times through all kernel source files with "conntrack" in the name.

I did, and it did me a world of good.

jhash is probably the hash function you want. Look out for it, and happy reading.

Sam