TCP's Welcome port vs connection port and the purpose of three way handshake [duplicate]

吃可爱长大的小学妹 提交于 2020-01-03 06:41:09

问题


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.

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?


回答1:


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:

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.




回答2:


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.



来源:https://stackoverflow.com/questions/50092809/tcps-welcome-port-vs-connection-port-and-the-purpose-of-three-way-handshake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!