Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TCP call flow in Linux Kernel

I am trying to get the TCP call flow inside the Linux Kernel with a version 3.8 for different user space APIs such as connect, bind, listen and accept. Can anyone provide me with a flowchart for flow calls? I was able to find for data flow using send and recv APIs.

Another question, when a client connects to a server, the server creates a new socket to that client for that specific connection returned by the accept API. My question does the Linux Kernel maintain any relation between the listening socket and the socket derived from it in some hash bind table or not?


1 Answers

1st question:

http://www.danzig.jct.ac.il/tcp-ip-lab/ibm-tutorial/3376c210.html

All the lectures at Haifux are classic:

http://www.haifux.org/lectures/172/netLec.pdf

http://www.haifux.org/lectures/217/netLec5.pdf

And this is from the original author/maintainer in linux networking himself:

http://vger.kernel.org/~davem/skb.html

http://vger.kernel.org/~davem/tcp_output.html

http://vger.kernel.org/~davem/tcp_skbcb.html

2nd question: Yes, all existing connections are maintained in a critical table: tcp_hashinfo. Its' memory address can be read from /proc/kallsyms. "critical" because reading from it requires locking, so don't try walking the table even though you have the address. Use globally exported symbols like "inet_lookup_listener" or "inet_lookup_established" to walk the table instead.

More info here:

How to identify a specific socket between User Space and Kernel Space?

like image 53
Peter Teoh Avatar answered Jul 07 '26 02:07

Peter Teoh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!