Computer Networks Cheat Sheet

computer-networks Last verified: 28 Jul 2026

OSI model — 7 layers

LayerNameFunctionExample protocol/device
7ApplicationUser-facing servicesHTTP, FTP, SMTP, DNS
6PresentationData translation, encryption, compressionSSL/TLS, JPEG
5SessionEstablishes/manages/terminates sessionsNetBIOS, RPC
4TransportEnd-to-end delivery, reliabilityTCP, UDP
3NetworkLogical addressing, routingIP, ICMP, Router
2Data LinkPhysical addressing, framingEthernet, MAC address, Switch
1PhysicalRaw bit transmissionCables, Hub, radio signals

Mnemonic (top to bottom): All People Seem To Need Data Processing.

OSI vs TCP/IP model

OSI (7 layers)TCP/IP (4 layers)
Application, Presentation, SessionApplication
TransportTransport
NetworkInternet
Data Link, PhysicalNetwork Access (Link)

OSI is a theoretical reference model; TCP/IP is the actual protocol suite the internet runs on. This distinction is a very common exam question.

PYQ

Which OSI layer is responsible for logical addressing and routing?

  • A) Data Link
  • B) Network
  • C) Transport
  • D) Session

Why: The Network layer (Layer 3) handles IP addressing and routing between networks. The Data Link layer (Layer 2) handles physical/MAC addressing within a single network segment.

PYQ

How many layers does the TCP/IP model have, compared to OSI's 7?

  • A) 3
  • B) 4
  • C) 5
  • D) 6

Why: TCP/IP combines OSI's Application+Presentation+Session into one Application layer, and Data Link+Physical into one Network Access layer — giving 4 layers total (some textbooks show 5 by splitting Network Access).

TCP vs UDP

PropertyTCPUDP
ConnectionConnection-oriented (handshake required)Connectionless
ReliabilityReliable — guarantees delivery, orderUnreliable — no delivery guarantee
SpeedSlower (overhead from reliability)Faster (minimal overhead)
Use caseWeb browsing, email, file transferVideo streaming, DNS, gaming
Header size20 bytes8 bytes

TCP three-way handshake

Client                          Server
  |----------- SYN ------------>|   (Client requests connection)
  |<-------- SYN-ACK -----------|   (Server acknowledges + requests back)
  |----------- ACK ------------>|   (Client confirms — connection established)

Connection termination uses a 4-way handshake (FIN, ACK, FIN, ACK).

PYQ

Which protocol would a live video call most likely use, and why?

  • A) TCP — because it's reliable
  • B) UDP — because low latency matters more than guaranteed delivery
  • C) HTTP — because it's simple
  • D) FTP — because it transfers data fast

Why: Real-time video/audio prioritizes speed over reliability — a dropped packet causing a brief glitch is preferable to TCP's retransmission delay stalling the whole stream.

IP addressing

IPv4 address classes

ClassRange (first octet)Default subnet maskTypical use
A1 – 126255.0.0.0 (/8)Very large networks
B128 – 191255.255.0.0 (/16)Medium networks
C192 – 223255.255.255.0 (/24)Small networks
D224 – 239Multicast
E240 – 255Reserved/experimental

127.x.x.x is reserved for loopback (localhost), not part of Class A’s usable range — a common trap.

CIDR notation

192.168.1.0/24

             number of bits used for the NETWORK portion

/24 = 255.255.255.0 = 256 addresses total, 254 usable
      (1 reserved for network address, 1 for broadcast address)

Usable hosts = 2^(32 - prefix) - 2

PYQ

How many usable host addresses are there in a /24 subnet?

  • A) 256
  • B) 254
  • C) 255
  • D) 128

Why: A /24 gives 2^8 = 256 total addresses, but 2 are reserved — one for the network address, one for the broadcast address — leaving 254 usable for hosts.

Switching techniques

TechniqueHow it worksTrade-off
Circuit SwitchingDedicated path reserved for the entire sessionGuaranteed bandwidth, but wastes idle capacity
Packet SwitchingData split into packets, routed independentlyEfficient sharing, but variable delay (jitter)
Message SwitchingEntire message stored and forwarded hop by hopSimple, but high latency, needs storage at each node

The modern internet uses packet switching — this is a frequently tested fact.

Routing

TypeStrategyExample protocol
Distance VectorEach router shares its full routing table with neighbors; picks path with fewest hopsRIP
Link StateEach router builds a full map of the network topology, computes shortest path itselfOSPF
Distance Vector: "I'll tell you what I know, you figure out the rest"
                 — simpler, but slower to converge, prone to routing loops

Link State:      "I'll tell everyone exactly what I see"
                 — faster convergence, more overhead, no loops

PYQ

RIP (Routing Information Protocol) is an example of which routing approach?

  • A) Distance Vector
  • B) Link State
  • C) Static Routing
  • D) Hybrid Routing

Why: RIP uses the Bellman-Ford algorithm and hop count as its metric — the defining trait of Distance Vector routing. OSPF is the classic Link State example.

Error detection

MethodHow it worksDetects
Parity bitAdds 1 bit to make the count of 1s odd/evenSingle-bit errors only
ChecksumSum of data blocks, transmitted and re-verifiedMost errors, some patterns missed
CRC (Cyclic Redundancy Check)Polynomial division, remainder appendedBurst errors — most robust of the three

CRC is the standard for Ethernet frames precisely because it reliably catches burst errors that simple parity or checksums can miss.

PYQ

Which error detection method is most effective at catching burst errors?

  • A) Parity bit
  • B) Checksum
  • C) CRC
  • D) All are equally effective

Why: CRC uses polynomial division across the entire data block, making it far more robust against burst errors (consecutive corrupted bits) than a simple parity bit or checksum.

Network devices

DeviceOSI LayerFunction
HubPhysical (1)Broadcasts to all ports — no intelligence
SwitchData Link (2)Forwards frames based on MAC address — learns port-MAC mapping
RouterNetwork (3)Forwards packets between different networks, based on IP
GatewayAny/allConnects networks using different protocols entirely

PYQ

A switch makes forwarding decisions based on which address?

  • A) IP address
  • B) MAC address
  • C) Port number
  • D) Domain name

Why: A switch operates at the Data Link layer and forwards frames using MAC addresses, learning which device sits on which port. Routers, by contrast, use IP addresses (Network layer).

DNS, HTTP & common ports

PortProtocolPurpose
20/21FTPFile transfer (data/control)
22SSHSecure remote login
23TelnetUnencrypted remote login
25SMTPSending email
53DNSDomain name resolution
80HTTPWeb traffic (unencrypted)
110POP3Retrieving email
443HTTPSWeb traffic (encrypted)
DNS resolution flow:
  Browser → Local DNS cache → Recursive Resolver
  → Root Server → TLD Server (.com, .in, etc.)
  → Authoritative Name Server → IP address returned

PYQ

What is the default port number for HTTPS?

  • A) 80
  • B) 21
  • C) 443
  • D) 25

Why: Port 443 is the standard for HTTPS (encrypted web traffic). Port 80 is its unencrypted counterpart, HTTP.

CDAC C-CAT — top networking exam traps

TrapRule
OSI vs TCP/IPOSI = 7-layer theoretical model. TCP/IP = 4-layer model that’s actually implemented on the internet.
TCP vs UDPTCP = reliable, connection-oriented, slower. UDP = unreliable, connectionless, faster. Streaming/gaming favor UDP.
Switch vs RouterSwitch works on MAC address (Layer 2). Router works on IP address (Layer 3).
Circuit vs Packet switchingThe modern internet uses packet switching, NOT circuit switching.
Distance Vector vs Link StateRIP = Distance Vector (hop count). OSPF = Link State (full topology map).
/24 usable hosts254, not 256 — 2 addresses are reserved (network + broadcast).
127.x.x.xReserved for loopback, NOT a usable Class A address.
CRC vs Checksum vs ParityCRC catches burst errors best. Parity only catches single-bit errors.
Three-way handshakeSYN → SYN-ACK → ACK. Termination uses a separate 4-way FIN/ACK exchange.
Port 80 vs 44380 = HTTP (unencrypted). 443 = HTTPS (encrypted, uses TLS/SSL).
DNS purposeTranslates domain names to IP addresses — it’s a lookup service, not a routing protocol.

PYQs are indicative of exam style, not guaranteed exact repeats.

Frequently Asked Questions

1 What is the difference between OSI and TCP/IP model?

OSI has 7 layers while TCP/IP has 4 layers. OSI is a theoretical model, TCP/IP is the practical implementation used on the internet.

2 Which layer handles routing in OSI model?

The Network Layer (Layer 3) handles routing, logical addressing, and path determination between source and destination.