19 December 2016

IP Address and its Significance


Every time we talk about network connection, whether WiFi or Ethernet or Mobile Data, there is one thing we always encounter if any of the above is not working.  We end up calling customer care and they would ask this question - Does your device has a valid IP Address?

What do they mean by a valid IP Address or an IP Address?



IP address


An IP address is a unique logical identifier of every device connected to the internet. EVERY single device, whether it is your laptop, phone, watch, smart home device, Amazon echo, smart router and anything which is interconnected. Strange right, because if every device has a unique IP address, why are we not running out. Well, the answer to that is we are actually running out of IP Addresses. Another answer to that is people involved in the formation of TCP/IP networking protocols had foreseen this and they came up with a workaround for that (Private addresses). A third answer is IPv6 - a newer generation of IP protocol.

Lets talk about why and how our devices get these IP addresses?

When you boot up your device, it is not connected to any network until the Wifi, mobile data or Ethernet module kicks in. So basically you would have a default IP address which is 0.0.0.0 and all the network interfaces will be inactive. (except loopback and local). Checkout what my Mac says when I hit "ifconfig" command (after disabling all network connections) :
------------------------------------------------------------------------------------------------------------
en0: flags=8823<UP,BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
ether ac:bc:32:c1:71:79
nd6 options=201<PERFORMNUD,DAD>
media: autoselect (<unknown type>)
status: inactive
------------------------------------------------------------------------------------------------------------

When one of your network interfaces - WiFi or RF modem or Ethernet connectivity module starts, it will perform DHCP (dynamic host control protocol) which sends a broadcast to an available router and thus acquire a valid IP address (through leases). Your newly acquired IP address will look like this:
------------------------------------------------------------------------------------------------------------
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether ac:bc:32:c1:71:79 
inet6 fe80::18b7:29d9:8bce:ecdb%en0 prefixlen 64 secured scopeid 0x4 
inet 192.168.0.13 netmask 0xffffff00 broadcast 192.168.0.255
...
media: autoselect

status: active
------------------------------------------------------------------------------------------------------------
DHCP mechanism

DHCP mechanism


If you want to learn more about DHCP mechanism, please leave a comment.


Classification of IP address

An IPv4 address is made up of 32 bits or 4 bytes so only 2^32 unique IP addresses are possible. As I said earlier, this is a very hard limitation as the number of devices are growing substantially everyday. I will talk about the workaround for this later in this section.

The total range of IP addresses is from 0.0.0.0 to 255.255.255.255 where each individual number is of 8 bits (8*4 = 32 total) also known as the octet. Originally the IP addresses were divided into classes based on the number of Hosts each class can support.

IP Address Classes can be classified as class A, B, C, D and E where A can support most number of hosts and C can support the least. Class D addresses were reserved for multicast purposes and class E for experimental use. The position of network ID and host ID was fixed at 8,16 or 24 for class A, B and C respectively.
Classful IP addressing

Classful IP addressing



However, due to address space wastage in classful addressing scheme (as the unused addresses within a class can't be redistributed), most organizations turned to Classless Addressing.


Classless Inter-Domain Routing 

With the increased usage of Internet, organizations realized the limitations of IP classes and started to move towards classless addressing where the network ID and host ID bits can be flexible (anything from 1 to 31). An address is represented as a.b.c.d/xx where xx denotes the number of network address bits, so for an address 124.128.xx.xx/9, 9 bits are reserved for network address and the rest 23 bits are for host address. This allows us to assign smaller/dynamic address ranges and also supports redistribution of addresses to other domains, if necessary.  Again, if you have questions regarding how this mechanism achieves scalability, please leave a comment.


So, is it possible to connect to a network without IP address?

When I was studying about IP protocol, I always used to wonder that if the TCP/IP layers are logical, then we probably don't need them if we want to just connect to a network in a raw manner. For network connectivity and data transfer, all we need is a medium (WiFi, radio), a device driver and raw data. On further study, this thought became stronger and it was proved correct during one of my academic project where I created my own data and sent this raw data via a medium (LAN).

One important thing that you must take care is of MAC address. As we all know that MAC address is the actual physical address that is used to identify a physical network device, it is necessary if we want to route a packet to a specific destination. Please leave a comment if you would like to learn more about MAC address and Layer 2 headers.

Example of a MAC address:
01-23-45-67-89-ab

MAC address

MAC address


Why don't we just use MAC address?

One simple answer to this is that there are different types of Layer 2 protocols and not thus Ethernet or WiFi. Protocols like ATM don't have MAC addresses.
Another very intriguing answer is that IP addressing has hierarchy which allows for distribution to domains (networks and sub-networks) and it is closely associated to DNS system. One can argue that we could build a DNS system for MAC addresses but that will be painful as MAC addresses inside a network don't follow any hierarchy and it is impossible to build a DNS lookup table for individual MAC.
Remember, when I said that IP addresses are limited, one of the most critical solution for that was Private Addressing within an organization. This eliminates the need of allocating a unique global IP to each member of that organization. If you check your IP address in your HOME network, it is a private IP, which means that all your devices connected to your router have private IP and only one global IP is used to identify your network. This kind of distribution is only possible through IP addresses and it is not feasible with MAC addresses.

There are a lot of questions that came to my mind while studying networking protocols and the reasons why this exist. You can keep me posted if you have any interesting question,  I will be glad to answer.

Any MX-5 fans, enjoy this video on the cute looks of Miata.


About Me

My photo
Passionate about technology and humans