In this phase, we are going to deal with an issue we didn't pay much attention before. That is when an command is finished, say a file is finished uploading to the server, a "Please type in command here:" message is displayed in the console and user is allowed to enter their commands. The message is displayed right after the Application send the last packet to the Datalink Layer. Is it safe to do this? When error rate is zero or extremely low, probably yes. But when the error rate is high, like 70% as we set in our code for now, it's not safe at all. The reason is, take window size 8 for an example, that the frame which are sent before the last frame is very likely to be still in the buffer and not acknowledged yet, and it may take a long time for all of them to be acknowledged. It's even more unsafe if the next command is to exit the program, because the client program may be shut down before a file is transmitted completely. So we need to come up with an mechanism that when the receiver sends the last few packets of a file from its Datalink Layer to Application Layer, it would notify the sender by adding extra information in its last ACK frame. It's not that tricky to fulfill this goal, what you need to do is to get hint from the buffer usage at receiver, the time at which the last frame is arrived, among other information you can gain at the Datalink Layer. When the sender receives such ACK frame, it knows the file has been transmitted completely, and can safely go for the next command.
Goal of Phase 8
Modify the code so that before an user can enter another command, the file that needs to transmitted in the current command is completely transmitted.
No comments:
Post a Comment