What Is an Address Mask?
A mask is a sequence of binary codes that performs a bitwise AND operation on the target field and masks the current input bits.
Mask
Right!
- First, convert the number of subnets from decimal to binary;
- Next, the number of bits of the binary number obtained by "1" is counted and set to N;
- Finally, first find the subnet mask of the address class corresponding to this IP address. Then set all the first N bits of the host address part of the subnet mask (that is, the "host number") to 1, so as to obtain the subnet mask of the IP address divided into subnets.
- (28) 10 = (11100) 2;
- The number of bits in this binary is 5, then N = 5;
- This IP address is a class B address, and the subnet mask of the class B address is 255.255.0.0, and the host address of the class B address is the last 2 digits (that is, 0-255.1-254). So set all the first 5 bits of the host address in the subnet mask 255.255.0.0 to get 255.255.248.0, and this set of values is the subnet mask of the class B IP address 167.194.0.0 divided into 28 subnets .
- First, convert the number of hosts from decimal to binary;
- Next, if the number of hosts is less than or equal to 254 (note: the two reserved IP addresses should be removed), the number of binary digits obtained from "1" is counted and set to N; if the number of hosts is greater than 254, N> 8, which means that the host address will exceed 8 bits;
- Finally, use 255.255.255.255 to set the host address digits of all such IP addresses to 1, and then set all N digits to 0 in the "back-to-front" order. The resulting value is the subnet you are looking for. The mask value.
- (500) 10 = (111110100) 2;
- The number of bits in this binary is 9, then N = 9;
- Set all the host addresses with the subnet mask 255.255.0.0 of this class B address to 255.255.255.255. Then set the back 9 to 0 from back to front, you can get: 11111111. 11111111.11111110.00000000, which is 255.255.254.0. This set of values is the subnet mask of a class B IP address 167.194.0.0 divided into 500 hosts.
- Mask is a string
- The source code and the mask are bitwise ORed
- The following mainly introduces the concept of IP Address and the calculation of its Subnet Mask.
- The currently used IPv4 protocol forcibly defines some reserved addresses for IP addresses, namely: "network address" and "broadcast address". The so-called "network address" refers to the IP address where the "host number" is all "0", such as: 125.0.0.0 (type A address); and the "broadcast address" refers to the IP when the "host number" is all "255" Address, such as: 125.255.255.255 (type A address).
- The subnet mask is used to identify whether two IP addresses belong to the same subnet. It is also a set of 32-bit binary values. The value on each bit represents a different meaning: "1" means that the bit is a network bit; if it is "0", it means that the bit is a host bit. Like the IP address, people also use (dot decimal) to represent the subnet mask, such as: 255.255.0.0. If two IP addresses are bitwise ANDed with the same subnet mask and get the same result, it means that the two IP addresses are in the same subnet. In other words, the two computers using these two IP addresses are like different departments in the same unit. Although their functions, functions, and even geographical locations may be different, they are in the same network.
- Subnet mask calculation methodSince various types of networks have been put into various applications, the network has undergone large-scale expansion at an incredible speed. The IPv4 currently in use has gradually exposed its disadvantages, namely, the network number is occupied. Too many and too few host numbers. At present, the most commonly used solution is to subdivide a higher class IP address, divide it into multiple subnets, and then provide different subnets to user groups of different sizes. When using this method, in order to effectively improve the utilization of the IP address, the high-order part of the "host number" in the IP address is taken as the subnet number, and it is expanded or compressed from the usual "network number" boundary Subnet mask, used to create a certain number of subnets of a certain type of IP address. Of course, the greater the number of subnets created, the fewer host addresses are available on each subnet.
- To calculate the subnet mask of an IP address, you can consider the following two cases:
- Case 1: There is no need to divide the IP addresses into subnets. Generally, calculating the subnet mask of this IP address is very simple at this time, and it can be written according to its definition. For example: an IP address is 12.26.43.0, there is no need to split the subnet. According to the definition, we can know that it is a class A address, and its subnet mask should be 255.0.0.0; if this IP address is a class B address, Its subnet mask should be 255.255.0.0; if it is a Class C address, its subnet mask is 255.255.255.0. Other analogies.
- Case 2: IP addresses to be divided into subnets. In this case, how to divide an IP address conveniently and quickly, and accurately calculate the mask of each subnet, the choice of method is very important. Below I introduce two more convenient methods: Of course, you must first know the number of subnets to be divided and the number of hosts required in each subnet before finding the subnet mask.
- Method 1: Use the number of subnets to calculate.
- For example: class B IP address 167.194.0.0 needs to be divided into 28 subnets:
- Method 2: Use the number of hosts to calculate.
- For example: class B IP address 167.194.0.0 needs to be divided into several subnets, each of which has 500 hosts:
- The main function of the subnet mask is to tell network devices which part of a particular IP address contains the network address and subnet address, and which part is the host address. The routing device of the network can make routing addressing decisions as long as it recognizes the network number and subnet number of the destination address. The host part of the IP address does not participate in the routing addressing operation of the router and is only used to uniquely identify a network device in the network segment. Interface.
- If the network system uses only three main types of addresses: A, B, and C, and does not subnet the three main types of addresses or summarize the main types of addresses, the network device uses the first byte of the IP address. The value range can be used to determine which of A, B, and C belongs to the main class network, and then the network part and host part of the IP address can be determined without the assistance of the subnet mask. However, in order to make the system subdivide the three main types of networks: A, B, and C, or use the Classless Inter-Domain Routing (CIDR) technology to summarize the network segments In order to correctly distinguish the network and subnet part of the IP address from the host part, you must rely on the help of the subnet mask.
- The subnet mask uses the same addressing format as IP. The part with a subnet mask of 1 corresponds to the network and subnet part of the IP address, and the part with a subnet mask of 0 corresponds to the host part of the IP address. After the AND operation of the subnet mask and the IP address, the host part of the IP address will be discarded, and the rest are the network address and the subnet address. For example, the destination IP address of an IP packet is: 10.2.2.1, if the subnet mask is: 255.255.255.0, and the result is ANDed: 10.2.2.0, the network device considers the network number and The net number is 10.2.2.0.
- Interrupt mask:
- Interrupt mask refers to the operation of authorizing the corresponding interrupt status word to allow or mask the relevant interrupt before interruption in assembly language. That is, read OCW1 to write the command word. OCW1 needs to write the odd entry address, the sequence is M7 ~ M0, if Mi = 1: shield the interrupt request introduced by IRI; if Mi = 0: allow the interrupt of IRi end to be introduced.