Computer Networks โ€“ University Level โ€“ Pak Notes Hub
๐ŸŒ University Level โ€” BS CS / BS IT

Computer Networks
Complete Notes

OSI Model ยท TCP/IP ยท Routing ยท Switching ยท DNS ยท Security ยท All in Easy English

OSI Model
Protocols
Network Security
Unit 1

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

TypeRangeExamples
PANFew metersBluetooth devices, Smartphone connections
LANSingle buildingOffice networks, Schools
MANCity-wideCity WiFi networks
WANWorldwideInternet, 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

TopologyStructurePros/Cons
BusAll connected to single cableSimple but failure prone
StarAll connected to central hubReliable but single point of failure
RingCircular connectionFair but complex
MeshMultiple connectionsReliable but expensive
TreeHierarchicalScalable and organized
โœ๏ธ Practice: Compare advantages of different network topologies
Unit 2

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

#LayerFunctionDevices
7ApplicationUser apps - HTTP, FTP, DNSBrowser, Mail client
6PresentationData formatting, encryptionEncryption software
5SessionEstablishes connectionsSession manager
4TransportReliable delivery - TCP, UDPGateway
3NetworkRouting - IP addressesRouter
2Data LinkFraming - MAC addressesSwitch, Bridge
1PhysicalCables, voltages, signalsHub, 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)
๐Ÿ’ก Mnemonic: Please Do Not Throw Sausage Pizza Away = Presentation, Data Link, Network, Transport, Session, Physical, Application
โœ๏ธ Practice: Trace data through OSI model from user to network
Unit 3

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

TypeSpeedDistance
10BaseT10 Mbps100m
100BaseT (Fast Ethernet)100 Mbps100m
1000BaseT (Gigabit)1 Gbps100m
10GbE10 GbpsLimited

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
โœ๏ธ Practice: Explain ARP protocol and MAC address resolution
Unit 4

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.

โœ๏ธ Practice: Calculate network address and broadcast from given IP and subnet mask
Unit 5

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

FeatureTCPUDP
ConnectionEstablishes connectionConnectionless
ReliabilityGuaranteed deliveryNo guarantee
OrderingIn-order deliveryOut-of-order possible
SpeedSlower (overhead)Faster (minimal)
UsesHTTP, FTP, Email, SSHDNS, 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
โœ๏ธ Practice: When would you use TCP vs UDP? Give examples
Unit 6

Application Layer

User Applications and Services

Common Application Protocols

ProtocolPurposePort
HTTP/HTTPSWeb browsing80/443
FTPFile transfer20/21
SMTPSend email25/587
POP3/IMAPReceive email110/143
DNSName resolution53
SSHSecure shell22
TelnetRemote login23

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 returned

HTTP 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)
โœ๏ธ Practice: Trace steps of DNS query and HTTP request
Unit 7

Routing Algorithms

Finding Optimal Paths in Networks

Routing Types

  • Static: Manually configured routes
  • Dynamic: Automatically adjusts to network changes

Routing Algorithms

AlgorithmTypeHow It Works
DijkstraLink-stateFind shortest path, calculates all routes
Bellman-FordDistance-vectorIterative, handles negative weights
RIPDistance-vectorHop count, simple but limited
OSPFLink-stateMost popular, hierarchical
BGPPath-vectorInternet 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
โœ๏ธ Practice: Apply Dijkstra's algorithm to find shortest path
Unit 8

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

MethodLatencyError Detection
Cut-throughLowNone
Store-and-forwardHigherCRC check
Fragment-freeMediumPartial 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.

โœ๏ธ Practice: Trace frame forwarding through multi-switch network
Unit 9

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

AttackHow It WorksPrevention
EavesdroppingListen to trafficEncryption (SSL/TLS)
DDoSFlood server with trafficFirewalls, Rate limiting
PhishingFake emails trick usersUser education
Man-in-the-MiddleIntercept communicationsDigital certificates
MalwareMalicious softwareAntivirus, 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
โœ๏ธ Practice: Explain how HTTPS secures data transmission
Unit 10

Wireless Networks

WiFi and Mobile Communications

Wireless Standards

StandardFrequencySpeedRange
802.11a5 GHz54 Mbps35m
802.11b2.4 GHz11 Mbps100m
802.11g2.4 GHz54 Mbps100m
802.11n (WiFi 4)2.4/5 GHz300 Mbps150m
802.11ac (WiFi 5)5 GHz1.3 Gbps100m
802.11ax (WiFi 6)2.4/5 GHz9.6 Gbps100m

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
โœ๏ธ Practice: Compare WiFi vs cellular networks

๐ŸŽ‰ 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