Introduction to Computer Networks
Definition:
A computer network is a system of interconnected devices that communicate with each other to share resources, data, and applications.
Applications of Computer Networks:
- Communication: Emails, messaging, video conferencing (e.g., Zoom, WhatsApp)
- Resource Sharing: Shared printers, cloud storage (e.g., Google Drive, OneDrive)
- Data Sharing: File transfer via FTP, peer-to-peer sharing
- Entertainment: Online gaming, streaming services (e.g., Netflix, YouTube)
- E-commerce: Online shopping platforms (e.g., Amazon, Flipkart)
Network Types
1. Local Area Network (LAN):
- Covers a small area (e.g., home, office, school)
- High-speed data transfer (e.g., Ethernet, Wi-Fi)
- Example: Office network connecting multiple computers
2. Metropolitan Area Network (MAN):
- Covers a city or large campus
- Faster than WAN but slower than LAN
- Example: City-wide broadband services
3. Wide Area Network (WAN):
- Covers large geographical areas (e.g., country, worldwide)
- Slower due to long-distance communication
- Example: The Internet
Network Topologies
1. Bus Topology:
- Single central cable (backbone) connects all devices
- Advantage: Cost-effective, easy to expand
- Disadvantage: If the main cable fails, the network fails
- Example: Small office networks
2. Star Topology:
- Central hub/switch connects all devices
- Advantage: Easy troubleshooting, reliable
- Disadvantage: If the central hub fails, the network goes down
- Example: Home or office Wi-Fi network
3. Ring Topology:
- Devices are connected in a closed loop
- Advantage: Equal access to data, no data collision
- Disadvantage: Failure in one device affects the entire network
- Example: Token Ring network
4. Mesh Topology:
- Every device is connected to every other device
- Advantage: High redundancy, reliable
- Disadvantage: Expensive and complex
- Example: High-security networks
5. Hybrid Topology:
- Combination of two or more topologies
- Advantage: Flexible and scalable
- Disadvantage: Complex structure
- Example: Enterprise networks
OSI & TCP/IP Models
OSI Model (7 Layers):
- Physical Layer - Transmission of raw data (e.g., cables, Wi-Fi signals)
- Data Link Layer - Error detection and MAC addressing (e.g., Ethernet)
- Network Layer - Routing and IP addressing (e.g., Routers, IP protocol)
- Transport Layer - Ensures reliable data transfer (e.g., TCP, UDP)
- Session Layer - Manages sessions between applications
- Presentation Layer - Data encryption and formatting (e.g., JPEG, MP3)
- Application Layer - User interface (e.g., HTTP, FTP, SMTP)
TCP/IP Model (4 Layers):
- Network Interface - Physical and data link layers combined
- Internet Layer - Handles IP addressing and routing
- Transport Layer - TCP/UDP for reliable/unreliable communication
- Application Layer - User applications like web browsing, email
Network Devices
1. Router:
- Connects different networks (e.g., LAN to the Internet)
- Uses IP addresses for data transmission
- Example: Home Wi-Fi router
2. Switch:
- Connects multiple devices within a LAN
- Uses MAC addresses for data transmission
- Example: Office network switch
3. Hub:
- Broadcasts data to all devices in a network
- No intelligence, slower than a switch
- Example: Outdated networking setups
4. Bridge:
- Connects two LANs together
- Works at the Data Link Layer
- Example: Connecting two office buildings' networks
5. Gateway:
- Connects different network architectures
- Converts protocols (e.g., IPv4 to IPv6)
- Example: Email gateway
6. Modem:
- Converts digital data to analog for transmission over telephone lines
- Example: DSL modems for broadband internet
7. Repeater:
- Amplifies and extends network signals
- Used in long-distance communication
- Example: Wi-Fi range extenders
Practice Questions
- What is the main purpose of a computer network?
- Differentiate between LAN, MAN, and WAN.
- Explain the advantages and disadvantages of different network topologies.
- What is the difference between a router and a switch?
- Compare OSI and TCP/IP models.
- Why is a repeater used in networking?
- What are the functions of a gateway in networking?
OSI Layers
Physical Layer
Transmission Media (Wired & Wireless)
- Wired Media:
- Twisted Pair Cable: Used in LANs, reduces interference.
- Coaxial Cable: Used in cable TV networks, provides better shielding.
- Fiber Optic Cable: High-speed data transfer, immune to electromagnetic interference.
- Wireless Media:
- Radio Waves: Used in Wi-Fi, Bluetooth.
- Microwaves: Used in satellite communication.
- Infrared: Used in remote controls.
Data Encoding Techniques
- NRZ (Non-Return to Zero): No transition for 1s, transition for 0s.
- Manchester Encoding: XOR operation between the clock and data.
- 4B/5B Encoding: Maps 4-bit data into 5-bit symbols for synchronization.
Signal Transmission (Analog vs Digital)
- Analog Signals: Continuous, used in radio and telephone systems.
- Digital Signals: Discrete, used in computers and digital communication.
- Example: Telephone voice transmission (analog) vs Ethernet (digital).
Multiplexing (FDM, TDM, WDM, CDMA)
- FDM (Frequency Division Multiplexing): Different frequencies for different signals (e.g., radio channels).
- TDM (Time Division Multiplexing): Time slots assigned to different signals (e.g., telephony systems).
- WDM (Wavelength Division Multiplexing): Used in fiber optics to transmit multiple signals.
- CDMA (Code Division Multiple Access): Each user has a unique code (used in mobile networks).
Switching Techniques (Circuit, Packet, Message Switching)
- Circuit Switching: Dedicated path, used in telephone networks.
- Packet Switching: Data broken into packets, used in the internet.
- Message Switching: Entire message transmitted at once, used in email systems.
Data Link Layer
Framing Techniques
- Character Count: Frame length specified in the header.
- Flag Bytes with Byte Stuffing: Special flag bytes indicate frame boundaries.
- Bit Stuffing: Extra bits inserted to prevent false frame detection.
Error Detection & Correction
- Parity Check: Adds a parity bit (even/odd) for error detection.
- Checksum: Sum of data bits checked at receiver.
- CRC (Cyclic Redundancy Check): Uses polynomial division.
- Hamming Code: Used for error correction by adding redundant bits.
Flow Control Protocols
- Stop-and-Wait: Sender waits for acknowledgment before sending next frame.
- Sliding Window: Allows multiple frames to be sent before acknowledgment.
MAC Addressing & ARP
- MAC Address: Unique identifier for network devices.
- ARP (Address Resolution Protocol): Maps IP addresses to MAC addresses.
Medium Access Control (ALOHA, CSMA/CD, CSMA/CA)
- ALOHA: Random transmission, used in early wireless networks.
- CSMA/CD (Carrier Sense Multiple Access with Collision Detection): Used in Ethernet.
- CSMA/CA (Collision Avoidance): Used in Wi-Fi to avoid collisions.
Ethernet & IEEE 802.3 Standards
- Ethernet: Wired LAN standard.
- IEEE 802.3: Defines Ethernet specifications, including frame structure and speeds.
Network Layer
IP Addressing (IPv4 & IPv6)
- IPv4: 32-bit address (e.g., 192.168.1.1).
- IPv6: 128-bit address, supports more devices.
Subnetting & Supernetting
- Subnetting: Divides a network into smaller sub-networks.
- Supernetting: Combines multiple subnets into a larger one.
- Example:
- Subnet Mask: 255.255.255.0 divides a network into 256 addresses.
Routing Algorithms
- Distance Vector: Uses hop count (e.g., RIP - Routing Information Protocol).
- Link State: Uses complete network topology (e.g., OSPF - Open Shortest Path First).
- RIP (Routing Information Protocol): Distance vector-based, slow convergence.
- OSPF (Open Shortest Path First): Link-state-based, fast convergence.
- BGP (Border Gateway Protocol): Used for inter-domain routing.
Network Address Translation (NAT)
- Purpose: Converts private IPs to public IPs.
- Example: Home router assigns private IPs (192.168.x.x) and uses a public IP for internet access.
Internet Control Message Protocol (ICMP)
- Purpose: Used for error reporting and network diagnostics.
- Example: Ping command uses ICMP.
Virtual LAN (VLAN)
- Definition: Logically segments a network into different broadcast domains.
- Example: Separating HR and IT departments on the same physical switch.
Sample Questions
- What is the difference between wired and wireless transmission media?
- Explain Manchester encoding with an example.
- How does FDM differ from TDM in multiplexing?
- Compare circuit switching and packet switching.
- What is the role of ARP in networking?
- How does CRC detect errors in data transmission?
- Explain the differences between IPv4 and IPv6.
- What are the advantages of using VLAN in a network?
- Describe the working of CSMA/CD in Ethernet.
- What is the purpose of NAT in networking?
Transport Layer
TCP vs UDP
- TCP (Transmission Control Protocol): Connection-oriented, reliable, ensures data delivery in order.
- Example: Web browsing (HTTP/HTTPS), Email (SMTP, IMAP, POP3)
- UDP (User Datagram Protocol): Connectionless, faster but unreliable, data may be lost or out of order.
- Example: Online gaming, VoIP, DNS
Connection Establishment & Termination (3-way Handshake)
- 3-Way Handshake (TCP Connection Establishment):
- SYN: Client sends a synchronization request.
- SYN-ACK: Server acknowledges with SYN-ACK.
- ACK: Client sends acknowledgment; connection established.
- Connection Termination (4-way Handshake):
- FIN (from client)
- ACK (from server)
- FIN (from server)
- ACK (from client)
Flow & Congestion Control
- Leaky Bucket: Packets are stored and processed at a constant rate to prevent bursts.
- Token Bucket: Tokens are generated at a constant rate; packets are sent only if tokens are available.
Sockets & Ports
- Sockets: Combination of IP address & port number, used for communication.
- Ports:
- Well-known ports (0-1023): HTTP (80), HTTPS (443), FTP (21)
- Registered ports (1024-49151): Custom applications
- Dynamic ports (49152-65535): Temporary communication
Quality of Service (QoS)
- Definition: Prioritizing network traffic to ensure performance.
- QoS Parameters:
- Bandwidth: Data transfer rate
- Latency: Delay in data transmission
- Jitter: Variations in delay
- Packet Loss: Dropped packets due to congestion
Application Layer
Common Protocols
- DNS (Domain Name System): Resolves domain names to IP addresses.
- DHCP (Dynamic Host Configuration Protocol): Assigns IP addresses dynamically.
- FTP (File Transfer Protocol): Transfers files (Port 21).
- SMTP (Simple Mail Transfer Protocol): Sends emails (Port 25).
- POP3 (Post Office Protocol 3): Retrieves emails (Port 110).
- IMAP (Internet Message Access Protocol): Accesses emails (Port 143).
- HTTP (Hypertext Transfer Protocol): Web browsing (Port 80).
- HTTPS (Secure HTTP): Secure web browsing using SSL/TLS (Port 443).
Web Services & APIs
- Web Services: Enable communication between applications over the internet.
- APIs (Application Programming Interfaces):
- REST (Representational State Transfer)
- SOAP (Simple Object Access Protocol)
Remote Access Protocols
- Telnet: Remote login without encryption (Port 23).
- SSH (Secure Shell): Secure remote login (Port 22).
Email Services & Protocols
- SMTP: Sending emails.
- POP3: Downloads emails to local storage.
- IMAP: Accesses emails from multiple devices.
Network Security
Basics of Cryptography
- Symmetric Encryption: Uses a single key for encryption & decryption (e.g., AES, DES).
- Asymmetric Encryption: Uses a public and a private key (e.g., RSA, ECC).
Network Attacks
- DoS (Denial of Service): Overloading a server to make it unavailable.
- DDoS (Distributed Denial of Service): Multiple devices attacking a server.
- Phishing: Deceptive attempts to steal sensitive information.
- MITM (Man-in-the-Middle): Intercepting communication between two parties.
Firewalls & VPNs
- Firewall: Filters traffic based on rules (hardware/software-based).
- VPN (Virtual Private Network): Encrypts data over public networks for secure communication.
Intrusion Detection & Prevention Systems
- IDS (Intrusion Detection System): Monitors network traffic for suspicious activities.
- IPS (Intrusion Prevention System): Detects and actively blocks threats.
Public Key Infrastructure (PKI)
- Definition: Framework for managing digital keys & certificates.
- Components:
- Certificate Authority (CA): Issues digital certificates.
- Public/Private Key Pair: Ensures secure communication.
- Digital Signatures: Validates sender authenticity.
Example Questions
- Explain the difference between TCP and UDP with examples.
- Describe the steps involved in a TCP 3-way handshake.
- How does a token bucket algorithm help in congestion control?
- What are sockets and why are they important in networking?
- What is Quality of Service (QoS) and how does it affect network performance?
- How does DNS resolve a domain name to an IP address?
- Explain the difference between POP3 and IMAP.
- What is the role of a firewall in network security?
- Differentiate between IDS and IPS.
- What is a Man-in-the-Middle (MITM) attack and how can it be prevented?
Wireless and Mobile Networks
Wi-Fi (802.11 Standards)
Wi-Fi is a wireless networking technology based on IEEE 802.11 standards that allows devices to communicate over a local area network (WLAN) without physical cables.
Common 802.11 Standards:
- 802.11a: 5 GHz, 54 Mbps
- 802.11b: 2.4 GHz, 11 Mbps
- 802.11g: 2.4 GHz, 54 Mbps
- 802.11n: 2.4/5 GHz, up to 600 Mbps
- 802.11ac: 5 GHz, up to 1 Gbps
- 802.11ax (Wi-Fi 6): 2.4/5 GHz, improved efficiency and speed
Example: A home router providing wireless internet to multiple devices.
Bluetooth & ZigBee
Bluetooth
- Short-range wireless technology (10-100 meters)
- Used for file sharing, audio streaming, and IoT devices
- Low power consumption
- Operates in the 2.4 GHz band
ZigBee
- Designed for low-power, low-data-rate applications (IoT)
- Uses the 2.4 GHz band
- Supports mesh networking
Example: Bluetooth headphones, ZigBee-based smart home devices.
Mobile IP & Cellular Networks (2G, 3G, 4G, 5G)
Mobile IP
- Protocol allowing mobile devices to maintain the same IP address while moving across networks.
Cellular Networks:
- 2G: GSM, CDMA; used for calls and SMS
- 3G: UMTS, EV-DO; supports internet access
- 4G (LTE): High-speed internet, VoLTE
- 5G: Ultra-low latency, high bandwidth, supports IoT & smart cities
Example: Using mobile data on a smartphone while traveling.
Ad-hoc Networks & MANET
- Ad-hoc Networks: No centralized infrastructure, devices communicate directly.
- Mobile Ad-hoc Networks (MANETs): Self-configuring networks where mobile nodes form a temporary network.
Example: Disaster recovery networks after an earthquake.
Network Programming & Simulation
Socket Programming (Python & C)
- Allows communication between devices using TCP/UDP protocols.
Python Example:
import socket
s = socket.socket()
s.bind(('localhost', 8080))
s.listen(1)
print("Waiting for connection...")
conn, addr = s.accept()
print("Connected to", addr)
conn.close()
C Example:
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
int main() {
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
printf("Socket created\n");
return 0;
}
Network Simulation Tools
- NS2 & NS3: Simulate network performance.
- Cisco Packet Tracer: Visualize network setups.
- Wireshark: Packet analysis tool.
Example: Using Packet Tracer to simulate a router network.
Advanced Topics & Emerging Trends
Software-Defined Networking (SDN)
- Separates control and data planes in networking.
- Centralized network management via controllers.
Example: OpenFlow protocol for SDN implementation.
Internet of Things (IoT) Networks
- Connects physical devices to the internet.
- Uses protocols like MQTT, CoAP.
Example: Smart home automation systems.
Cloud Networking
- Delivers network services via cloud infrastructure.
- Includes Virtual Private Networks (VPNs) and Software-Defined WAN (SD-WAN).
Example: AWS Virtual Private Cloud (VPC).
Edge & Fog Computing
- Edge Computing: Processing data near the source.
- Fog Computing: Extends cloud computing closer to the user.
Example: Self-driving cars using edge computing.
Blockchain in Networking
- Decentralized network security and data integrity.
- Used in secure transactions and identity management.
Example: Blockchain-based DNS systems.
Practice Questions
- What are the differences between 802.11a, 802.11b, and 802.11g?
- Explain the role of Mobile IP in cellular networks.
- Describe the working of ZigBee in IoT applications.
- What is the advantage of SDN over traditional networking?
- How does blockchain improve network security?