IP addressing, subnetting, routing algorithms, and protocols
Layer 3 - Logical addressing and routing across networks
| Function | Description |
|---|---|
| Logical Addressing | IP addresses for global identification |
| Routing | Find best path from source to destination |
| Forwarding | Move packets to appropriate interface |
| Fragmentation | Break large packets for smaller MTU |
32 bits = 4 octets (bytes)
Format: X.X.X.X (each X = 0-255)
Example: 192.168.1.100
Binary: 11000000.10101000.00000001.01100100
| Class | Range | Default Mask | Networks | Hosts/Net |
|---|---|---|---|---|
| A | 1.0.0.0 - 126.255.255.255 | 255.0.0.0 (/8) | 126 | 16M |
| B | 128.0.0.0 - 191.255.255.255 | 255.255.0.0 (/16) | 16K | 65K |
| C | 192.0.0.0 - 223.255.255.255 | 255.255.255.0 (/24) | 2M | 254 |
| D | 224.0.0.0 - 239.255.255.255 | - | Multicast | - |
| E | 240.0.0.0 - 255.255.255.255 | - | Reserved | - |
127.0.0.1 → Loopback (localhost)
0.0.0.0 → Default/Any
255.255.255.255 → Broadcast
10.x.x.x → Private (Class A)
172.16.x.x - 172.31.x.x → Private (Class B)
192.168.x.x → Private (Class C)
Dividing a network into smaller sub-networks
Subnet Mask: Identifies network vs host portion
255.255.255.0 = 11111111.11111111.11111111.00000000
|----Network bits----|--Host bits--|
CIDR Notation: /24 means 24 network bits
192.168.1.0/24 = Network with 256 addresses (254 usable)
Given: 192.168.1.0/24, need 4 subnets
Step 1: Need 2 bits for 4 subnets (2² = 4)
Step 2: New mask = /26 (24 + 2)
Subnets:
192.168.1.0/26 → 192.168.1.0 - 192.168.1.63
192.168.1.64/26 → 192.168.1.64 - 192.168.1.127
192.168.1.128/26 → 192.168.1.128 - 192.168.1.191
192.168.1.192/26 → 192.168.1.192 - 192.168.1.255
Each subnet: 64 addresses (62 usable)
Number of subnets = 2^(borrowed bits)
Hosts per subnet = 2^(host bits) - 2
Network address = First address (all host bits = 0)
Broadcast = Last address (all host bits = 1)
Destination Gateway Interface
192.168.1.0/24 0.0.0.0 eth0 (direct)
10.0.0.0/8 192.168.1.1 eth0 (via gateway)
0.0.0.0/0 192.168.1.1 eth0 (default route)
| Algorithm | Type | Description |
|---|---|---|
| RIP | Distance Vector | Hop count metric, max 15 hops |
| OSPF | Link State | Dijkstra's algorithm, fast convergence |
| BGP | Path Vector | Inter-AS routing, Internet backbone |
| Distance Vector (RIP) | Link State (OSPF) |
|---|---|
| Share with neighbors | Share with all routers |
| Simple, slow convergence | Complex, fast convergence |
| Count-to-infinity problem | No such problem |
| Uses hop count | Uses bandwidth/cost |
IPv4 Header (20-60 bytes):
┌────────┬────────┬────────────────┬───────────────┐
│Version │IHL │TOS │Total Length │
├────────┴────────┼────────────────┼───────────────┤
│Identification │Flags│Fragment Offset │
├────────┬────────┼────────────────┴───────────────┤
│TTL │Protocol│Header Checksum │
├────────┴────────┴────────────────────────────────┤
│ Source IP Address │
├──────────────────────────────────────────────────┤
│ Destination IP Address │
└──────────────────────────────────────────────────┘
Error and diagnostic messages:
- Echo Request/Reply (ping)
- Destination Unreachable
- Time Exceeded (TTL = 0)
- Redirect
Used by: ping, traceroute
IP → MAC address resolution
1. Host sends ARP broadcast: "Who has 192.168.1.1?"
2. Owner replies: "192.168.1.1 is at AA:BB:CC:DD:EE:FF"
3. Sender caches MAC in ARP table
IPv4: 32 bits → 4.3 billion addresses
IPv6: 128 bits → 340 undecillion addresses
Format: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Shortened: 2001:db8:85a3::8a2e:370:7334 (:: = consecutive zeros)
| Concept | Key Point |
|---|---|
| IPv4 | 32-bit, dotted decimal |
| Classes | A (large), B (medium), C (small) |
| Subnetting | Borrow host bits for more networks |
| CIDR | /n notation for flexible subnets |
| RIP | Distance vector, hop count |
| OSPF | Link state, fastest convergence |
| ARP | IP to MAC resolution |
Test your understanding with step-by-step solutions
10 questions · 90s per question
Each question has a 90-second time limit. Unanswered questions will be auto-submitted when time runs out.