The basic concept of TCP/IP detailed learning Note--tcp

Source: Internet
Author: User
Tags ack

1.TCP of services
虽然TCP和UDP最后都会通过IP层传输,但是二者却为用户提供完全不同的服务,TCP提供的是面向连接的,可靠的字节流服务面向连接意味着俩个使用TCP的应用在彼此交换数据之前必须先建立一个TCP连接。可以用打电话比喻TCP的连接,要想俩个人通话,首先一方要拨通另一方的电话,等待另一方接通电话之后才可以通话,TCP连接只有俩方能通话,这和UDP完全不同

TCP provides reliable service in the following ways
The application data is divided into the data blocks that TCP considers most appropriate.
When TCP emits a segment, it initiates a timer, waits for the destination to acknowledge receipt of the segment, and if it fails to receive confirmation in time, the segment will be re-sent.
When TCP receives data from the other end of the TCP, it sends a confirmation
. TCP will keep its header and data checked and this is an end-to-end test and is intended to verify that the data has not changed during transmission
If necessary, TCP will reorder the received data and hand the received data to the application tier in the correct order
. Duplicate data must be discarded on the TCP receiver side
. TCP Each side has a fixed-size receive buffer space, TCP provides traffic control based on this space

2.TCP Header Structure
16-bit source port number 16-bit destination port number
32-bit serial number 32-digit Confirmation number
4-Bit header length 6-bit reserved
16-bit window size 16-bit Checksum
16-bit emergency pointer Options
Data

(1) The port number of the end and source end, used to find the origin and the end application process
(2) The serial number is used to identify the data stream sent from the TCP originator to the receiving end, which represents the first data byte in this segment (in fact, it is used to identify the data segment)
(3) Confirm that the serial number contains the next sequence number that is expected to be received at one end of the sending confirmation, so the confirmation sequence number is valid only if the last received data segment sequence number plus 1 has an ACK of 1 o'clock
(4) The number of 32bit words in the first length to first department
(5) 6-bit flag many of them can be set to 1, as follows:

Bit
bits Specific Description
UGR Emergency pointers
Ack Confirm the serial number is valid
PSH The receiving party should give this segment to the application layer as soon as possible
Rst Rebuilding the connection
Syn The synchronization sequence number is used to initiate a connection
FIN The originator completes the task

(6) 16-bit window size for TCP traffic control
(7) The longest visible optional field is the longest message size, also known as MSS, which is usually indicated in the first message segment of the communication.

3. Basic Process Summary

TCP is a reliable connection-oriented byte-stream Transport layer service, TCP packages the user data into a message segment, which sends the data, generates a timer, the other end of the data received confirmation, reorder data, discard duplicate data, through the window size to provide end-to-end traffic control, and calculate and validate a mandatory end-to-end checksum

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The basic concept of TCP/IP detailed learning Note--tcp

Related Article

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.