Last Update By Kim - June 21, 2020
IP stands for Internet Protocol and the “v4” part means it’s the fourth version. The other three
versions were experimental until we landed on IPv4, which was the first major version ready for
world wide deployment. It was first used on ARPANET in 1983, and still powers most of the
internet to this day.
IPv4 has a theoretical limit of 4.3 billion addresses and in the 1980’s that was more than enough.
But time has changed since then, and as the internet expanded with billions of new devices,
we are close to running out of available IP space. This is one of the major fallbacks of
IPv4 and one of the reasons IPv6 was invented to remedy this issue.
It was originally intended that each host on every network should have a unique routable IP
address on the internet. Companies and organizations would have to fill out some paperwork
about their internal network with the amount of hosts connected to it. Soon after they would
receive the number of IP addresses needed. If we had continued down this road, where each
network in the world would get their own unique IP addresses, then we would have run out
of IP space a long time ago.
Private IP addressing was developed to slow down the limited supply of available IPv4 addresses.
Private addresses can be used by anyone in the world on their own network. They are not globally
unique, which means two different companies can use the same IPv4 addresses. If you’re connected
to your home network right now, your computer has probably been assigned the same IP address
as billions of other hosts. You can view your own IP by typing in this command:
Windows (Command Prompt):
ipconfig
Mac (Terminal):
ifconfig | grep inet
Your IPv4 address most likely look similar to this address: 192.168.0.2. The last two digits
will vary depending on how your router is configured and how many hosts are connected to it.
Take a look at the example below:
Here you can see two unrelated companies who have no business with each other.
However they can still use the same IP addresses in their respective internal networks.
How is that possible? How can packets get to the right receiver when there are more
than one host with the same IP address?
That is a good question and the answer is that the companies are using a
technology called Network Address Translation (NAT). Typically a router or firewall
at the edge of the network is doing the NAT. Network edge is referring to the last
device in the internal network who has a connection out towards the Internet Service
Provider (ISP).
NAT will get it’s own article. But in a nutshell NAT remembers the internal IP address
and uses a public IP address to fetch the request on the internet for that particular host.
That way hundreds of hosts in the internal network can share the same public IP address on the internet.
But it’s not only companies who utilize NAT. If you’re browsing this website in your home right now,
there is a high probability that your router already is doing the NAT for you. Your local router has
probably assigned you an IP that looks something like this: “192.168.1.2”, which is a common address
for home users.
However the IP address you’re using to browse this website is not the same. The IP
connecting to this website is registered to be: 192.168.10.12 That IP address is the one you got assigned from your ISP and that one is completely unique.
Your router is NATTING those two IP addresses and that’s the difference between a
private and a public IP address.
If your ISP receives a packet from a private IP range such as 192.168.0.2 they will be
discarded, because they are not allowed to be routable on the internet.
An IP address uniquely identifies a device on a network. Every device must have an IP
address otherwise no communication can happen. It would be like to call someone who
does not have a phone number.
Let’s take a look at this random IPv4 address and break it down: "192.10.255.20".
An IPv4 address is always written in decimal digits separated by periods. Each number
between the periods can range from 0 to 255. So, the full IP addressing range goes
from 0.0.0.0 to 255.255.255.255. But why is it an odd number like 255? Why not 999?
To explain this we need to break it further down into bits. As a reminder a bit is a
binary digit and can only represent as a 1 or 0. The reason each number only can reach
up to 255 is because of the binary system and how IPv4 was designed. In binary, 255 is
the maximum decimal number that 8 bits can produce.
To add perspective, here is the same IP address broken down into bits:
Every IPv4 address is 32 bits long and is grouped by 8 bits at a time. Each group of bits is called an octet. There are always 4 octets in an IP address, which are separated by the dots. As you can see from the 255 decimal number, all the bits underneath are 1’s. That means it’s the highest possible number you can obtain from 8 bits.
How do you convert an IP address to binary form and why is it important to understand? It’s
essential to know because IP addressing and subnetting is the core functionality of networking.
To see it from the perspective of a computer makes it much easier to understand addressing schemes,
subnetting and how computers talk to each other.
The 1s and 0s in binary represent “OFF” or “ON" respectively. These are the only two states that
are allowed and they are stored and used for calculations with the help of transistors. In a
transistor a "0" represents no electricity (OFF), and a “1” represents electricity that has
been allowed to flow (ON). Simply put, one transistor can answer one “yes or no” question.
Two transistors can answer four questions, three transistors can answer eight questions, and
up it goes! In modern computers today there exist billions of transistors. Basically a computer
can be seen as a bucket load of on and off switches.
Okay so now we know what makes a computer function and how bits comes into play. The next step
is to learn how bits are used to represent decimal numbers. In the binary system, two digits
(0 and 1) are used to build the numbers, while in the decimal system we use ten digits
(0,1,2,3,4,5,6,7,8,9) to build the numbers.
Here is a simple conversion table for the first 4 digits, using only 2 bits:
Decimal Number | Binary |
---|---|
0 | 00 |
1 | 01 |
2 | 10 |
3 | 11 |
From the table above we can see that 2 bits can represent 4 decimal numbers in total. But
how can the decimal number 3 equal to 11 in binary?
By learning this chart, you will understand how the binary number system works:
Exponent: | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
---|---|---|---|---|---|---|---|---|
Value: | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
The system utilizes exponents for the value. The exponent's value increases by one as you move
through each of the eight positions (20, 21, 22 etc.).
For an IPv4 address we only need to go up to 27 , but the scale continues for
larger numbers of course.
27 is just another way to write: 2 x 2 x 2 x 2 x 2 x 2 x 2 = 128
You don’t need the exponent row to do the actual number conversion. I show it, so you know how
the underlying base 2 number system works and how it got those values that we later use to
calculate with.
Now comes the fun part where we actually convert a decimal number to binary. First let’s see if 8
bits set to 1’s actually is the highest possible number in an IP Address:
Value: | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|---|
Bit: | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
Yep, 255 is indeed the highest number possible that 8 bits can produce. Let’s convert the
full IP Address 192.10.255.20 using the same system. We start with the first octet of
the IP Address which is 192.
Then you ask yourself this question for each of the columns. Does 128 go into 192?
Well yes it does, so we mark 1 bit beneath that value.
Value: | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|---|
Bit: | 1 |
Then we subtract the octet with the value: 192 - 128 = 64
Now we go to the next column and ask the same question with our new number.
Does 64 go into 64? Yes it does, so we mark it down:
Value: | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|---|
Bit: | 1 | 1 |
64 - 64 = 0
After the subtraction we do not have any leftovers. That means we can fill out the rest of
the table with 0’s.
Value: | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|---|
Bit: | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
This is the decimal number 192 converted to binary. Let’s convert the next octet of our IP Address
which is 10. It’s the same method as before.
Does 128 go into 10? No it doesn’t, so we mark zero in that column.
Value: | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|---|
Bit: | 0 |
Then we continue:
Does 64 go into 10? No
Does 32 go into 10? No
Does 16 go into 10? No
Does 8 go into 10? Yes!
We can then subtract the value with our number: 10 - 8 = 2 and mark 1 bit at the column.
Value: | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|---|
Bit: | 0 | 0 | 0 | 0 | 1 |
Next question: does 4 go into 2? No
Value: | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|---|
Bit: | 0 | 0 | 0 | 0 | 1 | 0 |
Move to the next column, does 2 go into 2?
Yes it does. Mark 1 bit down. Now we have no more leftovers,
so we mark down the last column with a zero.
Value: | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|---|
Bit: | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
If our calculations are correct the number 10 is “00001010” in binary.
For practise try and convert the last two octets to binary by yourself.
By learning IP conversion and seeing in binary form will make it much easier
to understand addresses and subnetting. Subnetting is covered in a different
article which is part of the same series.
There are 3 classes of available IP ranges used for private IPv4 networks. Each class allows for a range of valid IP addresses, as you can see in the following table:
Classes: | Private Address Range: | Use Cases: |
---|---|---|
Class A | 10.0.0.0 - 10.255.255.255 | Large networks with many hosts |
Class B | 172.16.0.0 - 172.31.255.255 | Medium-sized networks |
Class C | 192.168.0.0 - 192.168.255.255 | Small networks (home users) |
IP's within these ranges are not routable on the public internet and will be discarded by your ISP.
There are several different types of IP addresses based on function.
These addresses are used for one-to-one communication. Unicast sends direct packets to a single host on the network. In other words there is one sender and one receiver.
These addresses are used for one-to-many communication. A packet sent to a multicast address will be forwarded to a specific group of devices on the LAN. Only the hosts that need to receive the message will process the packet otherwise it will be discarded.
These addresses are used for one-to-everybody communication. Broadcast packets will be sent
out to everybody on the LAN except the port that initiated the packet. Each network or
subnet will have a dedicated broadcast address, which all hosts of the network can broadcast.
Examples where the broadcasting address is used: