The netmask explained to my daughter.

Dr. Emiliano Bruni, info/at/ebruni_dot_it
Copyright © 2006 Emiliano Bruni

Last modification: 2006/01/23
Licence Creative Commons

Abstract.

Between all the parameters for the formulation of the access to the net, the netmask it is between the elements mainly encircled from a aura mystery and that, of usual, it comes left 255.255.255.0 without not to know why. This document tries to explain with a comprehensible language, what the netmask is and in which way computer uses such information for sending data over the net.

The ill-famed one triade: IP, gateway and netmask.

Nearly all are capitato, at least once, of imbattersi in the cosi said IP address that is in that one quaterna of numbers, comprised between 0 and 255, separate to you from a point. Even made curious then from this object a po' has been searched on on the net meant its until discovering that the IP others is not if not the address univoco of every public machine on Internet.

IP address is therefore, in the virtual world of Internet, what the address mails them is in the life every day. In the real world the address mails univocamente identifies them an adressee (and sender) of a way letter that this can reach the only real adressee between all the billions of possible adressees. In the virtual world IP address univocamente identifies the sender and the adressee of a particular called object package TCP/IP.

Therefore as a letter contains, on the envelope, the address mails them of the sender and of the adressee, in the world of the TCP/IP, every package it contains on the envelope, call in this case "header", IP address of the sender and the adressee.

The information that the two computers want to be exchanged and that, nel real world, would make the veci del contained della letter, is called, nel world goddesses computer "payload".

Therefore two computers in order to communicate exchange packages TCP/IP containing in the header their respect IP addresses to you and in payload the true and own information.

So that all these functions without ambiguity are necessary that the allocation of the addresses publics of Internet is univoca and is not therefore possible gives an IP address arbitrarily. In fact, like in the real life, also in that virtual one we cannot invent an address but it comes assigned to us.

Description
Mask of configuration TCP/IP on windows

Once in possession of IP address to assign to our calculating we can open the relative shielded one to the configuration of the net. But any is our operating system will always find of forehead at least three parameters: already cited IP address, netmask and the gateway of default and until the configuration of these parameters it is not correct and coherent we will not be in degrees to approach the net resources.

But if in the real life, the address mails them enough for being able to send and to receive a letter, why on Internet IP address is not sufficient?

As the computer to the shipment of a package reasons on the net.

In order to understand why single IP address is not a sufficient information for being able to interact with other computers of the net we must follow the logical process that door to the creation of a package. We consider therefore that our S computer (source) with IP address, as an example, 195.32.69.2 must send to a information to a D computer (adressee) that for hour we identify with a generic IP address AAA.BBB.CCC.DDD.

Like saying, the information becomes therefore "payload" of a package TCP/IP and comes therefore inserted in one particular envelope TCP/IP. On the envelope it comes put the address of the sender, 195.32.69.2 and that one of the adressee.

We imagine, to this point, the calculating with the envelope in hand that os in the cassette mails them more neighbor. That that we would see, to this point, and that it finds itself to having to make one chosen.

In the real case the cassette has two fissures, one for the destined mail to the own city and the other for all the other destinations. The same thing happens in the net. The computer must decide if the letter is destined to a calculating of the own local net or if the adressee is "more far away". Moreover, while in the real case the choice can also be committed an error and be hoped that the letter comes equally recapitata, in the computer science case must be exact.

But why it must make this choice? Why the package goes dealt in different way to second of the various destination. In fact if the package is destined to the local net it can already be thrown cosi com' is on the net in how much the D computer, ivi in listens, will see the package to R-in.transito destined he and it will recover it. In the case in which the adressee it is remote, the package cannot be thrown cosi com' is on the net in how much D is not in listens on it. The package, in this last case, goes modified for being given in meal to a particular calculating of the local net, the gateway of default. And here therefore that ago its appearance the second fundamental parameter of the configuration of the net.

The gateway identifies the access to the external world and is to knowing like catching up the rest of Internet and is therefore to it that we must send the package so that comes correctly forwarded to D. Allora without one corrected configuration of the gateway of default could even catch up correctly our local computers but the rest of the world would be interdetto.

Once cleared therefore why of the necessity of the choice, it must clear like. How ago our PC to understand if the adressee is local or is remote?  In the real world the deductive process would be simple:

S lives in the city X. D lives in city X?

If the answer to this question is positive then the letter it goes sended in the fissure for the same city otherwise goes imbucata in the other. In the virtual case the question is similar:

S is found in the net X. D is found in net X?

The positive result or negative of this question decides the way with which the package it goes sended, if to a local computer or the gateway of default.

The netmask it resolves the problem of what is local and what is remote.

The question to which we must therefore know to answer still contains but one incognito. S has IP address 195.32.69.2 but what agrees for net X?

In order to calculate net X not enough the acquaintance of single IP address. Even if more scaltri they could answer that the net to which IP address 195.32.69.2 belongs is net 195.32.69.0 and this answer is often that right one, in the world of the computers enough not to often guess to us, must always guess to us.

You will sure have understood that in order to gain the net address to which an IP address it belongs there is need to know the netmask. The netmask, identifying the net to which an IP address it belongs, it identifies what is local and what is remote. Moreover the identification of what is local from also a visualization of qual' is the interval of local IP addresses and therefore of how much it is or it can be large our net in the sense of the number of computers that it can contain.

A little binary mathematics.

Hour we do not have to be scared but in order to understand in that way from the acquaintance of IP address and netmask the drifts the address of the net we must penetrate a po' in a world formed from zeri and uni, the world of the binary mathematics.

We begin to know this world making the acquaintance with the two main actors, Mr. ONE and Mr. ZERO. Thanks to these two symbols are possible to define whichever number and what we get ready to ourselves to make hour is to see like this thing, cosi from the first moment strange, it can work.

In the numeration system that we all know ten symbols enter in game with which we write all the numbers. These ten symbols are:

0 1 2 3 4 5 6 7 8 9

that it arranges with with one logical said posizionale to you they allow us to write a whichever number. For what it is "the posizionale" adjective? We try to understand it with an example. When we want to write the year of birth of following undersigned we the put one of flank to the other symbols

1 9 6 9

Our perception of this sequence of figures is a posizionale perception nel sense that this way to write from a different weight alle single been involved figures cosi that number 9 in second position from left does not have the same value dell' other 9.

Every position to the left of an other "hung" ten times more than that one to right and therefore taken the numbers over from right will be had that that number indicates nine times more once one more six times ten more nine times hundreds thousands. E' this and only this that we indicate when we write "1969".

Position 3 2 1 0    
Factor moltipl. 103 102 101 100   in powers
Factor moltipl. 1000 100 10 1   in value
Figures 1 9 6 9    

Ten symbols, posizionale increment of powers of ten, all this to repeat itself of value ten from the name to our called numerical system "decimates them".

Usually one says that the fact to have a system decimates them drift from the fact that we have ten fingers and therefore I use it of ten symbols it is only a convention and it is in truth possible to use an arbitrary number of symbols in order to write the numbers. In truth, the cosi said formed binary system exactly from the single symbols

0 1

the calculating covers a fundamental importance in the world of the computers in how much, working with currents or lives magnetic is alone in a position to less finding the presence or the absence of one of these fields in a memory element and the survey or than such fields it comes associated to the reading in the cell of memory of one or one zero.

But inasmuch as our brain is accustomed to the system decimates them, we see in the first place as a correspondence between the first numbers of the system is constructed decimates them and of that railroad.

Zero and one is obviously equal in all and the two systems. With the two we have the first difficulty. While in the system it decimates them exists an only symbol that identifies such value univocamente, in the binary system we have already exausted all the esprimibili numbers with a single figure and therefore we must pass to two figures. As in the case it decimates them in which after the nine it comes the ten, also in the binary case, after the 1, it is passed having to use two figures and therefore the binary corrispettivo of the two decimates them e' the 10. The three railroad decimates them will be the 11 and with the four we have ended also all the ways to express in railroad a number with two figures and therefore we pass to three and therefore the the 100 four decimates them e' railroad.

Reassuming and extending these associations, indicating with the pedice the type of relative numeration, will be had that

010 = > 02, 110 = > 12,

210 = > 102, 310 = > 112,

410 = > 1002, 510 = > 1012, 610 = > 1102, 710 = > 1112,

810 = > 10002, 910 = > 10012, 1010 = > 10102, 1110 = > 10112,

1210 = > 11002, 1310 = > 11012, 1410 = > 11102, 1510 = > 11112,

Obviously also the binary system is posizionale and, as in the numeration it decimates them a position on the left is ten times greater of that one to right, analogous in the binary system, a position on the left is two times greater of that one to right for which, as an example, 1001112 means, leaving from right, once one more once two more once four more once trentadue and therefore 3910.

Position 5 4 3 2 1 0    
Factor moltipl. 25 24 23 22 21 20   in powers
Factor moltipl. 32 16 8 4 2 1   in value
Figures 1 0 0 1 1 1    

Well, hour that we know the point of view of the calculating R-with regard to the numbers, we are in a position to watching IP address from a new point of view putting to us in the cloth of a computer.

When we human beings say that a calculating has address 195.32.69.2 which the computer sees is four sequences of eight binary symbols separates to you from a point. Every binary symbol 0.1 comes called in jargon "bit" and eight bit goes to form a new called element "byte". Therefore IP address can be seen like a sequence of 4 byte or, that it is the same thing, of 32 bit.

Why we have said that every element of the sequence is formed just from 8 bit? Why we have already said that the numbers separate you from the point can go from 0 to 255 and 255 in railroad are

27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1

 

That this is just the value that represents 255 in railroad sees without having to add all the terms over with a simple one trucchetto. Taken the number

28 27 26 25 24 23 22 21 20
256 128 64 32 16 8 4 2 1
1 0 0 0 0 0 0 0 0

that it is the successive one of the number over has that this is 28 = 256 in decimates them and therefore the number over is 28-1 that is just 255.

To this point, for pure delight we show our IP address used in the example from the point of view of the binary system

1 1 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 1 0
195 32 69 2

Gia that there are, we write also netmask the 255.255.255.0 in binary format. This is much simple one inasmuch as we have as soon as seen qual' it is the binary rappresentazione of number 255 for which

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0
255 255 255 0

But why there are threads in all these to you sfilze of uni and kilometric zeri? Why thanks to these we are hour in a position to introducing the operator who will allow to calculate us the net knowing the IP address and the netmask.

We make therefore the acquaintance with operator "AND". What we can say of this operator?

Beh, in the first place that it is a binary operator that is is a mathematical operation that goes applied to binary numbers and that some transformation executes one on the binary figures of the number transforming them in qualcos' other.

The type of transformation comes in this way defined to words: the AND between two binary figures from like result 1 if and if all and the two figures are 1 otherwise the result is only 0.

Inasmuch as the possible combinations of two binary figures are only four are possible to write the operation of operator AND listing all the possible cases and therefore writing that:

0 AND 0 = 0

0 AND 1 = 0

1 AND 0 = 0

1 AND 1 = 1

A way equivalent in order to express the operation of operator AND is to say that applying it to a whichever binary figure and the 0 from like result 0 while applying it with number 1 from the same binary figure.

Well, hour we have all the instruments in order to define and to calculate the net to which a data belongs IP address. The net of an IP address is the result of operator AND applied to the same address and its netmask therefore, in the specific case, expressing for brevity, for hour the two elements still in binary notation will be the result of the operation

net X = 195.32.69.2 AND 255.255.255.0

It is looked at endured that, in this case, the calculation is much simple one. We begin in fact to apply operator AND on the first byte of IP address and the netmask in order to obtain the first byte of the net address

19510 AND 25510= 110000112 AND 111111112

But, for said how much over, operator AND between a whichever binary number and 1 are the same binary number and therefore

19510 AND 25510= 110000112 AND 111111112= 110000112 = 19510

and it is looked at therefore endured that the result of the AND on the first three byte of same the 3 IP address is byte begins them. Going to calculate the fourth byte of the net whose value is the result of the operation

210 AND 010= 000000102 AND 000000002

that, for how much before said that is that the operation of AND between a whichever number and zero from always zero us door to conclude that

210 AND 010= 000000102 AND 000000002= 000000002= 010

Therefore we are joints to the definitive result. The net to which IP address 195.32.69.2 with netmask 255.255.255.0 belongs is net 195.32.69.0.

Which are therefore local IP addresses to our S computer? For as we have made the accounts over are looked at endured that the addresses of the shape 195.32.69.x in how much are all, for every x its AND with zero will be always zero and therefore the net will be always that one over and therefore the same one of S.

Then we are hour in a position to deciding if our package between S and D goes forwarded through the gateway of default or is for a local IP. If AAA.BBB.CCC.DDD is of the shape 195.32.69.x then the envelope is destined to a computer to search directly on the local net, otherwise it goes sended to the gateway of default for the instradamento on Internet.

Next to this point someone could think that the calculation of the net address banally is made placing zero the last byte of IP address. But this is not true and it it is alone and only if the netmask it is that one up to now used as an example.

We see to clear this with an ulterior example. We take a communication that is involved two computers with 195.32.69.2 address 195.32.68.2 and. These belong or not to the same net? Pensateci well a moment before answering....

The answer is that... dipende. It depends on the netmask assigned. If the netmask it is that one considered up to now then you will have guessed the answer that, for said how much over, is obviously not. But I make you to see that often it convene to make the accounts until has at least not taken a little familiarity and of manualità with the IP and the netmask.

We consider the two IP over but we also consider that she has been they assigned an other netmask: 255.255.254.0 and we calculate of new the net to which the two IP they belong.

For the first address it is had that

195.32.68.2 AND 255.255.254.0 = 195.32.xxx.0

in how much, being to us never capitato the calculation 68 AND 254 we do not know how much face a priori. Executing it is had that

6810 = 110000102 , 25410 = 111111102 and therefore

  1 1 0 0 0 0 1 0   AND
  1 1 1 1 1 1 1 0   =
  1 1 0 0 0 0 1 0    

and therefore the result is of new 6810 and therefore the net to which address 195.32.68.2 with netmask 255.255.254.0 belongs seems to still verify the rule empiricist seen over that is from like result net 195.32.68.0.

We see hour the net of the other address. Of new, the only calculation that we have not never executed e' 69 AND 254 and being

6910 = 110000112 are had that

  1 1 0 0 0 0 1 1   AND
  1 1 1 1 1 1 1 0   =
  1 1 0 0 0 0 1 0    

and here the surprise 6910 AND 25410 = 6810!!! For which both IP addresses belong to same net 195.32.68.0 and therefore they are addresses that belong to two computers of the same local net.

If the netmask it is 255.255.255.0 then 195.32.68.2 and 195.32.69.2 they belong to two different nets and the computers will send the packages of communication between the two blot some to their respect gateway to you but if the netmask it is 255.255.254.0 then the calculating will directly send the envelope on the local net expecting that the other computer directly is connected to it.

As it has been looked at, the netmask it is therefore a discriminating element in order to decide what is local and what is remote and the question which net belongs an IP address is badly specific mail if not also the netmask to assigned it.

We list to hour some remarkable cases.

Netmask the 255.255.255.0 said class C, that sight over, that it has addresses available for 28-2 computers (8 are the bit to zero) that is 253 usable addresses in order to assign to the computers of the net

Netmask the 255.255.255.192 that divides one class C in four sottoreti of 26-2 = 62 computers

Netmask the 255.255.255.128 that divides one net of 256 addresses in four sottoreti of 27-2 = 126 computers

Netmask the 255.255.255.253 2 addresses available are the smallest usablenetwith 2 2 -2 =, often used in the point-point where an address is the IP of a side of the logon and the other is the address of the other point (the third party is the net address and the quarter over is cited address of broadcast)

Netmask the 255.255.255.254 are inusabile in how much also not are an IP available 2 1-2= 0 here (embezzle two why one is the address of inusabile net and the other is an other particular address that all the nets must have called address of broadcast).

Netmask the 255.255.255.255 represent the single host in how much, being all the bit to 1 from like result the single same IP. Al speech IP relatively available this is a degenerate case with which one is not identified net but the address del same computer.

Netmask the 255.255.0.0 said B class that it has local addresses available for 216-2 computers formed therefore from 255 classes C.

Netmask the 255.0.0.0 said also class To computers formed from 255 B classeshavelocal addresses available for 2 24 -2.