It’s been a long time since I published my last blog post for this series. With some genuine feedback from people I have tried my best to improve on contents. Last blog post was just to give a gentle introduction to IP address in non technical perspective. In this blog post , we will go a little bit more technical.
1) Bit : either 0 or 1 is called a bit. For eg. 11000 is 5 bits in size. Just count the total number of 0’s and 1’s.
2) Byte : A sequence of 8 bits is called a byte. For eg. 10000101 is one byte or octet.
3) Broadcast : An ip address used by a network to inform all devices in the given network.
Some familiarity with binary – decimal conversion and vice-versa. Just kidding. We will learn how to do the conversion right away.
Let’s say we want to convert 192 which is in decimal number system to a binary number system. We divide 192 by 2 , keep track of remainder and put the remainder in a reverse order . Now , we have the binary number.
In the picture given below you can see how it’s converted.
Conversely, we can convert the binary number to decimal by multiplying each bit by 2 to the power of offset from its right and adding the result together.
Now we have some basics covered. Let’s recap the gist of what we have learned in the last blog post. IP address is a unique number assigned to any device connected to a network. Today we shall cover about IPv4 . I will refer to IPv4 as IP for the sake of convenience. IP address is a 32 bit address separated by a dot and represented in decimal in general. Each number before or after the dot is 8 bits hence called octet. There are 4 such octets which make IP address 32 bits in size.
192.168.1.1 (Decimal representation of an IP address)
You might be familiar with the IP address listed above. Technically , we call such IP address as ‘Private IP’.
You might have guessed if there is a ‘Private IP ‘ then there must be ‘Public IP’ as well. Absolutely ! We shall cover about those as well.
In the picture above there are 5 devices and one router. Router assigns IP address to every devices connected to the network. So if any device surfs Internet then it goes to router and the router sends the traffic to the Internet. Suppose all devices are trying to connect to google. The traffic first goes to the router and to the Internet(Google). Google has its own IP address 22.214.171.124 . Here five devices have five different IP addresses which are connecting to Google.
Devices send packet to the router and router knows which devices sent the data with the help of IP address and MAC address(Forget this for now we shall cover this later). Now , the router has to send all those packets to the destination server in our case ‘Google’. A little bit of trick happens here. Router has to send its IP address so that Google knows where to send the response to. Once router receives the data it then sends to the associated device in the local network. So every devices communicate with the help of unique number known as IP address. Here , all the IP addresses router assigns is also known as ‘Private IP’ address and the IP address router uses to communicate with the server of google and the IP address of google are ‘Public IP’ addresses. Your router at home is given a unique IP address by your Internet Service Provider which is known as Public IP address. Your router uses that Public IP address to communicate with the Internet. So the bottom line is your router distributes IP address to all the devices connected to the network which are also known as “Private IP” addresses. Those IP addresses are not routed in the Internet. The ‘IP address’ which your router uses to communicate with the Internet is known as “Public IP address’. Public IP addresses are routed in the Internet.
Why do we need public IP address?
– Every day you surf so many things in the Internet. You use google to search for things , you use Facebook to connect with friends and families , you use Dropbox to store your backup etc. Those are the services hosted somewhere. You need public IP address to connect to those services. If you want to run such services on your own then you again need public IP addresses. In short , you need public IP to connect to the Internet.
How many IPv4 addresses are there?
-Since IPv4 is 32bit in size and each bit can either be 0 or 1 there can be 2^32 possibilities. So, there are total of 2^32 possible ipv4 addresses.
Static vs Dynamic IP Address
The IP address obtained by networking devices can be either static or dynamic. By static it means that the same IP address will not be given to any other device in the network. On the other hand dynamic IP address can be rotated meaning that the current IP address your device is currently assigned can be given to other devices in future .
Classfull IP Address
Your IP address is made up of two parts ; network address and host address. Network address identifies the network you are on whereas host address uniquely identifies the particular machine on the network. It depends on the subnet mask. For example consider the subnet mask 255.255.255.0. The IP address 192.168.10.1 has a network address of 192.168.10.0/24 and hosts can take any value from 1-254. It also means that your network can have total of 254 devices meaning that this is favorable for small sized home network.The host can not take the last value of octet which is 255 as it is used as a broadcast value. If we want a bigger network then the subnet mask should be chosen accordingly. If the subnet mask is 255.255.0.0 then there can be total of 2^16-2 = 65534 number of hosts in the given network which is very large. The following table shows the type of classfull IP addressess along with their range.
|Class||Leading bits||Start Address||End Address|
Class A 0. 0. 0. 0 = 00000000.00000000.00000000.00000000 127.255.255.255 = 01111111.11111111.11111111.11111111 0nnnnnnn.HHHHHHHH.HHHHHHHH.HHHHHHHH Class B 128. 0. 0. 0 = 10000000.00000000.00000000.00000000 126.96.36.199 = 10111111.11111111.11111111.11111111 10nnnnnn.nnnnnnnn.HHHHHHHH.HHHHHHHH Class C 192. 0. 0. 0 = 11000000.00000000.00000000.00000000 188.8.131.52 = 11011111.11111111.11111111.11111111 110nnnnn.nnnnnnnn.nnnnnnnn.HHHHHHHH Class D 224. 0. 0. 0 = 11100000.00000000.00000000.00000000 184.108.40.206 = 11101111.11111111.11111111.11111111 1110XXXX.XXXXXXXX.XXXXXXXX.XXXXXXXX Class E 240. 0. 0. 0 = 11110000.00000000.00000000.00000000 255.255.255.255 = 11111111.11111111.11111111.11111111 1111XXXX.XXXXXXXX.XXXXXXXX.XXXXXXXX