TCP/IP ICMP protocol, port number, TCP 3-time handshake to establish a connection

Source: Internet
Author: User

    1. ICMP Protocol (Internet Control Message Protocol)

1.1. Definition: A protocol used by a host or router to send error or query information to a source point.

1.2. Message structure

IP Header ( up to four bytes)
Note: TheICMP message is encapsulated in the IP packet, so include the IP header

Type of message (2 bytes)

Report Text field (2 bytes)

Checksum (4 bytes)

ICMP message content (length depends on The type of ICMP message)

Note: Here the first eight bytes are the first eight bytes of the IP packet, and they contain the port number of the application on the source destination host.

1.3. Type of message

The case of the message is divided into 2 categories, error reports and query reports. There are a lot of small classes under each big class with different situations, and there are different error responses for the small classes in each case.

1.3.1. Error Reporting

The error report is sent to the source host when the destination is unreachable, the source is suppressed (race), the time-out (TTL), the parameter problem (theIP header field is wrong), and the routing (change of path) is changed.

1.3.2. Query

This is primarily used for loopback requests and responses (judging whether they are reachable), timestamp requests, and questions and answers (time synchronization) in both cases.

1.4. ICMP Example

1.4.1. Ping

Determine if the destination host is reachable.

1.4.2. Tracert

Displays the routing path to which the destination host will pass.

2.TCP(Internet Control Message Protocol)

2.1. Port number

Background: In TCP/IP tiering, the processes of application-level applications can send and receive application data on the same transport layer. Application layer application processes can pass application data to the same transport layer. But after the transport layer receives the data from the network layer, how can it transfer this data to the application-tier applications?

For example: Now the application layer of the program process has http,ftp,svn etc 3 svn Application data reached the application layer, The transport layer transmits the application data to the svn application, The question came, how did the transport layer know to put svn svn application, Instead of giving other applications http ,

In the TCP/ IP protocol, in order to enable the Transport layer to pass data to the application layer of application, can distinguish between the application, in the IP Datagram defines a port number, the transport layer on the IP The port number of the packet transmits the application data to the corresponding application layer application.

The port number is a soft port that differs from the router's hardware port, which is dependent on a single host. You can have the same port number on different hosts, but you cannot have the same port number on the same host.

2.1.1. Division

On the partition of the port, we should understand the two concepts of server and client first. In the communication process, the application that actively opens the connection is called the client, and the passive open connection application is called the service side.

1) Service port

To communicate with the server, the client must know the port number of the server. The service-side program keeps the data on the listening port, and the port must be open all the time.

Some applications have ports that are famous, such as FTP.

2) Ephemeral port

When the client wants to connect with the server, it randomly registers a port number that is not used on the client host and unregisters the port number when the client disconnects. That is, the port is temporary, not long-term open.

2.2. Establish a connection

The client needs to pass 1 requests and 2 confirmations (so-called 3 handshakes) to establish a connection to the server .

1) client sends a connection request to the server

2) After the server receives the client's connection request, the client agrees to establish a connection if it is allowed to establish a connection.

3) The client receives a service-side consent to establish a connection after the response is sent to the server to establish a connection confirmation message.

Note: Why 3) step is required to prevent "failed to establish connection request".

Creates a situation in which a connection request is established to establish a failure.

The client sends a connection request message to the server, but the message is not reachable in response time due to the congestion of the routing, then the client does not receive confirmation message from the server to establish the connection, so the service side refuses to establish the connection. However, the connection request message after a period of time to reach the service side, the server agreed to establish a connection, the client sent a "consent to establish a connection" message, the client may be due to the connection is not established then closed, or the client due to not send a new connection request message, will reject the service side of the message. At this point the server will always listen to the failure to establish a successful connection, resulting in a waste of service resources /. In this case, the connection request message received by the server is a "failed to establish connection request" message.

TCP/IP ICMP protocol, port number, TCP 3-time handshake to establish a connection

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.