
Click the above blue text to follow the Network Technology Platform
When a user issues a command using the TCP/IP application layer protocol, a series of events is triggered. The user’s command or message is sent through the TCP/IP stack on the local machine and then reaches the receiving protocol over the network medium. Each layer’s protocol on the sending host adds information to the original data.
As the user’s command passes through the protocol stack, each layer’s protocol on the sending host also interacts with the peer on the receiving host.
Data Encapsulation and TCP/IP Protocol Stack
A packet is the basic unit of information transmitted over a network, consisting of a header containing the addresses of the sending and receiving hosts and a body containing the data to be transmitted. As the packet passes through the TCP/IP protocol stack, each layer’s protocol adds or removes fields from the basic header. When the protocol on the sending host adds data to the packet header, this process is known as data encapsulation. Additionally, each layer has different terminology for the modified packet, as shown in the figure below.

This section summarizes the lifecycle of a packet, from when the user issues a command or sends a message to when the corresponding application on the receiving host receives the packet.
Application Layer – User Initiates Communication
When a user on one host sends a message or issues a command that requires access to a remote host, the history of the packet begins. The application protocol associated with the command or message formats the packet so that it can be handled by the appropriate transport layer protocol, either TCP or UDP.
For example, if the user issues an rlogin command to log in to a remote host, this rlogin command uses the TCP transport layer protocol. TCP expects to receive data in the form of a byte stream containing information from the command. Thus, rlogin sends this data as a TCP stream.
However, not all application layer protocols use TCP. For instance, if the user wants to mount a file system on the remote host, the NIS+ application layer protocol is initiated. NIS+ uses the UDP transport layer protocol. Therefore, the packet containing the command must be formatted in a way expected by UDP. This type of packet is referred to as a message.
Transport Layer – Data Encapsulation Begins
When data reaches the transport layer, the protocol at that layer initiates the data encapsulation process. The final result depends on whether TCP or UDP is handling the information.
TCP Segmentation
TCP is often referred to as a “connection-oriented” protocol because it ensures that data is successfully delivered to the receiving host. The figure above illustrates how the TCP protocol receives the stream from the rlogin command. TCP divides the data received from the application layer into multiple segments and attaches a header to each segment.
The segment header contains the sender and receiver ports, segment ordering information, and a field known as checksum. The TCP protocols on both hosts use the checksum data to determine whether the data has been transmitted correctly.
Establishing a TCP Connection
TCP uses segments to determine whether the receiving host is ready to accept data. When the sending TCP wants to establish a connection, it sends a segment called SYN to the peer TCP protocol running on the receiving host. The receiving TCP responds with a segment called ACK to confirm the successful receipt of that segment. The sending TCP then sends another ACK segment and continues to send data. This exchange of control information is known as three-way handshake.
UDP Packet
UDP is a “connectionless” protocol. Unlike TCP, it does not check to ensure that data reaches the receiving host. Instead, UDP receives messages from the application layer and formats them into UDP packets. UDP adds a header to each packet that includes the sender and receiver host ports, a field containing the packet length, and a checksum.
The sending UDP process attempts to send the packet to the peer UDP process on the receiving host. The application layer determines whether the receiving UDP process acknowledges the receipt of the packet. UDP does not require receipt notifications and does not use a three-way handshake.
Internet Layer
Both TCP and UDP pass their segments and packets down to the Internet layer, where they are handled by the IP protocol. IP prepares them for delivery by formatting them into units known as IP datagrams. IP then determines the IP address of the datagram for effective delivery to the receiving host.
IP Datagram
In addition to the information added by TCP or UDP, IP also attaches an IP header to the segment or packet header. The information in the IP header includes the IP addresses of the sending and receiving hosts, the length of the datagram, and the sequence order of the datagram. This information is provided if the datagram exceeds the byte size allowed by the network packet and must be fragmented.
Data Link Layer – Framing
Data link layer protocols (such as PPP) format the IP datagram into a frame. They attach a third header and a footer to “frame” the datagram. The frame header includes a cyclic redundancy check (CRC) field used to check for errors as the frame is transmitted through the network medium. The data link layer then passes the frame to the physical layer.
Physical Network Layer – Preparing the Frame for Transmission
The physical network layer on the sending host receives the frame and converts the IP address into a hardware address suitable for the network medium. The physical network layer then sends the frame out through the network medium.
How the Receiving Host Processes the Packet
When the packet arrives at the receiving host, it passes through the TCP/IP protocol stack in the reverse order from the sender. The figure above illustrates this path. Furthermore, each protocol on the receiving host strips off the header information that the peer added to the packet on the sending host. Here’s what happens:
-
The physical network layer receives the packet in the form of a frame. It calculates the CRC of the packet and then sends the frame to the data link layer.
-
The data link layer verifies whether the CRC of the frame is correct and removes the frame header and CRC. Finally, the data link protocol sends the frame to the Internet layer.
-
The Internet layer reads the information in the header to identify the transport and determine whether it is fragmented. If the transport is fragmented, IP reassembles the segments into the original datagram. It then strips the IP header and passes the datagram to the transport layer protocol.
-
The transport layer (TCP and UDP) reads the header to determine which application layer protocol must receive the data. TCP or UDP then strips its relevant header and sends the message or stream to the receiving application.
-
The application layer receives the message and performs the action requested by the sending host.

E N D

Recommended Highlights
Series Articles
Illustrated Network
Switch Routing
Strange Knowledge
Getting Started Articles
36 Images Explaining Basic Network Knowledge
36 Images Explaining DNS: Navigation in the Network World
23 Images Explaining Routing Protocols: Core Technologies of Computer Networks
38 Knowledge Points of Network Devices
53 Images Explaining 55 Knowledge Points of Firewalls
49 Images Explaining What WiFi Is?
123 Images Explaining 177 Computer Network Terms