🌐 Internet Protocol (IP) Masterclass
A/L ICT Chapter 06 | Data Communication & Networking
What is an IP Address?
Theory: A unique logical address assigned to every device on an IP network. It allows devices to identify each other and communicate.
Example: Just like your house has a postal address (No. 25, Main Street) for the post office, a computer has an IP (e.g., 192.168.1.20) for routers to deliver data.
IPv4 Structure (32-bit)
Theory: IPv4 is a 32-bit logical address divided into 4 equal parts called octets (8 bits each). Each octet ranges from 0 to 255 in decimal.
192 . 168 . 10 . 25 │ │ │ │ Oct1 Oct2 Oct3 Oct4
Binary: 11000000.10101000.00001010.00011001
Network ID vs Host ID
Network ID: Identifies the specific network (like the street name). All devices on the same LAN share this.
Host ID: Identifies the individual device (like the house number).
Example: In 192.168.1.20, if the network is 192.168.1, then the Host ID is 20.
Rules for Valid IPv4
- Must contain exactly four octets.
- Each octet must be between 0 and 255.
- Must be unique within the same network (otherwise, IP conflict occurs).
Special IPv4 Addresses
- Network Address: Host ID is all 0s (e.g.,
192.168.1.0). Represents the network itself. - Broadcast Address: Host ID is all 1s (e.g.,
192.168.1.255). Sends data to all devices. - Loopback:
127.0.0.1. Used to test the local TCP/IP stack. - Unspecified:
0.0.0.0. Represents an unknown address during startup.
Types of Communication
- Unicast: One-to-One (e.g., Sending an email).
- Broadcast: One-to-All (e.g., ARP request in a LAN).
- Multicast: One-to-Many/Selected Group (e.g., Live online lecture).
IPv4 Address Classes
| Class | 1st Octet | Default Mask | Use |
|---|---|---|---|
| A | 1 – 126 | 255.0.0.0 (/8) | Large Networks |
| B | 128 – 191 | 255.255.0.0 (/16) | Medium Networks |
| C | 192 – 223 | 255.255.255.0 (/24) | Small Networks |
| D | 224 – 239 | N/A | Multicast |
| E | 240 – 255 | N/A | Experimental |
Subnet Mask & CIDR
Theory: A 32-bit number that separates the Network ID (1s) from the Host ID (0s).
CIDR Notation: A shorter way to write the mask by counting the 1s.
255.0.0.0= /8 (8 ones)255.255.0.0= /16 (16 ones)255.255.255.0= /24 (24 ones)
Public vs Private IP
Public IP: Globally unique, assigned by ISP, accessible on the Internet.
Private IP: Used only inside a LAN. Cannot be routed on the Internet.
Private Ranges:
- Class A:
10.0.0.0to10.255.255.255 - Class B:
172.16.0.0to172.31.255.255 - Class C:
192.168.0.0to192.168.255.255
Static vs Dynamic & DHCP (DORA)
Static IP: Manually configured, permanent (used for servers).
Dynamic IP: Automatically assigned by a DHCP server.
DHCP DORA Process:
- D - Discover: Client broadcasts looking for a DHCP server.
- O - Offer: Server offers an available IP.
- R - Request: Client requests to use that IP.
- A - Acknowledge: Server confirms and finalizes the lease.
NAT (Network Address Translation)
Theory: Translates multiple Private IPs inside a LAN into a single Public IP for Internet access. Conserves public IPv4 addresses and adds security by hiding internal IPs.
IPv6 Structure
Theory: Uses 128-bit addresses divided into 8 groups of 16 bits, written in Hexadecimal and separated by colons (:).
Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Simplification Rules:
- Remove leading zeros:
0db8→db8 - Replace continuous zeros with
::(only once):2001:db8::1
IPv4 vs IPv6 Comparison
| Feature | IPv4 | IPv6 |
|---|---|---|
| Size | 32-bit | 128-bit |
| Format | Decimal | Hexadecimal |
| Addresses | ~4.3 Billion | Virtually Unlimited |
| Security | Optional | Built-in (IPsec) |
| Configuration | Manual/DHCP | Auto-configuration |
Routing, Gateway & TTL
Router: Connects different networks and forwards packets based on IP addresses using a Routing Table.
Default Gateway: The router's IP that a device uses to communicate with outside networks (e.g., the Internet).
TTL (Time To Live): A value in the IP header that decreases by 1 at each router. Prevents packets from looping endlessly. Discarded when it reaches 0.
DNS, ARP & ICMP
- DNS (Domain Name System): Resolves human-friendly domain names (
www.google.com) into IP addresses. - ARP (Address Resolution Protocol): Maps a known IP address to an unknown MAC address within a local LAN.
- ICMP: Used for error reporting and diagnostics. Tools include Ping (tests reachability) and Traceroute (shows the path taken).
Complete IP Communication Journey
Example: Opening www.google.com
- 1. DNS: Browser asks DNS for Google's IP.
- 2. TCP: Connection established with the server.
- 3. IP Packet: Source/Dest IPs added.
- 4. ARP: Finds the MAC address of the Default Gateway.
- 5. Routing: Routers forward the packet across the Internet.
- 6. Response: Google server sends data back.
Important A/L Short Questions
Q: What is an IP address?
A: A unique logical address assigned to a device for identification and communication over an IP network.
Q: State two differences between IPv4 and IPv6.
A: 1) IPv4 uses 32-bit addresses (decimal), while IPv6 uses 128-bit addresses (hexadecimal). 2) IPv6 has built-in security, whereas it is optional in IPv4.
Q: What is the purpose of ARP?
A: ARP (Address Resolution Protocol) is used to find the physical MAC address corresponding to a known IP address within a local network.
Q: What is the function of TTL?
A: TTL (Time To Live) prevents packets from travelling indefinitely in a network by discarding them when the TTL counter reaches zero.
🌐 IP → Logical addressing + Routing
🏠 DNS → Domain name → IP address
🔗 ARP → IP address → MAC address
📢 DHCP → Automatic IP assignment (DORA)
🎭 NAT → Private IP ↔ Public IP translation
🛡️ ICMP → Error reporting + Ping/Traceroute