A TCP server application is programmed to listen on port number P on host S. A…

2021

A TCP server application is programmed to listen on port number P on host S. A TCP client is connected to the TCP server over the network. Consider that while the TCP connection was active, the server machine S crashed and rebooted. Assume that the client does not use the TCP keepalive timer. Which of the following behaviors is/are possible?

  1. A.

    If the client was waiting to receive a packet, it may wait indefinitely.

  2. B.

    The TCP server application on S can listen on P after reboot.

  3. C.

    If the client sends a packet after the server reboot, it will receive a RST segment.

  4. D.

    If the client sends a packet after the server reboot, it will receive a FIN segment.

Attempted by 109 students.

Show answer & explanation

Correct answer: A, B, C

Explanation: what can happen to a TCP client and server when the server machine crashes and reboots.

  • If the client was waiting to receive a packet, it may wait indefinitely.

  • The client can remain blocked on receive because a server crash does not guarantee a FIN or RST is sent to the client; without the client sending data or using keepalive, the local TCP stack has no stimulus to detect the dead peer.

  • The TCP server application on the host can listen on the same port after reboot.

  • A reboot clears the kernel TCP state for previous connections, so the server process (after restarting) is normally able to bind and listen on the same port number.

  • If the client sends a packet after the server reboot, it can receive a RST segment.

  • When the rebooted host has no TCP state for that connection and no process is listening on the destination port, the host’s TCP implementation will normally reply with a RST to indicate the port/connection is not valid. If the server process has already restarted and is listening, the client may instead get a response or a new connection setup, so RST is possible but not guaranteed.

  • If the client sends a packet after the server reboot, it will receive a FIN segment.

  • A FIN indicates an orderly, graceful close initiated by the peer. A crash/reboot is abrupt and does not perform a graceful shutdown, so receiving a FIN from the rebooted host for the old connection is not the expected behavior.

Conclusion: the behaviors that are possible in this scenario are: the client may wait indefinitely when blocked on receive, the server can listen on the same port after reboot, and the client may receive a RST if it sends data after the reboot. Receiving a FIN is not generally expected.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir