TCP/IP protocol stack -- IP Option Processing

Source: Internet
Author: User

The IP Input Function (ipintr) processes the options after verifying the Group format (check, length, etc.) and determining whether the group has reached the destination. This indicates that the Group

Each vro encountered and the final target host process the option to be grouped.

An IP group can contain optional fields that are processed before the group is forwarded or received. IP implementation can be processed in any order. A maximum

40-byte options.


1. The option format IP option field may contain 0 or multiple independent options. There are two types of options: single-byte and multi-byte. :
All options start with the 1-byte type field. In the multi-byte option, the Type field is followed by a length LEN field and data is stored in other fields. When the first byte of many option data fields is 1 byte, The bitfield offset field points to a byte in the data field. The Length Byte calculation covers the type, length, and data fields. The data type is further divided into three sub-fields: 1bit backup copied flag, 2bit class field, and 5bit number field. Lists the IP options currently defined. The first two options are single-byte options, and the others are multi-byte options.
The 1st column shows the net/3 option constant. The 2nd column and the 3rd column are the decimal and binary values of this type, and the 4th column is the length of the option. The net/3 column displays the options implemented by ip_dooptions in net3. The IP address must automatically ignore all options that it does not recognize. Among them, security and stream ID are not implemented in net/3, the stream ID Option is outdated, and the security option is mainly used by the US military. When net/3 is used to partition an option group, it checks the copied flag. Indicates whether all options are backed up to the IP header of each shard. The class field groups related options. Except that the timestamp option has class 2, all options are Class 0.
2. The ip_dooptions function ipintr calls ip_dooptions before detecting the target address of the group. This function processes all the options it waits for in the group. Ip_dooptions reads each option sequentially and processes it. If the EOL option is encountered, the loop is terminated. If the NOP option is encountered, the loop is ignored. If the option is unknown, the loop is ignored. After the group option is processed, if the group needs to be forwarded, the group will be sent to ip_forward. If an error occurs during the processing option, the function will initiate error processing and send an appropriate ICMP error message. The following sections describe how to process the options.
3. record routing options record routing options so that the routes that the Group passes through the Internet are recorded in the group. The item size is determined by the source host during construction, all expected addresses must be saved. We remember that in the IP Group header, the option can only have 40 bytes at most. The record routing option can have three bytes of overhead. The list followed by the address (4 bytes for each address). If this option is unique, a maximum of 9 addresses (3 + 4*9 = 39) can appear. Once the space allocated to this option is filled up, the group will be forwarded as usual, and the system in the middle will no longer record the address. Describes the format of a record routing option.
If the IP address is a system address (the group has reached the destination), the address of the receiving interface is recorded in the option; otherwise, the address of the outgoing interface provided by the ip_rtaddr function is recorded. If ip_rtaddr cannot find the destination route, an ICMP Host error message is sent.
Ip_rtaddr function this function queries the route cache and, if necessary, queries the complete route table to find the route for the given IP address. The function returns a pointer to the in_ifaddr structure, which is related to the outbound interface of the route. In this function, the rtalloc function searches the route table to find the route to the destination.
4. The source station and record routing options are usually forwarded to the group on the path selected by the Intermediate router. The Origin Site and record routing options allow the origin site to clearly define a route to the destination and overwrite the route selection of the intermediate router. In addition, this route is recorded when the group reaches its destination. A strict route contains the IP address of each intermediate router between the Origin Site and the destination site. Loose routing only specifies some intermediate router addresses. In loose routing, the router can freely select any path between the two systems. In strict routing, the router is not allowed to do so. For example, A, B, and C are routers, while HS and HD are source and target hosts. Because each interface has its own IP address, we can see that router A has three addresses: A1, A2, and A3. Similarly, B and c have multiple addresses.
The source and destination addresses of the IP header, as well as the displacement and address tables listed in the options, specify the route and the position of the Group in the current route. It shows how the group changes from a, B, c to HD based on this loose route. Each row represents the status of the system sent when the group is displayed in column 1st, the last row shows that the group is received by HD. Each system places the interface address in the option. In this way, the routes used by the Group are recorded in the options. The recorded routes will be reversed by the target system and placed on the reply group so that they can be sent in the reverse direction of the original route. Except UDP, net/3 always reverts the received source route when responding.
Option processing mainly includes the following parts: 1. end of source route if the destination address of the IP header is a local address and the offset points to more than the end of the source route, the source route has no address, and the Group has reached the destination, call save_rte to save the source route in the ip_srcrt structure shown in. Because in the final destination, the transport protocol must be able to use the route recorded in the group, the Transport Protocol must reverse the route and attach it to all the response groups.
2. for the next hop Update group, if the destination IP address of the IP header is a local address and the offset points to an address in the option, the system is an intermediate system specified in the source route, the Group has not reached its destination. In a strict route, the next system must be located on a directly connected network. In a loose route, if the interface or route of the next system is not found, sends an ICMP source route failure error message. If an interface or a route is found, the destination IP address of the updated IP address is set to the IP address pointed to by offset. In the source route option, replace the address of the outbound interface with the address of the intermediate system, increase the offset, and point to the next address of the route. 3. If the new destination address is not a multicast address, after processing all the options, the group should not be forwarded to ipintr. The multicast address in the source route allows two multicast routers to communicate through an intermediate router that does not support multicast.
5. When a group passes through the Internet, the timestamp option enables each system to record its current time in the group option. The time is calculated in milliseconds starting from midnight in UTC and is recorded in a 32bit field. If the system does not have accurate UTC or does not update at least 15 times per second, it is not used as the standard time. Non-Standard Time must set the high position of the timestamp field. There are three TIMESTAMP options. NET/3 is accessed through the ip_timestamp structure shown in.
The three TIMESTAMP options specified by ip_flg are as follows:
The initial host must construct a timestamp option with a sufficient data area to store possible timestamps and addresses. For the timestamp option with ipt_flg 3, when the initial host constructs this option, fill in the address of the system to record the timestamp. The structure of the three TIMESTAMP options is displayed.
Because the IP option has only 40 bytes, the timestamp option can have only 9 timestamps, or 4 address and timestamp pairs.

TCP/IP protocol stack -- IP Option Processing

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.