[TCP/IP details: Study Notes] IP: network protocol

Source: Internet
Author: User

IP: network protocol

 

IP is the most core protocol in the TCP/IP protocol cluster. It provides unreliable and connectionless datagram transmission services.Unreliable means that it cannot guarantee that the IP datagram can successfully reach the destination. The IP address only provides the transmission service. If a router buffer is exhausted when an error occurs, the IP address discards the datagram and sends an ICMP message to the source.Any required reliability must be provided by the upper layer (such as TCP ).Connectionless means that the IP address does not maintain any status information about subsequent datagram, that is, IP datagram can be received in the order of sending.

 

The format of IP datagram is 1.

 

Figure 1 IP datagram format and fields in the header

 

In Figure 1, the highest bit is on the left, and the value is 0 bit; the second bit is on the right, and the value is 31 bit. 4-byte 32-bit values are transmitted in the following order: the first is 0 ~ 7 bit, followed by 8 ~ 15 bit, then 16 ~ 23 Bit, last 24 ~ 31 bit. This transmission order is known as the Big endian byte order and also becomes the network byte order.

Fields in the beginning of the IP data department:

    1. Currently commonProtocol versionYes 4;
    2. Header LengthIt refers to the number of 32 bit characters, including any options;
    3. Service type (ToS) FieldContains a 3-bit priority field, a 4-bit TOS sub-field and a 1-bit unused bit, but must be set to 0. 4-bit TOS: Minimum latency, maximum throughput, maximum reliability, and minimum cost;
    4. Total length fieldIt refers to the length of the entire IP datagram, in bytes. When a datagram is split, the value of this field also changes;
    5. Id fieldUniquely identifies each datagram sent by the host. Generally, the value of each sent packet is increased by 1;
    6. TTL survival time fieldSets the maximum number of routers that a datagram can pass. When the value of this field is 0, the datagram is discarded and an ICMP message is sent to the source host;
    7. Protocol FieldIndicates which protocol uses IP datagram;
    8. Header check and FieldIt is the checksum code calculated based on the IP address header;
    9. Each IP packet containsSource IP address and destination IP address;
    10. Any optionIs an optional variable length information in the datagram. It uses 32 bit as the boundary and can use 0 as the padding byte if necessary. Any options are defined as follows:

L record path

L Timestamp

L loose Origin Site Selection

L Strict Source Site Selection

 

IP Route Selection:

If the target host is directly connected to the source host (that is, point-to-point link) or both are on a shared network (Ethernet or a licensing Ring Network), IP datagram is directly sent to the target host; otherwise, the host sends the datagram to a default vro and a vro is used to forward the datagram.

 

The IP can receive and send data packets (that is, locally generated data packets) from TCP, UDP, ICMP, and IGMP, or receive data packets (the data packets to be forwarded) from network interfaces) and send it. The IP layer has a route table in the memory.

When a data packet is received and sent, the IP sending function searches the route table. When a packet comes from a network interface, the IP address first checks whether the destination IP address is one of the local IP addresses or the IP broadcast address. If one of these addresses is identified, the datagram is sent to the protocol module specified by the IP header protocol field for processing. If the destination of the datagram is not these addresses, (1) If the IP layer is set as the router function, the datagram is installed; otherwise (2) the datagram is discarded.

 

Information contained in each item in the route table:

    1. Destination IP address;
    2. The IP address of the next (or next hop) router (next-hop router) or a directly connected network IP address. A next-hop router is a vro directly connected to a network. It can forward data packets;
    3. Flag. One flag indicates whether the destination IP address is a network address or a host address, and the other indicates whether the next stop is a router or a directly connected host;
    4. Specify a network interface for data transmission.

 

The IP route is selected on a hop-by-hop basis. It does not know the complete path to any destination (except for directly connected hosts ).

IP Route Selection Process(Search from top to bottom ):

    1. Search the route table to find the target IP address;
    2. Search the route table to find the table items that match the destination network number;
    3. Search the route table and find the table items marked as "default;

If one of the preceding three conditions is met, IP datagram is sent to the next stop router or directly connected network interface specified by the table project. If none of the preceding steps are successful, the datagram cannot be transmitted.If the data that cannot be transmitted comes from the local machine, the data is generally sent to the application that generates the data.ProgramThe error "host inaccessible" or "Network inaccessible" is returned.

Specifying a vro for a network without having to specify a vro for each host is another basic feature of the IP routing mechanism.Note that the destination IP address of the data frame transmitted over the Ethernet will not change, but the destination IP address of the link layer in the Ethernet data frame always refers to the link layer address of the next stop.

 

Subnet Mask:

Given the IP address and subnet mask, the host can determine that the destination IP address is:

(1) hosts on the subaccount network;

(2) hosts in other subnets of the Network;

(3) hosts on other networks.

 

 

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.