๐ŸŽ“ BookMCQ
โ† Back to 27. Network Management

๐Ÿ“ Fault management in computer networks (12 MCQs)

๐Ÿ“– From Data Communication and Networks โ€ข 27. Network Management โ€ข 12 questions available

What is Fault management in computer networks?

Fault management is the process of detecting, isolating, correcting, and logging network failures or abnormalities to minimize downtime and maintain service availability through tools like alarms, diagnostics, and automated recovery mechanisms.

4
Easy
5
Medium
3
Hard

๐Ÿ“ All Fault management in computer networks MCQs

Q1. In the echo server code, if the call to accept() fails, what immediate action does the program take?

A.It retries the accept call
B.It prints an error message with perror and exits โœ…
C.It logs the error and continues
D.It closes the listening socket and restarts
๐Ÿ’ก Difficulty: easy | โœ… Correct: B

๐Ÿ“– Explanation: When accept() returns a negative value, the code enters the ifโ€‘block, calls perror to display the system error message, and then invokes exit(1). This sequence halts the program immediately, preventing any further processing of client connections.

Q2. Considering the infinite for(;;) loop, which of the following best describes the effect on fault detection when a client disconnects unexpectedly?

A.The server terminates
B.The server enters a busy-wait state
C.The server continues to accept new connections โœ…
D.The server ignores the disconnection and leaks resources
๐Ÿ’ก Difficulty: medium | โœ… Correct: C

๐Ÿ“– Explanation: The for(;;) construct repeats the acceptโ€‘receiveโ€‘send cycle indefinitely. If a client drops the connection, the recv() loop ends, the socket is closed, and control returns to the top of the loop where a new accept() is issued, allowing the server to handle subsequent clients without terminating.

Q3. If the pointer 'ptr' is advanced by n bytes in each iteration without resetting before the next client connection, what fault is most likely to occur after several connections?

A.Memory leak
B.Socket descriptor exhaustion
C.Incorrect echo of data
D.Segmentation fault due to buffer overflow โœ…
๐Ÿ’ก Difficulty: hard | โœ… Correct: D

๐Ÿ“– Explanation: Each connection assumes 'ptr' points to the start of a fresh buffer. Failing to reset it causes subsequent writes to occur beyond the allocated region, corrupting adjacent memory. After enough iterations this overflow triggers a segmentation fault, a classic crash resulting from accessing invalid addresses.

Q4. Compare the error handling of the accept() call and the recv() call in the code. Which statement is true?

A.Both use perror and exit on error
B.recv() ignores errors and continues
C.accept() returns -1 and the loop continues
D.accept() checks for <0 while recv() loops until <=0 โœ…
๐Ÿ’ก Difficulty: easy | โœ… Correct: D

๐Ÿ“– Explanation: The accept() call is wrapped in an ifโ€‘statement that tests for a return value less than zero; on failure it prints an error with perror and exits. In contrast, recv() is placed inside a while loop that continues while the return value is positive, exiting the loop when it becomes zero or negative, thereby handling errors differently.

Q5. Evaluate the impact of not resetting 'maxLen' to its original buffer size at the start of each new connection. Which outcome is most accurate?

A.The server will always allocate new memory
B.The server will reject new connections
C.The server will send duplicate data
D.Subsequent receives may read fewer bytes than available โœ…
๐Ÿ’ก Difficulty: medium | โœ… Correct: D

๐Ÿ“– Explanation: 'maxLen' tracks the remaining space in the buffer. If it is not restored for a new client, the next recv() call may think the buffer is almost full and stop reading early, causing the server to accept fewer bytes than the client actually sends.

Q6. Differentiate between fault management strategies appropriate for TCP (as in this code) versus UDP. Which statement correctly reflects a key difference?

A.TCP provides builtโ€‘in error correction unlike UDP
B.Both protocols use the same fault detection mechanisms
C.TCP sockets cannot detect packet loss, UDP can
D.TCP requires explicit retransmission handling while UDP does not โœ…
๐Ÿ’ก Difficulty: hard | โœ… Correct: D

๐Ÿ“– Explanation: TCP establishes a reliable connection with acknowledgments and automatic retransmission, so fault management often focuses on connection errors. UDP is connectionless and does not guarantee delivery; therefore, applications must implement their own checks for loss, ordering, or corruption, making its faultโ€‘handling strategy fundamentally different.

Q7. Which function in the code is primarily responsible for detecting runtime errors related to socket operations?

A.close()
B.send()
C.perror() โœ…
D.malloc()
๐Ÿ’ก Difficulty: easy | โœ… Correct: C

๐Ÿ“– Explanation: The perror() function examines the global errno variable set by preceding system calls (such as accept(), recv(), or send()) and prints a humanโ€‘readable description of the error. It is the central mechanism in this program for reporting socketโ€‘related failures to the user.

Q8. Explain the relationship between the return value of recv() and the detection of a clientโ€‘initiated closure. Which condition indicates that the client has closed the connection?

A.recv() returns -1
B.recv() returns a positive number less than requested
C.recv() throws an exception
D.recv() returns 0 โœ…
๐Ÿ’ก Difficulty: medium | โœ… Correct: D

๐Ÿ“– Explanation: When the peer performs an orderly shutdown, recv() returns zero, signalling endโ€‘ofโ€‘file on the socket. A negative return indicates an error condition, while a positive value less than the requested size simply means fewer bytes were available, not that the connection has closed.

Q9. To improve fault tolerance, a developer proposes adding a check after send() to verify that the number of bytes sent equals 'len'. What advantage does this modification provide?

A.It ensures complete transmission even if the socket buffers are full โœ…
B.It prevents memory leaks
C.It eliminates the need for recv()
D.It automatically reconnects the client
๐Ÿ’ก Difficulty: hard | โœ… Correct: A

๐Ÿ“– Explanation: send() may transmit fewer bytes than requested when the underlying socket buffer cannot accommodate the entire payload. By comparing the return value with the intended length, the program can detect partial sends and retry, guaranteeing that the full echo is delivered before closing the connection.

Q10. In the context of this C program, what does the 'perror' function do?

A.Returns the last error code
B.Prints a descriptive error message to stderr โœ…
C.Closes the socket
D.Allocates memory for error strings
๐Ÿ’ก Difficulty: easy | โœ… Correct: B

๐Ÿ“– Explanation: perror() takes a custom prefix string, appends a description of the current errno value, and writes the combined message to the standard error stream. This provides immediate feedback about why a system call such as accept() failed.

Q11. Analyzing the code's resource management, which of the following best describes a potential fault if 'close(s)' were omitted after handling a client?

A.The server would run out of file descriptors over time โœ…
B.The server would crash immediately
C.The server would reset the listening socket
D.The server would ignore subsequent connections
๐Ÿ’ก Difficulty: medium | โœ… Correct: A

๐Ÿ“– Explanation: Each accepted connection consumes a file descriptor. Failing to close the descriptor after the client interaction leaves it allocated, and repeated omissions eventually exhaust the process's descriptor limit, preventing new connections and causing subsequent accept() calls to fail.

Q12. Given the code fragment, if 'recv()' returns -1 due to an interrupt signal, what logical step should the server ideally take to maintain robustness?

A.Terminate the server
B.Close the client socket and continue
C.Retry the recv() call โœ…
D.Ignore the error and proceed
๐Ÿ’ก Difficulty: medium | โœ… Correct: C

๐Ÿ“– Explanation: An EINTR error indicates the system call was interrupted by a signal but the socket remains valid. The robust approach is to repeat the recv() operation, allowing the server to continue receiving data without treating the interruption as a fatal failure.

๐Ÿ”— Related Topics (MCQs)