Options

Fundamental of TCP/IP Transport, Applications and Security

e24ohme24ohm Member Posts: 151
Folks:
I am having a hard time understanding how Multiplexing works with sockets, and maybe some of you can offer some help, or explain it in different ways.

When client (a) connects to a server that is running a FTP server, I understand the server has ports 20 and 21 open; however, does the client use port 20 and 21 as well or does a dynamic port get assigned to the client, since more than one FTP connection can be established?

I am confused because my Cisco book says “TCP and UDP solve this problem by using a port number field in the TCP and UDP header, respectively. Each of Hannah’s TCP and UDP segments uses a different destination port number”.

Thank you,
E
Utini!

Comments

  • Options
    stuh84stuh84 Member Posts: 503
    You are correct, a dynamic port will be assigned, the FTP port is merely the destination, the source port will be what is unique.

    As far as the different destination port, that would only apply if you had the same services (say a web server) serving/listening on multiple ports.
    Work In Progress: CCIE R&S Written

    CCIE Progress - Hours reading - 15, hours labbing - 1
  • Options
    docricedocrice Member Posts: 1,706 ■■■■■■■■■■
    There should be some clarification on port 20 (FTP's DATA port). This is dependent on whether active or passive FTP is involved. TCP 20 is used when active mode is negotiated between the client and server via the PORT command.

    At the risk of being self-promoting, here's an article I wrote on this:

    http://kimiushida.com/bitsandpieces/articles/packet_analysis_ftp/

    FTP is a quirky old protocol and was problematic for firewall admins back in the day (stateful firewalls which could determine these dynamic ports by inspecting the traffic as it passed by solved this). It's not the most straight-forward protocol as an example in learning the transport layer. However, in general TCP / UDP communications relies on the client initiating the connection with a ephemeral source port (something above 1023) while the destination port is whatever the server is running on (80 for HTTP, 443 for SSL / TLS, etc.). The server has to respond back to the client somehow, and the client will be listening for response traffic on that ephemeral port.

    I don't know about the book you're referring to, so I'm only hoping I'm interpreting your question correctly.
    Hopefully-useful stuff I've written: http://kimiushida.com/bitsandpieces/articles/
  • Options
    tech-airmantech-airman Member Posts: 953
    e24ohm wrote: »
    Folks:
    I am having a hard time understanding how Multiplexing works with sockets, and maybe some of you can offer some help, or explain it in different ways.

    When client (a) connects to a server that is running a FTP server, I understand the server has ports 20 and 21 open; however, does the client use port 20 and 21 as well or does a dynamic port get assigned to the client, since more than one FTP connection can be established?

    I am confused because my Cisco book says “TCP and UDP solve this problem by using a port number field in the TCP and UDP header, respectively. Each of Hannah’s TCP and UDP segments uses a different destination port number”.

    Thank you,
    E

    e24ohm,

    To help reduce the apparent confusion, let's look at the TCP header for the segment. In the TCP header, there are at least _two_ fields. One field in the TCP header is for the _destination_ port. One field in the TCP header is for the _source_ port.

    So let's take the segment sent from the client to the FTP server. The TCP segment from the client would have a _destination_ port of 21, however the client will make up some type of random _source_ port. Let's say the random source port is 5000. So here's a bit of a diagram of the segment being sent from client to FTP server...

    [client]
    {source port = 5000, destination port = 21}-->---[FTP server]

    Once the FTP server receives this segment, it'll keep track of the client based on the source port of 5000. So when the FTP server replies to the client, like a paper envelope, it'll swap the destination address with the source address as follows...

    [client]
    <
    {destination port = 5000, source port = 21}
    [FTP server]

    So once the client receives the reply segment from the FTP server, it'll notice the port number of 5000 so the client should know to forward this segment to the FTP application.

    So in review, understand that there's more than one TCP or UDP ports involved through destination port and a _source_ port.

    Did this help?
  • Options
    e24ohme24ohm Member Posts: 151
    Thank everyone for all the help. I see that the source (client) will always have a dynamic port - where the server will always have the port associated with the service.

    thanks again.
    Utini!
Sign In or Register to comment.