TCP/IP Detailed learning notes (9)-TCP Protocol Overview

Source: Internet
Author: User
Tags port number

Finally see the TCP protocol, this is the TCP/IP detailed inside the most important is the most exciting part, it will take great effort to read. The previous TFTP and BOOTP are simple protocols, no notes, no writing.

TCP and UDP are at the same level---transport layer, but TCP and UDP are the most different place, TCP provides a reliable data transmission service, TCP is connection-oriented, that is, two hosts using TCP communication first to go through a "call" process, Until the end of the communication is ready to transfer data, and finally end the call. So TCP is more reliable than UDP, UDP is to send the data directly, regardless of whether the other party is not receiving the letter, even if the UDP can not be delivered, it will not produce ICMP error messages, which once reiterated many times.

The simple working principle of TCP guarantee reliability is summarized as follows: The application data is divided into the data block that TCP thinks is most suitable for sending. This is completely different from UDP, and the datagram length that the application produces will remain unchanged. The unit of information that is passed to the IP by TCP is called a segment or segment (segment) (see Figure 1-7). In section 1, 8.4 We will see how TCP determines the length of the message segment. When TCP sends out a segment, it initiates a timer, waiting for the destination to acknowledge receipt of the message segment. If a confirmation cannot be received in time, the message segment will be re-sent. In the 21st chapter, we will understand the adaptive timeout and retransmission strategies in the TCP protocol. When TCP receives data from the other end of the TCP connection, it sends an acknowledgment. This acknowledgement is not sent immediately and will typically be deferred for a fraction of a second, which will be discussed in section 1 9.3. TCP will keep its header and data checked and. This is an end-to-end test and is designed to detect any changes in the data during transmission. If the test and error of the segment are received, T p will discard this segment and not acknowledge receipt of this message segment (expecting the originator to timeout and re-send). Since TCP packets are transmitted as IP datagrams, and the arrival of IP datagrams can be out of order, the arrival of the TCP message segment may also be out of sequence. If necessary, TCP will reorder the received data and hand the received data to the application tier in the correct order. TCP can also provide traffic control. Each side of a TCP connection has a fixed-size buffer space. The receiving side of TCP only allows the other end to send the data that the receiving buffer can accept. This prevents faster hosts from causing buffer overruns for slower hosts.

As you can see from this passage, the way to maintain reliability in TCP is to time out the resend, which makes sense, although TCP can also use a variety of ICMP packets to deal with these, but this is not reliable, the most reliable way is to resend the datagram as long as it is not recognized, Until you get confirmation from the other party.

The header of TCP is the same as the UDP header, with the sending port number and the receive port number. But obviously, TCP has more header information than UDP, and you can see that the TCP protocol provides all the necessary information needed to send and confirm. This is described in detail in the p171-173. It can be imagined that the sending of a TCP data should be a process like the following. Both parties establish a connection sender to the receiver TCP datagram, and then wait for the other party to confirm the TCP datagram, if not, to resend, if any, to send the next datagram. The receiving party waits for the sender's datagram, sends an ACK (acknowledgment) datagram, and waits for the next TCP datagram to arrive if the datagram is received and verified to be correct. Abort the connection until the fin is received (send completion datagram)

As you can imagine, in order to establish a TCP connection, the system may establish a new process (the worst is a thread) to transmit the data

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.