Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, An Introduction to Computer Networking for Teachers. Join the course to learn more.

Internet Protocol (IP) Addresses

Last week, we introduced Ethernet addresses, which are tied to physical devices: the term ‘physical address’ always refers to an Ethernet or similar data link layer address.

Imagine a gigantic worldwide Ethernet network of interconnected switches. For each switch to be able to switch incoming data frames to the correct port, the switch would need to have some sort of list where it can look up the physical address of every connected device in the network.

A switch with a long list of devices

This list would be huge, and it would take a lot of memory storage and processor time to use it and keep it updated. And how would the system cope if a device moved? What about technologies that don’t use Ethernet addresses? It just wouldn’t work!

Internet Protocol (IP) addresses are logical addresses

This is why a new addressing scheme was invented: the IP address system. Like postal addresses, IP addresses are logical addresses: they have a logical structure and provide a set of instructions for reaching a destination.

Take this postal address as an example:

  • 12, Clooney Hill
  • Birmingham
  • UK

It can be read from the bottom up, so a letter with this address would be first sent to the UK, then to Birmingham, and then to the right street and house number.

When IP addresses were invented, in the 1970s, it was decided to make them 32 bits long. 32 bits allow for 4 billion unique addresses, enough so that each person on Earth at the time could have one. We didn’t know how big the interconnected network — or internet — we were building would become!

This 32-bit IP address is usually not written in binary. Instead, it is split into four 8-bit chunks (bytes), and each chunk is converted to decimal. The address is then written in dotted decimal notation, with the four decimal values separated by dots.

So the IP address 11000000101010000000111000010111 becomes:

Binary 11000000 10101000 00001110 00010111
Dotted decimal 192 168 14 23

11000000 10101000 00001110 00010111 = 192.168.14.23

The logical structure of an IP address

Network bits are the initial bits in an IP address. They identify a particular network. The remaining bits are called host bits and identify a device (or ‘host’) in that network.

The first value of an IP address indicates address is split into network bits and host bits. There are three classes of addresses identified by this initial value:

  • Class A uses 8 network bits and 24 host bits
  • Class B uses 16 network bits and 16 host bits
  • Class C uses 24 network bits and 8 host bits

A graphic showing how the 32 bits are split between class A, B and C IP addresses. Class A uses 8 network bits and 24 host bits, for 128 networks each (Not 256 as the leading bit is fixed to be a 0) with 16,777,216 hosts. Class B uses 16 network bits (starting 10) and 16 host bits, for 16,384 networks each with 65,536 hosts. Class C uses 24 network bits (starting 110) and 8 host bits, for 2,097,152 networks, each with 256 hosts.

The more network bits, the more networks can be identified. But more network bits mean fewer host bits, meaning smaller networks.

IP addresses for mobile devices

Mobile devices (including laptops) are automatically given a different IP address each time they join a different network, because the network bits of their address need to identify the new network. Later in the course, you will learn how IP addresses are automatically allocated.

A laptop moves between a house and a cafe. In the middle, its IP address changes as it moves between networks.

The IP packet

Sending data using IP addresses is very similar to sending data using MAC addresses and Ethernet frames:

The source and destination IP addresses are sent first (together with some additional fields you will learn about later). Then follows the actual data to be transmitted. This structure is called an IP packet, and it looks different to an Ethernet frame.

A simplified IP packet, consisiting of "Other header fields", a 4-byte long "Source IP address", a 4-byte long "Destination IP address", and up to 65,553 bytes of Data.

Private IP addresses

Within each IP address class, a specific range is allocated for private IP addresses. That means these addresses can be used many times over on different networks, as long as these networks do not become connected. In class C networks, all networks starting with 192.168. are private.

The future is here now

The current version of IP is version 4 (IPv4). The 32 bits in IPv4 give 4,294,967,296 addresses, but we are running out.

Therefore, IP version 6 (IPv6) has been developed, with 128 bits allocated for each address: a colossal 3.4×1038 (340,282,366,920,938,463,463,374,607,431,768,211,456) addresses.

IPv6 addresses are written in hexadecimal as 32 digits in blocks of four, e.g.:

FE80:CD00:0000:0CDE:1257:0000:211E:729C

IPv6 has been designed to coexist with IPv4, so both systems can run in parallel.

Next step

We’ve now introduced IP addresses and IP packets — how do these coexist with Ethernet addresses and frames? In the next step, we will look at why we still need the Ethernet frames of the data link Layer and how these transport IP packets.

Questions

  • Have we really used up 4 billion IP addresses?
  • How many devices can we have on a 192.168.1.0 network?
  • What can you deduce about a device with an IP address of 130.16.200.11?

Join in the discussion below to share your thoughts.

Share this article:

This article is from the free online course:

An Introduction to Computer Networking for Teachers

Raspberry Pi Foundation