[eli5]What is a subnet mask?

816 views

I can’t find a good answer on google.

In: Technology

5 Answers

Anonymous 0 Comments

Numbers in computers are (ultimately) represented as binary digits. One of the operations you can do on binary digits is called ‘AND’ (the term ‘bitwise’ is often appended to distinguish between the operation we’re talking about and slightly different implementations).

If you’ve got two 1’s, that’s a 1 as output. Otherwise, it’s a 0 as output. So: 10110110 AND 01001010 = 00000010

One common way of using this operation is to ‘mask’ a number to expose only certain bits. I put a ‘1’ in every digit place where I want to keep the original bit and a ‘0’ in every digit place where I want to eliminate the original bit. When I perform the AND, this gives me an answer where the digit is zero in every location I ‘masked off’ and the original value in every location I didn’t.

When you encode different fields of information in a number, this allows you to isolate fields of interest. For example, standard floating point numbers are represented as scientific notion with three fields – a sign bit, an exponent and the number you’re multiplying by (the ‘mantissa’). If I only want to check the sign bit, I would use a mask to isolate the sign bit so I don’t have to worry about the rest of the bits messing up what I’m trying to do.

In Internet addressing, an IPv4 address is 4 8-bit numbers. These numbers identify where the traffic is going. These four numbers are akin to listing a country, a city, a street and then a house number on the street (IP addresses do not literally correspond to physical addresses) – each is giving more information about where the traffic is going.

With a ‘subnet mask’, you’re normally focusing on the grand scale numbers – the ones we’re analogizing as countries, cities and streets – while not concerning yourself much with the actual street addresses. It’s the equivalent of sorting mail into a bin where the same bin contains all the addresses on a street – and you just hand the bin to the mailman who works that street and let him sort it out there.

You are viewing 1 out of 5 answers, click here to view all answers.