Computer networks MCQs with answers and explanations
Review network models, protocols, addressing and transport concepts, then practise questions with explanations. Build networking foundations for technical placement tests, interviews and GATE CS.
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
10 rulesUsable IPv4 Subnet Hosts: , where is the number of host bits (excluding network and broadcast addresses)
Subnet Mask Prefix:
Number of Subnets: , where is the number of borrowed subnet bits
Propagation Delay: , where is distance and is propagation speed
Transmission Delay: , where is packet length in bits and is bandwidth in bps
Bandwidth-Delay Product (BDP):
TCP Max Throughput:
CSMA/CD Minimum Frame Size:
Channel Efficiency: Pure ALOHA ; Slotted ALOHA
Hamming Distance Bounds: To detect bit errors, ; to correct bit errors,
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.
TCP vs UDP
Transport Layer Protocols - choose based on application needs:
TCP (Transmission Control Protocol):
Connection-oriented (3-way handshake: SYN, SYN-ACK, ACK)
Reliable delivery with acknowledgments and retransmissions
Ordered delivery (sequence numbers, reordering at receiver)
Flow control (sliding window algorithm)
Congestion control (slow start, congestion avoidance, fast retransmit)
Header size: 20-60 bytes
Use cases: Web browsing (HTTP), email (SMTP), file transfer (FTP)
UDP (User Datagram Protocol):
Connectionless (no handshake, immediate transmission)
Unreliable (no acknowledgments, no retransmissions)
No ordering guarantees
No flow or congestion control
Header size: 8 bytes (much smaller than TCP)
Use cases: Video streaming, online gaming, VoIP, DNS queries
TCP Header Fields: Source/Dest Port, Sequence Number, Ack Number, Data Offset, Flags (URG, ACK, PSH, RST, SYN, FIN), Window Size, Checksum, Urgent Pointer, Options
UDP Header Fields: Source Port, Destination Port, Length, Checksum
Well-known Ports: 0-1023 (reserved)
20/21: FTP
22: SSH
25: SMTP
53: DNS
80: HTTP
110: POP3
143: IMAP
443: HTTPS
3306: MySQL
5432: PostgreSQL
Network Devices
Devices operate at different OSI layers with distinct functions:
Repeater (Layer 1): Amplifies and regenerates signals to extend cable length. No intelligence, just signal boosting.
Hub (Layer 1): Multi-port repeater. Broadcasts data to all connected devices. Creates one collision domain and one broadcast domain. Inefficient, rarely used today.
Bridge (Layer 2): Connects two network segments. Uses MAC addresses to filter traffic. Reduces collision domains.
Switch (Layer 2): Intelligent multi-port bridge. Uses MAC address table to forward frames only to intended recipient. Each port is a separate collision domain. Types: unmanaged, managed, PoE.
Router (Layer 3): Connects different networks (LANs, WANs). Uses IP addresses and routing tables to forward packets. Separates broadcast domains. Implements routing protocols.
Gateway (Layer 4-7): Protocol converter between different network architectures. Can translate between different protocols at multiple layers.
Access Point (Layer 2): Wireless connectivity device. Bridges wireless clients to wired networks.
Firewall (Layer 3-7): Security device filtering traffic based on rules. Types: packet filter, stateful inspection, application layer (proxy).
Load Balancer (Layer 4-7): Distributes traffic across multiple servers. Algorithms: round-robin, least connections, IP hash.
Routing Algorithms and Protocols
Routing determines the best path for data packets to travel from source to destination.
Types of Routing:
Static Routing: Manually configured routes. Simple, secure, but not scalable for large networks.
Dynamic Routing: Automatically adapts to network changes using routing protocols.
Routing Protocol Categories:
1. Distance Vector Protocols (Bellman-Ford algorithm):
RIP (Routing Information Protocol): Uses hop count (max 15), broadcasts every 30s
IGRP (Cisco proprietary): Uses bandwidth, delay, load, reliability
Characteristics: Simple, slower convergence, count-to-infinity problem
2. Link State Protocols (Dijkstra's SPF algorithm):
OSPF (Open Shortest Path First): Fast convergence, hierarchical with areas, uses cost metric
IS-IS: Similar to OSPF, used in large ISP networks
Characteristics: Complex, faster convergence, maintains complete topology map
3. Path Vector Protocols:
BGP (Border Gateway Protocol): Inter-domain routing between autonomous systems (AS). Uses policy-based routing with attributes.
eBGP: Between different AS
iBGP: Within same AS
4. Hybrid Protocols:
EIGRP (Enhanced IGRP): Cisco proprietary, combines distance vector and link state features
Routing Metrics: Hop count, Bandwidth, Delay, Load, Reliability, Cost
Autonomous System (AS): Collection of IP networks under single administrative control. Identified by AS Number (ASN).
Network Topologies
Physical and logical arrangements of network devices:
Bus Topology: All devices connected to single cable (backbone). Simple, cheap, but single point of failure and collision issues.
Star Topology: All devices connected to central hub/switch. Easy to manage, single device failure doesn't affect others, but central device failure is critical. Most common in LANs.
Ring Topology: Devices connected in circular fashion. Token passing controls access (Token Ring). No collisions, but single break disrupts entire network.
Mesh Topology: Every device connected to every other device. Highly redundant and reliable, but expensive and complex. Full mesh: n(n-1)/2 connections for n devices. Partial mesh: selected connections.
Tree Topology: Hierarchical star structure. Combines multiple star networks. Good for large networks, but root failure affects large portion.
Hybrid Topology: Combination of two or more topologies. Common in enterprise networks.
Ethernet (IEEE 802.3): Dominant LAN technology
CSMA/CD (Carrier Sense Multiple Access with Collision Detection): Listen before transmit, detect collisions, backoff and retry
Ethernet types: 10Base-T (10 Mbps), 100Base-TX (Fast Ethernet), 1000Base-T (Gigabit), 10GBase-T
Full-duplex (simultaneous send/receive, no collisions) vs Half-duplex
Network Security Concepts
Securing network communications and infrastructure:
Firewalls:
Packet Filtering: Examines source/dest IP, port, protocol. Fast but limited.
Stateful Inspection: Tracks connection state. More secure than simple filtering.
Application Layer (Proxy): Intercepts and inspects application data. Most secure, slower.
Next-Generation (NGFW): Deep packet inspection, intrusion prevention, application awareness.
VPN (Virtual Private Network):
Creates encrypted tunnel over public Internet
Types: Site-to-Site (connecting networks), Remote Access (individual users)
Protocols: IPsec (L3 encryption), SSL/TLS VPN (L4-7, via browser), PPTP, L2TP
NAT (Network Address Translation):
Translates private IPs to public IP(s)
Types: Static NAT (1:1), Dynamic NAT (pool of public IPs), PAT/Port NAT (many:1, port multiplexing)
Hides internal network structure, conserves IPv4 addresses
Encryption Protocols:
TLS/SSL: Secures web traffic (HTTPS)
IPsec: Secures IP communications (VPNs)
SSH: Secure remote login (replaces Telnet)
WPA2/WPA3: Wi-Fi security protocols
Threats: DDoS attacks, Man-in-the-Middle, Packet Sniffing, IP Spoofing, DNS Poisoning, ARP Spoofing
Worked examples
Example 1
A network block 192.168.10.0/24 needs to be partitioned into 4 subnets with at least 50 hosts per subnet. What subnet mask must be used?
Solution
Step 1: Determine subnet bits borrowed.
To create 4 subnets: .
New CIDR prefix = .
Step 2: Verify host capacity.
Remaining host bits .
Step 3: Convert to dotted decimal.
Answer: 255.255.255.192 (or /26).
Example 2
In TCP, a sender operates with a congestion window of 8,000 bytes over a path with ms. What is the maximum theoretical throughput?
Solution
Step 1: Express throughput in terms of Window Size and RTT.
Step 2: Convert to kilobits per second.
Answer: 640 kbps.
Example 3
A CSMA/CD network operates at 1 Gbps. The maximum distance between any two stations is 2 km, and signal propagation speed is . Find the minimum frame size required for collision detection.
Solution
Step 1: Calculate propagation delay .
Step 2: Collision detection requires transmission time .
Step 3: Convert to bytes.
Answer: 2,500 bytes (or 20,000 bits).
Example 4
In pure ALOHA, stations generate frames at an arrival rate of frames per frame-time. What is the channel utilization (throughput)?
Solution
Step 1: Apply the pure ALOHA throughput equation.
Step 2: Substitute .
Answer: Approximately 18.4%.
Representative solved questions
See the kind of question in this topic before opening the full practice set.
Question 1
Which routing protocol uses the Dijkstra algorithm to calculate the shortest path?
Answer: B. OSPF
ExplanationStep 1: RIP uses distance vector algorithm with hop count.
Step 2: OSPF (Open Shortest Path First) is a link-state protocol.
Step 3: OSPF uses Dijkstra's SPF algorithm to compute shortest paths.
Step 4: BGP is a path-vector protocol for inter-domain routing.
Answer: OSPF
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 type of NAT allows multiple internal hosts to share a single public IP address using different port numbers?
Answer: C. PAT (Port Address Translation)
ExplanationStep 1: Static NAT maps one private IP to one public IP (1:1).
Step 2: Dynamic NAT maps private IPs to a pool of public IPs.
Step 3: PAT (also called NAT Overload) uses port numbers to distinguish connections.
Step 4: This allows many-to-one mapping, conserving public IP addresses.
Answer: PAT (Port Address Translation)
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
In the TCP three-way handshake, what is the correct sequence of flags?
Answer: A. SYN, SYN-ACK, ACK
ExplanationStep 1: Client sends SYN (synchronize) to initiate connection.
Step 2: Server responds with SYN-ACK (synchronize-acknowledge).
Step 3: Client sends ACK to complete the handshake.
Step 4: This establishes the TCP connection for data transfer.
Answer: SYN, SYN-ACK, ACK
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
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.