FTP header question
Results 1 to 5 of 5

Thread: FTP header question

  1. #1
    Senior Member
    Join Date
    Aug 2003
    Posts
    1,019

    FTP header question

    Part of the problem with trying to learn some of this on your own is that you miss the basics.
    I'm reading through a TCP tutorial, and I'm hoping someone can help me understand a few things (or point me in the right direction).

    "The first frame shows the FTP client sending a control frame to the FTP server. The control connection port number is 1183, making the data connection port number 21. The port number 1184 (FTP command) is calculated in the FTP header. You will understand where these port numbers fit in the whole scheme of things as you follow this trace.

    Frame Source Address Dest. Address Summary
    1 [192.168.10.4] [192.168.10.5] FTP: C PORT=1183 PORT 192,168,10,4,4,160"


    C PORT 1183=port 21? Is there a table that one follows for that? Or in other words, how does 1183=21?


    "
    This will define the TCP file transfer connection port number. The first four comma-delimited numbers represent the IP address. This is where it gets interesting: The last 2 numbers (4, 160) are numbers inserted in a simple equation calculating the data connection port number that will be used to transfer the requested file.

    4 x 256 + 160 = 1184. Watch for port 1184 in the next few frames. "

    Do the last 2 numbers in the sequence always designate the port number? Why is it multiplied by 256, and not, say, 128?

    I think what is confusing me is the 3 different port designations. Would anyone be kind enough to help me clear up my brain fog?

    Thanks

  2. #2
    Senior Member
    Join Date
    Jul 2002
    Location
    Texas
    Posts
    168
    Port 21 on the server is the daemon, port 20 on the server transfers data to your computer on the port that is computed. Thats the basics without me having to go and look up the rest.
    <chsh> I've read more interesting technical discussion on the wall of a public bathroom than I have at AO at times

  3. #3
    Senior Member
    Join Date
    Jul 2002
    Posts
    339
    Hi, I believe you're seeing an EXAMPLE in the tutorial.

    It should be mentioned in the tutorial that FTP traffic is divided by to "channels", the control connection for sending/receiving commands and the data connection to sending/receiving data.

    In the example, port 1183 represents any available ephemeral port (usually above 1023) on the client, as the source port for FTP control connection. Port 21 represents the (default) FTP control port on the server, as the destination port for FTP control connection. At different times, the client may connect from port 12345 to port 21 on the server, port 23456 to port 21, etc...

    Then in the example, port 1184 again represents any available ephemeral port (above 1183) on the client, as the source port for FTP data connection. Port 20 represents the (default) FTP data port on the server, as the destination port for FTP data connection.


    DATA PORT (PORT)

    The argument is a HOST-PORT specification for the data port
    to be used in data connection. There are defaults for both
    the user and server data ports, and under normal
    circumstances this command and its reply are not needed. If
    this command is used, the argument is the concatenation of a
    32-bit internet host address and a 16-bit TCP port address.
    This address information is broken into 8-bit fields and the
    value of each field is transmitted as a decimal number (in
    character string representation). The fields are separated
    by commas. A port command would be:

    PORT h1,h2,h3,h4,p1,p2

    where h1 is the high order 8 bits of the internet host
    address.
    So now, ip 192.168.10.4 port 1184 is rewritten as 192,168,10,4,4,160. Remember 2^8 = 256 and that's where 256 comes from.

    Looks like the author is missing some details or you may want to (re)read TCP/IP basics first . Links anybody?

    Peace always,
    <jdenny>
    Always listen to experts. They\'ll tell you what can\'t be done and why. Then go and do it. -- Robert Heinlein
    I\'m basically a very lazy person who likes to get credit for things other people actually do. -- Linus Torvalds


  4. #4
    Senior Member
    Join Date
    Aug 2003
    Posts
    1,019
    Thank you jdenny...I did find some more basic tutorials (along with tests), and had just come to the same conclusion.

    http://compnetworking.about.com/cs/basictcpip/


    Darksnake, thank you also, even though it confused me more. Where does port 20 come in? I think perhaps I'm trying to make it too simple asking how C PORT 1183=port 21?

    Is that another mathematical function? Maybe the reverse of 4.160 equalling 1184?

    I think some details are lacking, or the original tut assumes some basic knowledge...

    EDIT: I just stubled onto those last night mittens....that oughta keep me and my printer busy for a bit

  5. #5
    Just a Virtualized Geek MrLinus's Avatar
    Join Date
    Sep 2001
    Location
    Redondo Beach, CA
    Posts
    7,324
    Best link (and probably most accurate) is at the RFC Archives. Just type FTP into the search feature and you'll get all 67 RFCs relating to FTP.
    Goodbye, Mittens (1992-2008). My pillow will be cold without your purring beside my head
    Extra! Extra! Get your FREE copy of Insight Newsletter||MsMittens' HomePage

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides