IPv4 Addresses

Each host in the network located can be identified by the so-called Media Access Control address (MAC). This would allow data exchange within this one network. If the remote host is located in another network, knowledge of the MAC address is not enough to establish a connection. Addressing on the Internet is done via the IPv4 and/or IPv6 address, which is made up of the network address and the host address.

It does not matter whether it is a smaller network, such as a home computer network, or the entire Internet. The IP address ensures the delivery of data to the correct receiver. We can imagine the representation of MAC and IPv4 / IPv6 addresses as follows:

It is possible for a single IP address to address multiple receivers (broadcasting) or for a device to respond to multiple IP addresses. However, it must be ensured that each IP address is assigned only once within the network.


IPv4 Structure

The most common method of assigning IP addresses is IPv4, which consists of a 32-bit binary number combined into 4 bytes consisting of 8-bit groups (octets) ranging from 0-255. These are converted into more easily readable decimal numbers, separated by dots and represented as dotted-decimal notation.

Thus an IPv4 address can look like this:

NotationPresentation
Binary0111 1111.0000 0000.0000 0000.0000 0001
Decimal127.0.0.1

Each network interface (network cards, network printers, or routers) is assigned a unique IP address.

The IPv4 format allows 4,294,967,296 unique addresses. The IP address is divided into a host part and a network part. The router assigns the host part of the IP address at home or by an administrator. The respective network administrator assigns the network part. On the Internet, this is IANA, which allocates and manages the unique IPs.

The IP network blocks in the past were divided into 5 classes (A - E). Each class had a different range of IP addresses that could be assigned to devices. Class A had the largest range and was used for large networks, while Class C had the smallest range and was used for smaller networks. The different classes were distinguished by the length of the network and host shares.

ClassNetwork AddressFirst AddressLast AddressSubnetmaskCIDRSubnetsIPs
A1.0.0.01.0.0.1127.255.255.255255.0.0.0/812716,777,214 + 2
B128.0.0.0128.0.0.1191.255.255.255255.255.0.0/1616,38465,534 + 2
C192.0.0.0192.0.0.1223.255.255.255255.255.255.0/242,097,152254 + 2
D224.0.0.0224.0.0.1239.255.255.255MulticastMulticastMulticastMulticast
E240.0.0.0240.0.0.1255.255.255.255reservedreservedreservedreserved

Subnet Mask

A further separation of these classes into small networks is done with the help of subnetting. This separation is done using the netmasks, which is as long as an IPv4 address. As with classes, it describes which bit positions within the IP address act as network part or host part.

ClassNetwork AddressFirst AddressLast AddressSubnetmaskCIDRSubnetsIPs
A1.0.0.01.0.0.1127.255.255.255255.0.0.0/812716,777,214 + 2
B128.0.0.0128.0.0.1191.255.255.255255.255.0.0/1616,38465,534 + 2
C192.0.0.0192.0.0.1223.255.255.255255.255.255.0/242,097,152254 + 2
D224.0.0.0224.0.0.1239.255.255.255MulticastMulticastMulticastMulticast
E240.0.0.0240.0.0.1255.255.255.255reservedreservedreservedreserved

Network and Gateway Addresses

In an IPv4 network, there are two special addresses: the network address and the broadcast address. The default gateway is the name of the router that connects different networks and systems with different protocols and manages addresses and transmission methods. It's common for the default gateway to be assigned the first or last address in a subnet. This has become a standard in network environments of all sizes.

At your home the router will be the default gate way to the rest of the internet.

ClassNetwork AddressFirst AddressLast AddressSubnetmaskCIDRSubnetsIPs
A1.0.0.01.0.0.1127.255.255.255255.0.0.0/812716,777,214 + 2
B128.0.0.0128.0.0.1191.255.255.255255.255.0.0/1616,38465,534 + 2
C192.0.0.0192.0.0.1223.255.255.255255.255.255.0/242,097,152254 + 2
D224.0.0.0224.0.0.1239.255.255.255MulticastMulticastMulticastMulticast
E240.0.0.0240.0.0.1255.255.255.255reservedreservedreservedreserved

Broadcast Address

In a network, the broadcast IP address is used to send a message to all the devices that are connected to it. It doesn't require any response. Think of it like a megaphone - when you want to communicate with everyone in a room, you use a megaphone to make sure everyone can hear you. In the same way, when a device wants to communicate with all other devices in a network, it sends a message to the broadcast IP address. This IP address is always the last address in the network and is used to identify all the devices that are connected to it.

ClassNetwork AddressFirst AddressLast AddressSubnetmaskCIDRSubnetsIPs
A1.0.0.01.0.0.1127.255.255.255255.0.0.0/812716,777,214 + 2
B128.0.0.0128.0.0.1191.255.255.255255.255.0.0/1616,38465,534 + 2
C192.0.0.0192.0.0.1223.255.255.255255.255.255.0/242,097,152254 + 2
D224.0.0.0224.0.0.1239.255.255.255MulticastMulticastMulticastMulticast
E240.0.0.0240.0.0.1255.255.255.255reservedreservedreservedreserved

Binary system

The binary system is a number system that uses only two different states that are represented into two numbers (0 and 1) opposite to the decimal-system (0 to 9).

An IPv4 address is divided into 4 octets, as we have already seen. Each octet consists of 8 bits. Each position of a bit in an octet has a specific decimal value. Let's take the following IPv4 address as an example:

Here is an example of how the first octet looks like:

1st Octet - Value: 192

1st Octet - Value: 192

Values:         128  64  32  16  8  4  2  1
Binary:           1   1   0   0  0  0  0  0

If we calculate the sum of all these values for each octet where the bit is set to 1, we get the sum:

OctetValuesSum
1st128 + 64 + 0 + 0 + 0 + 0 + 0 + 0= 192
2nd128 + 0 + 32 + 0 + 8 + 0 + 0 + 0= 168
3rd0 + 0 + 0 + 0 + 8 + 0 + 2 + 0= 10
4th0 + 0 + 32 + 0 + 0 + 4 + 2 + 1= 39

The entire representation from binary to decimal would look like this:

IPv4 - Binary Notation

IPv4 - Binary Notation

Octet:             1st         2nd         3rd         4th
Binary:         1100 0000 . 1010 1000 . 0000 1010 . 0010 0111
Decimal:           192    .    168    .     10    .     39

This addition takes place for each octet, which results in a decimal representation of the IPv4 address. The subnet mask is calculated in the same way.

IPv4 - Decimal to Binary

IPv4 - Decimal to Binary

Values:         128  64  32  16  8  4  2  1
Binary:           1   1   1   1  1  1  1  1
OctetValuesSum
1st128 + 64 + 32 + 16 + 8 + 4 + 2 + 1= 255
2nd128 + 64 + 32 + 16 + 8 + 4 + 2 + 1= 255
3rd128 + 64 + 32 + 16 + 8 + 4 + 2 + 1= 255
4th0 + 0 + 0 + 0 + 0 + 0 + 0 + 0= 0

Subnet Mask

Subnet Mask

Octet:             1st         2nd         3rd         4th
Binary:         1111 1111 . 1111 1111 . 1111 1111 . 0000 0000
Decimal:           255    .    255    .    255    .     0

CIDR

CIDR, or Classless Inter-Domain Routing, is a way to represent IP addresses and their associated network masks. CIDR notation specifies an IP address, a slash (‘/’) character, and a number called the prefix length. The prefix length specifies how many of the bits in the IP address are part of the network portion of the address. CIDR does not specify subnet classes, but rather allows for more flexible allocation of IP addresses by eliminating the traditional class A, B, and C network distinctions.

Let us stick to the following IPv4 address and subnet mask as an example:

Now the whole representation of the IPv4 address and the subnet mask would look like this:

The CIDR suffix is, therefore, the sum of all ones in the subnet mask.

Subnet Mask

Octet:             1st         2nd         3rd         4th
Binary:         1111 1111 . 1111 1111 . 1111 1111 . 0000 0000 (/24)
Decimal:           255    .    255    .    255    .     0