Computer Networks
OSI model, TCP/IP, protocols
Computer Networks form the backbone of modern communication systems. This topic covers the fundamental concepts of how computers connect and communicate, including network models (OSI and TCP/IP), addressing schemes, protocols, and routing mechanisms. Understanding these concepts is essential for technical interviews in software engineering, system administration, and network engineering roles.
Key formulas and rules
Key concepts
OSI Model (7 Layers)
The Open Systems Interconnection model standardizes network communication:
1. Physical Layer: Transmits raw bit stream over physical medium (cables, hubs, repeaters). Deals with voltage levels, pin layouts, timing.
2. Data Link Layer: Provides node-to-node delivery with error detection (MAC addressing, switches, bridges). Divided into LLC and MAC sublayers.
3. Network Layer: Handles logical addressing and routing (IP, routers). Determines best path from source to destination.
4. Transport Layer: End-to-end communication, reliability, flow control (TCP, UDP). TCP provides reliability; UDP provides speed.
5. Session Layer: Establishes, manages, and terminates sessions between applications. Handles dialogue control and synchronization.
6. Presentation Layer: Data translation, encryption, compression. Converts data formats between application and network.
7. Application Layer: Interface for applications to access network services (HTTP, FTP, SMTP, DNS).
Mnemonic: 'Please Do Not Throw Sausage Pizza Away' (bottom-up) or 'All People Seem To Need Data Processing' (top-down).
TCP/IP Model (4 Layers)
The practical implementation model used in the Internet:
1. Network Interface (Link) Layer: Combines OSI Physical and Data Link. Handles physical transmission and MAC addressing (Ethernet, Wi-Fi, ARP).
2. Internet Layer: Corresponds to OSI Network Layer. Responsible for logical addressing, routing, and fragmentation (IP, ICMP, IGMP).
3. Transport Layer: Same as OSI Transport. Provides process-to-process communication (TCP for reliable, UDP for fast).
4. Application Layer: Combines OSI Session, Presentation, and Application. Supports user applications (HTTP, HTTPS, FTP, SSH, DNS, SMTP).
Key Protocols by Layer:
Link: Ethernet, Wi-Fi (802.11), PPP, ARP
Internet: IPv4, IPv6, ICMP (ping), IGMP (multicast)
Transport: TCP, UDP, SCTP
Application: HTTP/80, HTTPS/443, FTP/20,21, SSH/22, DNS/53, SMTP/25, POP3/110, IMAP/143
IP Addressing and Subnetting
IPv4 addresses are 32-bit numbers written in dotted decimal notation (e.g., 192.168.1.1).
Address Classes (legacy, now mostly obsolete due to CIDR):
Class A: 1.0.0.0 to 126.255.255.255 (default mask /8, 16M hosts)
Class B: 128.0.0.0 to 191.255.255.255 (default mask /16, 65K hosts)
Class C: 192.0.0.0 to 223.255.255.255 (default mask /24, 254 hosts)
Class D: 224.0.0.0 to 239.255.255.255 (multicast)
Class E: 240.0.0.0 to 255.255.255.255 (reserved)
Private IP Ranges (RFC 1918):
10.0.0.0/8 (10.0.0.0 - 10.255.255.255)
172.16.0.0/12 (172.16.0.0 - 172.31.255.255)
192.168.0.0/16 (192.168.0.0 - 192.168.255.255)
Subnetting: Borrowing bits from host portion to create subnets.
CIDR notation: IP/prefix length (e.g., 192.168.1.0/24)
/24 = 255.255.255.0 = 256 addresses, 254 usable hosts
/16 = 255.255.0.0 = 65,536 addresses
IPv6: 128-bit addresses in hexadecimal (e.g., 2001:0db8:85a3::8a2e:0370:7334), eliminating NAT issues and providing vast address space.
Worked examples
Example 1
A company has been allocated the network 192.168.10.0/24. They need to create 4 subnets with at least 50 hosts each. What subnet mask should they use?
Step 1: Determine how many bits to borrow for subnets.
Need 4 subnets -> 2^n >= 4 -> n = 2 bits
Step 2: Check remaining host bits can support 50 hosts.
Original: /24 means 8 host bits
After borrowing 2 bits: 6 host bits remain
Hosts per subnet = 2^6 - 2 = 64 - 2 = 62 hosts
62 >= 50, so this works.
Step 3: Calculate new subnet mask.
Original /24 = 255.255.255.0
Borrowing 2 bits: /24 + 2 = /26
/26 in binary: 11111111.11111111.11111111.11000000
Decimal: 255.255.255.192
Step 4: Verify subnets.
Subnet 1: 192.168.10.0 - 192.168.10.63 (usable: .1 - .62)
Subnet 2: 192.168.10.64 - 192.168.10.127
Subnet 3: 192.168.10.128 - 192.168.10.191
Subnet 4: 192.168.10.192 - 192.168.10.255
Answer: /26 or 255.255.255.192
Example 2
In TCP, a sender has a window size of 8000 bytes and RTT of 100ms. What is the theoretical maximum throughput? If the packet size is 1000 bytes, how many packets can be in flight simultaneously?
Step 1: Calculate throughput using Bandwidth-Delay concept.
Throughput = Window Size / RTT
Window Size = 8000 bytes = 64000 bits
RTT = 100ms = 0.1 seconds
Step 2: Calculate throughput.
Throughput = 64000 bits / 0.1 s = 640,000 bps = 640 Kbps
Step 3: Calculate packets in flight.
Packet size = 1000 bytes
Window size = 8000 bytes
Packets in flight = 8000 / 1000 = 8 packets
Step 4: Verify interpretation.
With window size of 8000 bytes, sender can send 8 full packets (1000 bytes each) before needing acknowledgment. This maximizes pipeline utilization.
Answer: Maximum throughput = 640 Kbps, Packets in flight = 8 packets
Example 3
A network uses CSMA/CD with a bandwidth of 1 Gbps. The maximum distance between any two stations is 2 km, and the signal propagation speed is 2 x 10^8 m/s. What is the minimum frame size required?
Step 1: Understand CSMA/CD timing requirement.
For CSMA/CD to work, transmission time must be at least twice the propagation time.
Minimum frame size condition: Transmission Time >= 2 x Propagation Time
Step 2: Calculate propagation time.
Distance = 2 km = 2000 meters
Propagation speed = 2 x 10^8 m/s
Propagation Time = Distance / Speed = 2000 / (2 x 10^8) = 10^-5 seconds = 10 microseconds
Step 3: Calculate required transmission time.
Transmission Time >= 2 x 10^-5 seconds = 20 microseconds
Step 4: Calculate minimum frame size.
Bandwidth = 1 Gbps = 10^9 bits/second
Minimum Frame Size = Bandwidth x Transmission Time
= 10^9 bits/s x 20 x 10^-6 s
= 10^9 x 20 x 10^-6 bits
= 20,000 bits
= 2,500 bytes
Answer: Minimum frame size = 2500 bytes (or 20,000 bits)
Example 4
In a network using pure Aloha, stations transmit at 1000 frames/second. If the frame transmission time is 1ms, what is the throughput?
Representative solved questions
See the kind of question in this topic before opening the full practice set.
Question 1
Which layer of the OSI model is responsible for routing packets between different networks?
Transport layer
Network layer
Data Link layer
Session layer
Answer: B. Network layer
ExplanationStep 1: The OSI model has 7 layers.
Step 2: The Network layer (Layer 3) handles logical addressing and routing.
Step 3: It determines the best path for data packets to travel from source to destination across multiple networks.
Step 4: Routers operate at this layer using IP addresses.
Answer: Network layer
Sources and review notes
This is an AISEA-authored practice question.
Review status: accepted · Reviewed 2026-08-13 · structure and answer-key checks, editorial quality checks, duplicate screening
Question 2
What is the default port number for HTTP?
21
80
443
8080
Answer: B. 80
ExplanationStep 1: HTTP (Hypertext Transfer Protocol) uses well-known port numbers.
Step 2: Port 80 is the standard/default port for HTTP traffic.
Step 3: Port 443 is for HTTPS (secure HTTP).
Step 4: Port 21 is for FTP, and 8080 is commonly used as an alternative HTTP port.
Answer: 80
Sources and review notes
This is an AISEA-authored practice question.
Review status: accepted · Reviewed 2026-08-13 · structure and answer-key checks, editorial quality checks, duplicate screening
Question 3
Which protocol is connectionless and provides best-effort delivery?
TCP
UDP
HTTP
FTP
Answer: B. UDP
ExplanationStep 1: TCP is connection-oriented with guaranteed delivery.
Step 2: UDP (User Datagram Protocol) is connectionless.
Step 3: UDP sends data without establishing a connection or confirming receipt.
Step 4: It provides faster transmission but no reliability guarantees.
Answer: UDP
Sources and review notes
Common mistakes and useful habits
- Memorize OSI layer order and functions using mnemonics. Common interview question: 'What layer does a router/switch operate at?' Router = Layer 3 (Network), Switch = Layer 2 (Data Link).
- For subnetting problems, always draw out the binary representation. Practice converting between dotted decimal and CIDR notation quickly. Remember: number of hosts = 2^(host bits) - 2.
- TCP 3-way handshake sequence is always SYN -> SYN-ACK -> ACK. Remember that final ACK may contain data. Connection termination uses 4-way handshake (FIN-ACK in each direction).
- For routing protocol questions: Distance Vector = RIP (hop count, slow convergence); Link State = OSPF (cost-based, fast convergence); Path Vector = BGP (policy-based, inter-domain).
- HTTP default port is 80, HTTPS is 443, SSH is 22. These come up frequently in interview questions about troubleshooting connectivity or firewall rules.
- Understand NAT types: Static NAT (1-to-1 mapping), Dynamic NAT (pool-based), PAT (Port Address Translation - many-to-one using different ports). PAT is most common in home routers.
Ready to test your understanding?
Work through 176 questions with explanations after each answer.