Understanding Computer Networks
A computer network is a collection of interconnected computers that share resources and communicate with each other. Networks are essential infrastructure for modern computing, from local office networks to the global internet.
Network Goals:
- Share resources (files, printers, internet)
- Enable communication (email, video calls, messaging)
- Provide computing power through distributed systems
- Ensure reliability and redundancy
Network Models
OSI Model (7 Layers)
Layer 7: Application Layer
├─ Protocols: HTTP, HTTPS, FTP, SMTP, POP3, DNS
├─ Services: Email, web browsing, file transfer
Layer 6: Presentation Layer
├─ Data encryption, compression, translation
├─ Formats: SSL/TLS encryption
Layer 5: Session Layer
├─ Manages connections between applications
├─ Example: Login sessions, call setup
Layer 4: Transport Layer (TCP/UDP)
├─ Protocols: TCP (reliable), UDP (fast)
├─ Concepts: Ports (80, 443, 22), connections
Layer 3: Network Layer (Routing)
├─ Protocols: IP (IPv4, IPv6)
├─ Devices: Routers
├─ Concepts: IP addressing, routing tables
Layer 2: Data Link Layer
├─ Protocols: Ethernet, Wi-Fi
├─ Devices: Switches, bridges
├─ Concepts: MAC addresses, frames
Layer 1: Physical Layer
├─ Hardware: Cables (fiber, copper), wireless
├─ Concepts: Voltage, wireless frequenciesTCP/IP Model (Simplified - 4 Layers):
- Application (HTTP, SMTP, DNS)
- Transport (TCP, UDP)
- Internet (IP routing)
- Link (Ethernet, Wi-Fi)
Network Protocols
TCP vs UDP
TCP (Transmission Control Protocol) - Reliable
Characteristics:
- Connection-oriented (establish before sending)
- Guaranteed delivery (no data loss)
- Ordered delivery (arrives in order)
- Slower (extra overhead for reliability)
- Used for: Email, file transfer, web browsing
Example:
Client connects to server
Data sent reliably
Client disconnectsUDP (User Datagram Protocol) - Fast
Characteristics:
- Connectionless (no setup)
- No delivery guarantee
- Fast (minimal overhead)
- Used for: Video streaming, online gaming, DNS
Example:
Send packet without connection
Fire and forgetCommon Protocols
HTTP/HTTPS (Web):
Port: 80 (HTTP), 443 (HTTPS)
Purpose: Transfer web pages
Method: GET (retrieve), POST (submit)
Status codes: 200 (OK), 404 (Not Found), 500 (Error)DNS (Domain Name System):
Purpose: Translate domain names to IP addresses
Query: What's the IP of google.com?
Response: 142.251.174.102SMTP/POP3 (Email):
SMTP: Send mail (port 25, 587)
POP3: Receive mail (port 110)
IMAP: Advanced mail (port 143)FTP (File Transfer):
Purpose: Transfer files between computers
Port: 21
Example: Upload website files to serverIP Addressing
IPv4 (32-bit address)
Notation: 192.168.1.1
Binary: 11000000 . 10101000 . 00000001 . 00000001
11000000 10101000 00000001 00000001
64 + 168 + 1 + 1
Address Classes:
Class A: 1.0.0.0 to 126.255.255.255 (Large networks)
Class B: 128.0.0.0 to 191.255.255.255 (Medium networks)
Class C: 192.0.0.0 to 223.255.255.255 (Small networks)
Private IP ranges (can't reach internet):
10.0.0.0 - 10.255.255.255
172.16.0.0 - 172.31.255.255
192.168.0.0 - 192.168.255.255Subnetting
Network: 192.168.1.0/24
192.168.1.0 - 192.168.1.255 (256 addresses)
Subnet mask: 255.255.255.0 (first 24 bits = network)
Example breakdown:
192.168.1.0 = Network address
192.168.1.1 = Router (gateway)
192.168.1.2-254 = Usable hosts
192.168.1.255 = Broadcast addressIPv6 (128-bit address)
Format: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Advantages over IPv4:
- Larger address space (340 undecillion addresses)
- Better security (IPSec built-in)
- Auto-configuration
- Simplified headerNetwork Devices
Router
Purpose: Directs packets between networks
Function: Reads IP addresses, forwards packets
Example: Home WiFi router connects your devices to ISPSwitch
Purpose: Connects devices within same network
Function: Forwards frames based on MAC addresses
Faster than router (local network only)Gateway
Purpose: Connects two different network types
Example: Convert from Ethernet to WiFiFirewall
Purpose: Security - blocks unwanted traffic
Function: Inspects packets, applies rules
Rules: Allow/deny based on IP, port, protocolNetwork Architectures
LAN (Local Area Network)
Distance: Single building or campus
Speed: 100 Mbps - 1 Gbps
Example: Office network connected via Ethernet
Devices: Computers, printers, servers in buildingWAN (Wide Area Network)
Distance: Multiple cities/countries
Speed: 1 Mbps - 100 Mbps
Example: Internet, branch offices connected
Technology: Leased lines, MPLS, VPNWireless Networks
Wi-Fi (802.11):
Standards: 802.11a, 802.11b, 802.11g, 802.11n, 802.11ac
Frequencies: 2.4 GHz, 5 GHz
Range: 30-100 meters
Speed: 11 Mbps to 1+ Gbps
Security: WEP, WPA, WPA2, WPA3Cellular (4G/5G):
4G LTE: 100 Mbps download
5G: 1+ Gbps download
Used by: Mobile phones, IoT devicesNetwork Layering & Addressing
Complete path from Application to Physical:
Application
(HTTP request to google.com)
↓
DNS lookup: google.com → 142.251.174.102
↓
Transport Layer: TCP port 443
↓
Network Layer: Add IP header with destination 142.251.174.102
↓
Data Link: Add MAC address header
↓
Physical: Convert to electrical signals
↓
Cable/WiFi transmission
↓
(Reverse at destination)Network Security
Threats
Malware:
- Virus: Replicating code attached to programs
- Worm: Standalone replicating code
- Trojan: Looks benign but contains malicious code
Attacks:
DDoS (Distributed Denial of Service):
- Flood server with requests
- Server can't respond to legitimate users
Man-in-the-Middle:
- Intercept communication between two parties
- Read or modify data in transit
Phishing:
- Trick users into revealing credentials
- Fake login pages, emailsSecurity Solutions
Encryption:
HTTPS (SSL/TLS):
- Encrypts data in transit
- Ports 443 (web)
- Protects against eavesdroppingFirewall:
Rules: Allow port 80, 443 (web)
Block port 23 (telnet)
Block suspicious IPsVPN (Virtual Private Network):
Purpose: Encrypt all traffic through VPN server
Anonymous: Hide your IP address
Secure: Protect on public Wi-FiTroubleshooting Network Issues
Check Connectivity:
ping google.com # Test if host is reachable
tracert google.com # See route packets take
ipconfig /all # Check IP configuration
netstat -an # Show active connectionsCommon Issues:
No Internet:
1. Check router is on
2. Check cables/Wi-Fi connected
3. Run ipconfig to verify IP
4. Ping gateway (usually 192.168.1.1)
5. Ping DNS server (8.8.8.8)
Slow Network:
1. Run speed test (speedtest.net)
2. Check if many devices connected
3. Check Wi-Fi signal strength
4. Restart router
5. Check for malware
DNS Issues:
1. Can't reach by domain (google.com)
2. But can reach by IP (8.8.8.8)
3. Solution: Change DNS to 8.8.8.8 or 1.1.1.1Key Network Concepts Summary
| Concept | Definition | Example |
|---|---|---|
| IP Address | Unique computer identifier | 192.168.1.1 |
| MAC Address | Physical device identifier | 00:1A:2B:3C:4D:5E |
| Port | Application endpoint | 80 (HTTP), 443 (HTTPS) |
| Protocol | Communication rules | TCP, UDP, HTTP |
| Bandwidth | Data transfer capacity | 100 Mbps |
| Latency | Time for data to travel | 20 ms |
| Throughput | Actual data transfer rate | 80 Mbps (in practice) |