0% found this document useful (0 votes)
3 views51 pages

Tcpprotocols

The document discusses transport-layer protocols, focusing on Stop-and-Wait, Go-Back-N (GBN), and Selective-Repeat (SR) protocols. It explains the mechanics of each protocol, including sequence numbers, acknowledgment processes, and window sizes, highlighting the differences in efficiency and error handling. GBN allows multiple packets to be sent before acknowledgment, while SR resends only lost packets, improving reliability and efficiency in data transmission.

Uploaded by

Bhoomika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views51 pages

Tcpprotocols

The document discusses transport-layer protocols, focusing on Stop-and-Wait, Go-Back-N (GBN), and Selective-Repeat (SR) protocols. It explains the mechanics of each protocol, including sequence numbers, acknowledgment processes, and window sizes, highlighting the differences in efficiency and error handling. GBN allows multiple packets to be sent before acknowledgment, while SR resends only lost packets, improving reliability and efficiency in data transmission.

Uploaded by

Bhoomika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 51

TRANSPORT-LAYER

PROTOCOLS
• Simple protocol
• Stop and wait
• Go back N
• Selective repeat
Simple protocol
Stop-and-Wait Protocol
Sequence Numbers and Acknowledgment
Numbers
the sequence is 0, 1, 0, 1, 0, and so on. This is referred to as modulo 2

arithmetic.
Flow diagram
Pipelining
• In networking and in other areas, a task is often begun before the
previous task has ended. This is known as pipelining.
• There is no pipelining in the Stop-and-Wait protocol because a
sender must wait for a packet to reach the destination and be
acknowledged before the next packet can be sent.
• However, pipelining does apply to our next two protocols because
several packets can be sent before a sender receives feedback about
the previous packets.
• Pipelining improves the efficiency of the transmission if the number of
bits in transition is large with respect to the bandwidth delay product.
• The first is called Go-Back-N (GBN) (the rationale for the name will
become clear later).
• The key to Go-back-N is that we can send several packets before
receiving acknowledgments, but the receiver can only buffer one
packet.
• We keep a copy of the sent packets until the acknowledgments arrive.
Figure 23.23 shows the outline of the protocol.
• Note that several data packets and acknowledgments can be in the
channel at the same time.
Overview
Go-Back-N Protocol (GBN)
• To improve the efficiency of transmission (to fill the pipe), multiple
packets must be in transition while the sender is waiting for
acknowledgment.
• In other words, we need to let more than one packet be outstanding
to keep the channel busy while the sender is waiting for
acknowledgment
Send Window
• The send window is an imaginary box covering the sequence numbers of
the data packets that can be in transit or can be sent.
• In each window position, some of these sequence numbers define the
packets that have been sent; others define those that can be sent.
• The maximum size of the window is 2m − 1, for reasons that we discuss
later.
• In this chapter, we let the size be fixed and set to the maximum value, but
we will see later that some protocols may have a variable window size.
• Figure 23.24 shows a sliding window of size 7 (m = 3) for the Go-Back-N
protocol.
Sequence Numbers
• the sequence numbers are modulo 2m, where m is the size of the
sequence number field in bits.
• Acknowledgment Numbers
• An acknowledgment number in this protocol is cumulative and
defines the sequence number of the next packet expected.
• For example, if the acknowledgment number (ackNo) is 7, it means
all packets with sequence number up to 6 have arrived, safe and
sound, and the receiver is expecting the packet with sequence
number 7.
• The send window at any time divides the possible sequence numbers
into four regions.
• The first region, left of the window, defines the sequence numbers
belonging to packets that are already acknowledged.
• The sender does not worry about these packets and keeps no copies
of them.
• The second region, colored, defines the range of sequence numbers
belonging to the packets that have been sent, but have an unknown
status.
• The sender needs to wait to find out if these packets have been
received or were lost. We call these outstanding packets.
• The third range, white in the figure, defines the range of sequence
numbers for packets that can be sent; however, the corresponding
data have not yet been received from the application layer.
• Finally, the fourth region, right of the window, defines sequence
numbers that cannot be used until the window slides.
• The window itself is an abstraction; three variables define its size and
location at any time.
• We call these variables Sf (send window, the first outstanding packet), Sn
(send window, the next packet to be sent), and Ssize (send window, size).
• The variable Sf defines the sequence number of the first (oldest)
outstanding packet.
• The variable Sn holds the sequence number that will be assigned to the
next packet to be sent.
• Finally, the variable Ssize defines the size of the window, which is fixed in our
protocol.
• Figure 23.25 shows how a send window can slide one or more slots to
the right when an acknowledgment arrives from the other end. In the
figure, an acknowledgment with ackNo = 6 has arrived. This means
that the receiver is waiting for packets with sequence number 6.
Receive Window
• In Go-Back-N, the size of the receive window is always 1. The receiver is always
looking for the arrival of a specific packet.
• Any packet arriving out of order is discarded and needs to be resent.
• Figure 23.26 shows the receive window. Note that we need only one variable, Rn
(receive window, next packet expected), to define this abstraction.
• The sequence numbers to the left of the window belong to the packets already
received and acknowledged; the sequence numbers to the right of this window
define the packets that cannot be received.
• Any received packet with a sequence number in these two regions is discarded.
• Only a packet with a sequence number matching the value of Rn is accepted and
acknowledged.
• The receive window also slides, but only one slot at a time. When a correct packet
is received, the window slides, Rn = (Rn + 1) modulo 2m.
• Timers Although there can be a timer for each packet that is sent, in our
protocol we use only one.
• The reason is that the timer for the first outstanding packet always expires first.
• We resend all outstanding packets when this timer expires.
• Resending packets When the timer expires, the sender resends all outstanding
packets.
• For example, suppose the sender has already sent packet 6 (Sn = 7), but the
only timer expires.
• If Sf = 3, this means that packets 3, 4, 5, and 6 have not been acknowledged;
the sender goes back and resends packets 3, 4, 5, and 6.
• That is why the protocol is called Go-Back-N.
• On a time-out, the machine goes back N locations and resends all packets.
• FSMs Figure 23.27 shows the FSMs for the GBN protocol.
Send Window Size
• size of the send window must be less than 2m. As an example, we choose m = 2, which
means the size of the window can be 2m − 1, or 3.
• Figure 23.28 compares a window size of 3 against a window size of 4. If the size of the
window is 3 (less than 2m) and all three acknowledgments are lost, the only timer expires
and all three packets are resent.
• The receiver is now expecting packet 3, not packet 0, so the duplicate packet is correctly
discarded.
• On the other hand, if the size of the window is 4 (equal to 22 ) and all acknowledgments
are lost, the sender will send a duplicate of packet 0.
• However, this time the window of the receiver expects to receive packet 0 (in the next
cycle), so it accepts packet 0, not as a duplicate, but as the first packet in the next cycle.
This is an error.
• This shows that the size of the send window must be less than 2m.
• Figure 23.29 shows an example of Go-Back-N.
• This is an example of a case where the
• forward channel is reliable, but
• the reverse is not.
• No data packets are lost, but some ACKs are delayed and one is lost.
• The example also shows how cumulative acknowledgments can help
if acknowledgments are delayed or lost.
Go back N vs stop and wait
• In Go-Back-N,
the arithmetic is modulo 2m;
• in Stop-and-Wait it is modulo 2,
• which is the same as 2m when m = 1.
gen
Selective-Repeat Protocol
• Selective-Repeat (SR) protocol, has been devised, which, as the name
implies, resends only selective packets, those that are actually lost.
• The outline of this protocol is shown in Figure 23.31.
Windows
• The Selective-Repeat protocol also uses two windows: a send window
and a receive window.
• However, there are differences between the windows in this protocol
and the ones in Go-Back-N.
• First, the maximum size of the send window is much smaller; it is
2m−1.
• The reason for this will be discussed later.
• Second, the receive window is the same size as the send window.
• The send window maximum size can be 2m−1.
• For example, if m = 4, the sequence numbers go from 0 to 15, but the maximum
size of the window is just 8 (it is 15 in the Go-Back-N Protocol).
• We show the Selective-Repeat send window in Figure 23.32 to emphasize the size.
• The receive window in Selective-Repeat is totally different from the one in GoBack-
N.
• The size of the receive window is the same as the size of the send window
(maximum 2m−1).
• The Selective-Repeat protocol allows as many packets as the size of the receive
window to arrive out of order and be kept until there is a set of consecutive packets
to be delivered to the application layer.
• Because the sizes of the send window and receive window are the
same, all the packets in the send packet can arrive out of order and be
stored until they can be delivered.
• We need, however, to emphasize that in a reliable protocol the
receiver never delivers packets out of order to the application layer.
• Figure 23.33 shows the receive window in Selective-Repeat.
• Those slots inside the window that are shaded define packets that
have arrived out of order and are waiting for the earlier transmitted
packet to arrive before delivery to the application layer
• Timer
• Theoretically, Selective-Repeat uses one timer for each outstanding packet.
• When a timer expires, only the corresponding packet is resent.
• In other words, GBN treats outstanding packets as a group; SR treats them
individually.
• However, most transport-layer protocols that implement SR use only a single
timer. For this reason, we use only one timer.
• Acknowledgments
• There is yet another difference between the two protocols.
• In GBN an ackNo is cumulative; it defines the sequence number of the next packet
expected, confirming that all previous packets have been received safe and sound.
• The semantics of acknowledgment is different in SR.
• In SR, an ackNo defines the sequence number of a single packet that is received
safe and sound; there is no feedback for any other
FSMs
• Sender
• The sender starts in the ready state, but later it can be in one of the
two states: ready or blocking. The following shows the events and the
corresponding actions in each state.
• ❑ Ready state. Four events may occur in this case:
• a. If a request comes from the application layer, the sender creates a
packet with the sequence number set to Sn.
• A copy of the packet is stored, and the packet is sent. If the timer is
not running, the sender starts the timer.
• The value of Sn is now incremented, Sn = (Sn + 1) modulo 2m. If the
window is full, Sn = (Sf + Ssize) modulo 2m, the sender goes to the
blocking state.
• b. If an error-free ACK arrives with ackNo related to one of the
outstanding packets, that packet is marked as acknowledged.
• If the ackNo = Sf , the window slides to the right until the Sf points to
the first unacknowledged packet (all consecutive acknowledged
packets are now outside the window).
• If there are outstanding packets, the timer is restarted; otherwise, the
timer is stopped.
• c. If a corrupted ACK or an error-free ACK with ackNo not related to
an outstanding packet arrives, it is discarded.
• d. If a time-out occurs, the sender resends all unacknowledged
packets in the window and restarts the timer
❑ Blocking state. Three events may occur in
this case:
• a. If an error-free ACK arrives with ackNo related to one of the
outstanding packets, that packet is marked as acknowledged.
• In addition, if the ackNo = Sf , the window is slid to the right until the
Sf points to the first unacknowledged packet (all consecutive
acknowledged packets are now outside the window).
• If the window has slid, the sender moves to the ready state.
• b. If a corrupted ACK or an error-free ACK with the ackNo not related
to outstanding packets arrives, the ACK is discarded.
• c. If a time-out occurs, the sender resends all unacknowledged
packets in the window and restarts the timer.
• Receiver The receiver is always in the ready state. Three events may
occur:
• a. If an error-free packet with seqNo in the window arrives, the packet is
stored and an ACK with ackNo = seqNo is sent.
• In addition, if the seqNo = Rn, then the packet and all previously arrived
consecutive packets are delivered to the application layer and the
window slides so that the Rn points to the first empty slot.
• b. If an error-free packet with seqNo outside the window arrives, the
packet is discarded, but an ACK with ackNo = Rn is returned to the
sender.
• This is needed to let the sender slide its window if some ACKs related to
packets with seqNo < Rn were lost.
• c. If a corrupted packet arrives, the packet is discarded.
• This example is similar to
Example 23.8 (Figure 23.30) in
which packet 1 is lost.
We show how Selective-Repeat
behaves in this case.
Figure 23.35 shows the situation.
Window Sizes
• Let’s see why the size of the sender and receiver windows can be at
most one-half of 2m
• For an example, we choose m = 2, which means the size of the
window is 2m/2 or 2(m−1) = 2. Figure 23.36 compares a window size of 2
with a window size of 3.
• If the size of the window is 2 and all acknowledgments are lost, the timer
for packet 0 expires and packet 0 is resent.
• However, the window of the receiver is now expecting packet 2, not packet
0, so this duplicate packet is correctly discarded (the sequence number 0 is
not in the window).
• When the size of the window is 3 and all acknowledgments are lost, the
sender sends a duplicate of packet 0.
• However, this time, the window of the receiver expects to receive packet 0
(0 is part of the window), so it accepts packet 0, not as a duplicate, but as a
packet in the next cycle.
• This is clearly an error.

You might also like