Summary of knowledge points for TCP, UDP concepts, and TCP three-time handshake connections

Source: Internet
Author: User

OSI Computer Network 7-layer model

TCP/IP layer four network model

The transport layer provides logical communication between applications (end-to-end), the network layer provides host-to-host communication, and the transport layer provides reliable services.

The usual handshake in TCP refers to the definition of a connection and the process of establishing a connection. The IP protocol is not connected, but TCP is linked.

Port : The data link layer relies on the MAC address addressing, the network interface layer relies on the IP address addressing, the transport layer relies on the port number addressing, the port is the application layer's various protocol processes and the transport entity carries on the inter-layer Exchange address.

Port number: identifies the number of different processes, 16-bit, 2 16-time square, only meaningful locally. There are three categories, one is reserved port, such as FTP is 21,20,dns is 53,http is 80 port, SMTP is 25 and so on. The second is the registration port, the third is the client port number, also called the temporary port (the first two called the server port)

socket: host ip+ port number, only through the IP address and port number, only to determine the port of a connection. Uniquely identifies an application process in a host on the network.

Udp:

User Datagram Protocol, the implementation of non-connected services, no confirmation, unreliable delivery, low overhead, short delay, no congestion control, mainly used in real-time applications, such as IP telephony, QQ, video conferencing and so on. A UDP datagram is only part of an IP datagram.

Tcp

That is, the Transmission Control Protocol, the implementation of a connection-oriented service, up provides a reliable full-duplex logical channel, reliable delivery, overhead, note that the TCP connection channel is logical, not visible to the router, similar to virtual circuit.

Three segments of the TCP connection:

Build, transmit, release. The endpoint of the connection is called the socket (socket), which is determined by the unique communication endpoints, the CS architecture (client server model), and the TCP transport connection is built using a three-time handshake (which prevents the message segment from making errors during the transmission connection establishment).

The main purpose of the TCP three-time handshake is to ensure that the connection is duplex, and that more reliable is ensured by the retransmission mechanism.

First handshake: When a connection is established, the client sends a SYN packet (SYN=J) to the server and enters the Syn_send state, waiting for the server to confirm;

Second handshake: The server receives the SYN packet, it must confirm the customer's SYN (ACK=J+1), and also send itself a SYN packet (syn=k), that is, the Syn+ack packet, when the server enters the SYN_RECV state;

Third handshake: The client receives the server's Syn+ack packet, sends the acknowledgment packet ack (ACK=K+1) to the server, the packet is sent, the client and the server enter the established state, and the handshake is completed three times.

With such a three-time handshake, the client establishes a reliable duplex connection with the server to begin transmitting data.

But why do you have to do three handshake to ensure that the connection is duplex, not one at a time? Two times not? Let's take a real-life example of two people in language communication to simulate a three-time handshake.

Handshake for the first time:

In the exam, a classmate and b classmates are iron buddies, at this time a want to copy B's paper on the results of the first big question.

A just whisper to B, little B, I'll copy the answer to the first big question of your paper, I can't figure it out. There are two kinds of results at this time:

1, if small b focus on the answer, did not pay attention to a request, then, A and B communication establishment failure, that is to say, B students do not receive a classmate of the information, communication must be a failure.

2, if small B heard a whisper, good, the first dialogue (handshake) success. Explain a classmate's request to B classmate, B can accept.

Second handshake:

Small B heard the request for a copy of the information, the results are two kinds:

1, if the B students because of tension, although heard, but the content of the hearing is relatively vague, do not know a specific is to copy which problem, so simply casually perfunctory a sentence: I will not. At this time a classmate listen immediately angry, still can be a friend? I'm wrong about you! OK, the communication between A and B fails. Explain that B students can not make the correct response in the case of communication failure.

2, if B students heard and heard a classmate of the plagiarism request, so, B students to make the right answer, and a said the first big problem results, and AB brothers Love, B also afraid a he can't copy. Rhetorical question: A, have you copied it? Then the equivalent of the second handshake succeeds. through the first two dialogues (handshake) proved that B can hear and listen to a classmate said, and can be a classmate's request, to make the right answer. the third handshake follows.

Third handshake:

A got the correct feedback from classmate B, there are two results:

1, if a classmate is very happy, immediately began to copy it! A is carried away, copy of the Fly, the results did not pay attention to the last sentence of classmate B "You fired well?" , let others small B classmates wait for several minutes reply. b very frustrated, the heart said: "Good you, you copied to, forget me, to, I don't care about you, finally AB or communication failure." Explain that a classmate can not respond to B students in the case, AB communication failure.

2, if a classmate notice B feedback and rhetorical questions, so a classmate to B classmate said: I copy well. Then AB's third handshake succeeded, AB has established a pleasant and smooth communication channel, then A and B will continue to happily pass the answer.

Through the second and third handshake proof:

a classmate can hear the words of B students, and a students can make the correct feedback. visible, AB is effective and enjoyable to communicate, then this three-time handshake process is necessary.

In the same vein, the reason why TCP needs to do three handshakes is to understand the same thing:

In fact, for both sides of the request can be recognized, so logically at least three times. in order to ensure that the server can receive the client's information and can make the correct response to the first two times (first and second) handshake, in order to ensure that the client can receive information on the server and be able to make the correct response to the following two times (second and third) handshake.

Summary of knowledge points for TCP, UDP concepts, and TCP three-time handshake connections

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.