One way to implement this is when the Application Layer of server identifies the exit command from client, it sends a control packet to the Datalink Layer. Upon receiving that control packet, Datalink Layer notifies Timer Process to start an extra timer called Exit Timer, whose interval should be reasonably longer than the retransmission timer interval. After that, whenever a frame is received at server, the Exit Timer gets restarted. When the Exit Timer times out, server can shut itself down safely. (There is still one possibility that for some reason after sending the exit command, the client hangs up for a period that's longer than the interval of Exit Timer, then the server would shut itself down before client receives any ACK. We do not consider this scenaria).
Sunday, June 9, 2013
Related Topic: How to exit client program and server program safely
When the server receives the exit command from client, it need to make sure that client receives the ACK frame before it exit. But how would the server know the client has received the ACK frame? Does the client need to send another frame to server to notify its receipt of the command it sent? There is actually a very simple way to do this. We know that client would keep re-sending frames until it receives the ACK frames. So after receiving the last frame, if for a certain period of time (which must be longer than the retransmission timer interval), the server does not receive any more frame from client, it knows the client has received the ACK frame, and it can exit safely.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment