IP is an abbreviation of Internet Protocol (Internet Protocol), and is a network layer protocol in the TCP/IP system. The purpose of designing IP is to improve the scalability of the network: one is to solve the Internet problem and realize the interconnection of large-scale and heterogeneous networks; the other is to separate the coupling relationship between the top-level network application and the bottom-layer network technology to benefit the two Independent development. According to the end-to-end design principles, IP only provides the host with a connectionless, unreliable, and best-effort datagram transmission service.
IP is the core of the entire TCP/IP protocol suite and the foundation of the Internet. IP is located in the network layer of the TCP/IP model (equivalent to the network layer of the OSI model). On the top, it can carry information of various protocols of the transport layer, such as TCP, UDP, etc.; on the bottom, IP packets can be placed on the link layer , Through various technologies such as Ethernet and token ring network.
In order to adapt to heterogeneous networks, IP emphasizes adaptability, simplicity and operability, and has made certain sacrifices in reliability. IP does not guarantee the delivery time and reliability of the packets, and the transmitted packets may have problems such as loss, duplication, delay, or out of order.
IP mainly includes three aspects: IP addressing scheme, packet encapsulation format and packet forwarding rules.
IP packet forwarding rules
The router only forwards based on the network address. When an IP packet is forwarded by a router, if the target network is directly connected to the local router, the packet is directly delivered to the target host. This is called direct delivery; otherwise, the router looks up routing information through the routing table and forwards the packet to The specified next-hop router is called indirect delivery. In the indirect delivery of the router, if there is a route to the destination network in the routing table, the data packet is transmitted to the next-hop router specified by the routing table; if there is no route, but there is a default route in the routing table, the datagram is transmitted Give the specified default router; if neither is present, discard the packet and report an error.
IP fragmentation
An IP packet from the source host to the target host may need to pass through multiple different physical networks. Since the data frames of various networks have a maximum transmission unit (MTU) limit, for example, the MTU of an Ethernet frame is 1500; therefore, when the router is forwarding IP packets, if the size of the data packet exceeds the maximum of the egress link When transmitting the unit, the IP packet will be broken down into many small enough fragments to enable transmission on the target link. These IP fragments re-encapsulate an IP packet for independent transmission, and will only be reassembled when it reaches the target host.
IP packet structure
An IP packet consists of a header and data. The first 20 bytes of the header are all IP packets must have, also known as fixed header. Behind the fixed part of the header are some optional fields whose length is variable.
The services provided by IP can be roughly divided into two categories:
● Transmission of IP packets.
● Segmentation and reassembly of IP packets.
IP is a protocol for information transfer between networks. IP packets can be transferred from a source device (such as a user's computer) to a destination device (such as a department's www server). In order to achieve this, IP must rely on two mechanisms: IP address and IP router.
IP address
IP stipulates that all devices on the network must have a unique IP address, just like the address of the recipient must be marked on the mail before the postman can deliver the mail. Similarly, each IP packet must contain the IP address of the destination device before the packet can be correctly sent to the destination. The same device cannot have multiple IP addresses, and all network devices that use IP have at least one unique IP address.
IP routing
The Internet is a large network formed by many network connections. If you want to transmit IP packets on the Internet, in addition to ensuring that each device on the network has a unique IP address, there must be a mechanism for transmission between the networks in order to transfer the IP packets through the network to the destination Ground. This transmission mechanism is called IP routing.
The various networks are connected to each other through routers. The function of the router is to select the transmission path for IP packets. In other words, you must rely on the cooperation of routers along the way to send IP packets to their destinations. In the process of IP routing, the router is responsible for selecting the path, and the IP packet is the object to be transmitted.
IP address and IP routing are the basis of IP packet transmission. In addition, there is a very important feature in the transmission of IP packets, that is, the use of non-connected transmission. The non-connected transmission method refers to that when the IP packet is transmitted, the source device and the destination device do not need to be connected in advance to deliver the IP packet. That is, the source device does not care about the destination device at all, but simply sends out the IP packets one by one. As for whether the destination device receives each information packet, whether it receives the correct information packet, etc., the upper layer protocol (such as TCP) is responsible for checking.
The advantage of using the non-connection type is that the process is simplified and the transmission efficiency can be improved. In addition, since IP packets must pass through the IP routing mechanism and pass between routers, the non-connected transmission method is easier to run in this mechanism.
Compared with the non-connected transmission method, there is also a connected transmission method, that is, both the source and destination devices must first establish a connection before further data transmission, and TCP is to use a connected transmission method.
In order to place an IP packet in different physical frames, the maximum IP packet length can only be equal to the minimum MTU of all physical networks on this path. When a datagram passes through a network that can transmit frames of greater length, it is not economical to limit the size of the datagram below the minimum MTU on the Internet; if the length of the datagram exceeds the minimum MTU value on the Internet, then the When a datagram traverses the subnet, it cannot be encapsulated in a frame.
The IP protocol generally selects a suitable initial length when sending IP packets. If the MTU value of the intermediate physical network to be experienced by this packet is smaller than the length of the IP packet, the IP protocol divides the data portion of this packet into several smaller data pieces to form a smaller packet, and then put Go to the physical frame to send. Each small message is called a segment. The segmentation is generally performed on the router. If the router receives an IP packet from a network interface and forwards it to another network, and the MTU of the network is smaller than the length of the IP packet, then the IP packet must be divided into multiple small IP fragments Send them separately.
Reassembly is the inverse process of segmentation, recombining several IP segments to restore the original IP message. When the destination receives an IP message, it can determine whether it is a fragment based on its segment offset and MF flag. If the MF bit is 0, and the segment offset is 0, it indicates that this is a complete IP datagram. Otherwise, if the segment offset is not 0, or the MF flag is 1, it indicates that it is a segment. At this time, the destination needs to implement segment reorganization. The IP protocol determines which segments belong to the same original packet according to the value of the identifier field in the IP packet header, and determines the position of the segment in the original packet based on the segment offset. If all segments of an IP datagram reach the destination correctly, it is reorganized into a complete message and then handed over to the upper layer protocol for processing.
Summarized as follows: IP packets may pass through many networks using different technologies during transmission. Assuming that the IP packet is sent from the ATM network, the original length is 9180B. If the IP route passes through the Ethernet network, it will face the obstacle that the packet is too large to be transmitted on the Ethernet network. In order to solve this problem, routers must have a mechanism for splitting and recombining IP packets, and split overly long packets so that they can be transmitted on a network with a smaller maximum transmission unit. The divided IP packets are reassembled after being received by the destination device and restored to the original IP packets.
Support