Home › CSE Hub › Computer Networks

Computer Networks

Network types and topologies, the OSI and TCP/IP models, IP addressing and subnetting, TCP vs UDP, routing, and key protocols such as HTTP, DNS and DHCP.

हिंदी में: कंप्यूटर आपस में डेटा कैसे भेजते हैं — OSI मॉडल, IP एड्रेस, TCP/UDP और इंटरनेट प्रोटोकॉल।

What is a computer network?

A computer network is a group of devices connected to share data and resources. The internet is a “network of networks” connecting billions of devices.

By size: PAN (personal, e.g. Bluetooth), LAN (a building or campus), MAN (a city), WAN (countries — the internet).

Topologies: bus, star (most common in LANs), ring, mesh (highly reliable), tree and hybrid.

Devices: NIC, hub (layer 1), switch (layer 2, uses MAC addresses), router (layer 3, uses IP addresses), modem, access point, firewall.

The OSI model (7 layers)

# Layer Job Examples
7 Application Services for user applications HTTP, FTP, SMTP, DNS
6 Presentation Data format, encryption, compression TLS/SSL, JPEG
5 Session Opens, manages and closes sessions RPC, NetBIOS
4 Transport Process-to-process delivery, reliability TCP, UDP
3 Network Logical addressing and routing IP, ICMP
2 Data link Framing, MAC addressing, error detection Ethernet, Wi-Fi (802.11)
1 Physical Bits on the medium Cables, fibre, radio

The practical TCP/IP model has four layers: Application, Transport, Internet and Link (network access).

IP addressing

  • IPv4 – 32 bits, written as four decimal numbers (e.g. 192.168.1.10), about 4.3 billion addresses.
  • IPv6 – 128 bits, written in hexadecimal (e.g. 2001:db8::1), a practically unlimited address space.

Private IPv4 ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16. NAT lets many private devices share one public IP.

Subnetting example

192.168.1.0/26 means 26 network bits and 6 host bits. – Subnet mask: 255.255.255.192 – Addresses per subnet: 2⁶ = 64; usable hosts: 64 − 2 = 62 – Subnets: .0, .64, .128, .192

TCP vs UDP

TCP UDP
Connection Connection-oriented (3-way handshake: SYN, SYN-ACK, ACK) Connectionless
Reliability Guaranteed, ordered delivery with acknowledgements and retransmission Best effort; no guarantee
Control Flow control (sliding window) and congestion control None
Speed Slower, more overhead Faster, lightweight
Used by Web (HTTP/1.1, HTTP/2), email, file transfer DNS queries, video calls, online games, streaming

Note: HTTP/3 runs over QUIC, which is built on UDP.

Important protocols and ports

Protocol Purpose Port
HTTP / HTTPS Web pages 80 / 443
DNS Converts domain names into IP addresses 53
DHCP Automatically assigns IP addresses 67/68
SMTP Sending email 25 (587 for submission)
IMAP / POP3 Receiving email 143 / 110
FTP File transfer 20/21
SSH Secure remote login 22

ARP maps an IP address to a MAC address on a local network. ICMP carries error and diagnostic messages (used by ping and traceroute).

Routing

Routers forward packets using routing tables. – Distance vector (e.g. RIP) – routers share distances with neighbours (Bellman–Ford idea). – Link state (e.g. OSPF) – routers build a full map and run Dijkstra’s algorithm. – BGP – the path-vector protocol that connects networks across the internet.

Error detection and control

Parity bits, checksums and CRC detect errors; Hamming code can also correct single-bit errors. Flow control methods include stop-and-wait, Go-Back-N and Selective Repeat.

What happens when you open a website?

  1. The browser asks DNS for the IP address of the domain.
  2. A TCP connection (or QUIC) is opened to the server, then a TLS handshake secures it.
  3. The browser sends an HTTP request; the server returns an HTTP response (HTML, CSS, JS).
  4. The browser renders the page and fetches additional resources.

Quick revision

  • OSI: Please Do Not Throw Sausage Pizza Away (Physical → Application).
  • Switch = MAC (layer 2); router = IP (layer 3).
  • TCP is reliable; UDP is fast.
  • /26 gives 62 usable hosts.