Solution to Homework 6
Solution#1(10pts)
- The given code follows the operation shown in figure 3.14(b). Here it's assumed that both A and B start at the same time. This results in each of the frame transmitted twice. This will create a problem if the code at A and B are not started simulataneously.
- Remove the part of the code on B which transmits a frame before entering into the while loop.
- With this modification B will never get a chance to send first and if A does not have anything to send then B will have to just wait till it gets something from A.
Solution#2(5+5pts)
Failure Condition for Protocol 2:
Stop and Wait protocol presented here fails if one of the frames transmitted is lost. For example, A sends frame to B and B sends back an ack which gets lost. Now A keeps on waiting for an ack as there is no timeout occuring at A. So A is now hung up. The same thing will happen if the frame sent by A gets lost. In this case B never receives any frame and A is expecting to receive an ack from B.
One set of parameters to simulate this is,
sim 2 1000 40 20 20 3
Failure Condition for Protocol 3:
This protocol fails due to immature timeout at sender's end that is when the sender times out too early. The flow here is,
Suppose timeout interval = 3.
- Time 0: A send a packet to B seq = 0.
- Time 2: B receives a packet with seq=0 and sends an ack.
- Time 3: A times out and sends packet with seq=0.
- Time 4: B receives packet with seq=0 and transmits an ack.
- Time 5: A receives a first ack and sends packet with seq=1 which gets lost.
- Time 6: A receives an ack. (this is actually for second transmission of packet with seq=0). A now send next packet with seq=0.
Thus B never gets a packet with seq=1 which is lost in transmission.
One set of parameters to simulate this is,
sim 3 1000 15 25 15 3