IPV4 Address
Any device in the network is connected to the network through a network interface card (NIC), and if the device wants to be accessed by another device, its network card must have a unique address. A device can also have multiple network cards and access to multiple networks at the same time, corresponding to the device has multiple addresses, if the device is a host, is generally referred to as the multihomed host. Routers generally have multiple network cards and access to multiple networks, so routers also have multiple addresses, but generally do not refer to routers as multihomed hosts.
IPV4 uses a 32-bit binary address, so the theoretically available IPv4 address altogether consists of 4 294 967 296, i.e. < Span class= "Mrow" id= "mathjax-span-479" > 2 32 。 For ease of administration and addressing (routing), a 32-bit IPV4 address is divided into two parts: the network ID and the host ID. Several successive bits, starting from the left, are used as network IDs to identify the network on which the device resides, and the remaining bits as the host ID used to identify the device in the network. There are currently three methods of partitioning: taxonomy, subnetting, and CIDR.
Classification Basic classification
Taxonomy is one of the earliest and simplest partitioning methods. It divides the IPV4 address into five categories: A, B, C, D, and E.
Class A divides the first 8 bits into the network ID, but the 1th bit must be 0;
Class B divides the first 16 bits into network IDs, but the first 2 bits must be 10;
Class C divides the first 24 bits into network IDs, but the first 3 bits must be 110;
Class D is used for multicast, but the first 4 must be 110;
Class E as a reserved address, but the first 4 bits must be 1111.
The five-class address range of the taxonomy:
class |
take | the reference range
A |
0.0.0.0~127.255.255.255 |
B |
128.0.0.0~191.255.255.255 |
C |
192.0.0.0~223.255.255.255 |
D |
224.0.0.0~239.255.255.255 |
E |
240.0.0.0~255.255.255.255 |
As can be seen from the table, the reference range from a to e is continuous, that is, from the first address 0.0.0.0 of Class A to the last address of Class E 255.255.255.255, there is no discontinuity in the middle.
The taxonomy is characterized by the ability to easily and quickly determine the classification of any of the IPV4 addresses, since at most it is necessary to check the first 4 bits to determine it.
Special Address
Network address
When the bits of the host ID in an IP address is all 0 o'clock, the address is used to represent the network represented by its network ID. As 192.168.1.0, this network ID is 192.168.1.
Broadcast Address
When the bits of the host ID in an IP address is all 1 o'clock, the address is used to represent the broadcast address of the network represented by its network ID. As 192.168.1.255, this is a class C address that represents the broadcast address of the network with the network ID 192.168.1.0.
Host address of the current network
When the network ID in an IPV4 address is bits all 0 o'clock, the address is used to represent the host represented by the current network and its host ID. As 0.0.0.123 this address, represents the current network host ID 123.
Wildcard Address 0.0.0.0
Used to represent any IP address of this machine. In the Winsock2.h header file, Inaddr_any is defined as 0x00000000, or 0.0.0.0.
Ring back Address
In Class A addresses, all addresses from 127.0.0.0~127.255.255.255 are referred to as loopback addresses. As the name implies, loopback is self-issued to itself, that is, all the data sent to the address range is sent to the machine.
Generally speaking, we use 127.0.0.1 as the loopback address, and its name is generally called localhost. In the Winsock2.h header file, Inaddr_loopback is defined as 0x7f000001, which is 127.0.0.1.
Private address
A special IP address that is not recognized by the public network.
- 10.0.0.0~10.255.255.255 (Class A)
- 172.16.0.0~172.31.255.255 (Class B)
- 192.168.0.0~192.168.255.255 (Class C)
In addition, there is an address range 169.251.0.0~169.254.255.255, which is used when the host Automatic Private address assignment (APIPA). In a network environment where there is no DHCP server, each host can use APIPA to get to the address so that they can still communicate with each other.
Reserved address
- 0.0.0.0~0.255.255.255
- 128.0.0.0~128.0.255.255
- 191.255.0.0~191.255.255.255
- 192.0.0.0~192.0.0.255
- 223.255.255.0~223.255.255.255
0.0.0.0 is a wildcard address, but in fact it is also a reserved address, although we can use it in the program, but it cannot be used as an IP address to assign to a host.
Advantages and disadvantages of taxonomy
Advantage: The address itself contains category information and does not require additional information to determine the network ID and host ID of an address.
Cons: There is no question of having multiple sub-networks within an organization.
Sub-grid
On the basis of the original class three networks A, B and C, it is subdivided to subdivide the subnets (Subnet) which can Shi Ying various network sizes. Specifically, it is on the basis of A, B and C address, the host ID part of the partition, that is, the use of the first number of host ID as the subnet ID, the remaining bits as the host ID in the subnet.
Subnet mask
The subnet mask sets all bits that correspond to the network ID and subnet ID in the IPV4 address to 1 and the rest to 0. The goal is that when the IPV4 address and subnet mask are manipulated, the result is the full network address of the IPV4 address.
You can set the number of bits of the subnet ID based on the needs of your network. The more bits of the subnet ID, the more subnets are supported, and the fewer hosts each subnet can hold. Specifically, assuming that the original scheme in the taxonomy, the host ID number of BITS is n (24, 16, 8, respectively, corresponding to a, B, C Class), if we choose the former m (M>=0 && M<N
) bit as the subnet ID, the number of subnets supported is < Span class= "Mrow" id= "mathjax-span-605" > 2 m , the number of hosts supported per subnet is 2 N? M 。
Variable-length subnet mask
The variable-length subnet mask refers to the number of subnet IDs that we choose, and we do not need to make all the divided subnets have the same number of subnet IDs, but can specify a different number of subnet IDs for different subnets as needed.
Non-categorical inter-domain routing
CIDR is the application of Vlsm method, a IPV4 address is divided into network ID and host ID two parts, where the network ID number of bits can be flexibly configured according to the size of the network.
Use CIDR notation in CIDR notation to represent the number of bits of the network ID, that is, add a slash (/) after a IPV4 address, and then add a number after the slash, which is the number of bits of the network ID, such as 192.168.1.123/24, the first 24 of the address is the network ID, The back 8 bits are the host ID.
Network Protocol--IP