Thursday, February 4, 2021

How is the destination port number determined in case of TCP connections ?

I was reading the chapter on TCP in 'Computer Networking a Top Down Approach'. It said the following regarding destination ports in TCP:

When a TCP segment arrives from the network to a host, the host uses all four values to direct (demultiplex) the segment to the appropriate socket. In particular, and in contrast with UDP, two arriving TCP segments with different source IP addresses or source port numbers will (with the exception of a TCP segment carrying the original connection-establishment request) be directed to two different sockets.

So if I have

HOST A running Process A at port 8000 and Process B at 8001 communicating with Process C at port 1100 on HOST B.

Both processes A and B have TCP connection with Process C then both would have same destination ports but different source ports. The book says they will be assigned different sockets. From this I understand that they will get different port numbers lets say 1102 and 1103 to send data to.

Then how would the process at 1100 know that Process A and B were trying to communicate if the data is not send to 1100. Is there some kind of mapping stored in the HOST B?



No comments:

Post a Comment