TCP Connection Initiation

This section is dedicated exclusively to the various queues and tunable variable(s) used during connection instantiation. The socket API maintains some control over the queues. But in order to tune anything, you have to understand how listen and accept interact with the queues. For details, see the various books by Stevens mentioned in Section C.10.1 later in this appendix.

When the server calls listen, the kernel moves the socket from the TCP state CLOSED into the state LISTEN, thus doing a passive open. All TCP servers work like this. Also, the kernel creates and initializes various data structures, among them the socket buffers and two queues:

Incomplete connection queue

This queue contains an entry for every SYN that has arrived. BSD sources assign so_q0len entries to this queue. The server sends off the ACK of the client’s SYN and sends the server-side SYN. The connection gets queued and the kernel now awaits the completion of the TCP three-way handshake to open a connection (see Figure C.1). The socket is in the SYN_RCVD state. On the reception of the client’s ACK to the server’s SYN, the connection stays one round trip time (RTT) in this queue before the kernel moves the entry into the completed connection queue.

TCP three-way handshake, connection initiation

Figure C-1. TCP three-way handshake, connection initiation

Completed connection queue

This queue contains an entry for each connection for ...

Get Web Performance Tuning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.