October 10th, 2003, 03:49 AM
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?
October 10th, 2003, 04:25 AM
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
October 10th, 2003, 02:54 PM
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.
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.
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:
where h1 is the high order 8 bits of the internet host
Looks like the author is missing some details or you may want to (re)read TCP/IP basics first . Links anybody?
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
October 10th, 2003, 03:07 PM
Thank you jdenny...I did find some more basic tutorials (along with tests), and had just come to the same conclusion.
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
October 10th, 2003, 03:07 PM
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.