Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does TCP use an own thread?

TCP sends ACKs when it receives a network packet. It also resends packets when a timeout occurs. Now my question is: In which Thread does TCP do this? Is there a secret TCP background thread that listens for received packets and timeouts and triggers the sending of ACKs and resends? Or does this only happen synchronously when I call, for example, receive on the socket? Or is there maybe an own TCP daemon process from the OS which handles this?

Although my question refers to .net, I think it applies generally to any TCP implementation in any language.

like image 692
gexicide Avatar asked Dec 04 '25 14:12

gexicide


1 Answers

TCP and sockets in general are not dependent on the language, but rather on the system, and it's architecture.

Addressing your questions:

In which Thread does TCP do this? Definitely, not on any application thread. Usually, you can't really define that, since on kernel level there may be no such thing as "thread".

Is there a secret TCP background thread that listens for received packets and timeouts and triggers the sending of ACKs and resends? If you consider OS a "secret background thread" then... yes.

Or does this only happen synchronously when I call, for example, receive on the socket? When you call receive, the system checks whether there are any incoming packets in it's buffer. But then again, this may be more or less system-dependant.

Or is there maybe an own TCP daemon process from the OS which handles this? More or less this.

For more info you may want to check the following links: http://en.wikipedia.org/wiki/Protocol_stack http://www.ece.virginia.edu/cheetah/documents/papers/TCPlinux.pdf

PS. I couldn't quickly find detailed information about Windows TCP/IP implementation, but since winsocks are kind of based on BSD sockets, I persume it's similar.

like image 102
Marandil Avatar answered Dec 07 '25 13:12

Marandil



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!