IP version 4 Address

Before you start

Objectives: learn what is IP address, how it is constructed, how to convert it between its decimal and binary form, which IP address classes are there, and what is Subnetting.

Prerequisites: no prerequisites

Key terms: address, ip, subnet, network, class, decimal, binary, mask, host, octet, number, value, broadcast, class


Addressing

Each computer on the network must have a unique IP address assigned. IPv4 address are always used together with subnet addresses. Subnet address enables us to tell which part of the IP address is the network address, and which part is the host address. Different hosts on the same network will have the same network address and different host address. When hosts on one network need to communicate with hosts on another network, they need to send their messages to a router (also called Default Gateway). So, routers enable hosts on different networks to communicate. IP address can be assigned manually or dynamically by using DHCP. Related service to IP is a Domain Name System, which resolves logical names to IP addresses.

IP Address Format

IP address is a 32-bit binary number represented as four octets (four 8-bit numbers). Each octet is separated by a period. IP addresses can be represented in decimal or binary notation. In decimal notation, each octet must be between 0 and 255. In binary notation, each octet is an 8-character number. The IP address is a layer 3 address, meaning that it is a logical address associated with a Network layer. The decimal value of some IP address might be 100.100.100.100. IP address is represented as a decimal number because that’s easier for us to work with, but computers use binary numbers. To understand how IP addresses work we need to know about how the binary numbering system works.

Binary to Decimal Conversion

Each position within the IP address is called an Octet. Octet consists of eight binary numbers, or a series of ones and zeros. For example, the decimal number 100 would be represented in binary as 01100100. The whole IP address 100.100.100.100, in binary format would then be 01100100.01100100.01100100.01100100.

An Octet that is all zeros gives us the first possible value which is zero. An Octet that is all ones equals 255. That’s why each octet within the IP address must range between zero and 255. As we work with IP addresses sometimes we will need to convert the decimal form of the IP address to a binary form of the IP address. The easiest way to do this is to memorize the decimal equivalent of each bit within an octet. Let’s look that in a case of Octec with all ones (255 decimal).

Binary:

1

1

1

1

1

1

1

1

Decimal:

128

64

32

16

8

4

2

1

Notice that 1 in the most right position equals a decimal 1. A 1 in the second position equals decimal 2, 1in third position equals decimal 4, fourth position equals decimal 8, fifth position equals decimal 16, and so on. Recognize a pattern in which we’re simply doubling the number that has come before. Now that we know decimal equivalents of binary positions in an Octet, we can easily convert binary number to decimal. To do that we simply need to sum up all decimal values where there is 1 in the binary representation. In the case of 11111111 we have to add 128+64+32+16+8+4+2+1, which equals 255.

Let’s take a look at our other example, which is 01100100.

Binary:

0

1

1

0

0

1

0

0

Decimal:

128

64

32

16

8

4

2

1

Remember, we need to sum up decimal values which have 1 in the binary representation. So in this case we have to sum 64+32+4, which equals 100. To be more accurate, we actually add zero wherever there’s a zero in the binary form. So we actually add 0+64+32+0+0+4+0+0, which equals 100 again.

Let’s take another example, 10000011 and convert this binary number to decimal.

Binary:

1

0

0

0

0

0

1

1

Decimal:

128

64

32

16

8

4

2

1

Again, every time we have a 1 in binary, we take the decimal equivalent. In this case that is 128+0+0+0+0+0+2+1, or simply 128+2+1, which equals 131.

Decimal to Binary Conversion

To convert from decimal to binary, the process is in reverse. We start with the number as a possible value and working from the left we check if the numbers fit within the decimal value that we have. Let’s look at an example of 100 in decimal, which we want to convert to binary.

Number: 100
Decimal:

128

64

32

16

8

4

2

1

Binary:

First step is to check if 128 fits in 100. It doesn’t, so we put 0 in that position.

Number: 100
Decimal:

128

64

32

16

8

4

2

1

Binary:

0

Then we check if 64 fits in 100. It does, so we put 1 in that position. We also have to subtract 64 from 100, which is 36. Now we work with 36.

Number: 100-64=36
Decimal:

128

64

32

16

8

4

2

1

Binary:

0

1

Next, we check if 32 fits in 36. It does, so we put 1 in that position. We also subtract 32 from 36, which is 4. Now we work with 4.

Number: 100-64=36, 36-32=4
Decimal:

128

64

32

16

8

4

2

1

Binary:

0

1

1

Next, we check if 16 fits in 4. It doesn’t, so we put zero in that position. The same thing is with 8. We still work with number 4.

Number: 100-64=36, 36-32=4
Decimal:

128

64

32

16

8

4

2

1

Binary:

0

1

1

0

0

Next, 4 fits in 4, so we put 1 in that position. We also have to subtract 4 from 4, which is zero.

Number: 100-64=36, 36-32=4, 4-4=0
Decimal:

128

64

32

16

8

4

2

1

Binary:

0

1

1

0

0

1

Since now we work with zero, there is no chance that any number will fit it anymore. Therefore, we can write zeros in all remaining positions.

Number: 100-64=36, 36-32=4, 4-4=0
Decimal:

128

64

32

16

8

4

2

1

Binary:

0

1

1

0

0

1

0

0

So, the decimal 100 is the 01100100 in binary.

Subnet Mask

The IP address actually includes two different address, the subnet address and the host address. Part of the IP address identifies the subnet, and the other part identifies the host. To identify which part is the subnet address, and which part is the host address we use a Subnet Mask. A Subnet Mask looks like an IP address, since it has four octets as well. The Subnet Mask is designed to be used in conjunction with the IP address. The job of the subnet mask is to identify which portion of the IP address is the subnet address and which is the host address. Let’s look at an example of IP address and a Subnet Mask.

IP address:

150

150

100

100

Subnet Mask:

255

255

0

0

The thing is, wherever we see 255 we know that that particular octet is part of the network (subnet) address. So in our example, the subnet address is 150.150.0.0, while the host address is 100.100. We can have multiple hosts on the same subnet, and each host has to have a different host address. All hosts on the same subnet would share the same subnet address and would have unique host addresses.

Let’s say that we modify the Subnet Mask to include 255 in the third octet.

IP address:

150

150

100

100

Subnet Mask:

255

255

255

0

The subnet address is any octet, again, that has a value of 255 in Subnet Mask, which now gives us a subnet address of 150.150.100.0. In this case, the host address is simply 100. To understand how a subnet mask works let’s convert the 255 into binary, which is 11111111 or eight ones. A Subnet Mask on a binary level means that the values have been set to one for each bit position, giving us a decimal value of 255. It is possible to vary the Subnet Mask by using zeros instead of ones, which is called advance subnetting, and we’ll talk about that in another article. For now just be aware that a full octet of ones in the subnet mask is 255, which identifies an octet in IP address as a part of the network address.

To configure a network device, supplying just the IP address is not enough. The device needs to know which part of the address identifies the network (subnet) and which part identifies the host. For this reason we will typically supply the subnet mask in addition to the IP address.

IP Address Classes

IP addresses have what is called a default subnet mask, which is identified by the address class. IP addresses are divided into classes, each class having a default IP subnet mask. There are five IP address classes: A, B, C, D, and E. The IP addresses that fall into each class is identified by looking at the first octet in an IP address. So, to find the IP address class we simply look at the number in the first octet. The remaining numbers can be ignored for the purpose of identifying the address class.

Class A

Class A address in the first octet has a value between one 1 and 126. The default Subnet Mask associated with class A is 255.0.0.0. There are only 126 Class A network IDs. Each class A address gives us 16777214 hosts per network.

Class B

Class B address has a value of 128 to 191. It’s subnet mask is 255.255.0.0. There are 16384 Class B network IDs. Each class B address gives us 65534 hosts per network.

Class C

A class C address begins at 192 and goes up to 223, and it’s default Subnet Mask is 255.255.255.0. There are 2097152 Class C network IDs. Each class C address gives us 254 hosts per network.

Class D and E

These classes are used for special addresses, so they are not used to assign to hosts. They also don’t have a default subnet mask. Still, they have an address range. Class D addresses are between 224 and 239, and class E is 240 to 255. Class D addresses are what are called Multicast addresses. A Multicast address identifies multiple computers rather than a single host. Hosts may have multicast addresses assigned to them, but they will not be used for normal communication, since every host has to have a unique host IP address. Class E addresses are experimental.

Let’s determine an address class, default Subnet Masks, network (subnet) address and host address. The IP address is 100.100.100.100. What is the address class of that IP address? Remember, to find that out we look at the first octet and find the number range where the address fits. In our case 100 fits between 1 and 126, so this is a class A address. What is the default mask for that address? It is 255.0.0.0 for class A addresses, which is one octet full of ones. Next question is what is the subnet address for this IP address? When we look at the Subnet Mask we know that the first octet is used for the network address, giving us a network address of 100.100.0.0. Finally, what is the host address? It is 100.100.

Let’s do the same thing with the IP address 150.150.100.100. The class is B, since the number in first Octet lies between 128 and 191. The default Subnet Mask for class B addresses is 255.255.0.0. Because of the Subnet Mask, we know that the network address is 150.150.0.0, and the host address is 100.100.

Classes in Binary

If we take the first octet and convert it into binary, a class A address always begins with a zero and is followed by seven additional values (00000001-01111110), last value being 0 (to get 126, and not 127). A class B address begins with a 1 followed by a zero, followed by six additional characters (10000000-10111111). Class C address begins with two 1, followed by a zero, and then five additional characters (11000000–11011111). So if we can’t remember decimal boundaries between classes, we can remember the binary equivalent and then convert those to the decimal. It might be easier, or it might be easier to try to remember these ranges.

Special IP addresses

We need to understand special addresses when we’re assigning IP addresses to hosts on the network. To understand these special addresses let’s look at an example. We will use the IP address 200.150.100.50. This is a class C address because the first Octet falls within the range of 192 and 223. The default subnet mask is 255.255.255.0. The first address is the subnet address, which is 200.150.100.0. This address identifies the network or the subnet, and when we’re assigning addresses to hosts we do not use the subnet address to assign to a specific host. Another special address is called the Broadcast address. The Broadcast address is the network address followed by a host portion of all ones (255 decimal), which is 200.150.100.255 in our case. The Broadcast address indicates all hosts on the subnet. For instance, if we had a network with 10 devices and we send a broadcast packet, all devices on that network would receive and process that packet. The Broadcast address might also be designated by setting each of the network address bits to 0. For example, 0.0.0.255 is the broadcast address of a Class C address. This designation means “the broadcast address for this network.”

Let’s take another example, on IP address 150.150.100.100. This is class B address since the first Octet falls between 128 and 192. The subnet Mask is 255.255.0.0, so the network address is 150.150.0.0. Now we need to fill both host Octets with ones on a binary level, giving us 255.255 in decimal. The whole Broadcast address is then 150.150.255.255. Just like the network address we can not assign the Broadcast address to a host.

In the case of 200.150.100.0 network address, the possible values that we can assign to hosts on that network would be from 200.150.100.1 up to 200.150.100.254. Remember that we cannot assign the first address or the last address to hosts. In the case of class B network address 150.150.0.0, the host range would be 150.150.0.1 all the way up to 150.150.255.254.

When we talked about the default address classes you may have noticed that a class A address was between one and 126, while a class B address began at 128 up to 191. So what about this value right in the middle which is 127? 127 is another special address. In this case, the 127 address range is used to identify the local host. A common address you’ll see is 127.0.0.1, and what that means is “this host”. So if we’re working at a computer and we type in the address 127.0.0.1 we use the IP protocol on the same computer and we actually contact ourselves. This is useful in troubleshooting or some other cases when we want to access a service by using an IP address.

IANA

Because all IP addresses on a network must be unique, and because the Internet is a very large network, IP addresses on the Internet are assigned through a central managing authority. The Internet Assigned Numbers Authority, or IANA, is responsible for assigning IP addresses to hosts on the Internet (public addressing). But when we need an IP address to connect to the Internet we don’t actually go to IANA. Instead, IANA delegates a range of addresses to what are known as regional Internet registries, or RIRs. RIRs further allocate ranges of IP addresses to Internet Service Providers, or ISPs. When we need to connect our host directly to the Internet we can go to our ISP and request one or more IP addresses. The ISP, because it has received its range from the RIR and IANA ensures that the IP address we use is unique between all other hosts on the internet.

Subnetting

Subnetting is the process of dividing a large network into smaller networks. When we subnet a network, each network segment (called a subnet) has a different network address (also called a subnet address). In practice, the terms network and subnet are used interchangeably to describe a physical network segment with a unique network address. From a physical standpoint, subnetting is necessary because all network architectures have a limit on the number of hosts allowed on a single network segment. As our network grows, we will need to create subnets (physical networks) to increase the number of devices that can be added to the LAN (to overcome the architecture limits), to reduce the number of devices on a single subnet so that we reduce congestion and collisions, to reduce the processing load placed on computers and routers or to combine networks with different media types within the same internetwork (subnets can not be used to combine networks of different media type on to the same subnet).

Subnetting is also used to efficiently use the available IP addresses. Subnetting provides a way to break the single class network ID into multiple network IDs. Subnetting uses custom rather than the default Subnet Masks. For example, instead of using 255.0.0.0 with a Class A address, you might use 255.255.0.0 instead. Using custom Subnet Masks is often called classless addressing because the Subnet Mask cannot be inferred simply from the class of a given IP address. The address class is ignored and the mask is always supplied to identify the network and host portions of the address. When we subnet a network by using a custom mask, we can divide the IP addresses between several subnets. However, we also reduce the number of hosts available on each network. It is possible to use subnet masks that do not use an entire octet. For example, the mask 255.255.252.0 uses six extra binary bits in the third octet.

While subnetting divides a large address space into multiple subnets, supernetting combines multiple smaller network addresses into a single larger network. For example, this allows multiple Class C addresses to be combined into a single network. Classful addresses are IP addresses that use the default subnet mask. They are classful because the default subnet mask is used to identify the network and host portions of the address. Classless addresses are those that use a custom mask value to separate network and host portions of the IP address. Using classless addresses is made possible by a feature called Classless Inter-Domain Routing (CIDR). CIDR allows for non-default subnet masks (variable length subnet mask or VLSM). When we use a CIDR notation with IPv4 address, we actually specify the number of bits that are being used for network address. For example, the CIDR notation of the 255.255.255.0 subnet mask would be /24 (in binary: 11111111.11111111.11111111.00000000 – 24 consecutive ones in first three octets). A bit more complicated example is a CIDR notation of /25, which means the subnet mask of 255.255.128.0 (in binary: 11111111.11111111.10000000.0000000 – extra bit in the third octet).

Public vs Private IPv4 Addresses

Addresses which are used on the Internet are public addresses. Public addresses can be routed on IP networks. Private addresses can only be used in private networks, like our home or company network. Hosts on the private network do not use the public address in local communication. Public address is only used in communication with the public network like the Internet. This is usually implemented by using the Network Address Translation service (NAT), which enables us to use one public IP address and share it with all hosts on our private network when they need to communicate on the public network.

There are four private address ranges that are reserved by IANA for the purpose of private addressing. The ranges are:

  • 10.0.0.0 /8
  • 172.16.0.0 /12 to 172.31.255.255 /12
  • 192.168.0.0 /16
  • 169.254.0.0 /16 – this is used for Automatic Private IP Addressing (APIPA) feature in Windows. This range should not be used manually. This range is used automatically if our hosts can’t get an IP address from the DHCP server.

Remember

IP address is a 32-bit binary number represented as four octets. In decimal notation, each octet must be between 0 and 255. Subnet Mask is used to identify which part of the IP address is the subnet address, and which part is the host address. There are five IP address classes: A, B, C, D, and E. Class A address in the first octet has a value between one 1 and 126. The default Subnet Mask associated with class A is 255.0.0.0. Class B address has a value of 128 to 191. It’s subnet mask is 255.255.0.0. A class C address begins at 192 and goes up to 223, and it’s default Subnet Mask is 255.255.255.0. Class D addresses are what are called Multicast addresses. Class E addresses are experimental. The first address in an address range is used to identify the network itself. For the network address, the host portion of the address contains all 0’s. The last address in the range is used as the broadcast address and is used to send messages to all hosts on the network. In binary form, the broadcast address has all 1’s in the host portion of the address. Each host must have a unique IP address. Each host on the same network must have an IP address with a common network portion of the address. This means that we must use the same subnet mask when configuring addresses for hosts on the same network. When assigning IP addresses to hosts, be aware that you cannot use the first or last addresses in the range (these are reserved for the network and broadcast addresses respectively). Addresses in the 127.0.0.0 range are reserved to refer to the local host (in other words “this” host or the host you’re currently working at). The most commonly-used address is 127.0.0.1 which is the loopback address. The Internet Assigned Numbers Authority (IANA) manages the assignment of IP addresses on the Internet.

1 thought on “IP version 4 Address”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: