Summary of TCP/IP Fundamentals

Python Practical Community

Java Practical Community

Long press to recognize the QR code below,add as needed

Summary of TCP/IP Fundamentals

Scan to follow and add customer service

Join Python community ▲

Summary of TCP/IP Fundamentals

Scan to follow and add customer service

Join Java community

Author丨cxuan

Source丨Programmer cxuan

Summary of TCP/IP Fundamentals

When it comes to the protocols we encounter most in computer networking, it undoubtedly involves the TCP/IP protocol, which is also the most famous protocol on the Internet. Let’s talk about the TCP/IP protocol.

Historical Background of TCP/IP

Before the TCP/IP protocol was established, back in the 1960s, many countries and regions recognized the importance of communication technology. The US Department of Defense wanted to research a technology that could communicate through alternative routes even if communication lines were destroyed. To achieve this, packet networks emerged.

Summary of TCP/IP Fundamentals

Even if several nodes are damaged during communication between two nodes, they can still communicate by changing routes and other means.

This packet network facilitated the birth of ARPANET (Advanced Research Projects Agency Network). ARPANET was the first wide-area packet-switched network with distributed control and was the precursor to the first implementation of the TCP/IP protocol.

ARPANET was actually planned by the US Department of Defense’s Advanced Research Projects Agency.

Thus, the emergence of computer networks was initially driven by military research purposes.

In the 1990s, IOS initiated the OSI process for international standardization, but did not make substantial progress. However, it led to widespread use of the TCP/IP protocol.

The rapid development of the TCP/IP protocol may be attributed to its standardization. In other words, the TCP/IP protocol involves standards that are not present in OSI, and these standards will be the main focus of our discussion.

Let’s first understand the TCP/IP protocol. The TCP/IP protocol refers not only to the TCP and IP protocols but actually to a protocol suite. What is a protocol suite? Simply put, it is a comprehensive collection of protocols. If someone asks you what protocols are included in TCP/IP next time, you can show them the following diagram.

Summary of TCP/IP Fundamentals

The protocols summarized above comprise the TCP/IP protocol suite.

TCP/IP Standards

Compared to other protocol standards, TCP/IP focuses on two main aspects: openness and practicality, meaning whether the standard can be practically applied.

Openness refers to the fact that TCP/IP is discussed and formulated by the IETF, which is an organization that allows anyone to join in discussions.

Practicality means that if a framework is only theoretical and lacks practical implementation, it will never become mainstream.

The standard protocol for TCP/IP is what we know as RFC documents, which you can find online. RFC not only standardizes protocol specifications but also includes implementation and usage information.

For more RFC protocols, you can check the official documentation at https://www.rfc-editor.org/rfc-index.html

We will not elaborate further on this here; our article’s focus will be on the study of TCP/IP.

TCP/IP Protocol Suite

Next, let’s start discussing the TCP/IP protocol suite.

The TCP/IP protocol is the one we programmers encounter the most. The OSI model has seven layers: from bottom to top, they are the physical layer, data link layer, network layer, transport layer, session layer, presentation layer, and application layer. However, this is somewhat complex, so in the TCP/IP protocol, they are simplified into four layers.

Summary of TCP/IP Fundamentals

Now, let’s start introducing these layers and the protocols between them, beginning with the communication link layer.

Communication Link Layer

If we must subdivide, the communication link layer can also be divided into physical layer and data link layer.

Physical Layer

The physical layer is the lowest level of TCP/IP, responsible for the hardware used for transmission, such as Ethernet or telephone lines.

Data Link Layer

The other layer is the data link layer, which lies between the physical layer and the network layer. The data link layer defines how data is transmitted over a single link.

Network Layer

The network layer primarily uses the IP protocol, which forwards packet data based on IP addresses.

Summary of TCP/IP Fundamentals

The main function of the IP protocol is to send packet data to the target host.

The functions of the Internet layer and transport layer in the TCP/IP layering are usually provided by the operating system.

The IP protocol also implicitly includes functions of the data link layer, allowing hosts to communicate regardless of the underlying data link.

Although IP is also a packet-switching protocol, it does not have a retransmission mechanism. Even if data does not reach the other end, it will not be retransmitted, thus IP is considered an unreliable protocol.

Another protocol in the network layer is ICMP, which is used to send error notifications back to the sender if an IP packet cannot reach its target address due to an error. In this regard, ICMP can also be used to diagnose network conditions.

Transport Layer

Having just introduced the most important IP protocol in the TCP/IP protocol, let’s now discuss the transport layer protocol, which includes the TCP protocol.

The transport layer is like a highway connecting two cities. Below is the logical channel of the Internet, which you can imagine as a highway.

Summary of TCP/IP Fundamentals

The main function of the transport layer is to enable communication and data exchange between application programs at the application layer. Many applications run internally on a computer, each corresponding to a port number, which we typically use to distinguish these applications.

The transport layer protocols are mainly divided into connection-oriented protocol TCP and connectionless protocol UDP.

TCP

TCP is a reliable protocol that guarantees the reliable delivery of data packets. It can correctly handle packet loss, transmission order confusion, and other exceptional situations during transmission. Additionally, TCP provides congestion control to alleviate network congestion.

UDP

UDP is an unreliable protocol that cannot guarantee the reliable delivery of data. Compared to TCP, UDP does not check whether packets arrive or whether the network is congested, but UDP is more efficient.

UDP is commonly used in scenarios with smaller packet data or in broadcasting, multicasting, and multimedia communications.

Application Layer

In the TCP/IP protocol suite, the session layer and presentation layer of the OSI standard model are both categorized under the application layer. The architecture of the application layer mostly belongs to the client/server model, where the program providing services is called the server, and the program receiving services is called the client. In this architecture, the server is usually pre-deployed on a server to wait for client connections to provide services.

Summary of TCP/IP Fundamentals

The Journey of Sending a Packet

Next, we will introduce how a packet is sent from one packet to another through the application layer, transport layer, network layer, and communication link layer.

Packet Structure

First, let’s understand the structure of a packet. Here, cxuan will give you a brief introduction; later articles will provide more detailed information.

Summary of TCP/IP Fundamentals

In each layer above, a header is added to the data being sent, which contains the necessary information for that layer. Each layer processes the data and attaches the necessary information from that layer to the packet. Now, let’s discuss the process of sending a packet.

Packet Sending Journey

Assuming host A and host B are communicating, what peculiar operations will host A go through to send a packet to host B?

Application Layer Processing

When host A, i.e., the user, clicks on an application or opens a chat window and types cxuan, then clicks send, this cxuan will travel as a packet across the network. But wait, application layer also needs to process this packet, including character encoding, formatting, etc. This layer is actually doing the work of the presentation layer in OSI, but in the TCP/IP protocol, it is all categorized under the application layer.

At the moment of sending the packet, a TCP connection is established, which acts like a channel, and subsequently, other packets will use this channel to transmit data.

Transport Layer Processing

To ensure the information accurately reaches the other party, we use the TCP protocol for description. TCP is responsible for establishing connections, sending data, and disconnecting based on the application’s instructions.

TCP will attach a TCP header field in front of the application data, which includes the source port number and destination port number. These two port numbers indicate where the packet is sent from and which application program it needs to be sent to; the TCP header also includes a sequence number to indicate the sequence number of the byte in the entire data sent by the sender; the TCP header also includes a checksum to determine if the data is corrupted, and then the TCP header is attached to the packet and sent to IP.

Network Layer Processing

The primary protocol responsible for processing packets in the network layer is the IP protocol, which combines the TCP header received from TCP with the data and adds its own IP header in front of the TCP header. Therefore, the IP packet will closely follow the TCP packet, followed by the data itself. The IP header contains the destination and source addresses, and immediately following the IP header is information used to determine whether it is TCP or UDP.

Once the IP packet is generated, it will be judged by the routing control table to determine which host it should be sent to. The data packet modified by IP continues to be sent to the router or the network interface driver for actual data transmission.

If the target host’s IP address is unknown, the ARP (Address Resolution Protocol) can be used to look it up.

Communication Link Layer Processing

The data packet received via IP will have an Ethernet header added to the data and processed for sending. The Ethernet header contains the MAC address of the receiver, the MAC address of the sender, and flags the Ethernet data protocol type.

Below is the complete processing and parsing process.

Summary of TCP/IP Fundamentals

As shown in the figure above, the left side shows the data sending process, where application data is processed layer by layer to become a packet that can be sent to the specified host through physical media.

The packet receiving process is the reverse of the sending process, and the packet parsing will also go through the following steps.

Communication Link Parsing

When the target host receives the data packet, it first checks the MAC address in the Ethernet header to determine whether it is the intended recipient. If it is not, the packet will be discarded.

If the received packet is intended for itself, it will check the Ethernet type to determine which protocol it is. If it is an IP protocol, it will be handed over to the IP protocol for processing; if it is an ARP protocol, it will be handed over to the ARP protocol for processing. If the protocol type is an unrecognized one, the packet will be discarded.

Network Layer Parsing

The data packet processed by Ethernet will be handed over to the network layer for processing. Assuming the protocol type is IP protocol, when IP receives the packet, it will parse the IP header to check whether the IP address in the IP header matches its own IP address. If it matches, it will receive the data and check whether the upper layer protocol is TCP or UDP; if it does not match, it will be discarded directly.

Note: During routing forwarding, sometimes the IP address may not be its own. In this case, the routing table needs to assist in processing.

Transport Layer Processing

In the transport layer, we generally use the TCP protocol. During TCP processing, it first calculates the checksum to check whether the data is corrupted. Then it checks whether the data is received in order, and finally checks the port number to determine which application program it corresponds to.

Once the data is completely identified, it will be passed to the application program identified by the port number for processing.

Application Program Processing

The designated application program at the receiving end will process the data sent from the sender, recognizing the content of the data through decoding and other operations, then storing the corresponding data on the disk, and returning a success message to the sender. If saving fails, an error message will be returned.

The above is a complete process of sending and receiving a data packet. In the data transmission process described above, various addresses, port numbers, protocol types, etc., are involved between different layers, so now let’s analyze this.

After passing through each layer, the protocol of that layer will attach a header to the packet. A complete packet header diagram is shown below.

Summary of TCP/IP Fundamentals

During the packet sending process, each layer sequentially adds header information to the packet, each header containing the sender and receiver addresses as well as the protocol type of the previous layer. Ethernet uses MAC addresses, IP uses IP addresses, and TCP/UDP uses port numbers as identifiers for the addresses of the two hosts.

In addition, each packet header in each layer also contains an identification bit, which is used to identify the type of the previous layer protocol.

Summary of TCP/IP Fundamentals
Programmer Column
 Scan to follow and add customer service
 Long press to recognize the QR code to join the group




Recent Exciting Content Recommendations:
 Girlfriend thinks an annual salary of 500,000 is average, what to do?
 The sexy goddess of the largest straight man forum has turned over
 IntelliJ IDEA super comprehensive optimization settings, efficiency is great!
 Very useful Python tips




Here to share good articles with more people ↓↓




Leave a Comment