📝 Network Structure in The Linux System (21 MCQs)
Layered Linux Networking Architecture
The Linux network structure connects applications and kernel protocols with physical or virtual network interfaces. It includes the socket interface, transport and network protocols, packet-processing facilities, network devices, and device drivers. This layered design allows programs to use network communication services while the kernel handles packet routing, protocol processing, buffering, and hardware interaction.
Why Network Operations Need Structured Kernel Layers
Applications should not need to manipulate Ethernet frames, device registers, or routing tables directly. Separate layers divide application communication, transport reliability, IP addressing, and link delivery. This architecture supports multiple network technologies and lets Linux provide common socket interfaces across different hardware and protocols.
Socket Layer, Protocol Stack and Network Devices
An application creates a socket and sends data through a transport protocol such as TCP or UDP. The network layer constructs IP packets, and the link layer prepares frames for transmission. The kernel passes outgoing data through device queues to a network driver and NIC; incoming packets follow the reverse processing path.
Example of an Outgoing TCP Packet
A process writes 1000 bytes to a TCP socket. TCP adds transport information, IP adds addressing, and the link layer forms a frame. The network device driver places the packet onto the interface's transmit queue, and the NIC sends it through the connected network.
Packet Throughput, Queuing and Network Controls
Linux networking supports routing, filtering, traffic control, virtual interfaces, and high-throughput packet processing. Queueing and protocol processing consume CPU time, while congestion and packet loss affect performance. Features such as NAPI, multi-queue networking, and offload capabilities improve efficiency, but their benefits depend on driver, hardware, and workload support.
Misconceptions About Linux Networking
'The socket layer directly controls the NIC registers' ignores protocol and driver layers. 'Every received packet reaches the application unchanged' overlooks headers, filtering, and protocol processing. 'TCP and IP provide identical services' confuses reliable transport with network-layer addressing and routing.
Exam Focus: Packet Flow Through the Linux Stack
Trace outgoing and incoming data through sockets, transport protocols, IP, link processing, and device drivers. Distinguish routing from switching and packet filtering from transport reliability. Questions may examine network queues, NIC interrupts, NAPI polling, or the roles of TCP, UDP, and IP in communication.
Key Terms of Linux Network Structure
- Socket - Application network communication endpoint.
- NIC - Network interface hardware.
- sk_buff - Linux kernel packet buffer structure.
- NAPI - Hybrid interrupt and polling mechanism.
- Network driver - Software controlling a network interface.
📝 All Network Structure in The Linux System MCQs
Q1. What is the primary unit that the kernel uses when performing I/O on a block device?
📖 Explanation: The kernel works with blocks, which are fixed‑size chunks of data transferred to or from a device. A block represents the unit of I/O, meaning every read or write operation is expressed in terms of whole blocks. The other choices describe unrelated concepts: a character interface deals with streams, a network socket handles communication, and a process scheduler manages CPU time. Understanding blocks is essential for managing disk access efficiently.
Q2. Why is the C‑SCAN algorithm described as a unidirectional‑elevator algorithm?
📖 Explanation: C‑SCAN scans the request list from the lowest to the highest sector number, servicing requests as it moves in a single direction. When it reaches the highest sector, the head returns quickly to the lowest sector without servicing any requests, then resumes the same direction. This one‑way movement gives the algorithm its “unidirectional‑elevator” name. The other options mischaracterize its behavior.
Q3. A system with a heavy read workload needs higher throughput. Which I/O scheduler is most likely to improve performance?
📖 Explanation: The Completely Fair Queueing (CFQ) scheduler gives each process a time slice of I/O, which often results in better throughput for read‑intensive workloads because it can keep the disk busy while fairly sharing access. C‑SCAN still follows a strict head‑movement pattern that may not exploit read locality as well. FIFO simply processes requests in arrival order, and disabling scheduling removes any intelligent ordering, both of which can degrade performance.
Q4. When a new I/O request arrives while the driver is processing a current request, when can the new request be merged with existing ones?
📖 Explanation: Merging is performed only after the active request finishes, because the driver cannot safely combine an in‑flight operation with pending ones. Once the current I/O completes, the scheduler examines the request list and merges adjacent or overlapping requests to reduce disk seeks. Immediate merging could corrupt data, and merging is not limited to identical sectors; it works on contiguous ranges.
Q5. What does the acronym CFQ stand for in Linux I/O scheduling?
📖 Explanation: CFQ is short for Completely Fair Queueing, a scheduler introduced in Linux 2.6 that aims to allocate I/O bandwidth fairly among processes. The other expansions are fabricated and do not correspond to any Linux component. Knowing the correct expansion helps students recognize the scheduler’s design goal of fairness, which distinguishes it from older elevator‑style algorithms.
Q6. How does CFQ differ fundamentally from traditional elevator‑based I/O algorithms?
📖 Explanation: CFQ gives each process a time slice of I/O, allowing multiple processes to share the device in a fair manner, whereas elevator algorithms like C‑SCAN simply order requests by their sector numbers. This per‑process fairness is the key distinction. The other choices misrepresent CFQ’s behavior; it still respects sector ordering within a slice but does not rely solely on it.
Q7. What is the main benefit of request merging in block‑device I/O?
📖 Explanation: Merging combines adjacent or overlapping requests into a single larger operation, which means the disk head moves fewer times, reducing seek time and improving performance. The other options describe negative effects that merging does not cause; it does not increase latency, duplicate data, or interfere with caching. By decreasing seeks, merging directly contributes to faster I/O.
Q8. Why are request lists typically kept sorted by the starting‑sector number?
📖 Explanation: Sorting by starting sector allows the scheduler to service requests in an order that moves the disk head smoothly across the platter, which minimizes the distance it must travel and thus reduces latency. Randomizing or encrypting the order would increase seek time, and confusing drivers is not a design goal. The sorted list is a core optimization for mechanical disks.
Q9. A server shows long latency spikes when many small write requests arrive simultaneously. Which scheduler change is most likely to smooth the latency?
📖 Explanation: CFQ assigns time slices to processes, which helps smooth out bursts of small writes by preventing any single process from monopolizing the disk. C‑SCAN still processes writes in strict head order, which can still experience spikes. Disabling scheduling removes any intelligent ordering, and simply increasing block size does not address the bursty nature of the workload.
Q10. In a database that performs sequential reads followed by occasional random writes, which scheduler best balances read throughput with write handling?
📖 Explanation: The deadline scheduler maintains separate read and write queues and enforces timing constraints, allowing it to prioritize sequential reads while still servicing random writes promptly. CFQ provides fairness but may not give reads the priority they need for high throughput, and C‑SCAN treats all requests equally, potentially delaying writes. Noop does almost nothing, offering no advantage for mixed workloads.
Q11. If a block‑device driver reports that a request has completed but the request list still contains the entry, what is the most likely cause?
📖 Explanation: When a driver signals completion, it is expected to also delete the corresponding entry from the request list. If the entry remains, the most common explanation is a programming oversight where the removal step was omitted. The request is not pending—completion indicates it finished. Request lists are mutable, and merging would have already removed the entry during the merge operation.
Q12. A system equipped with SSDs shows no performance gain when switching from FIFO to CFQ. Why is this expected?
📖 Explanation: SSDs have almost no mechanical seek latency, so the primary advantage of CFQ—fair distribution of seek time—is irrelevant. Consequently, CFQ offers little or no improvement over a simple FIFO queue. While CFQ was introduced to improve HDD performance, it does not harm SSDs, but the expected benefit simply does not materialize.
Q13. How does the concept of a “time slice” in CFQ affect I/O fairness among processes?
📖 Explanation: CFQ divides the disk’s bandwidth into equal time slices that are allocated to each active process in turn, ensuring that no single process can dominate I/O resources. This per‑process allocation creates fairness. Faster processes do not get larger slices, priority does not change the basic slice size (though priority can affect weighting), and the allocation is deterministic, not random.
Q14. What is the impact of maintaining separate request lists for each block‑device driver?
📖 Explanation: Having an individual request list for each driver keeps the I/O streams of different devices independent, so a busy disk does not affect the scheduling of another device. This isolation improves performance and simplifies management. Merging all requests would create contention, deadlocks are unrelated, and the memory impact is modest rather than dramatically reduced.
Q15. A high‑performance web server uses multiple disks with different rotational speeds and currently runs C‑SCAN on all disks. Which scheduling strategy could maximize overall throughput while preventing slower disks from becoming bottlenecks?
📖 Explanation: Applying CFQ individually to each disk allows the scheduler to give faster disks more frequent service slices, matching their higher I/O capability, while still providing fairness. A single global C‑SCAN queue would force the slowest disk to dictate the overall head‑movement cadence, creating a bottleneck. Disabling scheduling on fast disks removes any intelligent ordering, and randomization would increase seek times.
Q16. During heavy load, the system’s I/O latency spikes every 30 seconds, correlating with the request manager’s merge attempts. Which modification could reduce these latency spikes?
📖 Explanation: Moving the merge operation to an asynchronous thread allows the main I/O path to continue processing without waiting for the potentially costly merge computation, smoothing latency spikes. Enlarging the merge window can actually increase merge time, disabling merging removes a performance benefit, and simply prioritizing reads does not address the merge‑related delay.
Q17. A kernel developer wants to test the effect of request ordering on SSD wear. Which algorithm should they replace CFQ with to produce the most sequential write pattern?
📖 Explanation: The noop scheduler performs virtually no reordering; it passes requests to the device in the order they arrive, preserving sequentiality. This behavior yields the most straightforward write pattern, useful for evaluating wear. C‑SCAN still imposes a head‑movement order, deadline adds timing constraints, and anticipatory attempts to predict future reads, none of which guarantee a purely sequential write stream.
Q18. In a virtualization environment, guest VMs issue interleaved I/O requests. Which scheduler helps isolate each VM’s I/O while still allowing high throughput?
📖 Explanation: CFQ maintains separate queues for each process (or VM), providing isolation that prevents one VM’s heavy I/O from starving others, while still delivering high throughput through its time‑slice mechanism. C‑SCAN treats all requests as a single stream, losing isolation. Deadline focuses on meeting deadlines but does not inherently separate VMs, and a proportional‑share scheduler is not a standard Linux I/O scheduler.
Q19. A request manager merges adjacent sectors. If two requests for sectors 100‑199 and 200‑299 arrive, will they be merged?
📖 Explanation: Adjacency is sufficient for merging; sectors 100‑199 and 200‑299 are directly contiguous, so the manager can combine them into a single request covering 100‑299, reducing the number of disk operations. The fact that they are separate requests does not prevent merging, and the process identity is irrelevant for pure sector adjacency. Overlap is not required; contiguous ranges are enough.
Q20. An embedded device with limited RAM cannot maintain large request lists. Which scheduler is most appropriate to minimize memory overhead?
📖 Explanation: The noop scheduler performs virtually no scheduling work and therefore keeps the request list very small, which is ideal for memory‑constrained environments. CFQ and deadline maintain more complex data structures to enforce fairness and timing, consuming additional RAM, while anticipatory adds extra bookkeeping for read‑ahead, also increasing memory usage.
Q21. A developer observes that after enabling CFQ, a low‑priority background backup job runs slower, while interactive tasks improve. Which property of CFQ explains this behavior?
📖 Explanation: CFQ assigns larger or more frequent time slices to processes that are deemed interactive, based on heuristics such as recent I/O activity. This design improves responsiveness for user‑focused tasks at the expense of background workloads like backups, which receive fewer slices and therefore run slower. The other options misrepresent CFQ’s behavior; it does not uniformly delay background jobs nor treat all processes identically.