Re: How does that tcp traffic work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bliss, Aaron wrote:
I know this is a bit of a networking question more than a redhat
question, however I'm sure you guys will be able to explain this to me;
I'm trying to understand exactly how this works, and have not been able
to find any solid authority on the subject; I understand the concept of
ports, well know ports, and part of the initial 3 way handshake of a new
tcp session; My question is, does the initial receiving host of a
session (usually a server) use the port that it's listening for the tcp
session, or does it negotiate a port number that is not in use like the
client does?  For example, host A is a client, host B is a webserver
listening on port 80; host A wants some data from host B's port 80; lets
say host A wants to use port 6785; will the tcp session then use port
6785 for host A and port 80 for host B, or will they also pick an
available port from host B as well; if port 80 is used, how are multiple
sessions possible; i.e. how can the host B serve up more web traffic if
port 80 is busy?  Thanks for your help.

Aaron
Here is what happens:

1) TCP Server listens on port X at address IP1
2) TCP Client connects ("handshake")
  to port X at address IP1
  from port Z at address IP2
3) TCP Server code will spawn a thread or process to handle this connection. The abstraction used to represent the connection is the 'socket', which is a source and sink
 of bytes, but basically it's a I/O buffer.

The TCP session identifier is: (IP1,Z,IP2,X), all TCP packets carry that information. The OS at IP1 will correctly route the packet to its destination I/O buffer (to be picked up by the handling thread) based on that identifier. Thus the packets can STILL go to the
same port X on the Server.

Note that for FTP, there is first a connection from the client to server port 21, then a negotiation over the TCP connection whereupon the server opens another server port (high-numbered) on the the server machine and the client additionally connects to
that to transfer data. But this means *two* TCP connections.


Best regards,

-- David

"four fifty -- press return"

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux