TCP – Three Way Handshake, which Port

tcp

I am trying to understand the Three way handshake in the TCP connection setup.
My book states, the client first contacts the server, say we want an HTTP connection, so it sends a SYN to port 80. (1)

The server then replies a SYN ACK package. (Here is my question) (2)

And now the client sends a final ACK. (3)

In the book the graphic shows, that (2) goes from the server socket back to the initial client scocket . Then the graphic shows that (3) goes from the client socket to a "Welcoming Socket".
The welcoming socket is not the same as the connection socket from (2).

I have downloaded the http.cap from the Wireshark wiki and am taking a look at the initial 3 packets. Here we have the SYN with port 3372 -> 80
then a SYNACK 80 -> 3372
and finaly ACK 3372 -> 80 (with potential Data already).

What confuses me is that the final ACK also goes to port 80 on the server. I thougth that we had created a new Welcoming Socket with a new port, such that the Connection Socket with port 80 can continue listening for new connections.

Best Answer

Your book is talking about system interface for sockets, which is a bit different from real TCP socket.

TCP RFC doesn't say about "welcoming socket".

So, let's look at definitions. From RFC:

The "three-way handshake" is the procedure used to establish a connection.

So, what is connection?

connection - A logical communication path identified by a pair of sockets.

Ok, so now we need know what is socket. Found:

socket - An address which specifically includes a port identifier, that is, the concatenation of an Internet Address with a TCP port.

So TCP socket is just a pair <address, port> which can accept connections, which need to be established with three-way handshake. Which is send between those two sockets ( and because port is part of socket, there is no welcoming port ).

So what is this "welcoming socket"?

Most systems ( eg. Linux ) uses a little more abstract model, that's made to be easier to use for programmers. ( So we don't have to write to the same structure for every connection. )

First we create abstract socket that represents our server addr/port ( the so called welcoming socket ), and then, when someone connects to it, we get ( via accept() ) from our OS an abstract socket that represents our connection between client and server.

It does cause some misunderstandings...

Related Topic