IP address: principle, use, writing

IP address principle use writing

The IP address is a numerical code used to uniquely identify a device connected to a network, and in particular to the Internet. Exactly like a telephone number that identifies a correspondent.

On the Internet, computers communicate with each other using the IP protocol (Internet-Protocol), which uses numeric addresses, called IP addresses, composed of 4 whole numbers (4 bytes) between 0 and 255 and noted in the form xxx.xxx.xxx.xxx. For instance, 194.153.205.26 is an IP address given in a technical form.

These addresses are used by computers on the network to communicate with each other, so each computer on a network has a unique IP address on this network.

This is ICANN (Internet Corporation for Assigned Names and Numbersreplacing the IANA, Internet Assigned Numbers Agencysince 1998) which is responsible for assigning public IP addresses, i.e. the IP addresses of computers directly connected to the public Internet network.

Decrypting an IP address

A IP adress is a 32-bit address, usually denoted as 4 dot-separated integers. There are actually two parts to the IP address:

  • part of the numbers on the left denotes the network is is called Network ID (in English netID),
  • The numbers on the right denote the computers in this network is is called Host ID (in English host-ID).

Take the example below:

Note the left network 194.28.12.0. It contains the following computers:

  • 194.28.12.1 to 194.28.12.4

Note the one on the right 178.12.0.0. It includes the following computers:

  • 178.12.77.1 to 178.12.77.6

In the above case, the networks are denoted 194.28.12 and 178.12.77then each of the computers constituting it is numbered incrementally.

Imagine a noted network 58.0.0.0. Computers on this network may have IP addresses ranging from 58.0.0.1 at 58.255.255.254. It is therefore a question of allocating the numbers in such a way that there is an organization in the hierarchy of computers and servers.

Thus, the smaller the number of bits reserved for the network, the more computers it can contain.

Indeed, a network noted 102.0.0.0 can contain computers whose IP address can vary between 102.0.0.1 and 102.255.255.254 (256*256*256-2=16777214 possibilities), while a network noted 194.26 can only contain computers whose IP address will be between 194.26.0.1 and 194.26.255.254 (256*256-2=65534 possibilities), this is the notion of IP address class.

Special addresses

When you cancel the host-id part, i.e. when you replace the bits reserved for network machines with zeros (for example 194.28.12.0), we get what is called thenetwork address. This address cannot be assigned to any computer on the network.

When the netid part is canceled, i.e. when the bits reserved for the network are replaced by zeros, we get themachine address. This address represents the machine specified by the host-ID which is on the current network.

When all the bits of the host-id part are at 1, the address obtained is called thebroadcast address (in English broadcasting). This is a specific address, allowing a message to be sent to all the machines located on the network specified by the netID.

Finally, the address 127.0.0.1 is called loopback address (in English loop back), because it designates the local machine (in English localhost).

Classes of networks

In the original ip network definition system, IP addresses were divided into classes, according to the number of bytes representing the network, itself determined by the first bits of the ip address:
Today this system has been replaced by CIDR in the mid-1990s.
At that time, there were 3 classes for unicast addresses, a class for multicast addresses, class D and an unused class E:

Class A

In a Class A IP address, the first octet represents the network.

The most significant bit (the first bit, the one on the left) is zero, which means that there are 2^7 (00000000 to 01111111) network possibilities, or 128 possibilities. However, network 0 (bits equal to 00000000) does not exist and the number 127 is reserved to designate your machine.

The networks available in class A are therefore the networks ranging from 1.0.0.0 at 126.0.0.0 (the last bytes are zeros which indicates that these are indeed networks and not computers!)

The three bytes on the right represent the computers on the network, so the network can contain a number of computers equal to:
2^24-2^1 = 16777214 computers.

A Class A IP address, in binary, looks like this:

0xxxxxxxxxxxxxxxxxxxxxxxxxxxx
NetworkComputers

Class B

In a class B IP address, the first two octets represent the network.

The first two bits are 1 and 0, which means that there are 2^14 (10 000000 00000000 to 10 111111 11111111) possible networks, or 16384 possible networks. The networks available in class B are therefore the networks ranging from 128.0.0.0 at 191.255.0.0

The two octets on the right represent the computers on the network. The network can therefore contain a number of computers equal to:
2^16-2^1 = 65534 computers.

A class B IP address, in binary, looks like this:

10xxxxxxxxxxxxxxxxxxxxxxxxxxx
NetworkComputers

Class C

In a class C IP address, the first three octets represent the network. The first three bits are 1,1 and 0, which means that there are 2^21 network possibilities, i.e. 2097152. The networks available in class C are therefore the networks ranging from 192.0.0.0 at 223.255.255.0

The right byte represents the computers on the network, so the network can contain:
2^8-2^1 = 254 computers.

A class C IP address, in binary, looks like this:

110xxxxxxxxxxxxxxxxxxxxxxxxx
NetworkComputers

Allocation of IP addresses

The purpose of dividing IP addresses into three classes A, B and C is to make it easier to find a computer on the network. In fact, with this notation, it is possible to first search for the network you wish to reach, then to search for a computer on it. Thus, the allocation of IP addresses is done according to the size of the network.

ClassNumber of possible networksMaximum number of computers on each
HAS12616777214
B1638465534
VS2097152254

Class A addresses are reserved for very large networks, while class C addresses are assigned to small corporate networks, for example.

Reserved IP addresses

It often happens in a company or an organization that a single computer is connected to the Internet, it is through it that the other computers on the network access the Internet (we generally speak of a proxy or gateway).

In this case, only the computer connected to the Internet needs to reserve an IP address with ICANN. However, the other computers still need an IP address to be able to communicate with each other internally.

Thus, ICANN has reserved a handful of addresses in each class to enable an IP address to be assigned to computers on a local network connected to the Internet without the risk of creating IP address conflicts on the network of networks. These are the following addresses:

  • Class A private IP addresses: 10.0.0.1 to 10.255.255.254, allowing the creation of large private networks comprising thousands of computers.
  • Class B private IP addresses: 172.16.0.1 to 172.31.255.254, allowing to create medium-sized private networks.
  • Class C private IP addresses: 192.168.0.1 to 192.168.255.254, for setting up small private networks.

netmask

To understand what a subnet mask is, it may be interesting to consult the “assembler” section which talks about masking in binary

In summary, we make a mask containing 1s at the locations of the bits that we want to keep, and 0s for those that we want to cancel. Once this mask has been created, all you have to do is make a logical AND between the value you want to mask and the mask in order to keep the part you want intact and cancel the rest.

Thus, a network mask (in English netmask) is in the form of 4 bytes separated by dots (like an IP address), it includes (in its binary notation) zeros at the bit level of the IP address that we want to cancel (and 1s at level of those that we wish to keep).

Benefit of a subnet mask

The first interest of a subnet mask is to simply identify the network associated with an IP address.

Indeed, the network is determined by a certain number of bytes of the IP address (1 byte for class A addresses, 2 for class B addresses, and 3 bytes for class C). However, a network is noted by taking the number of bytes which characterizes it, then by completing with 0. The network associated with the address 34.56.123.12 is for example 34.0.0.0because it is a Class A IP address.

To find out the network address associated with the IP address 34.56.123.12it is therefore sufficient to apply a mask whose first byte contains only 1s (i.e. 255 in decimal notation), then 0s on the following bytes.
The mask is: 11111111.00000000.00000000.00000000
The mask associated with the IP address 34.208.123.12 is therefore 255.0.0.0.
The binary value of 34.208.123.12 is: 00100010.11010000.01111011.00001100
A logical AND between the IP address and the mask thus gives the following result:

00100010.11010000.01111011.00001100         
  ET
11111111.00000000.00000000.00000000  
  =    
00100010.00000000.00000000.00000000

That is 34.0.0.0. This is the network associated with the address 34.208.123.12

By generalizing, it is possible to obtain the masks corresponding to each class of address:

  • For an address of Class A, only the first byte should be kept. The mask has the following shape 11111111.00000000.00000000.00000000that’s to say 255.0.0.0 in decimal notation;
  • For an address of Class Bthe first two bytes should be kept, resulting in the following mask 11111111.11111111.00000000.00000000corresponding to 255.255.0.0 in decimal notation;
  • For an address of Class Cwith the same reasoning, the mask will have the following form 11111111.11111111.11111111.00000000that’s to say 255.255.255.0 in decimal notation

Creating Subnets

Let’s take the example of the network 34.0.0.0 again, and suppose that we want the first two bits of the second byte to designate the network.
The mask to apply will then be:

11111111.11000000.00000000.00000000

i.e. 255.192.0.0

If we apply this mask, at the address 34.208.123.12 we obtain:

34.192.0.0

In reality there are 4 possible scenarios for the result of masking an IP address of a computer on the 34.0.0.0 network

  • Either the first two bits of the second byte are 00in which case the masking result is 34.0.0.0
  • Either the first two bits of the second byte are 01in which case the masking result is 34.64.0.0
  • Either the first two bits of the second byte are 10in which case the masking result is 34.128.0.0
  • Either the first two bits of the second byte are 11in which case the masking result is 34.192.0.0

This masking therefore divides a class A network (which can accommodate 16,777,214 computers) into 4 subnets – hence the name subnet mask – being able to admit 2^22 computers, that is to say 4,194,304 computers.

The number of subnets depends on the number of additional bits assigned to the network (here 2). The number of subnets is therefore:

Number of bitsNumber of subnets
12
24
38
416
532
664
7128
8 (impossible for a C class)256

ccn1