TCP/IP, Transmission Control Protocol/Internet Protocol, is the suite of two protocols, TCP and IP, used to interconnect network devices on the Internet. The TCP performs the handshake between the network devices to establish a socket. The socket remains open during the communication. The source TCP converts the data into packets and sends to the destination TCP. The TCP performs acknowledgment for the successful delivery of the packets. If a packet drops on the way, the source TCP resends the packet. The IP layer is responsible for sending and receiving the data to the correct destination. The TCP/IP stack is comprised of the following layers.
|Application||DNS, FTP, HTTP, IMAP, POP3, SMTP, SSH, Telnet, SSL, ...|
|Transport||TCP, UDP, ...|
|Network||IP (IPv4, IPv6), ICMP, ARP, ...|
|Data Link||802.3 (Ethernet), 802.11 (Wi-Fi), PPP, ...|
Application layer is the topmost layer of TCP/IP protocol suite. The Application layer is responsible for entertaining the requests initiated at the applications level. The application layer uses different protocols to complete the requests for different programs. Some of the protocols used by the application layer include HyperText Transfer Protocol (HTTP), File Transfer Protocol (FTP), and Simple Mail Transfer Protocol (SMTP). For example, when we request our browser to access a web server, it calls HTTP protocol to complete the request. Similarly, when we want to upload (or download) a file through a program, the application layer uses the FTP protocol to complete the request. The application layer uses the ports to pass on the data to the transport layer. The ports are logical addresses/interfaces that connect a computer to internal or external devices. The use of the ports makes it easier for the transport layer to understand the type of data. For example, a data sent over port 25 means the data is about the email request. A data sent over port 21 and port 22 means it is an FTP data.
The application layer sends the data to the lower layer, i.e. the transport layer. The transport layer converts the data into data packets and sends to the destination device. The transport layer uses Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP). The TCP is used for reliable communication while UDP is used where reliability is less important. When the transport layer receives data from the application layer, it is transformed into the data packets. The TCP and UDP add a header to the data packets. The TCP header contains different fields like source and destination port information; packets sequence number, acknowledgment information, and checksum values. Each field plays its role when data packets are exchanged. For example, the checksum field is used to check if any packet during the data exchange process has tampered or not. The sequence number tells the TCP at the destination about the order of the packet. The TCP at the receiver end combines the packets in the correct order with the help of the sequence numbers. When a packet is successfully transferred, the devices acknowledge the successful delivery of the packets. If the sender does not receive an acknowledgment by the receiver in a specified period of time or window, it resends the packet. The entire packets at the receiver end are arranged into correct order; the headers are removed from the packets before reassembling them into a complete message.
The data packets from the transport layer travel down to the network layer. Different protocols operate at the network layer including Internet Protocol (IP), Internet Control Message Protocol (ICMP), and Address Resolution Protocol (ARP). At the network layer, a header called IP header is added to the data packet. The IP header contains the source and destination IP address. The packet is sent out to the destination via a router. The router contains a table containing IP addresses of different hosts including the gateway devices (other routers). The router checks if the destination IP address matches with the IP address saved in the table. If the router fails to locate the destination IP address, it sends the data packets to the other router device. The process continues until the packet reaches the destination.
Data Link Layer
The data link layer is subdivided into three layers, namely (i) Logic Link Control, (ii) MAC Layer, and (iii) Physical Layer. The Logic Link Control (LLC) has the information about the protocol used by the network layer. The LLC, at the receiving end, helps in deciding the delivery of the data packet to the corresponding protocol at the destination network layer. The MAC layer adds the source and destination MAC address to the data frames. The physical layer converts the data frames into a format that can be transmitted over the network. For instance, the physical layer converts the data frames into electrical signals if the path is wired. Similarly, the data frames are converted into electromagnetic waves for wireless communication medium. The aforementioned layers work conversely at the receiving end. The electric signals or electromagnetic waves are converted back into data frames, the headers are removed from the packets; finally, the packets are reassembled into complete data.