TCP kernel hash function

From: Soohyun Cho (s0c6496_at_cs.tamu.edu)
Date: 05/30/04


Date: Sun, 30 May 2004 03:05:44 -0500

Hi all,

I want to find established TCP connections between same source-destination
hosts regardless of their ports.
While I was looking at Linux TCP kernel source codes I found Linux use hash
tables to find owner socket id of received packets.
This may be good to improve TCP session lookup speed than searching TCP
sockets using doubly linked lists as in BSD.
However if I want to find TCP connections going to the same destination host
I found it is very inefficient because Linux does not maintain linked lists
of socks.
I found sock->pprev or sock->next of struct sock are nothing but itself or
empty.
I needed to search whole possible hash value space to find small set of TCP
connections.
In Linux, this value is tcp_ehash_size and it is 131072. It's huge enough to
degrade TCP performance.
It took too much time to find some TCP socks going to the same hosts.

I couldn't narrow down the lookup speed because tcp_hashfn() generates so
randomly distributed hash numbers rather than grouping them according to
destination ip address.
The hash value could be anything from 0 to 131072..
I think this happens because source port number space is so big.

Is there any way to retrieve this kind of information fast in Linux kernel?
Do I have to insert additional structure to struct sock for this?

I would really appreciate who answer my question.
Thanks,

Soohyun Cho.



Relevant Pages

  • Dog slow TCP on 100 megabit/s LAN
    ... I'm having some TCP connectivity problems involving a WinXP box, ... and a router to share internet access and have a LAN for those two machines. ... DHCP server disabled (I use fixed IP on WinXP & Linux) ...
    (comp.os.linux.networking)
  • Dog slow TCP on 100 megabit/s LAN
    ... I'm having some TCP connectivity problems involving a WinXP box, ... and a router to share internet access and have a LAN for those two machines. ... DHCP server disabled (I use fixed IP on WinXP & Linux) ...
    (comp.os.linux.setup)
  • Re: TOE brain dump
    ... > When they've sorted out these problems, regular TCP has caught ... The Linux net stack just isn't built to be offloaded. ... TOE engines will ... NIC across the PCI bus using jumbo-ethernet-like data frames. ...
    (Linux-Kernel)
  • Re: TOE brain dump
    ... >> When they've sorted out these problems, regular TCP has caught ... > The Linux net stack just isn't built to be offloaded. ... TOE engines will ...
    (Linux-Kernel)
  • Re: Dog slow TCP on 100 megabit/s LAN
    ... How much buffer you have on the linux box ?. ... Maximum thruput at TCP level is ... > and a router to share internet access and have a LAN for those two ... > similar performance when running WinXP on the AMD Duron box. ...
    (comp.os.linux.setup)