Computer Networks
Complete Notes
OSI Model ยท TCP/IP ยท Routing ยท Switching ยท DNS ยท Security ยท All in Easy English
Computer Networks Basics
Introduction to Networking Concepts
What is a Network?
A computer network is a collection of interconnected computers that communicate and share resources through communication protocols.
Types of Networks
| Type | Range | Examples |
|---|---|---|
| PAN | Few meters | Bluetooth devices, Smartphone connections |
| LAN | Single building | Office networks, Schools |
| MAN | City-wide | City WiFi networks |
| WAN | Worldwide | Internet, Intercontinental links |
Network Models
- Peer-to-Peer (P2P): All computers equal, no central server
- Client-Server: Central server serves multiple clients
- Hybrid: Combination of P2P and client-server
Network Topologies
| Topology | Structure | Pros/Cons |
|---|---|---|
| Bus | All connected to single cable | Simple but failure prone |
| Star | All connected to central hub | Reliable but single point of failure |
| Ring | Circular connection | Fair but complex |
| Mesh | Multiple connections | Reliable but expensive |
| Tree | Hierarchical | Scalable and organized |
OSI Model
Seven Layers of Network Communication
OSI Model Overview
The Open Systems Interconnection (OSI) model is a 7-layer framework that standardizes network communication.
The 7 Layers
| # | Layer | Function | Devices |
|---|---|---|---|
| 7 | Application | User apps - HTTP, FTP, DNS | Browser, Mail client |
| 6 | Presentation | Data formatting, encryption | Encryption software |
| 5 | Session | Establishes connections | Session manager |
| 4 | Transport | Reliable delivery - TCP, UDP | Gateway |
| 3 | Network | Routing - IP addresses | Router |
| 2 | Data Link | Framing - MAC addresses | Switch, Bridge |
| 1 | Physical | Cables, voltages, signals | Hub, Modem |
Data Encapsulation
Application Layer (Data)
โ Adds header
Transport Layer (Segment)
โ Adds header
Network Layer (Packet)
โ Adds header
Data Link Layer (Frame)
โ Adds header
Physical Layer (Bits)
On receiving: Remove headers layer by layer (decapsulation)Data Link Layer
Managing Frame Transmission and MAC Addresses
Data Link Layer Functions
- Framing: Group bits into frames
- MAC Addressing: Identify devices on LAN
- Error Detection: CRC (Cyclic Redundancy Check)
- Media Access Control: Decide who sends next
MAC Address
48-bit address identifying devices on local network. Format: 6 pairs of hexadecimal (e.g., 00:1A:2B:3C:4D:5E)
First 3 octets (24 bits): Manufacturer ID (OUI) Last 3 octets (24 bits): Device-specific ID Example: 08:00:27:2C:2F:65 08:00:27 = Oracle VirtualBox 2C:2F:65 = Individual device
Ethernet Protocol
| Type | Speed | Distance |
|---|---|---|
| 10BaseT | 10 Mbps | 100m |
| 100BaseT (Fast Ethernet) | 100 Mbps | 100m |
| 1000BaseT (Gigabit) | 1 Gbps | 100m |
| 10GbE | 10 Gbps | Limited |
Media Access Control (MAC)
- CSMA/CD: Listen before sending, back off if collision
- Token Ring: Pass token to decide who sends
- Wireless (CSMA/CA): Collision avoidance
Network Layer
Routing and IP Addressing
Network Layer Functions
- Routing: Find best path from source to destination
- IP Addressing: Logical addresses for networks
- Forwarding: Move packets along the route
- Congestion Control: Manage network traffic
IPv4 Addressing
IPv4 Address: 192.168.1.1 Each octet: 0-255 (8 bits) Total: 32 bits = 2^32 = 4.3 billion addresses Classes: Class A: 1-126 (16.7 million hosts per network) Class B: 128-191 (65,000 hosts) Class C: 192-223 (256 hosts) Class D: 224-239 (Multicast) Class E: 240-255 (Reserved)
Subnetting
Divide large network into smaller subnets using subnet mask.
IP: 192.168.1.100 / 24 Subnet Mask: 255.255.255.0 Network Address: 192.168.1.0 Broadcast: 192.168.1.255 Usable IPs: 192.168.1.1 - 192.168.1.254
IPv6
128-bit address (2^128 addresses). Format: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 Shorthand: 2001:db8:85a3::8a2e:370:7334
ICMP & Ping
Internet Control Message Protocol for diagnostics. Ping tests reachability.
Transport Layer
TCP and UDP Protocols
Transport Layer Functions
- End-to-end communication
- Port numbers (0-65535) identify applications
- Reliability (TCP) or Speed (UDP)
- Flow control and error handling
TCP vs UDP
| Feature | TCP | UDP |
|---|---|---|
| Connection | Establishes connection | Connectionless |
| Reliability | Guaranteed delivery | No guarantee |
| Ordering | In-order delivery | Out-of-order possible |
| Speed | Slower (overhead) | Faster (minimal) |
| Uses | HTTP, FTP, Email, SSH | DNS, Video, VoIP, Gaming |
TCP 3-Way Handshake
Client Server |------ SYN (seq=x) ----->| |<---- SYN-ACK (seq=y) ----| |---- ACK (seq=x+1) ----->| | [Connection Established]
Well-Known Ports
- 20/21: FTP
- 22: SSH
- 23: Telnet
- 25: SMTP (Email)
- 53: DNS
- 80: HTTP
- 443: HTTPS
- 3306: MySQL
Application Layer
User Applications and Services
Common Application Protocols
| Protocol | Purpose | Port |
|---|---|---|
| HTTP/HTTPS | Web browsing | 80/443 |
| FTP | File transfer | 20/21 |
| SMTP | Send email | 25/587 |
| POP3/IMAP | Receive email | 110/143 |
| DNS | Name resolution | 53 |
| SSH | Secure shell | 22 |
| Telnet | Remote login | 23 |
DNS (Domain Name System)
Converts domain names to IP addresses. Hierarchical distributed system.
Query Flow:
User โ Local DNS Resolver โ Root Nameserver
โ TLD Nameserver (.com, .org)
โ Authoritative Nameserver
โ IP Address returnedHTTP Methods
- GET: Retrieve data
- POST: Submit data
- PUT: Update resource
- DELETE: Remove resource
- HEAD: Like GET but no body
Email Protocols
- SMTP: Sending mail (port 25)
- POP3: Receiving (deletes after download)
- IMAP: Receiving (keeps on server)
Routing Algorithms
Finding Optimal Paths in Networks
Routing Types
- Static: Manually configured routes
- Dynamic: Automatically adjusts to network changes
Routing Algorithms
| Algorithm | Type | How It Works |
|---|---|---|
| Dijkstra | Link-state | Find shortest path, calculates all routes |
| Bellman-Ford | Distance-vector | Iterative, handles negative weights |
| RIP | Distance-vector | Hop count, simple but limited |
| OSPF | Link-state | Most popular, hierarchical |
| BGP | Path-vector | Internet backbone routing |
Routing Table
Destination | Netmask | Gateway | Interface | Metric 10.0.0.0 | 255.255.255.0 | 0.0.0.0 | eth0 | 0 10.0.1.0 | 255.255.255.0 | 10.0.0.1 | eth0 | 1 192.168.0.0 | 255.255.0.0 | 10.0.0.1 | eth0 | 2
Switching
Forwarding Frames Within LANs
Switching Basics
Switches forward frames based on MAC addresses. Build MAC address table dynamically.
MAC Address Table
MAC Address | Port | TTL 00:11:22:33:44:55 | 1 | 300 AA:BB:CC:DD:EE:FF | 3 | 300 11:22:33:44:55:66 | 2 | 300 Switch learns addresses by observing source MACs Ages out entries after timeout (usually 5 min)
Switching Methods
| Method | Latency | Error Detection |
|---|---|---|
| Cut-through | Low | None |
| Store-and-forward | Higher | CRC check |
| Fragment-free | Medium | Partial check |
VLAN (Virtual LAN)
Logically segment network into separate VLANs. Same physical switch, different networks.
Spanning Tree Protocol (STP)
Prevents loops in switched networks. Blocks redundant paths.
Network Security
Protecting Networks from Threats
Security Goals
- Confidentiality: Keep data private
- Integrity: Ensure data not modified
- Authentication: Verify identity
- Non-repudiation: Can't deny sending
Common Attacks
| Attack | How It Works | Prevention |
|---|---|---|
| Eavesdropping | Listen to traffic | Encryption (SSL/TLS) |
| DDoS | Flood server with traffic | Firewalls, Rate limiting |
| Phishing | Fake emails trick users | User education |
| Man-in-the-Middle | Intercept communications | Digital certificates |
| Malware | Malicious software | Antivirus, Firewalls |
Encryption Methods
- Symmetric: Same key to encrypt/decrypt (AES, DES)
- Asymmetric: Public key to encrypt, private to decrypt (RSA)
- Hash: One-way function (MD5, SHA-256)
Firewalls & VPN
- Firewall: Filters traffic based on rules
- VPN: Encrypted tunnel for secure communication
- IDS/IPS: Intrusion detection/prevention
Wireless Networks
WiFi and Mobile Communications
Wireless Standards
| Standard | Frequency | Speed | Range |
|---|---|---|---|
| 802.11a | 5 GHz | 54 Mbps | 35m |
| 802.11b | 2.4 GHz | 11 Mbps | 100m |
| 802.11g | 2.4 GHz | 54 Mbps | 100m |
| 802.11n (WiFi 4) | 2.4/5 GHz | 300 Mbps | 150m |
| 802.11ac (WiFi 5) | 5 GHz | 1.3 Gbps | 100m |
| 802.11ax (WiFi 6) | 2.4/5 GHz | 9.6 Gbps | 100m |
WiFi Security
- WEP: Deprecated, easily cracked
- WPA: Improved encryption
- WPA2/WPA3: Current standard, AES encryption
Wireless Channels
2.4 GHz: 13 channels (1-13), overlapping. Non-overlapping: 1, 6, 11
5 GHz: Many non-overlapping channels for less interference
Mobile Networks
- 3G: Mobile broadband (WCDMA, CDMA2000)
- 4G/LTE: High speed (100+ Mbps)
- 5G: Ultra high speed, low latency
๐ Congratulations!
You've completed the Computer Networks course! Master these concepts for networking excellence!
๐ Pak Notes Hub โ Computer Networks Complete Notes | University Level | BS CS / BS IT
For corrections and suggestions: support@paknoteshub.com

