CSS 432
FAQ on Program 2: Sliding Window


Q1: Can I run Case 1 without making it hung?

When running the First Case on the Server Side, it always just hangs and never completes. You mentioned on the assignment sheet that the test may hang, but I haven't been able to run it without it hanging. I tried running it the last couple days. Is normal or am I doing something possibly wrong?

A: There are no quarantees to complete Case 1.

If you didn't see that Case 1 was completed in success, that's okay. Don't worry about it too much. You can recompile the test with fewer messages if you would like to see it finish.

Q2: How can I prevent my program from blocked?

When the window is full, and the client starts the 1500 usec timer, calls read(), and there is no acknowledgement to read, won't my program "hang" while executing read() because there is nothing to read?

A: Use UdpSocket::pollRecvFrom( ).

You have to check if the client's socket has data to read. Otherwise, your client proram will be blocked until data is available. Since UDP does not guarantee every single packet's delivery, once your client is blocked, it may not be resumed. Call pollRecvFrom( ) before reading the socket.

Q3: Strangely my Stop and Wait reports 19962 as the last message recieved but exits normally.

A: Stop and Waits should complete successfully.

One thing you have to be careful of is:

Whenever you receive an ack from the server, please check if its sequence number corresponds to the one you sent to the server. If so, you can increment the sequence number and send a new packet to the server. Otherwise, keep receiving a new ack until the timer is expired. If expired, resend the same packe to the server.

If you don't check the sequence number in the ack upon receiving it, you may end up with sending many packets. This is because an ack may be lost so that another ack with a larger sequence number will be coming and you won't notice this ack loss or packet losss until the very end.

Q4: Does close() prevent recvFrom() from blocking?

A: No.

Q5: Does the window size start from 0 or 1?

A: My hw2.cpp assumes that the window should have at least one packet to send.

Q6: How can the server program keep track of which packets have been delivered to it?

A: Prepare an array whose index corresponds to each packet's sequence number.

While the strict sliding window algorithm must allocate such an array whose size is the same as a given window size, you may allocate an array whose size is 20,000, in which case each array index corresponds to a different packt's sequence number. This simplifies your server program. Whenever the server program has received a new packet, simply mark the corresponding array element, so that you can find which packet the server program is expecting to receive.