The most important protocol at the network layer—IP protocol

IP protocol format

insert image description here

  • 4-digit version : take 4 or 6 here
  • 4-bit header length: Describes the length of the IP header. (Units are also4byte)
  • 16-bit total length : describes the total length of an IP datagram (header + payload)
  • 16-bit identifier : the same data is divided into multiple packages with the same identifier
  • 3 flags : is the end flag
  • 13-bit slice offset : identifies the sequence of multiple packets after splitting

16-bit flag, 3-bit flag, 13-bit slice offset, these fields are provided for auxiliary unpacking and grouping.

  • 8 bit time to live(TTL): The maximum time that a datagram can be transmitted on the network. The unit of this time is not seconds, but the number of times .

When a datagram is constructed, there will be an initial TTL value, such as 32 or 64, or 128. Every time this datagram is forwarded by a router, the TTL will be reduced by one. If it has been reduced to zero and has not reached the target, it is considered that the packet can be discarded at this time.

  • 8-bit protocol : describes which protocol the content of the current payload belongs to. (TCP/UDP)
  • 16-bit header checksum : Here, only the header needs to be checked, and the payload part (TCP/UDP datagram) already has a checksum.

Note : If the checksum is inconsistent here, the IP protocol will be discarded directly, and the retransmission will not be responsible. If the upper layer uses the TCP protocol, TCP will retransmit after not receiving the ACK.

  • 32-bit source IP address/32-bit destination IP address: It is the most important part of the IP protocol.

use three dots.Divide the 32-bit four-byte number. Divided into four parts, each part is represented by a 0-255 decimal integer. For example 172.18.33.76

Question 1 : Does the total length of 16 bits mean that an IP datagram can only support a maximum of 64KB?
answer : yesdenialYes, if the data payload carried by an IP datagram is too long and exceeds 64KB, the data will be split at the network layer, and one data will be split into multiple IP datagrams and sent to the receiver separately, and then reassembled.

Specific implementation process(The following is the operation for datagrams exceeding 64KB):
sender : hand over the data to the transport layer (encapsulation), and the transport layer to the network layer (encapsulation), and the network layer unpacks the data , for example, into two parts, These two copies are handed over to the data link layer and encapsulated into two data frames by Ethernet.
Receiver : The data link layer divides the two data frames, obtains two IP datagrams, and hands them over to the network layer. The network layer analyzes the two IP datagrams, assembles the payload into one, and then hands it over to the network layer. transport layer

Three ways to solve the problem of insufficient IP addresses

Method 1: Dynamically assign IP addresses

  • This method does not fundamentally increase the IP address, but only improves the utilization rate, which is not a cure for the symptoms .

Method 2: NAT network address translation

  • Essentially using one IP to represent a batch of devices. It can also greatly improve the utilization rate of IP addresses. Use the port number to distinguish.

In the context of NAT, IP addresses are divided into two categories:

  • Intranet IP/Private IP: 10.* , 172.16.* -172.31.* ,192.168.*
  • External network IP/public network IP: the rest is public network IP
    NAT requires that the public network IP must be unique, and the private network IP can appear repeatedly in different LANs.

Notice:
If a device in a private network wants to access a device in the public network, a corresponding NAT device (router) is required to map the IP address to complete network access.
Conversely, devices on the public network cannot directly access devices on the private network, and devices on private networks in different LANs cannot directly access each other.

Method 3: IPv6 (fundamentally solve the problem of insufficient IP)

  • Use 16 bytes to represent IP address

summary:

In fact, the world is still based onNAT+IPv4+dynamic allocationFor network construction, there are very few places where IPv6 is really used.

Address management of IP protocol

IP protocol address management divides an IP address into two parts, one is called the network number and the other is called the host number.

host number/network number

  • Host number : Identify the host. In the same network segment, hosts have the same network number, but must have different host numbers.
  • Network number : to identify the network segment, to ensure that the two network segments connected to each other have different identifications, that is, the local area network

subnet mask

Function: used to divide an IP address into a network number and a host number

  • The 1 part of the subnet mask describes how many bits of the IP are network numbers.

Special IP

  • Set all the host addresses in the IP address to 0, which becomesnetwork number, representing this LAN.
  • Set all the host addresses in the IP address to 1, and it becomesbroadcast address, used to send data to all hosts connected to each other in the same link.
  • IP addresses of 127.* are used fornative loopback(loop back) test, usually 127.0.0.1 (test program is working properly)

Guess you like

Origin blog.csdn.net/m0_63904107/article/details/130545779