TCP/IP makes the world a global village
The TCP Connection established by the TCPIP protocol is terminated on the earth. Humans are very small and distributed in every corner of the world. With the development of science and technology, people can now easily communicate with their loved ones and friends thousands of miles away in real time to get and share what is happening at the other end of the world. how incredible this is, however, the Internet has changed all this, making these incredible ideas a reality, making the earth a small village, and TCP/IP is the bond for realizing internet communication.
In the world, various computers run different operating systems to serve everyone. These computers use different methods to express the same information. Computer users realize that computers only work for individual soldiers and will not play a major role. Only by associating them can a computer realize its maximum potential. As a result, people tried to connect computers with wires. However, simple interconnection is far from enough. It is like two people with different languages have met each other and cannot communicate with each other. Therefore, they need to define something in common for communication, and TCP/IP is born for this. TCP/IP is not a single protocol, but a collective name of a protocol family. It includes the IP protocol, IMCP protocol, TCP protocol, and more familiar HTTP and FHP protocols. Computers can communicate freely with other computer terminals as if they have learned a foreign language. Simply put, the PC realizes network interconnection.
First, let's take a look at the TCP/IP protocol structure. How is it layered? 1:
Figure 1 TCP/IP hierarchy
TCP (Transmission Control Protocol) is short for the Transmission Control Protocol. It is a combination of various protocols in the network. It reflects the process of file Transmission in a network, from the upper-layer Protocol to the bottom-layer Protocol, from the underlying protocol to the upper-layer protocol. As shown in figure 1, TCP/IP protocol families are encapsulated layer by layer from top to bottom. Core Components cannot be detached or deleted, but can be reset. The top layer is the Application layer, which includes http, smtp, telnet, TFTP, DNS, E-mail, ftp, and other familiar protocols. The second layer is the Transport layer Transport, where the TCP and UDP protocols are located. The transport layer is only used for communication with each other. It can provide traffic control, detect data segments, and sort data segments without interpreting byte streams. The third layer is the network layer, where IP is used to add IP addresses and other data to the data to determine the transmission target. The fourth layer is the data link layer. This layer adds an Ethernet protocol header to the data to be transmitted and performs CRC encoding to prepare for the final data transmission. The hardware physical layer is responsible for network transmission. The definition of this layer includes the network standard and network card definition. The sending protocol host encapsulates the data according to the protocol from the top to the bottom, and the host receiving the data unpacks the data packet according to the protocol, and finally obtains the required data. This structure is very stack-like, so the TCP/IP protocol family is also called the TCP/IP protocol stack.
I. Application Layer
The Application Layer directly interfaces with applications and provides common network application services. The application layer is the highest level of an open system and serves application processes directly. It serves to complete a series of services required for business processing while multiple system application processes communicate with each other. The application layer is the most widely used and the most protocol standards are required. At the application layer, you can achieve transportation, access and management, send and receive e-mails, and remote job input information communication of the virtual terminal directory service. For example, DNS, HTTP, FTP and other protocols are all applied at this layer.
Ii. Transport Layer
The transport layer is the most critical layer and the only layer responsible for overall data transmission and data control. The transport layer provides an end-to-end data exchange mechanism. The transport layer provides reliable transmission services for the application layer and reliable destination site information for the network layer. TCP is the most common transport layer protocol. Its main function is to provide reliable transmission services for a conversation or connection, this service allows you to reuse a single physical connection to a network and provides end-to-end services such as serial number and traffic control, error control, and recovery over a single connection.
1. Establish a TCP connection
Figure 2 TCP protocol establishment and termination process
(A) connection establishment (B) connection termination
TCP is the transport layer protocol in the Internet. It uses the three-way handshake protocol to establish a connection. When the active Party sends a SYN connection request, wait for the other party to answer SYN + ACK, and finally execute ACK confirmation on the other party's SYN. As shown in (a), the TCP three-way handshake process is as follows:
The client sends the SYN (SEQ = x) packet to the server and enters the SYN_SEND status.
The server receives a SYN Packet and responds to a SYN (SEQ = y) ACK (ACK = x + 1) packet.
SYN_RECV status.
The client receives the SYN packet from the server and responds to an ACK (ACK = y + 1) packet.
Established status.
After three handshakes are completed, the TCP client and the server have successfully established a connection to start data transmission.
2. TCP connection termination
Three handshakes are required to establish a connection, and four handshakes are required to terminate a connection. This is caused by the semi-close of TCP. The specific process 2 (B) is shown.
(1) An application process first calls close, indicating that the end executes "active close ). The TCP End sends a FIN Shard, indicating that the data has been sent.
(2) The Peer of the received FIN executes passive close, which is confirmed by TCP.
(3) after a period of time, the application process that receives the file Terminator will call close to close its socket. As a result, TCP also sends a FIN.
(4) receive the final FIN's original sending end TCP (that is, execute the end of the active shutdown) to confirm the FIN.
Iii. Network Layer
The network layer function in the TCP/IP protocol system is defined and implemented by the IP protocol, which is also called the IP layer. The network layer is between the transport layer and the data link layer. It transfers data frames between two adjacent endpoints provided by the data link layer to further manage data communication in the network, data is transmitted from the source to the destination through several intermediate nodes to provide the most basic end-to-end data transmission service to the transport layer.
The purpose of the network layer is to achieve transparent data transmission between two end systems. Specific functions include addressing and routing selection, connection establishment, persistence, and termination. It provides services so that the transport layer does not need to understand the data transmission and exchange technologies in the network. IP defines the basic unit and data format for data transmission over the TCP/IP Internet, completes the routing selection function, selects the data transmission path, and contains a set of unreliable group transmission rules, specifies the grouping processing, error information, and grouping rules. The main functions of the IP protocol include no connection to datagram transmission, datagram routing, and error control. Supporting the IP protocol, IP Resolution Protocol ARP, Reverse Address Resolution Protocol RARP, internet packet protocol ICMP, and Internet Group Management Protocol IGMP are also used to implement its functions.
Iv. Data Link Layer
The data link layer provides services to the network layer based on the services provided by the physical layer. The most basic service is to reliably transmit data from the network layer to the target machine network layer of adjacent nodes. To achieve this goal, the data link must have a series of functions, mainly including: how to combine data into data blocks, such data blocks are called frame in the data link layer ), frames are the transmission units at the data link layer. How to control the transmission of frames over the physical channel, including how to handle transmission errors and how to adjust the transmission rate to match the receiver; the establishment, maintenance, and release of data link channels are also provided between two network entities.
V. Physical Layer
The Physical Layer (Physical Layer) is the lowest Layer in the TCP/IP protocol stack. It is directly oriented to the Physical media (that is, the communication channel) that actually undertakes data transmission ), the transmission unit of the physical layer is bit, that is, a binary bit ("0" or "1 "). The actual bit transmission must depend on transmission devices and physical media. However, the physical layer does not refer to a specific physical device or physical media for signal transmission, it refers to providing a physical connection for the previous layer (data link layer) to transmit the original bit stream on top of the physical media. Physical Layer rules: provide mechanical, electronic, functional, and standard features for the creation, maintenance, and removal of physical links required for data transmission. Simply put, the physical layer ensures that raw data can be transmitted on a variety of physical media. Including the network standard, network card definition, and other non-Protocol writing.