The world of networking is often misunderstood as just a Wi-Fi signal on your phone or an Ethernet cable for your computer. However, from a technical standpoint, it is much more than that—it's an intricate web of hardware and software that connects people, businesses, and even entire continents. At the heart of this complex system lies the IP protocol, which serves as a fundamental element for how data moves across networks. In this article, we will dive deep into the concepts of IP addresses, subnet masks, and subnetting to unravel the mechanics behind network communication.
1. What is the IP Protocol?
Before addressing what the IP protocol is, let's first define what a network is. To the average person, a network might just seem like a Wi-Fi signal or a cable connecting their devices. But academically speaking, a network is a collection of hardware and software that forms a communication system, enabling interactions across oceans and continents.
The IP (Internet Protocol) is one of the foundational protocols in the suite of networking protocols and resides at the network layer of the OSI model. There are different versions of the IP protocol, with the most important ones being IPv4 and IPv6. Although IPv4 is the most widely used today, IPv6 is expected to eventually replace it. This article will focus on the IPv4 protocol.
Being a protocol, IP establishes standards for how devices communicate over a network. Instead of exploring the entire protocol in detail, which would be too lengthy, we will focus on two key aspects: IP addresses and subnetting. If you're interested in reviewing the full IPv4 protocol specifications, you can refer to RFC 791, published by IETF in September 1981.
The IP protocol was designed under the assumption that network infrastructure is unreliable—due to issues like weather interruptions or power outages—and operates on a dynamic basis, without centralized monitoring or control. Consequently, the IP protocol only guarantees the "best effort" delivery of data packets, leading to potential issues like:
Data corruption or loss: A message sent from Nanjing to Shanghai may lose some packets due to a fiber cut in Suzhou, causing only 9 out of 10 messages to arrive.
Data misordering or duplication: The recipient in Shanghai may receive packets out of order or even duplicate packets.
Since IP only focuses on delivering the packets, ensuring data accuracy is handled by higher layers of the OSI model, such as the Transmission Control Protocol (TCP), which we'll discuss later.
2. IP Addresses
An IP address is a 32-bit binary number, for example, 11000000 10101000 00000001 00000011
. To make it easier for humans to read and remember, it is often represented in a dotted-decimal format, like 198.168.1.89
. IP addresses allow the identification of up to 4,294,967,296 (2^32) devices. According to RFC 791, IP addresses have two key purposes: locating a device and identifying where it is. In simple terms, it answers the question: "Where is this device located?"
To manage and locate these addresses efficiently, IP addresses are categorized into five classes: A, B, C, D, and E. Since Class D is used for multicast addresses and Class E is reserved for future use, we will focus on Classes A, B, and C.
IP addresses are structured into three parts: Network Identifier, Network Number, and Host Number—this is a key concept to grasp.
For example, with Class B addresses, the higher bits are fixed at 10
, which serves as the network identifier. The next 14 bits represent the network number, while the last 16 bits identify the specific host. This segmentation allows for efficient management and addressing within a network. The table below summarizes the categorization of IP addresses:
Description | Class A | Class B | Class C |
---|---|---|---|
Network Identifier | 0 | 10 | 110 |
IP Range | 0.0.0.0 – 127.255.255.255 | 128.0.0.0 – 191.255.255.255 | 192.0.0.0 – 223.255.255.255 |
Usable IP Range | 1.0.0.1 – 127.255.255.254 | 128.0.0.1 – 191.255.255.254 | 192.0.0.1 – 223.255.255.254 |
Number of Networks | 126 | 16,384 | 2,097,152 |
Hosts per Network | 16,777,214 | 65,534 | 254 |
Each class has a specific network identifier and host identifier, which determines the range and number of hosts that can be supported within that network.
3. Subnetting
In practical applications, it is uncommon for organizations to need a network that can accommodate over 65,000 devices (as in a Class B network). Additionally, having such large networks can result in inefficiencies in data transmission. Therefore, subnetting is used to divide a network into smaller, more manageable segments, similar to how a city might be divided into districts.
To achieve subnetting, we introduce the concept of a subnet mask. Like an IP address, a subnet mask is a 32-bit binary number, typically consisting of a continuous block of 1
s followed by 0
s. For example, the IP address 189.10.90.20/20
means the subnet mask consists of 20 1
s (255.255.240.0
in decimal). The remaining 12 bits are used to identify the specific host within the subnet, which allows for 4,092 hosts (2^12 - 2).
3.1. Determining If Two IPs Are on the Same Network
If two IPs have the same subnet mask, how can we tell if they are on the same subnet? By performing a bitwise AND operation between the IP address and the subnet mask. If the results are identical, the IPs are on the same network and can communicate directly. For example:
IP Address | Subnet Mask Calculation | Result |
---|---|---|
189.10.90.20 | 189.10.90.20 & 255.255.240.0 | 10111101 00001010 01000000 |
189.10.200.20 | 189.10.200.20 & 255.255.240.0 | 10111101 00001010 11000000 |
189.10.202.20 | 189.10.202.20 & 255.255.240.0 | 10111101 00001010 11000000 |
As you can see, 90.20
and 200.20
are not in the same network, but 200.20
and 202.20
are, meaning they can communicate directly.
3.2. Default Subnet Masks
Each IP class has its default subnet mask:
Class | Subnet Mask |
---|---|
Class A | 255.0.0.0 (Decimal: 8) |
Class B | 255.255.0.0 (Decimal: 16) |
Class C | 255.255.255.0 (Decimal: 24) |
4. Private IP Addresses
According to RFC 1918, some addresses are reserved for private use and cannot be routed on the public internet. These private addresses are used for internal communications within a home or organization and include:
Class | Range | Subnet Mask | Number of IPs |
---|---|---|---|
Class A | 10.0.0.0 – 10.255.255.255 | 10.0.0.0/8 | 16,777,216 |
Class B | 172.16.0.0 – 172.31.255.255 | 172.16.0.0/12 | 1,048,576 |
Class C | 192.168.0.0 – 192.168.255.255 | 192.168.0.0/16 | 65,536 |
These addresses are commonly used in local area networks (LANs) and other private networks.