# IP Address & Classes

In this article, I will explain the concept of IP Addresses, How it works, and its classifications and types in detail. I'll cover each one of these ones by one as simple as possible.  


## What is IP Address? 

An IP address, or Internet Protocol address, is a series of numbers that identifies any device on a network.

## Terminologies

### IP Addressing
**IP addressing** is the process of finding a unique IP address. A unique IP address is required for each host and network component that communicates using TCP/IP protocol.

### TCP/IP Protocol 

**TCP/IP** stands for Transmission Control Protocol/Internet Protocol and is a suite of communication protocols used to interconnect network devices on the internet. TCP/IP is also used as a communications protocol in a private computer network



## Working of IP Addresses 

The IP Address identifies a system's location on the network. An IP must be globally unique and have a uniform format.

Each IP address has two parts: 
- **Network ID**: It identifies the system that is located on the same physical networkID. It is also known as the network address.

- **Host ID**: It identifies the workstation, server, router, or other TCP/IP host within a network. The address for each host must be unique. to the networkID.

The use of the term networkID refers to any IP networkID, whether it is class-based, a subnet, or a supernet.


![netid](https://imgur.com/RD64rwK.png)


### Octets

An IP Address is `32-bits` long. It is a common practice to segment the `32-bits` of the IP address into four `8-bit` fields called **octets**. Each octet is converted to a decimal number (the base 10 numbering system) in the range of `0-255` and separated by a period (a dot). This format is called dotted decimal notation.

**Example IPv4 Address-** `128.168.112.201`

![octet](https://imgur.com/knjVN3z.png)


## Classes in IP Addresses 

TCP/IP defines five classes of IP addresses: Class A, B, C, D, and E. Each class has a range of valid IP addresses. The **value of the first octet** determines the class.

| Class | Range   |
|-------|--------|
| A     | 0-127   |
| B     | 128-191 |
| C     | 192-223 |
| D     | 224-239 |
| E     | 240-255 |


### Class A

Class A addresses are assigned to networks with a very large number of hosts. The high-order bit in a class A address is always set to `0`. The next seven bits (completing the first octets) complete networkID. The remaining `24 bits` (the last three octets) represent the host ID. 

![classA](https://imgur.com/mTzFoci.png)


#### Maximum Possible Networks in Class A

As shown in the above image the network ID only has `8-bits` the first bit is `0` (fixed bit for Class A) and the other `7-bits` are empty. So there can only be **2<sup>7</sup> - 2 (126)** maximum possible networks. I have subtracted the `2` from possible networks because [IANA](https://www.iana.org/) does not allow to use of the first and last bits of the address which are (`00000000` and `01111111`).

#### Maximum Possible Hosts in Class A 

As there are only `24-bits` left and we could do the math **2<sup>24</sup> - 2 (16777214)**. Now here I've also subtracted the 2 that is because in host id first bits of the host address represent the whole network. and the last address is used as the broadcasting address to the whole network.

![](https://imgur.com/nUdk2eG.png)

In the above, I have taken a network with IP address `72.0.0.0` in this `72`  represents the network ID and that is in the range of  `0-127` so we know it is a Class A IP address, and `0.0.0` represent host ID but we cannot assign to the user or host because this IP represents the whole network. 

And Broadcasting IP Address means that if anyone has to send the message or data to all the hosts then It can be done with the `72.255.255.255` which can also not be assigned to the host.


|Summary|
|---| |
|Max. Networks| **2<sup>7</sup> - 2  (126)**|
|Max. Hosts| **2<sup>24</sup> - 2 (16777214)**|
|Example IP Address | 72.21.96.242|


### Class B 

Class B addresses are assigned to medium-sized to large-sized networks. The two high-order bits in a class B address are always set to binary `10`. The next `14-bits` (completing the first and second octets) complete the network ID. The remaining `16-bits` (last two octets) represent the host ID.

![classB](https://imgur.com/5XyUZ8X.png)

#### Maximum Possible Networks in Class B

As shown in the above image, the network ID has `16-bits` in which `2-bits` are fixed (`10`) and there are `14-bits` left empty. So there can be maximum of **2<sup>14 </sup> (16384)** networks. There is no restriction by [IANA](https://www.iana.org/) as it was in Class A.

#### Maximum Possible Hosts in Class B

As there are only `16-bits` left and we could do the math **2<sup>16</sup> - 2 (65534)**. Now here I've also subtracted the 2 that is because in host id first bits of the host address represent the whole network. and the last address is used as the broadcasting address to the whole network as I mentioned in the Class A section.

|Summary|
|---| |
|Max. Networks| **2<sup>14</sup> (16384)**|
|Max. Hosts|**2<sup>16</sup> - 2 (65534)**|
|Example IP Address | 168.211.236.201|

### Class C

Class C addresses are used for small networks. The three high-order bits in class C are always set to binary `110`. The next `21-bits` (completing the first three octets) complete the network ID. The remaining `8-bits` (last octet) represent the host ID. 

![classC](https://imgur.com/QDZg7vS.png)



#### Maximum Possible Networks in Class C

As shown in the above image, the network ID has `24-bits` in which `3-bits` are fixed (`110`) and there are `21-bits` left empty. So there can be maximum of **2<sup>21 </sup> (2097152)** networks. There is no restriction by [IANA](https://www.iana.org/) as it was in Class A.

#### Maximum Possible Hosts in Class C

As there are only `8-bits` left and we can do the math **2<sup>8</sup> - 2 (254)**. Now here I've also subtracted the 2 that is because in host id first bits of the host address represent the whole network. and the last address is used as the broadcasting address to the whole network as I mentioned in the Class A section.

|Summary|
|---| |
|Max. Networks| **2<sup>21</sup> (2097152)**|
|Max. Hosts|**2<sup>8</sup> - 2 (254)**|
|Example IP Address | 192.168.216.105|

### Class D

Class D addresses are reserved for IP multicast addresses. The four high-order bits in a Class D address are always set to binary `1110`. The remaining bits are for the address that the interested host will recognize. Class D is never used for regular networking operations. It is a `32-bits` network address. Thus, there is no need to extract the host address from the IP address. 

**Example IP Address**: `225.231.47.153`


![classD](https://imgur.com/PDgrbGn.png)

### Class E

Class E addresses are reserved for experimental purposes only for R&D (Research and development) or Study. The high order bits in Class E are set to `1111`. 

**Example IP Address**: `244.171.88.113`

![classE](https://imgur.com/Iu0FmVv.png)

## Summary 


- An Ip address is assigned to devices connected to a computer network.
- An IP address works in a network like a postal address
- In a Class A type of network, the first `8-bits` (first octet) identify the network, and the remaining `24-bits` represent the host.
- In a Class B type of network, the first `16-bits` (first two octets) identify the network, and the remaining `16-bits` represent the host.
- In Class C, `24-bits` (first three octets) are used to represent the network, and the remaining `8-bits` represent the host. -
- Class D addresses are `32-bit` network addresses. There is no need to extract the host address from the IP.
- Class E IP address is defined by including the starting four network address bits as 1.


![summary](https://imgur.com/oEHzuM9.png)


## Wrapping up
This was it, I have not coved the concept such as IPv4, IPv6, and subnetting perhaps that's for another article. If you learn something new then don't forget to press ❤️. You can also follow me for more such articles.






