Graduation Design path (5)-ICMP, IGMP, TCP protocol

Source: Internet
Author: User

The weather is good today.

Internet Control Information Protocol (ICMP)The structure belongs to the transport layer, but it actually belongs to the network layer and is part of the IP layer. The ICMP protocol provides routing and transfer error reports for IP datagram during transmission.

ICMP messages are sent in the following situations: when the datagram cannot reach the destination, when the gateway has lost the cache function, when the gateway can direct the host to send on a shorter route.

The IP address is not designed to be absolutely reliable. This protocol is designed to return control information when a network problem occurs, rather than making the IP protocol absolutely reliable, and does not guarantee that data packets or control information can be returned. Some data packets will still be lost without any report. The upper-layer protocol must use its own error control program to determine whether the communication is correct. ICMP information usually reports errors in the process of handling data packets. To avoid unlimited return of information, ICMP messages are not sent into packets separately, and ICMP messages are sent only when the datagram offset is 0.

ICMP messages are sent in the basic IP header. The following is the ICMP encapsulation.

  • Type: 1 byte, indicating the type of the ICMP frame. ICMP information is both an error message and a query message.
  • Code: 1 byte, indicating the error code of this type. Only error reports are available, and all others are 0.
  • Checksum: The length is 2 bytes, indicating the 16-bit checksum of the entire ICMP frame. The calculation range is from the ICMP type to the end of the data. The calculation method is the same as the IP address checksum. The calculation method is the same as the IP address checksum.
  • Data of Specific Types: Almost all types of data have different lengths.
IGMP DatagramThe Internet Group Management Protocol (IGMP) is applied on an IP host and reports its multicast relationship to any neighboring router. This memorandum describes only how IGMP determines the relationship between the host and the vro. The behavior of this vro is the opposite to that of the multicast member host. IGMP can also be used between two routers. Like ICMP, IGMP is also an integral part of IP. It requires IGMP to be implemented on all hosts that want to receive IP multicast. An IGMP message is encapsulated in an IP Message, and its IP protocol number is 2. all the IGMP messages described in this document are transmitted with a TTL of 1 and the IP address header contains the IP address routing detection option. TCP protocolThe full name of the TCP protocol is the transmission control protocol. The TCP component can be known from the TCP/IP name. Describes the TCP protocol in four parts. The basis of TCP protocol frames; TCP connections; TCP traffic control; TCP timeout and retransmission. 1) Basis of TCP protocol Frames
  • Connection-oriented: The TCP protocol specifies that the establishment process of the TCP connection must be used for the two tickets before data transmission, and data transmission must be performed after the connection is established successfully. To terminate a connection, you must use the TCP connection interruption process to close the connection.
  • Bidirectional transmission: In TCP, each connection has two logical pipelines, one Receiving and one sending. Data can be sent and received at the same time. The TCP header contains the outgoing data and the serial number of the input data.
  • Reliable transmission: The TCP protocol stipulates that data should be sent in sequence during data transmission and confirmed by the receiver. The unconfirmed data will be resold and the repeated packets received by the receiver will be discarded, the out-of-order packet will be restored to the correct sequence. TCP verification characters provide bit-level integrity verification.
  • Data byte stream: The data transmitted in the TCP Input and Output Logic pipelines is considered as a continuous byte stream. The serial numbers and validation numbers of the TCP Header are determined in bytes. TCP does not know what the transmitted byte stream content is, where it starts, and where it ends. Analysis of byte stream data can only be performed through the Protocol at the application layer.
  • Flow Control: TCP also specifies Traffic Control for data transmission to prevent congestion. Both sides of the data transmission have a receiving buffer. If one side receives a buffer that is full, the other side will not send it until the buffer has free spare space. The buffers on both sides are independent and will never overflow.
  • Application Layer data segmentation: When TCP establishes a connection, both parties exchange the maximum segment that can be received. If the "maximum transmission unit of the path" MTU message of ICMP is received, the maximum segment of TCP is automatically adjusted.
  • One-to-one transmission: The TCP protocol can only implement one-to-one, while the UDP protocol can provide one-to-many services.
To sum up the preceding points, the TCP protocol provides reliable data transmission services for the upper-layer application layer protocol. Some Application layer protocols that do not provide reliable data transmission, such as HTTP, FTP, and SMTP, are transmitted over TCP. The structure of TCP frames. TCP frames are divided into two parts: header and payload. The length of the TCP header can be changed. The minimum length is 20 bytes (when no options or padding is available ). TCP HeaderThe following fields are available: (1) Source PortThe length is 2 bytes. Identifies the source application layer protocol. For example, 80 (HTTP server port) 20, 21 (FTP server port), and 23 (telnet server port. The server end of the application layer protocol generally receives the answer on a known port, while the client of the application layer protocol only accesses the default server port. (2) Target Port: 2 bytes to identify the target application layer protocol. The destination IP address of the IPO header and the destination port of the TCP Header constitute a globally unique and valid address. Adding one IP address and one port number is called a socket. (3) Order Column number (ISN): The length is 4 bytes. It indicates the serial number of the output byte stream based on the 1st bytes of valid data in the TCP frame. The serial number must be set even if no valid data exists, at this time, it is equal to the serial number of the next byte Based on the output byte stream. In addition, when a connection is established or disconnected, the serial number is added with 1. In this case, we will describe it in detail later. (4) ACK)The length is 4 bytes, indicating the serial number of the 1st bytes of the next TCP frame Data byte stream that the receiver wants to accept. The confirmation number is used to confirm the received data. If the sent data is not correctly confirmed, resend the data. Therefore, the receiver must actively confirm the received data. The validation number is very important for all TCP frames. (5) TCP frame Header Length: The length is four bits, indicating the length of the TCP frame header in the TCP frame. It is the same as the length of the IP header, and its value range is 0x5 ~ 0xf, which is a multiple of 4. For example, if the minimum TCP Header length is 20, it can be expressed as 0x5, and the maximum TCP Header length is 60. It can be expressed as 0xf, And the TCP Header size is always a multiple of 4. (6) Retained: The length is 6 bits. Set it to 0. (7) Flag: The length is 6 bits, indicating URG (Emergency pointer), Ack (confirming the serial number is correct), PSH (the receiver sends the data to the application layer as soon as possible), and RST (rebuilding the connection), Syn (synchronous serial number), FIN (complete) 6 flag. Set 1. The six digits can be set to 1. (8) at the same time) Remaining cache space: The length is 2 bytes, which indicates the remaining space of the sending side's receiving buffer. The unit is byte. The maximum value of the buffer is 65535 bytes. This field is used for a long time and the other party cannot send data. In fact, the buffer is for the application layer. If the application layer does not read the above data, the field will become smaller and smaller until it is 0. after the application layer protocol reads data, the value of this field increases, so that no data is lost. (9) Checksum: The length is 2 bytes, Which is TCP. Provides a comprehensive bit-level check. Its calculation includes the TCP pseudoreporting header, TCP header, and TCP payload, and does not send the TCP pseudoreporting header. The calculation method is the same as the IP packet checksum calculation method. Before calculation, you must first clear the TCP checksum field 0. below is the TCP pseudo-Report header. The source IP address and target IP address are the same as those in the IP header. Enter 0 for the undefined field, and 6 for the protocol field (indicating the TCP protocol), and the TCP Length indicates the length of the TCP packet. For the problem of the odd and even number of packet checksum, the solution is the same as that of UDP, that is, adding the padding byte 0 at the end. This is only for calculating the checksum, the added padding word 0 is not sent as the TCP pseudo-Report header. (10) Emergency pointer: The length is 2 bytes. It is useful only after the URG flag is set to 1. It is usually 0. It is a method for sending emergency data over TCP. It indicates the length and location of the emergency data in TCP valid data, and the emergency data is placed within the range from the beginning to the pointer of the current TCP valid data, the analytical expression of rfc793 points the emergency pointer to the last emergency data location, while the new rfc1122 resolution adds 1 more to the emergency pointer to the last emergency data location. (11) Options and fill: The length is increased by 4 bytes. The length is not fixed. Generally, it is 0. However, some packages, such as the synchronization package for establishing a connection, must be selected. The following describes the maximum segment size options. It describes the maximum data size of each TCP frame in this TCP connection (the data transmitted after the connection is established). Its model is 0x02 and its length is 0x04, then two bytes indicate the maximum segment size, in bytes. Sack selective retransmission describes which data needs to be re-transmitted from TCP. It has two default fields before use, two non-operational TCP selection fields, 0x01, 0x01, and then its option model and option length. Generally, it includes two forms: sack permission and SACK option. The option model for the sack license is 0x04 and the option length is 0x02. the option model of the sack option is 0x05, the option length is 10, 18, 26, 34, and so on, and then the left boundary (serial number, 4 bytes) and right boundary of the data to be resold. the left boundary and right boundary define a data segment. Each defined data segment uses 8 bytes. The length may be 10 (1 Data Segment) after the preceding option model and option length are added) or 18 (2 data segments), 26 (3 data segments), and 34 (4 data segments.

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.