Basic knowledge of IPv4

IPv4 address

The length of the IPv4 address is 32 bits and four bytes. The IPv4 address contains the network number and host number.

  • Network number: uniquely identifies a physical link or logical link, and the network number part is common to all devices connected to the link.
  • Host number: uniquely identifies the specific device connected on the link.

1. Classified according to the number of hosts

Large network Class A network A network containing a large number of hosts. Small number of large networks
Medium network Class B network A network containing medium hosts. Medium number of medium networks
Small network Class C network A network with a small number of hosts. Large number of small networks

Class A address ----The first bit of the first octet is always set to 0 . 0 is used as the default address part, and 127 is reserved as the internal loopback address. -Decimal range 1~126.

Class B address ---- Always set the first two digits on the left to 01. -Decimal range 128~191

Class C addresses - - always left to the top three 110. -Decimal range 192~223

Reserved addresses include:

10.0.0.0-10.255.255.255

172.16.0.0-172.31.255.255

192.168.0.0-192.168.255.255

Insert picture description here

2. Address mask

Address mask: indicates the address of the entire data link (actually the network number)

Insert picture description here

For each bit of the IPv4 address, the device performs a Boolean (AND) operation with the corresponding bit of the address mask. By assigning the address 172.16.1.1 and the mask 255.255.0.0 to the interface, the device will know that the interface belongs to 172.16.0.0.

3. Subnet and subnet mask

Each data link must have a unique address. Therefore, if all IPv4 addresses are used up, addresses can only be allocated to fewer than 17 million data links.

If the address assigned to the network is a class B address of 172.21.0.0. Five data links interconnect the host and router. The address mask is set to 24 bits, which is extended by 8 bits.

IPv4 addresses now include: network part, subnet part, and host part. The address mask becomes the subnet mask.

Not all routing protocols support subnet addresses. Some protocols cannot distinguish between the all-zero subnet and the main network number, such as subnet 0 172.21.0.0 and the main network IP address 172.21.0.0

The classful routing protocol also cannot distinguish the broadcast address of an all-one subnet from the broadcast address of an all-subnet. For example: All 1 subnet 172.21.255.0 has a broadcast address of 172.21.255.255, but this is also the broadcast address of all hosts on all subnets of the main network 172.21.0.0.

Subnetting correctly expresses "a class B address using 8 bits for subnetting" or "a class B address with a 24-bit mask"

4. Break the octet boundary

Every time you can borrow any bit to become a subnet

Insert picture description here

5. IPv4 message

Insert picture description here

  • version-----Specify that the IP version number is 4. This field is 4 bits long
  • Internet Header Length—Specify the number of blocks in the IPv4 packet header in units of 4 bytes. The length of this field is 4 bits. Because the minimum length of an IPv4 header is 20 bytes, the minimum value of the IHL field pair is 5. The IPv4 option can extend the length of the minimum IPv4 header by adding 4 bytes. If an IPv4 option does not use up all 4 bytes in the IPv4 option field, the remaining bytes will be filled with 0, so that the entire IPv4 header remains an integer multiple of 32 bits (4 bytes). When the maximum value of this field is 0xF, the maximum length of the options included in the IPv4 header is 60 (15×4).
  • Type of service------Specifies the type of service that the packet is expected to get when it is transmitted through the router on the IPv4 network. The length of this field is 8 bits, and it contains priority, delay, throughput and reliability characteristics.
  • Total Length-----Specifies the full length of the IPv4 packet (IPv4 header and IPv4 payload) and does not include link layer frames. The length of this field is 16 bits, which indicates that the maximum length of an IPv4 packet is 65535 bytes.
  • Identification-----Identify special IPv4 packets. The length of this field is 16 bits. The identification field is optional at the far end of the IPv4 packet. If the IPv4 packet is divided, the identification field will be reserved in all fragments so that the destination node can reassemble these fragments.
  • Flags-----Flags are used in segmentation processing. The length of this field is 3 bits, but only two of them are defined for current use. There are two flags-one indicates whether the IPv4 packet is divided, and the other indicates whether there are more fragments after the current frame.
  • Fragment offset------Specifies the offset position of the fragment relative to the original IPv4 payload. The length of this field is 13 bits.
  • Time to Live-----Specifies the maximum number of connections that an IPv4 packet can pass through before being discarded. The length of this field is 8 bits. The lifetime field is used as a time counter. According to the consumed TTL, an IPv4 router determines the necessary time (in seconds) required for forward transmission of IPv4 packets. q When TTL is equal to 0, an ICMP time-out (Time Expired) packet will be transmitted to the source IPv4 address, and the packet will be discarded.
  • Protocol------Specifies the high-level protocol. This field is 8 bits. For example, the protocol used by TCp is 6, the protocol used by UDP is 17, and the protocol used by ICMP is 1. The Protocol field is used to demultiplex an IPv4 packet into a higher-level protocol.
  • Header checksum------provides a check only for the IPv4 header. The length of this field is 16 bits. The IPv4 payload does not include this verification calculation as the payload, it usually contains its own verification. When each IPv4 node receives IPv4, it checks its IPv4 header verification, and discards the IPv4 packet if the verification fails. When the router forwards an IPv4 packet, it will consume TTL. Therefore, at each hop between the source station and the destination station, the head check will be recalculated.
  • Source Address-------Save the IPv4 address of the source host. 32 bit
  • Destination Address-----Save the IPv4 address of the destination host. 32-bit
    dress-------Save the IPv4 address of the source host. 32 bit
  • Destination Address-----Save the IPv4 address of the destination host. 32 bit
  • Options-save one or more IPv4 options. The length of this field is a multiple of 32 bits. If the IPv4 option does not use 32 bits, it must be padded to 32 bits to keep the IPv4 header as an integer multiple of the 4-byte block so that the Internet Header Length field can describe it.

Guess you like

Origin blog.csdn.net/qq_43710889/article/details/108805416