O'Reilly logo

Web Performance Tuning by Patrick Killelea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required