Mask

Mask
Collection
zero Useful+1
zero
The mask is a string Binary Code to target field Progressive bit and operation , mask the current input bit.

purpose

Announce
edit
Bitwise operation of source code and mask or Logical operation Get new Operands Bitwise operations such as OR and AND are used. It is used to change uppercase letters into lowercase letters in ASCII code.
For example, the ASCII code value of A is 65=(01000001) 2, and the ASCII code value of a is 97=(01100001) 2. To convert capital letter A to lower case letters, you only need to perform OR operation between the ASCII code of A and (00100000) 2 to get the lower case letter a.

IP address mask

Announce
edit

rule

The rule 255.255.255.0 of IP address indicates Subnet mask Address.
take Subnet mask After conversion to binary code, for example: 192.168.1.2/24
It is judged that the address 192.168.1.2 is a class C address, so the subnet mask is 255.255.255.0. When converted to binary, it is 11111111.11111111.11111111.00000000.

explain

1 represents the network bit and 0 represents the host bit. As Subnet mask Both 1 and 0 must be continuous.

Masking effect

Announce
edit
The following mainly introduces the concept of IP address and Subnet mask (Subnet Mask).
The IPv4 protocol used imposes some reserved addresses on IP addresses, namely:“ network address ”And“ Broadcast address ”。 The so-called“ network address ”It means“ host IP addresses whose numbers are all "0", such as 125.0.0.0 (Class A address); And“ Broadcast address ”It refers to the IP address when the "host number" is all "255", such as 125.255.255.255 (Class A address).
Subnet mask It is used to identify whether two IP addresses belong to the same subnet. It is also a set of 32 bits long Binary Value, the value on each bit represents different meanings: "1" means that this bit is a network bit; If it is "0", it means that this bit is host Bit. Like IP address, people also use (dotted decimal) to express Subnet mask , such as 255.255.0.0. If two IP addresses are the same Subnet mask The same result is obtained after the bitwise AND calculation, which 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 all in the same network.
Subnet mask Computing methods Since various types of networks have been put into various applications, the network has expanded at an incredible speed on a large scale, and the IPv4 in use has gradually exposed its drawbacks, namely: network number Too many bits, but too few host number bits. The most common solution is to subdivide a higher IP address into multiple IP addresses Subnet 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 bit of the "host number" in the IP address is taken as Subnet Number, from the usual“ network number ”Expand or compress in bounds Subnet mask Used to create a certain number of subnets of certain IP addresses. Of course, created Subnet The more, the more available on each subnet Host address The number of will be reduced accordingly.
To calculate an IP address Subnet mask , which can be considered separately in the following two cases:
Case 1: No need to divide into Subnet The IP address of the. Generally speaking, calculate the IP address's Subnet mask It is very simple and can be written according to its definition. For example, if an IP address is 12.26.43.0, there is no need to divide it Subnet According to the definition, we can know that it is a Class A address Subnet mask It should be 255.0.0.0; If this IP address is a Class B address Subnet mask It 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: To be divided into Subnet IP address of. In this case, how to divide an IP address conveniently and quickly, and calculate each IP address accurately Subnet The selection of methods is very important. Here are two convenient methods: Subnet mask You must first know the number of subnets to be divided and the number of hosts required in each subnet.
Method 1: Use Subnet Count.
  1. one
    First, put Subnet Number converted from decimal number to Binary Number;
  2. two
    Then, count the number of bits of the binary number obtained by "1" and set it to N;
  3. three
    Finally, first find out the address category corresponding to this IP address Subnet mask Then the calculated subnet mask Host address All the first N bits of part (that is, the "host number") are set to 1, so that the subnet mask of the subnet divided by the IP address can be obtained.
For example, it is necessary to Class B IP address 167.194.0.0 is divided into 28 subnets:
  1. one
    (28)10=(11100)2;
  2. two
    this Binary If the number of digits of is 5, then N=5;
  3. three
    This IP address is a Class B address, and Subnet mask It is 255.255.0.0, and the class B address Host address It is the last two digits (0-255.1-254). So I will Subnet mask In 255.255.0.0 host If all the first five bits of the address are set to 1, we can get 255.255.248.0, and this group of values is the class B IP address 167.194.0.0 divided into 28 subnets Subnet mask
Method 2: Use host Count.
  1. one
    First, put host Number converted from decimal number to Binary Number;
  2. two
    Then, if the number of hosts is less than or equal to 254 (note: the two reserved IP addresses should be removed), count the number of bits of the binary number obtained from "1" and set it to N; If the number of hosts is greater than 254, N>8, that is Host address Will exceed 8 bits;
  3. three
    Finally, use 255.255.255.255 to set the Host address Set all the digits to 1, and then set all the N digits to 0 in the order of "from back to front". The value obtained is the value obtained Subnet mask Value.
For example, the class B IP address 167.194.0.0 needs to be divided into several Subnet , each subnet has host 500 sets:
  1. one
    (500)10=(111110100)2;
  2. two
    this Binary If the number of digits of is 9, N=9;
  3. three
    Set the Subnet mask Set all the host addresses of 255. 255.0.0 to 1, and get 255.255.255.255. Then move the rear 9 position 0 from the rear to the front to get: 11111111 11111111.11111110.0000000, i.e. 255.255.254.0. This group of values is divided into host It is the subnet mask of 500 Class B IP addresses 167.194.0.0.
Subnet mask Its main function is to tell network devices which part of a specific IP address contains network address And subnet address, which part is Host address Networked route The device only needs to identify the destination address network number And Subnet No addressing Decision, IP address host Partial non participation Router The routing addressing operation of is only used in Network segment The interface that uniquely identifies a network device in.
If only the three main class addresses A, B and C are used in the network system, instead of the three main class addresses Subnet division Or summarize the main class address, the network device can judge which main class network of A, B, C belongs to according to the value range of the first byte of the IP address, and then determine the network part and host Partial, not required Subnet mask The assistance of. But in order to make the system Subnet Or Classless Inter Domain Routing (CIDR) pair Network segment Under the condition of summary, the network and subnet of IP address can also be compared with host To make a correct distinction between parts, we must rely on Subnet mask Help for.
Subnet mask Use the same as IP Addressing Format: 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. take Subnet mask After the AND operation with the IP address host Some will be discarded, the rest is network address And subnet addresses. For example, the destination IP address of an IP packet is 10.2.2.1. If Subnet mask If it is 255.255.255.0, and it is calculated as 10.2.2.0, then the network equipment considers the network number and subnet number of the IP address as 10.2.2.0.
Interrupt mask:
Interrupt mask refers to the operation that the corresponding interrupt status word needs to be authorized to allow or mask related interrupts before interrupts are performed in assembly language. That is, read OCW1 to write the command word. OCW1 needs to write the odd entry address in the order of M7~M0, if Mi=1: mask the interrupt request introduced by IRi; If Mi=0: the introduction of IRi end interrupt is allowed.