Analysis of TCP, UDP, and IP protocols

Source: Internet
Author: User

The current operating system basically implements the TCP/IP protocol. The TCP/IP protocol stack is divided into five layers:

Application Layer: A group of common applications provided to users, such as telnet, FTP, SMTP, SNTP, DNS, and HTTP, which have a port to identify.

Transport Layer: The main protocols are TCP and UDP, which provide application communication.

Network Layer: The main protocol is the IP protocol, which defines the IP address format and is the key to smooth data transmission between different applications over the network.

Link Layer: This is the lowest layer of TCP/IP software. It is responsible for receiving IP data packets and sending them over the network, or receiving physical frames from the network, extracting IP data packets, and handing them over to the IP layer.

Physical Layer:

Each layer has different protocols, which are actually a format for communication between the two parties. Here we analyze the TCP/UDP/IP protocol.

650) This. length = 650; "src =" "width =" 400 "Height =" 392 "border =" 0 "hspace =" 0 "vspace =" 0 "Title =" "style =" width: 400px; Height: 392px; "/>

In the network, the format of an Ethernet packet is as follows:

650) This. width = 650; "src =" "alt =" 26833883_13670531_ktcl.png "/>

1. TCP protocol

TCP is a connection-oriented transmission protocol that ensures high reliability (no data loss, no out-of-order, no errors, no duplicates. The TCP Header will not be detailed here. In TCP transmission, the key point is to understand the three-way handshake to establish a connection and four-way handshake to release the connection, which is explained in my socket communication blog.

How does TCP ensure reliable transmission? In TCP, a mechanism named "positive validation with retransmission" is used as the basis for providing reliable data transmission services. This technology requires the recipient to send the ACK message to the origin site after receiving the data. The sender keeps a record for each sent group and waits for confirmation before sending the next group. The sender starts a timer while sending the group, and resends the group that was just sent when the timer expires and the confirmation information has not arrived. For example, if the left side shows normal transmission, and the right side shows group loss, when the sender has not received the confirmation message sent by the receiver within the normal time, start the timer, retransmission group after the timer times out.

To avoid late confirmation and repeated confirmation due to network delay, the Protocol requires that a group serial number be included in the confirmation information so that the recipient can correctly associate the group with the confirmation. As shown in figure 3-5, although the network has the capability of two-way communication at the same time, the sending of the next group must be postponed before receiving confirmation information from the previous group, simple validation protocols waste a lot of valuable network bandwidth. Therefore, TCP uses a sliding window mechanism to improve network throughput and address end-to-end traffic control. Therefore, the sliding window technology is generated.

650) This. width = 650; "src =" "width =" 528 "Height =" 254 "/>

The sliding window technique is a more complex deformation of the simple validation mechanism with retransmission, which allows the sender to send multiple groups before waiting for a confirmation message. As shown in figure 3-7, the sender needs to send a group sequence. The Sliding Window Protocol places a fixed-length window in the group sequence, and then sends all the groups in the window; when the sender receives a confirmation message for the first group in the window, it can slide backward and send the next Group. As the confirmation arrives, the window also slides backward.

650) This. width = 650; "src =" "width =" 440 "Height =" 252 "/>

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: 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.