Quick Refresher on IPV4

So before we start covering the topics of the ENSLD exam, let’s start by a short reminder on IPv4 Addresses.


First of all what is IPv4 ? Let’s start with the definition :


IPv4 stands for Internet Protocol version 4. It is the underlying technology that makes it possible for us to connect our devices to the web. Whenever a device accesses the Internet, it is assigned a unique, numerical IP address such as 99.48.227.227. To send data from one computer to another through the web, a data packet must be transferred across the network containing the IP addresses of both devices.


Source : https://www.thousandeyes.com/learning/techtorials/ipv4-vs-ipv6

What does that mean ? Remember how a MAC address is a unique physical address assigned per-device which we use to communicate with other devices on the same network segment ? How would we do to communicate with a web-server sitting on the internet ? To achieve this we use IP addresses, which are logical addresses that tell’s us where the address “lives” in the network for others to send data to it. An example of an IP Address in decimal notation would be 172.16.8.0 (Notice there are 4 numbers separated by periods. Each of these numbers signify an octet, which is a collection of 8 bits in binary). So an IP Address is just a 32-bit number assigned to a host on a network.


Binary Math

To better understand IPV4 subnetting you will have to understand binary math, yes I’m sorry guys, but we have to go through it.. I always hated math when I was in school but this is not really like complex algebra it’s actually quite easy to understand once you understand how it works. (I think an algebra teacher will say the same about algebra 😉 )


So what’s binary math? Binary math is mathematics using binary number system, a number system that that uses only two digits, 1’s and 0’s, to represent numbers on the contrary of the decimal system that uses 10. Computers, at the fundamental level, rely on binary for all it’s operations because of the nature digital signals. Digital signals have two states, high-voltage and low-voltage, to make it short, computers components only understand ON and OFF (1 and 0). it was designed that way to take advantage of the perfect fidelity of digital signalling, but humans don’t speak with 1’s and 0’s so how in the heck do we go from that to readable decimal characters ?That’s what we’ll see !


So how do we count using binary ? it’s rather easy, it goes :


0

1

… ?

That’s it ! the only numbers we can use in binary are one’s and zero’s, a binary digit is called a bit. let’s compare this with decimal counting :


0       Start at 0

…       Count 1,2,3,4,5,6,7,8, and then…

9       This is the last digit in Decimal

10      So we start back at 0 again, but add 1 on the left

what happens when we run out of digits ? once we arrive at 99 we start at 100 but we add 1 on the left : 101,102,103,104 … You all know that right.


This is what we do in binary :


0       Start at 0

1       Then 1

10      Start back at 0 again, but add 1 on the left

11       

100     start back at 0 again, and add one to the number on the left…

… but that number is already at 1 so it also goes back to 0 …

… and 1 is added to the next position on the left

101      

110      

111      

1000        Start back at 0 again (for all 3 digits),

add 1 on the left

1001        And so on!

So how do we go from 11000000.10101000.00000001.00000001 to 192.168.1.1 ? IPv4 Addresses are 32-bit addresses which means they are 4 bytes or 4 octets (an octet is a byte composed of 8 bits)


inside each byte there are 8 bits, each bit’s “place” represent’s a power of 2 :


1 = 2⁰ = 1


10 = 2¹ = 2


100 = 2² = 4


1000 = 2³ = 8


10000 = 2⁴ = 16


and so on and so on, if you want to convert a number from binary to decimal just have you can add up the “places” above :



source : http://217.133.6.122/EN/Network/Addressing_the_Network-IPv4.html


This is a network’s engineer best friend, the binary table ! Always have it somewhere near you will studying or even while at work until you can subnet with your eyes closed ! It shows you which exponent and which number is associated with each bit position, so all you have to do is look at each position’s number, “turn on” the bit’s you need to reach the number you want and “turn off” the other ones. For example if you need the number 128 in binary it would be 10000000 because you turn on the first bit which gives you 128 and then you turn off all the others.


Let’s put this in practice :


192.168.25.38 = 11000000.10101000.00011001.00100110 : (128+64=192).(128+32+8=168).(16+8+1=25).(32+4+2=38)


So that’s about it for binary math ! I hope this was crystal clear for you , have some fun and do some exercices with other IP addresses.


IPv4 Address classes

IP addresses are seperated into 2 parts, see these as 2 different blocks :


the network part which determines to which network does this address belong to,

the host part which determines how many hosts are there in a given subnet 

Remember your subnetting tables from your CCNA classes ? IP addresses are 32 bits, which also means 4 byte addresses. The most important part in determining the network class is the first bits of the address.


There are 5 classes : A,B,C,D E, Each one has a specific use.


Class   Highest bits    Network address range   Use Number of networks  Number of hosts

Class A  0xxxxxxx   1.0.0.0-126.0.0.0   Unicast private Adresses        128 (27)        16,777,216 (224)

Class B  10xxxxxx   128.0.0.0-192.255.0.0   Unicast private Adresses        16,384 (214)        65,536 (216)

Class C  110xxxxx   192.0.0.0-223.255.255.0 Unicast private Adresses        2,097,152 (221)     256 (28)

Class D  1110xxxx   224.0.0.1 to 239.255.255.255    Multicast       

Class E  1111xxxx   240.0.0.0-254.255.255.255   Reserved        

There are still 2 concepts to clarify :


When we talk about host addresses we mean the whole address space available for hosts, that doesn’t mean endpoints and devices. For example in an enterprise when we design a /24 subnet like 192.168.1.0, if we look at the classful boundaries definition we can see that the address space is 256. That means you could assign addresses from 192.168.1.0-192.168.1.255 right ? (.0 is an actual address if someone is wondering), hmmm not exactly.


 For starters you have to remove the 192.168.1.0 which is the “Network address” and 192.168.1.255 which is the “broadcast address”, then you would have to choose your router IP which is usually the last IP of the range : 192.168.1.254 , your HSRP addresses if you have multiple routers, and so-on and so-on.


So just keep in mind here that when we are talking about available hosts it’s the address space reserved to hosts not the exact number of IP’s you would have available for your network design.


Subnet Masks

You can’t talk about IPv4 without talking about subnet masks.



Remember above when we talked about address classes above ? Depending on the classes you choose you have a certain number of hosts available to use, but in real life we have to cut and divide subnets even further, that is called subnetting.


Why do we do subnetting ? Imagine for your enterprise you choose a class A address with 16,777,216 host addresses available and you keep adding hosts in that network, that would be a lot of broadcast messages for each device to discover each other which may cause major issues. Or imagine you have only 2 devices that need to connect together (like a WAN point-to-point link) and you assign them to a class C network with 256 host addresses available, that’s a little overkill don’t you think ? That’s why we need a way to work past those initial IPv4 classes and we do that using subnet masks to split the network into multiple subnetworks.


So what is a subnet mask ? Let’s start with the definition :


A subnet mask is a 32-bit number created by setting host bits to all 0s and setting network bits to all 1s. In this way, the subnet mask separates the IP address into the network and host addresses.


The “255” address is always assigned to a broadcast address, and the “0” address is always assigned to a network address. Neither can be assigned to hosts, as they are reserved for these special purposes.


The IP address, subnet mask and gateway or router comprise an underlying structure—the Internet Protocol—that most networks use to facilitate inter-device communication.


When organizations need additional subnetworking, subnetting divides the host element of the IP address further into a subnet. The goal of subnet masks are simply to enable the subnetting process. The phrase “mask” is applied because the subnet mask essentially uses its own 32-bit number to mask the IP address.


source : https://avinetworks.com/glossary/subnet-mask/

So what does that mean ? Clearly put, a subnet mask indicates us which part of the IP address belongs to the networks and which one belong to the host, Which part of the address can change (host part) and which one cannot (network part). It helps us know which addresses are on the same network as us. how does it do that ? Let’s dive back in to binary again.



Source : Plurasight course : Designing Cisco Enterprise Networks: IPv4 and IPv6 Addressing Design

Look at the table above, the 1’s in the mask part specify which part of the number cannot change, while the 0’s specify which part can. Yeah but we still don’t know how to use this on IP addresses I hear you saying, I’m getting there.


let me show you this with an example :


Decimal IP address : 192.168.1.1 binary IP address : 11000000.10101000.00000001.00000001


Decimal Subnet Mask : 255.255.255.0 binary subnet mask : 11111111.11111111.11111111.00000000


the subnet mask is, as it’s name indicates, a mask used to subnet, look at how ,in it’s binary form, it comes on top of the IP address to say which part is reserved for which usage, you can see here that for the 192.168.1 part all bits are turned on which means that that is the network part and the 1 part at the end means that it’s the host part.


SUBNETTING. I should start by saying that I'm not… | by Tom Church | Tech  Jobs Academy | Medium

Source : https://medium.com/tech-jobs-academy/subnetting-8ca804ec10c8

We saw what is exactly subnetting, why we subnet, what is a subnet mask but now we have to cover how do we manipulate subnet masks to split and divide networks to our needs ? That’s what we’ll see here.


Subnetting

So how do we subnet ? It’s all a question of borrowing bit’s and bytes left or right, let me explain :


imagine you have an IP address of 192.168.1.0 with a subnet mask of 255.255.255.0, in binary that would be :


Decimal Binary

192.168.1.0 11000000.10101000.00000001.00000000

255.255.255.0   11111111.11111111.11111111.00000000

that means the network part is 192.168.1 (first 3 octets) and the host part is the 0 (last octet) , as all bits are set to 0 in the last octet, there are 256 host addresses available for this network, what if that was too much for us and we only wanted half of those ? To do that you would borrow 1 octet to to the right to extend the network part of the mask :


Decimal     Binary  

192.168.1.0     11000000.10101000.00000001.00000000 

255.255.255.128     11111111.11111111.11111111.10000000 

as we borrowed 1 octet on the right the decimal form of the subnet masks becomes 255.255.255.128 and if you count the 7 remaining bit’s then you’ll get the answer of 127 : 64+32+16+8+4+2+1 does that mean we have 127 addresses in this network ? No ! Because 0 counts as an address as well so you have 128 usable addresses. If you superpose the subnet mask on top of the IP address in binary you can see that the first bit of the 4th octet is covered by it, so the only ones that can change are the 7 last ones. What we basically do is take a Class C subnet and chop it in half. It’s the same thing if I want to cut it in half again, I would borrow a bit on the right once again :


Decimal Binary

192.168.1.0 11000000.10101000.00000001.00000000

255.255.255.192 11111111.11111111.11111111.11000000

So the host part is extended to the right once again which means we can use all the “0” bit’s as host’s 32+16+8+4+2+1 which means 64 usable addresses. It’s the same principle for class B and class A addresses, just take the initial mask and borrow bits to the right to divide the available hosts in half depending on your needs.


That’s about it for IPv4 Basics ! There is still a lot to talk about regarding IPv4 headers and the history of IPv4 but I think it’s about enough for the topics of the first bullet of the CCNP ENSLD exam. Let me know if this has helped you and thank you for viewing this post !


Comments