Forum Moderators: open

Message Too Old, No Replies

Subnet mask

Don't know where else to ask this

         

snowman

9:05 pm on Jan 14, 2005 (gmt 0)

10+ Year Member



I was explaining to someone how to configure a TCP/IP control panel for setting up their computer on a router-connected DSL line. I have to admit I'm left wondering why on earth anyone designing a bit of software would need to impliment this.

I know how it modifies an IP address - it's kind of like subtraction. But why would anybody want to impliment such a cumbersome step in something that ought to be pretty straight forward and simple?

It almost seems like taking something as simple stating 3 and turning it into 500-497=3.

For example, why for my router is the subnet mask 255.255.255.0 required when all that is really required is it's IP address? For what possible purpose could such a mathematical filter be needed when it doesn't add any great deal of functionality?

Or am I just missing something?

snowman

4:06 am on Jan 15, 2005 (gmt 0)

10+ Year Member



no takers?

mcavic

7:04 am on Jan 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are asking what purpose the netmask serves, and why it needs to be such a long number:

The netmask does add important functionality. It designates which IP addresses are inside your network, and which ones are outside. And thus, your machine can tell whether the traffic needs to go to your router or not. If your netmask is incorrect, chances are that your network will still run, but you may be unable to access certain machines.

As for why it's represented as 255.255.255.0, I bet there's a mathematical reason why, in binary, it's easier/faster for routers to evaluate it in that form. (Speed is very important to a router, because it may need to do many of those calculations per second). Also, it's nice for humans because at a glance, you can tell that it's a netmask. Once you're used to it, the only cumbersome part is saying it out loud.

TheDoctor

11:10 am on Jan 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To say it, you could adopt the style of a bingo caller: "All the ones - 255!". Would definitely puzzle those who don't know binary :)

snowman

2:24 pm on Jan 15, 2005 (gmt 0)

10+ Year Member



Yup, I know about masking.....but don't understand why the need is there.

Still trying to wrap my mind around why it should be deemed necessary to impliment such a step, since it does involve making extra calculations and this could be a detriment towards speed. I just don't see the advantage.

Anyone else?

mcavic

3:46 pm on Jan 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For a home user, the mask is almost always 255.255.255.0, so it seems pointless. But on corporate network, when your ISP has given you a certain number of IP addresses from their block, the mask will be different. And that's when, if you use .0 instead of say .240, you'll be unable to access some of your ISP's other customers. And if you use .240 instead of .0, you'll be unable to access some machines on your own network.

The more advanced your network topology is, the more important the mask is. And if it's necessary for only some networks, that means everyone has to use it.

snowman

4:22 pm on Jan 15, 2005 (gmt 0)

10+ Year Member



Ok. But why?

For example, imagine if everybody's house address was masked like this. It would be very cumbersome to try and figure out what's what.

People's house addresses are there in the open, unmodified. Same with phone numbers. They work.

Dynamic addressing aside, why not just let an address be an address?

mcavic

4:41 pm on Jan 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Because the mask is important in order for routers to understand what's going on. Just consider it a second piece to the IP address.

Let's say the only people you ever call on the phone are your next-door neighbors. You might think you should only have to dial 5550 or 5551 to reach them. But the rest of the number is very important to the phone company, even if for you it's always the same.

snowman

4:47 pm on Jan 15, 2005 (gmt 0)

10+ Year Member



Can you give an example of how a mask - say 255.255.255.0 - affects an IP address and why a router needs to know this?

Suppose an IP address for this example is: 70.49.98.16

mcavic

5:21 pm on Jan 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



With an IP of 70.49.98.16, and a mask of 255.255.255.0, it's indicated that all addresses 70.49.98.x are inside your network, and thus any traffic to those addresses will not be sent to the router, but will remain on your LAN.

That's easy. But here's a better example:

Let's say your ISP has assigned you 16 IP addresses. Your workstation is set to an address of 192.168.1.9, with a mask of 255.255.255.240. Just from that, you can calculate the rest of the addresses that belong to you: 192.168.1.8 through 192.168.1.23.

So, any IPs outside that range are remote, and will be passed to the router. Without the mask, 192.168.1.50 for example would be thought to be local... your workstation would try sending it only on the local LAN, and would get no response.

snowman

5:37 pm on Jan 15, 2005 (gmt 0)

10+ Year Member



Thanks. The latter example is a little tricky to follow since I'm a network of just one computer. I'll have to give it more thought and time to try and understand it.

mcavic

5:43 pm on Jan 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No problem. Just think big: you might have a router with three or four ISP connections, and specific IP addresses need to take specific routes.

Also, if you have just a modem, and no router, your mask might confuse you even more. But in that case, your computer knows that *all* IP addresses other than your own are outside your home. It can't quite follow the rules in that case, because 255.255.255.255 is not a valid mask.

snowman

5:48 pm on Jan 15, 2005 (gmt 0)

10+ Year Member



Now you're losing me! :)

mcavic

5:49 pm on Jan 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



:) I'm just saying that the mask makes more sense on a large, complicated network.

snowman

1:26 am on Jan 16, 2005 (gmt 0)

10+ Year Member



So is there ever a subnet mask of 0.0.0.0?

How are the values for the mask arrived at?

mcavic

2:36 am on Jan 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



0.0.0.0 is a valid mask (come to think of it, 255.255.255.255 is also). But it's not valid for the mask of a particular machine to be set to either of those. If it were, it would indicate that your network encompasses either the whole world, or no machines at all.

Here's how you calculate your own mask. Say you're using a DSL router, and your network is 192.168.1.x. Take the lowest IP that's available to you, and convert it to binary.

192.168.1.0 = 11000000 10101000 00000001 00000000 

Now, the purpose of the mask is actually to indicate which part of the IP is designating the network, and which part is designating the host. So, use 1's to indicate which part of the address is the network part (in this case, it's the first 3 octets of the IP), and 0's to indicate which is the host part.


192.168.1.0 = 11000000 10101000 00000001 00000000
...... mask = 11111111 11111111 11111111 00000000

The latter is the netmask in binary, and converted to decimal it equals 255.255.255.0.

Here's another example:

Your ISP is allocating you 16 IP's, from 10.11.12.0 to 10.11.12.15. Take the lowest IP, which is your Network Number:

10.11.12.0 = 00001010 00001011 00001100 00000000 

Now, your network has 16 IP's, and that would require 4 binary bits to represent. So, the last 4 bits of your IP are the host designation.


10.11.12.0 = 00001010 00001011 00001100 00000000
..... mask = 11111111 11111111 11111111 11110000

And that mask converts to 255.255.255.240.

snowman

2:52 am on Jan 16, 2005 (gmt 0)

10+ Year Member



So you're actually comparing - on a bit by bit basis - the IP address assigned from my ISP to the router's subnet mask and performing a logical "OR" operation to determine the IP address my computer should be set to?

Seems complicated.

snowman

3:01 am on Jan 16, 2005 (gmt 0)

10+ Year Member



Or.....let's say in a company's network for example.

Are computers grouped together when connected to the network, and the netmask is used to "gate" data to only certain groups, by virtue of which bits get set high and which get set low? Is that how it works?

mcavic

3:30 am on Jan 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



the netmask is used to "gate" data

Basically. It's really just a modifier that tells whether two addresses are local or remote in relation to each other.

by virtue of which bits get set high and which get set low?

Yes.

a logical "OR" operation

All I did was to turn on a certain number of bits, and call that the mask. But machines will use boolean operations to evaluate the IP against the mask, yes.

snowman

3:50 am on Jan 16, 2005 (gmt 0)

10+ Year Member



Ok, it's slowly starting to make a little bit of sense.

I always thought you just set a 4 byte IP address, and so long as the server let you log in, data meant for your computer at your assigned IP address simply went to there, without any complications - like sending a letter or making a phone call.

Is all of this stuff actually written down somewhere for folks like me to understand? There's nothing inherently intuitive about it, so someone somewhere had to put it in writing and make up the rules so it would work, right?

Now one more question? Does the subnet mask actually change the data that flows into your computer, or is it only used to help steer addressing concerns?

I've been trying to read up about this. There are different classes in this? Class A, B and C?

mcavic

4:43 am on Jan 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The mask doesn't alter any data, it only aids routing.

Yes, A, B, and C are the main address classes. The difference between them is in how many addresses can be assigned to a network, but subnetting is used to remove the limitations that the classes impose.

Here are some books [amazon.com] that might help.

snowman

5:25 am on Jan 16, 2005 (gmt 0)

10+ Year Member



Ok, live and learn! I didn't know there was a TCP/IP for dummies! Those books are very well written!

Thanks for all of the help! I'll see if my library has the dummies book.