A subnet allows the flow of network traffic between hosts to be segregated based on a network configuration. By organizing hosts into logical groups, subnetting can improve network security and performance. Subnet Mask Perhaps the most recognizable aspect of subnetting is the subnet mask. Like IP addresses, a subnet mask contains four bytes (32 bits) and is often written using the same \"dotted-decimal\" notation. For example, a very common subnet mask in its binary representation 11111111 11111111 11111111 00000000 is typically shown in the equivalent, more readable form 255.255.255.0 Applying a Subnet Mask A subnet mask neither works like an IP address, nor does it exist independently from them. Instead, subnet masks accompany an IP address and the two values work together. Applying the subnet mask to an IP address splits the address into two parts, an \"extended network address\" and a host address. For a subnet mask to be valid, its leftmost bits must be set to \'1\'. For example, 00000000 00000000 00000000 00000000 is an invalid subnet mask because the leftmost bit is set to \'0\'. Conversely, the rightmost bits in a valid subnet mask must be set to \'0\', not \'1\'. Therefore, 11111111 11111111 11111111 11111111 is invalid. All valid subnet masks contain two parts: the left side with all mask bits set to \'1\' (the extended network portion) and the right side with all bits set to \'0\' (the host portion), such as the first example above.
Image masks Raster graphic sprites (left) and masks (right)In computer graphics, when a given image is intended to be placed over a background, the transparent areas can be specified through a binary mask. This way, for each intended image there are actually two bitmaps: the actual image, in which the unused areas are given a pixel value with all bits set to 0\'s, and an additional mask, in which the correspondent image areas are given a pixel value of all bits set to 0\'s and the surrounding areas a value of all bits set to 1\'s. In the sample at right, black pixels have the all-zero bits and white pixels have the all-one bits. At run time, to put the image on the screen over the background, the program first masks the screen pixel\'s bits with the image mask at the desired coordinates using the bitwise AND operation. This preserves the background pixels of the transparent areas while resets with zeros the bits of the pixels which will be obscured by the overlapped image. Then, the program renders the image pixel\'s bits by blending them with the background pixel\'s bits using the bitwise OR operation. This way, the image pixels are appropriately placed while keeping the background surrounding pixels preserved. The result is a perfect compound of the image over the background. This technique is used for painting pointing device cursors, in typical 2-D videogames for characters, bullets and so on (the sprites), for GUI icons, and for video titling and other image mixing applications. Although related (due to being used for the same purposes), transparent colors and alpha channels are techniques which do not involve the image pixel mixage by binary masking.