[Network] - TCP/IP layer four (five layers) protocol - Internet layer (network layer) - IP address


insert image description here

I. Overview

The previous article briefly introduced the Internet Protocol IP. The Internet Protocol IP is roughly divided into three major functional modules, ①IP addressing, ②routing (forwarding to the final node), ③IP packetization and grouping.
This article focuses on detailing the basics of IP addresses. Including the composition, classification, broadcast address, multicast, subnet mask, etc. of the IP address.

When communicating with TCP/IP, hosts and routers are identified by IP addresses . In order to ensure normal communication, it is necessary to configure the correct IP address for each device. In Internet communication, the correct IP address must be set all over the world. Otherwise, normal communication cannot be realized at all.

Therefore, the IP address is like a cornerstone of TCP/IP communication.
insert image description here

insert image description here

Second, the definition of IP address

An IP address (IPv4 address) is represented by a 32-bit positive integer, and is processed in a binary (binary refers to the method of representing numbers with 0 and 1) inside the computer.

In reality, it is more commonly used 点分十进制to represent the IP address, that is, the 32-bit IP address is divided into 4 groups of 8 bits, each group is separated by ".", and then each group of numbers is converted into a decimal number.
insert image description here

When the numbers expressed as IP addresses are calculated as a whole, the following values ​​are obtained. 2 32 2^{32}232 = 4294967296. From this calculation result, it can be known that up to 4.3 billion computers can be connected to the network. However, some hosts contain multiple network cards, and multiple IP addresses need to be set. In this case, there are fewer available IP addresses. Moreover, the IP address is divided into a network part and a host part, so that the available number of IP addresses is much smaller. So how to solve the problem of the number of IP addresses? You can use IPv6 to increase the number of IP addresses, but NAT technology (a technology that uses private addresses, which will be discussed in a later article) is commonly used now.

insert image description here

3. Composition of IP address

An IP address consists of two parts: a network identifier (network address) and a host identifier (host address). Network ID Configure different values ​​in each segment of the data link, which is the ID commonly used to distinguish network segments. The hosts connected in the same segment must have the same network address . The host address is not allowed to appear repeatedly in the same network segment.

So, in the 32-bit IP address, how many bits are occupied by the network address and the host address ?
Initially, the number of bits occupied by network addresses and host addresses was differentiated in a sorted manner. Now it is basically distinguished by the subnet mask (network prefix). The subnet mask allows the user to set the number of digits occupied by the network address and the host address. For example: 192.168.128.10/2424 means that the subnet mask has 24 bits, and also indicates the network address. Takes 24 bits.
insert image description here

insert image description here

4. Classification of IP addresses

The IP address distinguishes its network identifier and host identifier according to the bit string from the 1st to the 4th, and is divided into 5 categories in total:

  • Class A address: the first 8 digits are the network address (network number), and the remaining 24 digits are the host address (host number); the first digit of
    the network address0 starts with , and the remaining 7 digits, a total of 2 7 2^{7}27 = 128, in dotted decimal notation, the class A network address range is: 0.0.0.0 ~ 127.0.0.0, which0.0.0.0is a reserved address, which means this network;127.x.x.xthe address is reserved as a local softwareloopback test, for example,127.0.0.1it is a loopback address. A total of 126 digits are available.
    The host addresshas2 24 2^{24}224 = 16,777,216, subtractx.0.0.0the sumx.255.255.255, so there are 16,777,214.
  • Class B address: the first 16 bits are the network address (network number), and the remaining 16 bits are the host address (host number); the first two bits of
    the network address10 start with , and the remaining 14 bits, a total of 2 14 2^{14}214 = 16384, in dotted decimal notation, the class B network address range is: 128.0.0.0 ~ 191.255.0.0, which128.0.0.0cannot be used, and the minimum class B address that can be used is2 14 2^{14}128.1.0.0in total214 -1=16383 pieces.
    The host addresshas2 16 2^{16}216 = 65536, subtractx.x.0.0the sumx.x.255.255, so there are 65534.
  • Class C address: the first 24 bits are the network address (network number), and the remaining 8 bits are the host address (host number); the first three bits of
    the network address110 start with , and the remaining 21 bits, a total of 2 21 2^{21}221 =2,097,152, in dotted decimal notation, the class C network address range is: 192.168.0.0 ~ 239.255.255.0, which192.0.0.0cannot be used, and the minimum address of class B that can be used is192.0.1.0, the total number of usable network address digits is2 21 2^{21}221 -1==2,097,151.
    The host addresshas2 8 2^{8}28 = 256, subtractx.x.x.0the sumx.x.x.255, so there are 254.
  • Class D addresses: 32 bits are all network addresses (network numbers), without host addresses, and are often used for multicast . The first four digits of
    the network address1110 are the beginning, and the remaining 28 digits, a total of 2 28 2^{28}228 = 268,435,456, the range of class C network addresses is expressed in dotted decimal: 224.0.0.0 ~ 239.255.255.255.
  • Class E address: the first four digits are 1111the beginning, unused and reserved.
    insert image description here

insert image description here

5. Broadcast address

The broadcast address is used to send data packets between hosts connected to each other in the same link (network segment).

Setting all the host address parts in the IP address to 1 becomes a broadcast address, for example, 192.168.1.255/24a broadcast address.

Similarly, if all the bits of the MAC address are set to 1, then FF:FF:FF:FF:FF:FFthe broadcast address is formed. When the broadcast IP packet is sent in the form of a data link frame, it needs to be FF:FF:FF:FF:FF:FFforwarded through the MAC address with all 1 bits.

There are two types of broadcasting: local broadcasting and direct broadcasting. Broadcasting within the network is called local broadcasting, and broadcasting between different networks is called direct broadcasting.


Reference materials:
"Computer Network" 7th Edition Xie Xiren edited
"Illustrated TCP/IP" 5th Edition
insert image description here

The definition of a host should refer to a device that is configured with an IP address but does not perform routing control. A device that is equipped with an IP address and has routing control capabilities is called a "router", and a node is a general term for a host and a router.

Guess you like

Origin blog.csdn.net/wkd_007/article/details/130794506