CNT 5106C HW 3
CNT 5106C HW 3
P5: Suppose that the UDP receiver computes the Internet checksum for the received UDP segment and
finds that it matches the value carried in the checksum field. Can the receiver be absolutely certain that
no bit errors have occurred? Explain.
Solution:
Though UDP checksum provides error detection, this alone cannot guarantee that no error bits have
occurred. For example, consider two messages being transmitted:
0000101100011011
0010110010010100
0011011110101111 – 1’s compliment = 1100100001010000 – Checksum
The checksum carried over will be: 1100100001010000.
Now, lets assume that the messages have been changed at two places in such a way that the sum of the
messages remains same.
0000100110011011
0010111000010100
0011011110101111, 1’s compliment is 1100100001010000 – checksum computed at receiver.
Here we can observe that the checksum transmitted, and checksum calculated is equal however there
are error bits in the transmitted message. Hence, thought the checksum matches we cannot be certain
that no bit errors have occurred.
P6: Consider our motivation for correcting protocol rdt2.1. Show that the receiver, shown in Figure 3.57,
when operating with the sender shown in Figure 3.11, can lead the sender and receiver to enter a deadlock
state, where each is waiting for an event that will never occur.
Solution:
Considering the receiver from Fig 3.11 and incorrect receiver in Fig 3.57, we can observe a deadlock
situation where one state is waiting for an event at another state to occur. Let’s consider the case
where,
1. Sender will send the duplicate packet – 1 to receiver and move to wait for ACK/NAK 1.
2. Say, the receiver is waiting for a packet – 0 from below but receives a non-corrupt seq –
1(duplicate) packet from sender.
3. Receiver receives the packet and send NAK even though the packet is not corrupt and is a
duplicate that in our best interest should be disregarded. The receiver remains in the same state
of waiting for packet 0 from below.
4. Sender Receives this NAK and retransmits the message again to receiver.
5. Receiver waiting for 0 again receives packet sequence – 1 and above steps repeat in a loop
leading the system into a state of deadlock.
The solution for this problem is it send an ACK to sender when receiving a duplicate packet. This
functionality is lacking in the incorrect receiver figure. The sender keeps on waiting for ACK of packet – 1
and receiver continues to wait for packet – 0 from sender. Both of the states are waiting for a event to
occur in other forming a deadlock.
P12. The sender side of rdt3.0 simply ignores (that is, takes no action on) all received packets that are
either in error or have the wrong value in the acknum field of an acknowledgment packet. Suppose that
in such circumstances, rdt3.0 were simply to retransmit the current data packet. Would the protocol still
work?
Sol:
We are sending packet zero and waiting for ack – 0 but if there was a premature timeout for the packet –
1 in the previous step we may get an ack -1. In this case the sender needs to understand that it is a
duplicate acknowledgement and ignore it. However, as mentioned above if the sender retransmits the
current packet, then the receiver receives another packet – 0. As the receiver has already processed
packet – 0 and sent and acknowledgement it considers this packet as a duplicate and send ACK without
transmitting the message. On the sender side as soon as it retransmits the packet – 0 it may receive the
acknowledgment for packet – 0 for the original transmission. Now, the sender moves to state – 1 and
sends the packet -1 but again receives the retransmitted packet – 0 acknowledgement. This process
continues decreasing the efficiency of the channel with duplicates.
However, there might be a case where the packet – 0 received at the receiver has bit errors. In that case,
the receiver sends ACK – 1 for packet – 0 to indicate the packet has bit errors. In such a scenario it is
meaningful to retransmit the packet as soon as we receive ACK -1. Because ACK – 1 here does not indicate
duplicate packet but indicates bit errors in the same packet. So, the protocol with the above-mentioned
feature works and has its own advantages and disadvantages.
P13. Consider the rdt3.0 protocol. Draw a diagram showing that if the network connection between the
sender and receiver can reorder messages (that is, that two messages propagating in the medium
between the sender and receiver can be reordered), then the alternating-bit protocol will not work
correctly (make sure you clearly identify the sense in which it will not work correctly). Your diagram should
have the sender on the left and the receiver on the right, with the time axis running down the page,
showing data (D) and acknowledgment (A) message exchange. Make sure you indicate the sequence
number associated with any data or acknowledgment segment.
Sol: In this case, the sequence – 0 packet’s acknowledgment from the receiver is received after the
timeout. So the sender retransmits the packet sequence 0. Now the sender received the original ack of
packet – 0 and proceeds to sending packet -1. Packet – 1 ack is sent back to the sender who then proceeds
to sending sequence – 0. Now, there might be a case where the duplicate D0 transmitted from sender
reaches the receiver instead of original D0 that was transmitted. As we can see in this case, the alternating
bit protocol will not work as shown in below diagram.
P15: Consider the cross-country example shown in Figure 3.17 . How big would the window size have to
be for the channel utilization to be greater than 98 percent? Suppose that the size of a packet is 1,500
bytes, including both header fields and data.
In fig.3.17, Round Trip Time(RTT) = 30ms. Transmission Rate= 1Gbps(109 bits per sec), Packet Size =
1500bytes
Time need to transmit the packet into link = L/R = 1500*8bits/109 bits/s = 12 microseconds.
Hence the window size for about 98% utilization should have a minimum of 2451 packets.
P19. Consider a scenario in which Host A wants to simultaneously send packets to Hosts B and C. A is
connected to B and C via a broadcast channel—a packet sent by A is carried by the channel to both B and
C. Suppose that the broadcast channel connecting A, B, and C can independently lose and corrupt packets
(and so, for example, a packet sent from A might be correctly received by B, but not by C). Design a stop-
and-wait-like error-control protocol for reliably transferring packets from A to B and C, such that A will
not get new data from the upper layer until it knows that both B and C have correctly received the current
packet. Give FSM descriptions of A and C. (Hint: The FSM for B should be essentially the same as for C.)
Also, give a description of the packet format(s) used.
Sol:
The above FSM denotes single receiver B, the same steps happen in receiver C.
The sender sends data with sequence number, data, checksum. If sender receives a ACK-1 waiting for ACK-
0 or a corrupt packet then it does nothing and wait till the timeout to retransmit the packet.
FSM Description of B is same as C.
It starts with checking the received packet. If the packet is not corrupt and has seq – 1 when waiting for
0, then receiver sends ACK-1 to receiver (who waits for timer to end and retransmits). If the received
packet is not corrupt and seq-0 then data is extracted. If the receiver receives a corrupt message, it sends
ACK -1 instead of ACK -0 to the receiver.
P22. Consider the GBN protocol with a sender window size of 4 and a sequence number range of 1,024.
Suppose that at time t, the next in-order packet that the receiver is expecting has a sequence number of
k. Assume that the medium does not reorder messages. Answer the following questions:
a) What are the possible sets of sequence numbers inside the sender’s window at time t? Justify your
answer.
Ans. After time t, if the nex sequence number expected by the receiver is k, it can:
(i) The sender has sent k-1 packets and all the k-1 acknowledgements have been received. Now
the sender sends the packet k. So, the window can have a max of k+3 packets. (Total 4
packets).
(ii) The receiver have received all 4 packets in the window with sequence number – k-1 and is
now expecting seq number -k. So the range of packets sent by the sender can be [k-1-3, k-1]
= [k-4]. So the least sequence number than can be in the sender window is k-4.
So the possible sequence numbers in the sender window are any 4 consecutive sequence numbers in
between k-4 and k+3.
b) What are all possible values of the ACK field in all possible messages currently propagating back to the
sender at time t? Justify your answer.
Sol. Say after time t, the receiver has acknowledged k-1 seqnumber and is waiting for k. If a receiver is
waiting for packet k, it means that is has acknowledged the previous packets of that window. As the
window size is 4, only 4 packets are propagating at a time. Now, if the next packet to be received is k then
the k-N packet’s acknowledgement has to be propagated back to the sender. So the acknowledgements
can range from k-4 to k-1 (but not necessarily all 4).
P23. Consider the GBN and SR protocols. Suppose the sequence number space is of size k. What is the
largest allowable sender window that will avoid the occurrence of problems such as that in Figure 3.27
for each of these protocols?
Sol: To avoid the SR dilemma the receiver should not be given a chance to get confused between the
original packet and the duplicate packet. If the window size is too large or just equal to the size of the
sequence numbers. There can be a case where the ACK for sequence number – 0 fails to be received by
the receiver and the receiver retransmits the sequence number – 0 original message which is actually a
duplicate but will be perceived as original by the receiver.
This situation arises because of the large size of the window. However, having a window size equal of less
than the half the size of the sequence number space can avoid this problem even in the worst-case
scenario where all the packets sent must be retransmitted.
Hence, if window size = k/2(half the sequence number space) then the SR Receiver dilemma due to large
window size can be avoided.
P24. Answer true or false to the following questions and briefly justify your answer:
a. With the SR protocol, it is possible for the sender to receive an ACK for a packet that falls outside
of its current window
Sol. True, In case the window size is small and the time out of the packets occurs before the
acknowledgment is received from the receiver. Say, the sender initially sent 3 packets(0,1,2) to the
receiver. The receiver acknowledges the packets but due to delay they don’t make it back to the
sender before the timeout. So the sender retransmits the packets 0,1,2. Now, the sender receives the
initial acknowledgments and moves to the next packets say – 3,4,5. The second set of duplicates(0,1,2)
are now received by the receiver and the acknowledgments are again sent back to the sender. The
sender who is now in another window receives acknowledgements for the packets of previous
window.
b. With GBN, it is possible for the sender to receive an ACK for a packet that falls outside of its current
window.
Sol: A similar scenario as mentioned in the above SR case can happen here.
c. The alternating-bit protocol is the same as the SR protocol with a sender and receiver window
size of 1.
Sol: True, they are similar in a way that handle errors by sending the same packet until it is
acknowledged. The SR protocol has a window size and buffer where-as alternating bit protocol
operate only with one packet at a time. But both have same error handling.
d. The alternating-bit protocol is the same as the GBN protocol with a sender and receiver window
size of 1.
P27. Host A and B are communicating over a TCP connection, and Host B has already received from A
all bytes up through byte 126. Suppose Host A then sends two segments to Host B back-to-back. The
first and second segments contain 80 and 40 bytes of data, respectively. In the first segment, the
sequence number is 127, the source port number is 302, and the destination port number is 80. Host
B sends an acknowledgment whenever it receives a segment from Host A.
A. In the second segment sent from Host A to B, what are the sequence number, source port
number, and destination port number?
B. If the first segment arrives before the second segment, in the acknowledgment of the first
arriving segment, what is the acknowledgment number, the source port number, and the
destination port number?
C. If the second segment arrives before the first segment, in the acknowledgment of the first
arriving segment, what is the acknowledgment number?
D. Suppose the two segments sent by A arrive in order at B. The first acknowledgment is lost and
the second acknowledgment arrives after the first timeout interval. Draw a timing diagram,
showing these segments and all other segments and acknowledgments sent. (Assume there
is no additional packet loss.) For each segment in your figure, provide the sequence number
and the number of bytes of data; for each acknowledgment that you add, provide the
acknowledgment number.
Sol.
D.