Bachelor of Science in Computer Science
Course ContentIP Addressing
Habari Second Year! Let's Talk about Digital Addresses!
Welcome back to Computer Networks! I hope you're ready for one of the most important topics in this entire course. Think about this: how does a letter sent from Mombasa find its way to your specific P.O. Box at the GPO in Nairobi, and not your friend's box in Eldoret? It's all about the address, right? The postal system needs a unique address to deliver mail.
In the digital world, it's exactly the same! When you watch a video on YouTube, send a WhatsApp message, or browse a website, tiny packets of data are flying across the internet. For these packets to reach your specific phone or laptop and not someone else's, they need a unique address. That magical address is called an IP Address. Today, we are going to become masters of this digital postal system!
Image Suggestion: [A vibrant, futuristic illustration of a digital data packet, glowing with blue light and shaped like a dhow, sailing swiftly on a river of light representing the internet. The destination is a glowing map of Kenya, with major cities like Nairobi, Mombasa, and Kisumu highlighted.]
What Exactly is an IP Address?
An IP Address, which stands for Internet Protocol Address, is a unique numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication.
Think of it like your M-Pesa phone number. For someone to send you money, they need your exact number. It must be unique! An IP address is the network's version of that phone number. It ensures that the data you requested (like a webpage or a video stream) gets delivered precisely to you.
- It's a logical address, meaning it can be changed. It's not permanently burned into the hardware like a MAC address.
- It allows devices to find and talk to each other, whether on a local network (like in your university's computer lab) or across the globe.
- There are two main versions in use: IPv4 (the classic one we will focus on today) and IPv6 (the new, much longer one designed because we were running out of IPv4 addresses!).
Cracking the Code: The Structure of an IPv4 Address
An IPv4 address looks complicated, but it has a very simple structure. It's a 32-bit number, but to make it easy for us humans to read, we write it as four numbers separated by dots. This is called dotted-decimal notation. Each of these four numbers is called an octet, because it represents 8 bits of data.
Example IP Address: 192.168.1.10
Let's break it down:
192 . 168 . 1 . 10
| | | |
(1st Octet) (2nd Octet) (3rd Octet) (4th Octet)
Each octet = 8 bits.
4 octets * 8 bits = 32 bits total.
Computers, however, don't see `192`. They see binary - a series of 1s and 0s. Understanding this is the key to mastering networking! Let's convert our example IP to the language computers speak.
DECIMAL BINARY
192 -> 11000000
168 -> 10101000
1 -> 00000001
10 -> 00001010
So, 192.168.1.10 in binary is:
11000000.10101000.00000001.00001010
Network vs. Host: Who Lives Where?
Every IP address has two parts: a Network ID and a Host ID.
Let's use an analogy. Think of Nairobi County as the Network and your specific plot number in an estate like South C as the Host. Everyone living in South C shares the "Nairobi" part of their address, but each house has a unique plot number. The Network ID identifies the specific network a device is on, while the Host ID identifies the specific device on that network.
But how do we know where the network part ends and the host part begins? That's the job of the Subnet Mask! It's a special 32-bit number that "masks" the IP address to reveal the network and host portions. Where you see 255 (or all 1s in binary), that's the network part. Where you see 0, that's the host part.
IP Address: |--- Network Portion ---|--- Host Portion ---|
+-----------------------+--------------------+
Subnet Mask: |---- All 1s (255s) ----|----- All 0s (0s) ----|
Real-World Scenario: Imagine Zetech University's main campus network. All the computers in the library might be on the `172.16.10.0` network. The network part (`172.16.10`) is the same for all of them. But one PC is `172.16.10.5`, another is `172.16.10.6`, and so on. The `.5` and `.6` are the unique host IDs that distinguish one computer from another within the same "digital estate".
IP Address Classes (The Old School Way)
Originally, IPv4 addresses were divided into "classes" to define the default network and host portions. While we now use a more flexible system called CIDR (Classless Inter-Domain Routing), understanding classes is still fundamental.
- Class A: For massive networks (like a huge ISP like Safaricom). The first octet is for the network, the last three are for hosts. Default Mask: `255.0.0.0`. Range: `1.x.x.x` to `126.x.x.x`.
- Class B: For medium-to-large networks (like a big university or company). The first two octets are for the network. Default Mask: `255.255.0.0`. Range: `128.x.x.x` to `191.x.x.x`.
- Class C: For small networks (like your home Wi-Fi or a small office). The first three octets are for the network. Default Mask: `255.255.255.0`. Range: `192.x.x.x` to `223.x.x.x`.
- Class D & E: Reserved for special uses like multicasting and research.
Private vs. Public IP Addresses: Your Home vs. The World
Not all IP addresses can be used on the public internet. We have two types: Public and Private.
The analogy here is simple. A Public IP is like your official Post Office Box number at Kenya Posta – it's globally unique and anyone in the world can send mail to it. A Private IP is like your specific desk number inside your office building – only people inside your company use it to find you. It's not unique outside your building.
- Public IP: Globally unique, assigned by your Internet Service Provider (ISP) like Safaricom, Zuku, or Faiba. This is your address on the global internet.
- Private IP: Used within a local network (LAN) like your home, school, or office. Your router uses a clever technology called NAT (Network Address Translation) to let all your devices (with private IPs) share its single public IP to access the internet.
These are the ranges reserved for private networks. You've probably seen them before!
10.0.0.0 to 10.255.255.255 (A huge range for large organizations)
172.16.0.0 to 172.31.255.255 (For medium networks)
192.168.0.0 to 192.168.255.255 (Most common for homes and small offices)
Image Suggestion: [A clear diagram showing a home router (labeled 'Zuku/Faiba Router'). It has one cable pointing out to a cloud icon (labeled 'Internet') with a Public IP `41.204.160.5` next to it. On the other side of the router, several devices (a laptop, a smartphone, a smart TV) are connected via Wi-Fi signals. Each device has a Private IP address: Laptop `192.168.1.2`, Phone `192.168.1.3`, TV `192.168.1.4`. Arrows labeled 'NAT' show the translation process.]
Let's Do Some Math! Calculating Network Information
Now for the fun part! Let's take an IP address and its subnet mask and act like network detectives to find out everything about its network.
Problem: Given the IP address 192.168.50.75 with a subnet mask of 255.255.255.0. Find:
- The Network Address.
- The Broadcast Address.
- The total number of usable hosts.
Step 1: Find the Network Address
To find the address of the "digital estate", we perform a bitwise AND operation between the IP address and the subnet mask. Think of the mask as a filter: whatever is under a `1` passes through, whatever is under a `0` is blocked (becomes 0).
Let's focus on the last octet as the others are easy (X AND 255 = X)
IP Address (last octet): 75 -> 01001011
Subnet Mask (last octet): 0 -> 00000000
-------------------------------------------
AND Result (binary): -> 00000000
AND Result (decimal): 0
Full Calculation:
192.168.50.75 AND 255.255.255.0 = 192.168.50.0
Therefore, the Network Address is 192.168.50.0
Step 2: Find the Broadcast Address
The broadcast address is a special address used to send a message to ALL devices on the network simultaneously. It's like a public announcement in the estate. We find it by taking the network address and flipping all the host bits to `1`.
Our network address is 192.168.50.0.
In binary: 11000000.10101000.00110010.00000000
The host portion is the last 8 bits (because the mask is 255.255.255.0).
Let's flip all these host bits to 1:
Broadcast Binary: 11000000.10101000.00110010.11111111
Now, convert that last octet back to decimal:
11111111 -> 255
Therefore, the Broadcast Address is 192.168.50.255
Step 3: Calculate the Number of Usable Hosts
This tells us how many devices (computers, phones, printers) can actually be connected to this network. The formula is simple and very important: 2h - 2, where 'h' is the number of host bits.
1. Total bits in an IPv4 address = 32.
2. Our subnet mask is 255.255.255.0. Let's count the network bits (the 1s):
11111111.11111111.11111111.00000000
That's 8 + 8 + 8 = 24 network bits.
3. Number of host bits (h) = Total bits - Network bits
h = 32 - 24 = 8 host bits.
4. Apply the formula: 2h - 2
= 28 - 2
= 256 - 2
= 254
This network can support 254 usable devices.
"But Teacher, why do we subtract 2?" Excellent question! We always subtract two addresses because they are reserved. The very first address (e.g., `192.168.50.0`) is the Network Address itself (the name of the estate), and the very last one (e.g., `192.168.50.255`) is the Broadcast Address (the public announcement system). You can't assign these to a single device!
Conclusion: You're Now an IP Address Guru!
And there you have it! IP addresses are not so scary after all. They are the logical, organized system that makes our modern internet possible. We've learned that they are the unique digital addresses for our devices, composed of a network and host part, defined by a subnet mask. We now understand the difference between public and private IPs and, most importantly, we can do the math to analyze any network.
This might feel like a lot of numbers, but practice is the key. Go to your phone's Wi-Fi settings, find its IP address and subnet mask, and try to calculate its network and broadcast address. The more you do it, the more it will become second nature. In our next lesson, we will dive deeper into the powerful technique of Subnetting.
Great work today! Keep that curiosity burning. Kwaheri for now!
Pro Tip
Take your own short notes while going through the topics.