What does it mean something like FTP being encapsulated into TCP?
One analogy that I think helps here is to compare TCP/IP's 4 layers to transportation network:
- Application layer - cargo (application instructions / data)
- Transport layer - cities (reliability, topology hiding)
- Internet layer - cars (addressing, packet exchange, routing)
- Link layer - roads (physical connectivity)
Here's a sample:
- Application layer - "Hi Mark - listen, I need this letter (application data) sent to my friend Alicia. Could you send it for me?"
- Transport layer - "Hi Joe, can you get this box to Chicago? That's where Alicia is (topology hiding). I know you know the road to Chicago, thanks! And here's the contents of the box (error correction). Let me know if it doesn't make it, I'll send a copy (flow control)"
- Internet layer - OK, so I'm at 35th west and Lexington Ave. How do I get to King St and 9th east (addressing)? Let's open Google maps on my new flashy Android. OK, so the shortest / least busy way is this one (translates to: number of router hops / bandwidth)... Let's go! (routing)
- Link layer - Here I am at the crossing. The only thing I see is the next traffic light. Let's get there without hitting anybody or anything. (Error correction - if you do get hit by another car and only if it's a minor damage, you might get a mechanic in this part of the street to repair your car and you can still continue delivering the package)
It's a somewhat crude analogy, but hope it helps. To return to your original question:
What does it mean something like FTP being encapsulated into TCP?
FTP allows you to transfer files. So e.g. you can connect to a server with address 192.168.1.50
(how you get there is handled by IP and that you actually reach reliably it is handled by TCP). So you can say e.g.:
ftp> get file.txt
which will fetch file named file.txt
from the remote FTP server. Here get file.txt
is a FTP command with data. This is cargo in the above transport analogy. FTP client wants server to get this and do something. The file (i.e. contents of file.txt
) that server sends back is also cargo, just in the other direction.
Application layer (FTP) doesn't care about how this cargo will get there. That's the job of the next underlying layer, which is TCP. So what happens is this:
- FTP (application layer) tells TCP: "Hey TCP, here's a letter (
get file.txt
). Please make sure this reaches my destination"
- TCP (transport layer) will take that and put it into a bigger box, stamping it with some additional data such as "Contents: one letter". That bigger box is the encapsulation. TCP needs some more information to do what it does (flow control, error correction, etc.). When the other side receives it, the TCP layer on the other end can say something like "OK, I'm expecting this box to contain one letter" and searches the box. If one letter is found, all good (error correction). If not, then this might be a box destined for somebody else, so let me see what to do...
- TCP then sends this down to (link layer) IP ("Hey IP, please send this box to
192.168.1.1
"), etc.
Hope this helps.