Difference between revisions of "IPv4 calculations"

(Created page with "Dealing with IPv4 addresses is part of the day in and day out job of network and system administrators. Unfortunately, when the words "netmasks" and "subnet" jump in... ouch.....")
 
Line 1: Line 1:
Dealing with IPv4 addresses is part of the day in and day out job of network and system administrators. Unfortunately, when the words "netmasks" and "subnet" jump in... ouch...  For simple home networks, you generally pick up a network address coming from the reserved ranges (10.0.0.0, 172.16.0.0 or 192.168.0.0) and use it to assign addresses to your hosts letting the black magic of networking do the rest for you. For corporate networks the problem is more complex, even ways more complex, because they involves dozens of servers, desktop computers, network printer, mobile devices not counting IP voice devices, guests access, addresses to reserve for management ports of your various routers / switches and so on with all that devices spread on several departments (even campus through WAN links) making likely to run out of IP addresses when the network becomes big enough. Designing networks is far beyond the scope of this article, what you will learn here is some basic principles to feed your cookie monster with parsimony at the basis :-)
+
WARNING: Work in progress. Do not edit this article unless you are the original author.
  
Having a good comprehension of what happens and how do calculations is a requirement of your daily job, misassignments of IP addresses and masks can lead to hard-to-troubleshoot problems. If you intend to pass an IT certification in a domain related to network administration you are required to know the gory details lying there and do your calculations both in a fast and accurate manner (do not even think to take your exam if you 1. spend more than 30 seconds on a network address calculation and 2. have less than 100% accuracy). System administrators : your destiny is a bit more comfortable but you are required to master subjects related to networks and addressing is one of those.
 
  
= Classfull and classless networks =
+
= Refresh on OSI model =  
  
The engineers who created the Internet Protocol nearly four decades ago (RFC 791 dates back to september 1981) used a 32 bits numbering scheme for network addresses (who will ever need millions of addresses afterall?). Those addresses follows the thereafter logic:
+
When the ARPANet (a packet oriented network) was born in those good old seventies, engineers had to solve the problem of making computers being able to exchange packets of information over the network and they invented in 1974 something you are now using to view this page: TCP/IP! TCP/IP is a collection of various network protocols, being organized as a stack. Just like your boss does not do everything in the company and delegates at lower levels which in turn delegates at an even more lower level, no protocol in the TCP/IP suite takes all responsibilities, they are working together in a hierarchical and cooperative manner.  A level of the TCP/IP stack knows what its immediate lower subordinate can do for it and whatever it will do will be done the right way and will not worry about the manner the job will be done.  Also the only problem for a given level of the stack is to fulfill its own duties and deliver the service requested  by the upper layer, it does not have to worry about the ultimate goal of what upper levels do.
 +
 
 +
<illustration goes here TCP/IP model>
 +
 
 +
The above illustration sounds horribly familiar : yes, it is sounds like this good old OSI model indeed it is a tailored view of the original OSI model, and it works the exact same way.
 +
 
 +
 
 +
 
 +
= Classful and classless networks =
 +
 
 +
 
 +
Who would ''ever'' need millions of addresses afterall? So in theory with those 32 bits we can have around 4 billions of computers within that network and arbitrarily retain that the very first connected computer must be given the number "0", the second one "1", the third one "2" and so on until we exhaust the address pool at number 4294967295 giving no more than 4294967296 (2^32) computers on that network because no number can be a duplicate.  
 +
 
 +
 
 +
Those addresses follows the thereafter logic:
  
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
| colspan="2" '''32 bits (fixed length)''' |
+
| colspan="2" | '''32 bits (fixed length)'''
 
|-
 
|-
| '''Network''' part (variable length of N bits ) || '''Host''' part (length : N - 32 bits)
+
| '''Network''' part (variable length of N bits ) || '''Host''' part (length : 32 - N bits)
 
|}
 
|}
  
* The network address : this part is uniquely assigned amongst all of the organizations in the world  
+
* The network address : this part is uniquely assigned amongst all of the organizations in the world (i.e. No one in the world can hold the same network part) 
 
* The host address :  unique within a given network part
 
* The host address :  unique within a given network part
  
Is the network part assigned by each organization to itself? Of course not! Assignment are coordinated at the worldwide levels by what we call Regional Internet Registries or RIRs which, in turn, can delegate assignments to third-parties located within their geographic jurisdiction. Those latter are called Local Internet Registries or LIRs (the system is detailed in RFC 7020). All of those RIRs are themselves put under the responsibility of now now well-known Internet Assigned Numbers Authority or [http://www.iana.org IANA]. As of 2014 five RIR exists :
+
So in theory we can have something like this (remember the network nature is not to be unique, it hs to be be a collection of networks  :
 +
 
 +
* Network 1 Host 1
 +
*
 +
 
 +
 
 +
Just like your birthday cake is divided in more or less smaller parts depending on how guests' appetite, the IPv4 address space has also been divided into more or less smaller parts just because organizations needs more or less computers on their networks. How to make this possible? Simply by dedicating a variable number of bits to the network part! Do you see the consequence? An IPv4 address being '''always''' 32 bits wide, the more bits you dedicate to the network part the lesser you have for the host part and vice-versa, this is a tradeoff, always. Basically, having more bits in :
 +
* the network part : means more networks possible at the cost of having less hosts per network 
 +
* the host part : means less networks but more hosts per network
 +
 
 +
It might sounds a bit abstract but let's take an example : imagine we dedicate only 8 bits for the network part and the remaining 24 for the hosts part. What happens?  First if we only
 +
 
 +
 +
 
 +
Is the network part assigned by each organization to itself? Of course not! Assignment are coordinated at the worldwide level by what we call Regional Internet Registries or RIRs which, in turn, can delegate assignments to third-parties located within their geographic jurisdiction. Those latter are called Local Internet Registries or LIRs (the system is detailed in RFC 7020). All of those RIRs are themselves put under the responsibility of now now well-known Internet Assigned Numbers Authority or [http://www.iana.org IANA]. As of 2014 five RIR exists :
 
   
 
   
 
* ARIN (American Registry for Internet Numbers) : covers North America
 
* ARIN (American Registry for Internet Numbers) : covers North America

Revision as of 21:41, 15 January 2014

WARNING: Work in progress. Do not edit this article unless you are the original author.


Refresh on OSI model

When the ARPANet (a packet oriented network) was born in those good old seventies, engineers had to solve the problem of making computers being able to exchange packets of information over the network and they invented in 1974 something you are now using to view this page: TCP/IP! TCP/IP is a collection of various network protocols, being organized as a stack. Just like your boss does not do everything in the company and delegates at lower levels which in turn delegates at an even more lower level, no protocol in the TCP/IP suite takes all responsibilities, they are working together in a hierarchical and cooperative manner. A level of the TCP/IP stack knows what its immediate lower subordinate can do for it and whatever it will do will be done the right way and will not worry about the manner the job will be done. Also the only problem for a given level of the stack is to fulfill its own duties and deliver the service requested by the upper layer, it does not have to worry about the ultimate goal of what upper levels do.

<illustration goes here TCP/IP model>

The above illustration sounds horribly familiar : yes, it is sounds like this good old OSI model indeed it is a tailored view of the original OSI model, and it works the exact same way.


Classful and classless networks

Who would ever need millions of addresses afterall?  So in theory with those 32 bits we can have around 4 billions of computers within that network and arbitrarily retain that the very first connected computer must be given the number "0", the second one "1", the third one "2" and so on until we exhaust the address pool at number 4294967295 giving no more than 4294967296 (2^32) computers on that network because no number can be a duplicate. 


Those addresses follows the thereafter logic:

32 bits (fixed length)
Network part (variable length of N bits ) Host part (length : 32 - N bits)
  • The network address : this part is uniquely assigned amongst all of the organizations in the world (i.e. No one in the world can hold the same network part)
  • The host address : unique within a given network part

So in theory we can have something like this (remember the network nature is not to be unique, it hs to be be a collection of networks  :

  • Network 1 Host 1


Just like your birthday cake is divided in more or less smaller parts depending on how guests' appetite, the IPv4 address space has also been divided into more or less smaller parts just because organizations needs more or less computers on their networks. How to make this possible? Simply by dedicating a variable number of bits to the network part! Do you see the consequence? An IPv4 address being always 32 bits wide, the more bits you dedicate to the network part the lesser you have for the host part and vice-versa, this is a tradeoff, always. Basically, having more bits in :

  • the network part : means more networks possible at the cost of having less hosts per network
  • the host part : means less networks but more hosts per network

It might sounds a bit abstract but let's take an example : imagine we dedicate only 8 bits for the network part and the remaining 24 for the hosts part. What happens? First if we only


Is the network part assigned by each organization to itself? Of course not! Assignment are coordinated at the worldwide level by what we call Regional Internet Registries or RIRs which, in turn, can delegate assignments to third-parties located within their geographic jurisdiction. Those latter are called Local Internet Registries or LIRs (the system is detailed in RFC 7020). All of those RIRs are themselves put under the responsibility of now now well-known Internet Assigned Numbers Authority or IANA. As of 2014 five RIR exists :

  • ARIN (American Registry for Internet Numbers) : covers North America
  • LACNIC (Latin America and Caribbean Network Information Centre): covers South America and the Caribbean
  • RIPE-NCC (Réseaux IP Européens / or RIPE Network Coordination Centre): covers Europe, Russia and middle east
  • Afrinic (Africa Network Information Center) : covers the whole Africa
  • APNIC (Asian and Pacific Network Information Centre) : covers oceania and far east.