CS Engineering Gyan

IP Addressing in Computer Networks

In the previous chapter, we looked at Network Protocols, including DNS, which translates a familiar domain name into the numerical address a browser actually needs to connect to the correct server. That numerical address is called an IP address, and this chapter looks at exactly what an IP address is, how it's structured, and how it allows every single device on a network, from a home laptop to a massive data centre server, to be uniquely identified and reached.

Just as a postal address allows a letter to be delivered to the correct house on the correct street in the correct city, an IP address allows data travelling across a network to be delivered to the correct device, out of potentially billions of other devices connected to the same global internet. Without a consistent addressing system, routers would have no reliable way of knowing where to actually send the data passing through them.


What is an IP Address?

An IP address, short for Internet Protocol address, is a unique numerical label assigned to a device connected to a network, allowing that device to send and receive data correctly. Every device that communicates over a network, whether it's a personal computer, a smartphone, a printer, or a server, needs an IP address so that other devices on the network know exactly where to direct data intended for it. IP addresses are used at the network layer, working alongside the routers discussed in the earlier Network Devices chapter to determine how data actually finds its way from a source device to its intended destination, potentially across many interconnected networks.

There are currently two versions of IP addressing in widespread use: IPv4, the older and still most commonly encountered format, and IPv6, a newer format designed to address some of IPv4's fundamental limitations. Both are explained in detail below.


IPv4 Addressing

IPv4, short for Internet Protocol version 4, is the original and still most widely recognised format of IP addressing. An IPv4 address is 32 bits long, and rather than being written out as a single long string of binary digits, it is conventionally split into four sections of 8 bits each, known as octets. Each of these four octets is converted into its decimal equivalent, ranging from 0 to 255, and the four resulting decimal numbers are written out separated by dots, a format commonly referred to as dotted-decimal notation.

Since each octet is 8 bits long, IPv4 provides a theoretical total of a little over four billion unique addresses. While this may sound like an enormous number, the explosive growth in the number of internet- connected devices worldwide, from computers and phones to smart home devices and industrial sensors, has meant that the total pool of available IPv4 addresses has become increasingly scarce, which is one of the main reasons IPv6 was later introduced.


Classes of IPv4 Addresses

To help organise how the total pool of IPv4 addresses is allocated to networks of different sizes, IPv4 addresses were originally divided into five distinct classes, labelled Class A through Class E, each identified by the value of the very first few bits of the address.

Class A addresses are intended for extremely large networks and reserve only the first octet to identify the network itself, leaving the remaining three octets available to identify individual devices, or hosts, within that network. This allows a huge number of hosts under a relatively small number of Class A networks, making this class suitable for very large organisations.

Class B addresses strike a middle ground, using the first two octets to identify the network and the remaining two octets to identify hosts within it, making it appropriate for medium to large-sized networks, such as those belonging to universities or mid-sized companies.

Class C addresses use the first three octets to identify the network, leaving only the final octet available for identifying hosts. This results in a much larger number of possible networks, but each individual network can only support a comparatively small number of connected devices, making Class C well suited to smaller networks, such as those found in homes or small offices.

Class D addresses are reserved specifically for multicast communication, where a single transmission needs to be delivered simultaneously to a defined group of interested devices, rather than to just one specific destination. Class E addresses are reserved for experimental and research purposes and are not used for standard everyday networking.


Private vs Public IP Addresses

Beyond the class-based grouping, IPv4 addresses are also categorised based on where they can actually be used: private IP addresses and public IP addresses.

A private IP address is used only within a local, internal network, such as a home or office network, and is not directly reachable from the wider internet. Certain specific ranges of addresses have been set aside exclusively for this private use, and because these ranges are not routed across the public internet, the very same private address can safely be reused across countless different private networks around the world without causing any conflict, since each one remains isolated within its own local network.

A public IP address, on the other hand, is globally unique and is directly reachable from anywhere on the internet. When devices on a private home network want to communicate with servers out on the internet, the router connecting that home network to the internet service provider typically uses one single public IP address on behalf of every device inside the home, translating between the internal private addresses and this one external public address. This means an entire household of devices, each with its own private address, can share just one public address when communicating with the outside world.


IPv6 Addressing

IPv6, short for Internet Protocol version 6, was introduced specifically to solve the growing shortage of available IPv4 addresses. While IPv4 uses 32-bit addresses, IPv6 dramatically expands the address space by using 128-bit addresses instead, resulting in a vastly larger number of possible unique addresses, more than enough to comfortably assign a distinct address to every device likely to ever connect to the internet, well into the foreseeable future.

Because a 128-bit address written out in decimal or binary form would be extremely long and difficult for people to work with, IPv6 addresses are instead written using hexadecimal digits, grouped into eight sections separated by colons rather than dots. This hexadecimal, colon-separated format is quite different in appearance from the familiar dotted-decimal format used by IPv4, which is often one of the first things people notice when comparing the two.

Beyond simply offering a larger address space, IPv6 was also designed with some additional improvements in mind, including a simpler address structure intended to make certain routing operations more efficient. Although adoption of IPv6 has been gradual, since many existing systems were originally built around IPv4, its use continues to grow steadily as the pool of available IPv4 addresses becomes increasingly constrained.


How Devices Are Identified Using IP Addresses

Every device on a network relies on its IP address to both send and receive data correctly. When a device sends data intended for another device, it includes both its own IP address and the destination device's IP address within that data. As this data passes through routers on its way to its destination, each router examines the destination IP address to determine the most appropriate next step toward delivering that data, gradually moving it closer to its final destination, one hop at a time, until it finally arrives at the device with the matching IP address.

This addressing system, working together with the network devices and protocols covered in earlier chapters, is what ultimately allows an almost unimaginable number of individual devices scattered across the entire world to reliably locate and communicate with one another over the shared, interconnected system of networks that makes up the modern internet.


Comparison of IPv4 and IPv6

Feature IPv4 IPv6
Address Length 32 bits 128 bits
Format Dotted-decimal, e.g. four numbers separated by dots Hexadecimal, eight groups separated by colons
Total Address Space A little over four billion addresses Vastly larger, sufficient for the foreseeable future
Adoption Older, still the most widely used format Newer, adoption growing steadily

Best Practices While Learning IP Addressing


Common Mistakes Beginners Make

Mistake Correct Practice
Assuming every device on a network needs its own public IP address. Remember that private IP addresses are used internally, while a router usually shares just one public IP address on behalf of many devices.
Mixing up which IPv4 class supports the most hosts per network. Class A supports the largest number of hosts per network, since it reserves only one octet for identifying the network itself.
Thinking IPv6 addresses are just longer versions of IPv4 addresses. IPv6 uses a completely different hexadecimal, colon-separated format, not an extended version of dotted-decimal notation.
Forgetting that private IP addresses can be reused across different networks. Since private addresses are never routed on the public internet, the same private address range can safely be reused inside many separate local networks.

Frequently Asked Interview Questions

  1. What is an IP address?
    An IP address is a unique numerical label assigned to a device on a network, allowing it to send and receive data correctly.
  2. How many bits does an IPv4 address contain?
    An IPv4 address is 32 bits long, typically written as four decimal numbers separated by dots.
  3. What is the difference between a private and a public IP address?
    A private IP address is used only within a local network and is not directly reachable from the internet, while a public IP address is globally unique and directly reachable from anywhere on the internet.
  4. Why was IPv6 introduced?
    IPv6 was introduced to solve the shortage of available IPv4 addresses by using a much larger 128-bit address space instead of the 32-bit space used by IPv4.
  5. What is the main difference between Class A and Class C IPv4 addresses?
    Class A reserves only the first octet for the network, allowing a very large number of hosts per network, while Class C reserves the first three octets, allowing many more networks but far fewer hosts on each one.
  6. What are Class D IP addresses used for?
    Class D addresses are reserved for multicast communication, where a single transmission is delivered to a specific group of devices at once.
  7. How is an IPv6 address written differently from an IPv4 address?
    An IPv6 address is written using hexadecimal digits grouped into eight sections separated by colons, while an IPv4 address is written as four decimal numbers separated by dots.

Summary

IP Addressing is the numbering system that allows every device on a network to be uniquely identified and correctly reached. We looked at IPv4, its dotted-decimal structure, and its five address classes, along with the important distinction between private IP addresses used inside a local network and public IP addresses reachable from the wider internet. We also looked at IPv6, the newer, much larger addressing format introduced to address IPv4's shrinking pool of available addresses.

With a solid understanding of how devices are identified and located on a network, you are now ready to move on to network security, which explains how networks protect the data travelling between these identified devices from unauthorised access and attack.


← Previous: Network Protocols Next: Network Security →

Home Visit Our YouTube Channel