TCP/IP protocol Series

Source: Internet
Author: User

According to the previous several protocols, the IP protocol, TCP protocol, and UDP protocol are combined, so the TCP/IP protocol is available. Nowadays, communication between many applications is based on the TCP/IP protocol and is widely used. It is necessary to learn about it.

For example, the TCP/IP protocol can be regarded as the relationship between the post office and the postman (the actual TCP/IP protocol family includes four layers: application layer, transmission layer, network layer, and link layer ). Which computer is located for the IP protocol in this protocol family, and which port (Application) of this computer requires TCP protocol, one belongs to the network layer, and the other belongs to the transport layer, which is mutually dependent, provides effective measures to solve communication problems. This is like in 1990s, you write a love letter to your distant lover, the love letter first sent from the post office to the destination post office, then the local cute postman to send the love letter to your lover comrades, your feelings have warmed up.

Figure 2-2-5-1: the TCP/IP protocol also contains the UDP protocol, which is composed of three protocols: TCP, IP, and UDP. This figure shows the TCP/IP communication model. host a is displayed on the left and communicates with host B through the communication channel (generally Ethernet. Assume that the application of host a needs to send data to the application of host B, the application of host a will access the services provided by TCP and UDP through the socket API, and then use the IP protocol, the TCP/IP protocol is used to establish a connection with host B over the communication channel. The data transmitted to host B goes through the IP protocol layer and TCP protocol layer in sequence and is received by the Application of host B.

Figure 2-2-5-1 TCP/IP Communication Model

The functions of each layer on the layer are different. The Application Layer mainly sends user application data, which is called by the system to the transport layer for processing. The transport layer is responsible for establishing connections, splitting data transmission, releasing connections, data restructuring, and error handling; the Network Layer determines the route to which data is sent. The link layer verifies the transmission of binary user data. The following describes the differences between different layers from different perspectives:

(1) running process status. The Application Layer runs in the user program process and belongs to the user State. The other three layers run in the system kernel process and belong to the core state.

(2) Communication Mode. The transport layer refers to the communication between processes and end-to-end communication. The network layer refers to the communication between machines and point-to-point communication.

(3) data transmission unit. The transport layer is the TCP or UDP packet segment, the network layer is the IP data packet, and the data link layer is the frame data.

(4) addressing mode. The network layer uses IP addressing; the link layer uses MAC addressing (the transport layer uses port addressing; generally, the MAC address is the only and constant in the world. Computer Communication actually relies on MAC addresses instead of IP addresses, however, the MAC address cannot be changed or is not flexible, so the application layer uses IP addresses for addressing ).

 

The following figure shows the data transmission process of the Layer 2-2-5-1:

① Host a organizes data at the application layer, sends the data to the transport layer, and calls the system API to notify TCP to establish a connection.

② Host a transmission layer receives data from the application layer, organizes TCP packets, sends them to the network layer, establishes connections, and adds the target and source ports.

③ Host a receives TCP data from the transport layer, organizes IP packets, and sends them to the link layer. The destination and source IP addresses are added to the packets.

④ The Link Layer receives network layer data and assembles the link packets. The MAC address is added to the packets.

⑤ The link data is sent by the Network Adapter. Find the MAC address of the nearest vro based on the target IP address, send the data packet to it, determine the next route, and finally send the data packet to the network adapter of host B.

⑥ Host B obtains IP data packets at the network layer and unpacks the packets according to the IP protocol.

7. The transmission layer of host B obtains TCP data packets and unpacks the packets according to the TCP protocol.

The application layer of host B obtains the packet after TCP unpacking for parsing, and completes the corresponding business logic processing.

In these four layers, the changes of data packets can be expressed in Figure 2-2-5-2. After the data at the application layer reaches the transport layer, the data is packaged by the TCP protocol (this figure assumes that the TCP protocol is used ), this adds a TCP header packet, and the application layer data is encapsulated into a TCP packet style. Continue to the network layer, and the TCP packet is packaged by the IP protocol. An IP header packet is added, and the entire TCP packet is encapsulated into an IP packet style. At the end of the link layer, the IP packet is packaged by the link-related Protocol. At this time, the header message and the End message are added. The entire IP packet is encapsulated into a link protocol report style.

Figure 2-2-5-2 encapsulation of layer-4 TCP/IP data

 

For our research server, we need to have a deep understanding of the packets at the transport layer and the network layer. Next we will describe the TCP and IP packet combinations in a more detailed diagram. Based on the TCP buffer size, each segment is divided into TCP segments, which are composed of IP groups and TCP segments. In the previous chapters, the IP Protocol packet structure is described in detail. We will not go into details here. The option area of the IP packet will be loaded into the TCP packet, so that the TCP packet will be embedded into the IP packet, you can use the IP protocol to send and transmit data.

Figure 2-2-5-3 TCP/IP packets

TCP/IP protocol Series

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.