Fundamentals of communication and networking: IP addresses

From Wikibooks, open books for an open world
Jump to navigation Jump to search

PAPER 2 - ⇑ Fundamentals of communication and networking ⇑

← Standard application layer protocols IP address structure Subnet masks →


IP addresses[edit]

Each device connected to the Internet needs a unique address. The design of IP version 4 (IPv4) specified a 32-bit field for this in the IP header. In theory this allows for 232 addresses (4,294,967,296) which, at the time, seemed a big enough address space to allow for future expansion. However due to the way in which the addresses space was structured and allocated, and the unimaginable growth of the Internet, the address space is now depleted.

In preparation for this depletion a new version of IP has been developed and is called IP version 6 (IPv6). This uses 128-bit addressing. As of 2016 both systems are in use, with major new networks using IPv6. However IPv4 is still predominant and will coexist for many more years.

This section will deal with IPv4.

To write out the 32-bit address we don't usually write it in binary. We split it into four 8-bit chunks (bytes) and convert each byte to decimal. We then write the four decimal values with a '.' between them. This is then referred to as dotted decimal notation.

Binary 11000000 10101000 00001110 00010111
Dotted decimal 192 168 14 23

11000000101010000000111000010111 = 192.168.14.23

Exercise: IP addresses
What is the address 00110001 11001100 00000100 11111111 in dotted decimal

Answer:

49.204.4.255
What is the address 172.18.231.47 in binary

Answer:

10101100 00010010 11100111 00101111


IP address structure[edit]

An IP address has structure in a similar way that a postal address has structure. A postal address is a multi-level route to the destination.

10, Popular Road
Newtown
London
UK

This tells us to get to this location we first need to get to the UK, then London, then Newtown then the road. On the road we will find number 10.

IP address have a two-level address. First we have the network address, then the host address and all within the 32-bit address. The network address will be common to all devices connected to a particular network such as a home, an office or a big business. Generally the network is under one administrative control. The network may be divided into sub networks but more of that later. Thus we first have to deliver the packet to the right network and this is the job of a router or routers. Once it is on the right network we can deliver it to the correct host.

The question arises as to how many of the 32 bits we should devote to the network address and how many to the host.

  • 8 bits for the network leaves 24 bits for hosts. This gives us 256 networks each of which can have 16,777,216 hosts.
  • 16 bits for the network leaves 16 bits for hosts. This gives us 65,536 networks each of which can have 65,536 hosts.
  • 24 bits for the network leaves 8 bits for hosts. This gives us 16,777,216 networks each of which can have 256 hosts.

CPT-Network-IPAddressDivision.svg

None of these options are ideal by themselves. We have a few really big networks, many mid-sized networks and many small networks. Thus we adopt all three approaches and define three classes of networks.

Class A,B and C IP addresses[edit]

We use the first bit or bits of the IP address to indicate the class.

CPT-Network-IPv4Classes.svg

Class A addresses start with a binary 0 hence the first byte is in the range 0-127

7 6 5 4 3 2 1 0 Decimal Value
0 0 0 0 0 0 0 0 0
0 * * * * * * * -
0 1 1 1 1 1 1 1 127

Class B addresses start with binary 10 hence the first byte is in the range 128-191

7 6 5 4 3 2 1 0 Decimal Value
1 0 0 0 0 0 0 0 128
1 0 * * * * * * -
1 0 1 1 1 1 1 1 191

Class C addresses start with binary 110 hence the first byte is in the range 192-223

7 6 5 4 3 2 1 0 Decimal Value
1 1 0 0 0 0 0 0 192
1 1 0 * * * * * -
1 1 0 1 1 1 1 1 223
Exercise: IP address classes
What class of address is 192.168.14.11

Answer:

Class C
How many bits are used to specify hosts in the address 180.14.110.240

Answer:

16 bits

Host address field[edit]

For all devices on a given network, the network bits will be the same. The host bits will then be different for each device. With each class of address (A, B or C) we have 8, 16 or 24 bits respectively for hosts, so we can calculate the range of possible host addresses we can have. However, in any network, the first and last addresses are special. The first address (all 0's) is used to refer to the network itself. This is not usable as a destination address but is used in routing protocols. The last address (all 1's) is called the network directed broadcast and can be used to send an IP packet to all devices in the network.

IP Address Class Description
192.168.14.255 Class C Broadcast to the 192.168.14.0 network
184.16.0.0 Class B The 184.16.0.0 network
38.255.255.255 Class A Broadcast to the 38.0.0.0 network
Exercise: IP address
Are the addresses 45.16.253.11 and 45.17.23.10 in the same network ?

Answer:

Yes. They are both class A addresses and have the first 8 bits in common.
One PC with IP address 200.11.32.90 pings another PC with address 200.11.33.45. Will the ping have to travel onto a different network ?

Answer:

Yes. Both addresses are class C but are different in the first 24 bits. Hence they are different networks.


Extension: Subnetting, VLSM and CIDR

A large business with a Class A or B address will probably have many separate subnetworks in their organisation. They subdivide the host field in their allocated address by 'borrowing' bits to create subnetworks. We now ignore the class of the address and have a common new division of the bit structure which is specified with a sunet mask. Research how this works.

When an organisation has subnetted their network, some subnets may need further division. Thus we end up with subnets of varying sizes. We hence have different structures of bits in different networks. Thus we have many different subnet masks, hence the name Variable Length Subnet Masks (VLSM). Research how to do this.

With the structure of the Internet, many companies who own sequential network addresses may all be interconnected and share a common link back towards the core. Thus it is possible to aggregate several addresses together to create 'supernets'. We then have to ignore the class of address and just use the subnet masks. This is called Classless Inter Domain Routing.(CIDR). How has this helped keep the Internet working.