3

This is the picture from the textbook James F. Kurose, Keith W. Ross: Computer networking: a top-down approach, ISBN-13: 978-0-13-285620-1. ISBN-10: 0-13-285620-4.

enter image description here

According to the picture, the welcoming port is different to actual connection port.(since different socket is assigned a different port number. So let's say Client is initializing a HTTP request, so the welcoming port is 80 on the web server, and then the actual connection port is different than 80?

The second question is, what's the purpose of handshaking for TCP? I was only taught that why TCP's handshaking is but don't actually know why handshaking is essential. If we get rid of handshaking from TCP, we can still make TCP a reliable data transfer protocol, can't we?

user207421
  • 305,947
  • 44
  • 307
  • 483
whoisit
  • 269
  • 3
  • 12
  • 1
    Note that the diagram you have included shows that there are two *sockets* on the server process. Not two *ports*. The same server port is used for both sockets. (The idea of a "socket" is just a software thing on the server side and doesn't have anything to do with what is sent over the wire.) – Greg Hewgill Apr 30 '18 at 01:22

2 Answers2

5

According to the picture, the welcoming port is different to actual connection port.

No it isn't. There is nothing in the picture that indicates that. It indicates that the listening and connected sockets are different. Not the same thing.

(since different socket is assigned a different port number).

No it isn't. An accepted socket has the same local port number as the listening socket it was accepted from. I don't know where you got the term 'welcoming port' from, or the author got the term 'welcoming socket' from. The correct terminology is 'listening port'.

So let's say Client is initializing a HTTP request, so the welcoming port is 80 on the web server, and then the actual connection port is different than 80?

No. It is 80.

The second question is, what's the purpose of handshaking for TCP? I was only taught that why TCP's handshaking is but don't actually know why handshaking is essential. If we get rid of handshaking from TCP, we can still make TCP a reliable data transfer protocol, can't we?

No. It has several purposes, one of which is to establish that both sides know that the connection exists, and another of which is to establish an initial sequence number in each direction, which makes it harder for an attacker to inject data.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • so what's the difference between socket and port number? I was told that "IP address and Port " together is called "Socket", so since ip address and port number are the same for welcoming and connection socket, how come we have two different sockets? – whoisit Apr 30 '18 at 02:42
  • See [What is the difference between a port and a socket](https://stackoverflow.com/questions/152457/what-is-the-difference-between-a-port-and-a-socket). – user207421 Apr 30 '18 at 02:46
  • thanks for posting the answer. but since IP address and Port " together is called "Socket", so how come we have 2 different sockets:welcoming and connection sockets, since their ip address and port number are the same? – whoisit Apr 30 '18 at 02:49
  • No, again. 'IP address and Port " together is called "Socket"' is false. A socket is an endpoint of a connection. See the link I just posted, and the other duplicates. – user207421 Apr 30 '18 at 02:53
3

At the lowest level the "welcoming socket" is a file descriptor that represents the listening socket on a particular port. When another computer connects to that port and the server calls accept then a new file descriptor is generated that represents that specific connection. That's the "connection socket" on this diagram.

The three way handshake is necessary to establish the parameters of the TCP/IP session. TCP/IP is a fairly minimal protocol, there's not a lot of fuss or ceremony. The SYN, SYN-ACK, ACK process ensures that both ends of the connection are in sync before data transfer begins.

This synchronization process quite familiar:

enter image description here

Without that final ACK the party that sent the SYN-ACK doesn't know if their response was received or not. That third packet is necessary to provide confirmation.

tadman
  • 208,517
  • 23
  • 234
  • 262