TCP/IP protocol broken read

Source: Internet
Author: User
Tags ack

The entire TCP process description:

1) The default state of the server is listen, the client first sends a SYS to the server, indicating that it requires a link, when the client is in Sys_sent state;

2) The server receives SYS, returns an ACK, and then complements a sys, at which point the server is in sys_receive state;

3) The client receives the SYS returned by the server, evolves itself into a established state, and then answers that ACK, and the server receives the ACK and evolves into a established state. So two of them are completely connected.

The above referred to as "three times handshake".


The client and the server can then transmit the data, keepalive.


4) The client sends a fin to the server to tell the server to disconnect, and the client is in the Fin_wait 1 state.

5) The server received this information can be disconnected, the server is in the Close_wait state, and then send a message to tell the client, the server is in the Last_ack state.

6) The client receives information from the server confirming the disconnection, evolves into a fin_wait 2 state, and finally becomes the TIME_WAIT state. Wait some time to make sure you receive the server's answer.

The above process is referred to as "four waves".


The transmission process of TCP is altogether 11 states: Listen,sys_sent,sys_receive,established,fin_wait 1,fin_wait 2,close_wait,closeing,last _ack,time_wait,closed.

Closeing: Pending connection termination request acknowledgement for remote TCP

CLOSED: Not connected (in fact, does not exist)


So why does TCP have to take three handshakes?

The main reason is to prevent "due to network congestion, failure of information and the Resurrection" situation, for example:

A to the B data, at the beginning of a pass a request, but this request failed, so after a period of time, a again wore a request, this time B received, two start happy communication. The exchange is complete and both sides are disconnected. But this time the failure of the information finally climbed to the B-terminal, B will open the port with a to establish a connection, a a look at B to open arms, then a also want to open arms, but a original intended data has been obtained, this time although the establishment of the link, but nothing can be. Then such a link is empty connection, wasted bandwidth.


TCP VS UDP

First say the same point, both of them can be full duplex, and are end-to-end Transport Layer communication protocol.

TCP is generally used for file transfer, because the file transmission requirements are true, shred can not be less, so every time the establishment must require that the data are perfect.

TCP is only one-to-many, does not support broadcast and multicast, and TCP is byte-stream oriented. Slow transmission speed.


UDP is generally used for network voice transmission, the establishment of the main, communication quality second.

Although UDP is unreliable but will do its best to deliver, he is a message-oriented, application layer to UDP what kind of message, UDP transmission what kind of message.

UDP supports one-to-one, one-to-many, many-to-many (various video conferencing), transmission speed.

This article is from "Life is waiting for Gordo" blog, please make sure to keep this source http://chenx1242.blog.51cto.com/10430133/1746515

TCP/IP protocol broken read

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.