A simple explanation of a file transfer over TCP/IP

Mohammad Humayun Khan
3 min readNov 8, 2021
Photo by Fionn Große on Unsplash

Let’s look at a brief overview of the dominant network models.

The Open Systems Interconnection (OSI) 7-layer model is used to characterize and standardize the communication functions of telecommunication or computing systems.

The TCP/IP 5-layer model was developed for the US Department of Defense’s packet switching network ARPANET (Advanced Research Projects Agency Network). Currently, it’s maintained by the IETF (Internet Engineering Task Force) under the IAB (Internet Architecture Board).

Looking at their differences, the most relevant being in the number of layers itself as we see in the diagram below.

If you wanna go into details, there are already a lot of cool articles there on both of them. So, let us move on to what the title suggests. We’ll see how network operations happen over TCP/IP with the example of an application data file transfer between two host computers.

Say, an application on Host computer A creates a user data file that needs to be transferred to Host computer B.

The application data file is divided into payload segments based on the MTU (Maximum Transfer Unit) size of the IP packet and Ethernet frame size requirements. This creates multiple payload segments that need to be transferred.

A TCP (Transmission Control Protocol) Header is then, added to the data segment, and both Computer Host A and B set up a TCP session using a TCP 3-way handshake.

The 3-way handshake is based upon the TCP units of both A and B, wherein firstly, A will send a SYN message to B requesting synchronization. In reply to A, B will acknowledge the synchronization request by sending an ACK and it also requests synchronization in the opposite direction by sending a SYN to A. Finally, A will acknowledge the synchronization request by sending back an ACK to B. Now, a TCP session has been established.

Error-Control and TCP Flow are only controlled end-to-end by Host computers A and B, not by the routers in between them.

An IP (Internet Protocol) Header is now added to form an IP packet. The IP Header includes the Source and Destination IP addresses. IPv4 (32-bit) and IPv6 (128-bit) have different IP headers.

Then, an Ethernet header and trailer are added to the IP packet which will be used by Ethernet switches. Ethernet switches will essentially conduct Flow and Error Control. Other protocols (e.g., Wi-Fi) will use their own protocol header and trailer.

The intermediate routers, R1, R2, and R3 will use the IP addresses to route the IP packets. Usually, routers use a routing table to determine where to send the packets and optimal routing paths are set up using routing algorithms.

The Ethernet frame will be received at Computer host B’s Network Interface Card (NIC). The Ethernet Header and Trailer will be used to detect errors in the frame. If an error is detected, the frame is discarded and frame retransmission is requested.

The Ethernet Header and Trailer are removed to reveal the IP packet. The IP packet header contains many network control functions which are checked, for e.g., ECN (Explicit Congestion Notification) in IPv4.

Now, the IP header is removed to reveal the TCP header. TCP will control the window size to increase or decrease the data transfer rate. TCP includes the port address that will connect the data to Computer host B’s application (APP X).

The TCP header is removed to reveal the payload segment. And finally, the payload segments are combined to reconstruct the application data file, which is then, delivered to APP X.

So, that's how an application data file is transferred between two host computers.

Hope you liked the content. Thanks, Have a great week!

--

--