How TCP Communication Works

Source: Internet
Author: User

How TCP Communication Works

I,TCP three-way handshake
The Transport Control Protocol is a connection-oriented and reliable transmission Protocol.Layer Protocol. Connection-oriented means that a normal TCP transmission needs to pass through the TCP client and the TCP ServiceEnd CreationA specific virtual circuit connection is usually called a three-way handshake ". Reliability can be guaranteed through many methods. Here we are concerned with data sequence and validation. TCP uses a sequence in a data SegmentNo. GuaranteeAll transmitted data can be reorganized at the remote end in normal order, and the integrity of data transmission can be ensured through confirmation. To transmit data over TCP, a connection must be established between the two hosts. For example, the TCP client and the TCP ServiceEnd CreationThe connection process is as follows:

TCP Client

Flags

TCP Server

1 Send SYN (Seq= W)

---- SYN --->

SYN encoded ed

2 SYN/ACK Received

<--- SYN/ACK ----

Send SYN (Seq= X), ACK (w + 1)

3 Send ACK (x + 1)

---- ACK --->

ACK Received, Connection Established

W: ISN (Initial Sequence Number) of the Client

X: ISN of the Server

In step 1, the clientEnd proposalConnection Request. In this case, the tcp syn flag is set. Client tells server SequenceRegionValid. Check required. The client in the TCP HeaderIn the serial number AreaInsert your own ISN. After receiving the TCP segment, the server responds with its own ISN (SYN flag) in the second step, and confirms that it receives the first TCP segment (ACK flag) of the client ). In step 3, the client confirms that the ISN (ACK flag is set) of the server is received ). So far, a complete TCP connection is established to start the data transmission process in full duplex mode.

II,TCP flag

It is necessary to introduce the Flag position in TCP segments. As shown in:

* SYN: synchronization flag
Synchronize Sequence Numbers)Effective. This flag is valid only when three handshakes are used to establish a TCP connection. It prompts the TCP Connection ServiceClient checkSerial number, which is the serial number of the initial TCP connection end (usually the client. Here, we can regard the TCP sequence number as a 32-bit counter ranging from 0 to 4,294,967,295. Each byte in the data exchange over TCP connections is serial number. Serial number in the TCP HeaderColumn includesThe serial number of the first byte in the TCP segment.

  * ACK: confirm the flag
Acknowledgement Number)Effective. In most cases, this flag is set. The validation number (w + 1, Figure-1) contained in the validation number column in the TCP header is the next expected sequence number, prompting that the remote system has successfully received all data.

  * RST: reset flag
The reset flag is valid. Used to reset the corresponding TCP connection.

  * URG: emergency sign
The urgent pointer sign is valid. Emergency flag placement,

  * PSH:Push flag
When this flag is set,The acceptor does not setThe data is processed in the queue, but the data is transferred to the application as soon as possible. This flag is always set to a bit when you connect to telnet, rlogin, or other interactive modes.

  * FIN: End flag
The packet with this flag is used to end a TCP session, but the corresponding port is still open, ready to receive subsequent data.

III,TCP port

To support concurrent access requests,TCP provides a user interface called "Port. Port is the core of the operating system used to identify different network calls. This is a strict definition of the transport layer. The TCP port and IP address can be used together to provide communication means to reach the terminal. In factIThe interconnection network connection at a time can be described by four numbers: source IP address and source port, destination IP address and destination port. It is located on different system platforms to provide services at one end through standard ports. For example, the standard TELNET daemon listens to TCP port 23 to receive client connection requests.

IV,TCP cache (TCP Backlog)

Generally, the operating system uses a limited memory for processing.TCP connection request. Each time the SYN flag sent by the user end sets a valid port for the connection request to the server (TCP server is provided)

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.