(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
Computer Communication Networks- Introduction to Transport layer
1. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 1
23.1 Introduction
The Transport layer (TL) is located between the application layer
and the network layer. It provides a process-to-process
communication between two application layers, one at the local
host and the other at the remote host
A process is an application-layer entity (running program) that
uses the services of the transport layer
23.1.1 Transport Layer Services
The transport layer is responsible for providing services to the application layer;
it receives services from the network layer.
1) Process to Process Communication
• The network layer is responsible for delivery of datagram between two
hosts. This is called host-to-host delivery.
• The transport-layer protocol is responsible for delivery of a message to
the appropriate process on the destination computer.
• There are several ways to achieve process-to-process communication; the
most common one is through the client/server paradigm.
• A process on the local host, called a client, needs services from a process
usually on the remote host, called a server.
2) Addressing in Transport Layer:
For communication between two hosts, we must define the local host,
local process, remote host and remote process. The local host and the
remote host are defined using IP addresses. The processes are identified
by 16-bit port numbers (integers from 0 to 65535).
The server and/or client may run several processes at the same time.
The client program defines itself with a port number, chosen randomly by
the transport layer software running on the client host, called the
ephemeral port number.
The server process must also define itself with a port number. In the
Internet model, it is decided to use universal port numbers for servers;
these are called well-known port numbers.
2. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 2
Every client process knows the well-known port number of the
corresponding server process. Figure 23.3 shows this concept,
• The destination IP address defines one host among multiple
hosts in the world. After the host has been selected, the port
number defines one of the processes on this particular host.
Fig 23.4: IP addresses Vs Port numbers
ICANN (Internet Corporation for Assigned Names and Numbers)
The ICANN has divided the port numbers into three ranges: well-
known, registered, and dynamic (or private)
Well-known ports: the port numbers ranging from 0 to 1023 are
assigned and controlled by ICANN. These are the well-known
ports. Usually allocated to Servers and publicly advertised.
3. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 3
Registered ports: the ports ranging from 1024 to 49,151 are not
assigned or controlled by ICANN. They are registered with
ICANN to prevent duplication.
Dynamic ports: the ports ranging from 49152 to 65,535 are
neither controlled nor registered. They can use by any process.
These are the ephemeral ports.
Some Examples of Well-known ports used in the Internet:
3) Socket Address
A transport-layer protocol needs both the IP address and the
port number at each end, to make a connection. The combination
of an IP address and a port number is called a socket address.
The client socket address defines the client process and the
server socket address defines the server process uniquely.
Fig.23.6
Note: A transport layer protocol needs a pair of socket addresses: the
client socket address and the server socket address.
4) Encapsulation and Decapsulation
To send a message from one process to another, the TL protocol
encapsulates and decapsulates messages.
4. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 4
Encapsulation happens at the sender site. The packets at the transport
layer in the Internet are called user datagrams, segments, or packets,
depending on what transport-layer protocol is used.
Decapsulation happens at the receiver site. When the message arrives at
the destination TL, the header is removed and the transport layer delivers
the message to the process running at the application layer.
5) Multiplexing and Demultiplexing
Whenever an entity accepts items from more than one source, this is
referred to as multiplexing (many to one). Whenever an entity delivers
item to more than one source, this is referred to as Demultiplexing (one to
many)
TL at the source performs multiplexing; the TL at the destination performs
Demultiplexing.
5. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 5
Fig.23.8 shows that communication between a client and two servers. Three
client processes are running at the client site: P1, P2 and P3. The processes
P1 and P3 communicate with one server and process P2 needs to send a
request to the corresponding server process running at another server.
The transport layer at the client accepts 3 messages from these 3 processes
and creates 3 packets. It acts as a multiplexer. Packets 1 and 3 use the same
logical channel to reach the TL of the first server. When they arrive at the
server, the TL distributes (Demultiplexing) the messages to two different
processes. The TL at the second server receives packet 2 and delivers it to
the corresponding process.
6) Pushing or Pulling
Consider two entities: one which produces items and another which
consumes them. If the items are produced faster than they can be
consumed, the consumer can be overwhelmed (buffer gets full) and may
need to discard some items. In this case, we need Flow control
mechanisms.
Delivery of items from a producer to a consumer can occur in one of two
ways: Pushing or Pulling.
If the sender delivers items whenever they are produced (without a prior
request from the consumer) the delivery is referred to as pushing.
If the producer delivers the items after the consumer has requested them,
the delivery is referred to as pulling.
7) Flow Control at the Transport Layer
In communication at the TL, we are dealing with four entities: sender
process, sender transport layer, receive transport layer, and receiver
process.
The sending process at the application layer is only a producer. It produces
message chunks and pushes them to the transport layer.
The sending TL is both a consumer and a producer. It consumes the message
pushed by the producer (Application layer). It encapsulates the messages in
packets and pushes them to the receiver transport layer.
The receiving TL is again both consumer and producer. It consumes the
packets sent by sender, decapsulates the messages and delivers to the
Application layer, whenever the application requests.
6. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 6
We need at least two cases of flow control: from the sending TL to the
sending application layer and from the receiving TL to the sending TL.
Shown in Fig. 23.10
Buffers
One way to implement Flow control is to use two buffers: one at the sending
TL and the other at the receiving TL.
A buffer is a set of memory locations that can hold packets at the sender and
receiver. The flow control communication can occur by sending signals
from the consumer to the producer.
When the buffer of the sending TL is full, it informs the application layer to
stop passing of messages; when its not full, it informs the application layer
that it can pass message again.
Assume that each TL uses a single memory location to hold a packet. When
this single slot in the sending TL is empty, the sending TL sends a note to
the application layer to send its next chunk; when this single slot in the
receiving TL is empty, it sends an acknowledgment to the sending TL to
send its next packet. However, using a single-slot buffer at the sender and
the receiver is inefficient.
8) Error Control at the Transport Layer
Reliability can be achieved to add error control services to the transport layer,
since IP at network layer in the Internet is unreliable.
Error control involves only the sending and receiving transport layer. The
receiving TL manages error control by informing the sending transport layer
about the problem.
Error control at the TL responsible for:
1. Detecting and discarding corrupted packets.
2. keeping track of lost and discarded packets and resending them
3. recognizing duplicate packets and discarding them
4. buffering out-of-order packets until the missing packets arrive
.
Sequence Numbers and Acknowledgement Numbers:
For error control, sending TL should know which packet is to be resent
and the receiving TL should know which packet is a duplicate, or which
7. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 7
packet has arrived out of order. This can be done if the packets are
numbered. We can add a field to the transport-layer packet to hold the
sequence number of the packet.
When a packet is corrupted or lost, the receiving TL can inform the
sending TL to resend that packet using the sequence number.
Packets are numbered sequentially. If the header of the packet has m-bit
field for the sequence number, the sequence numbers range from 0 to
2m−1. For ex, if m is 4, the sequence numbers are 0 through 15. To account
for more packets, we can wrap around the sequence. So the sequence
numbers in this case are:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, …
So, the sequence numbers are modulo 2m.
Acknowledgment
The receiver can send an acknowledgment (ACK) for a group of packets
that have arrived safely. The receiver can discard the corrupted packets.
The sender can detect lost packets if it uses a timer. When a packet is sent,
the sender starts a timer. If an ACK does not arrive before the timer
expires, the sender resends the packet.
Duplicate packets can be discarded by the receiver. Out-of-order packets
can be either discarded (to be treated as lost packets by the sender), or
stored until the missing one arrives.
9) Flow Control and Error Control
As discussed earlier, Flow control uses two buffers; Error control uses sequence
and ACK numbers. We can combine these two; i.e, use two numbered buffers-
one at sender and one at the receiver. Also, the buffer has more than one slot to
store the messages. The operation is explained with a abstract concept called
Sliding-window.
Sliding Window
Since the sequence numbers use modulo 2m, a circle can represent the
sequence numbers from 0 to 2m − 1 (Fig 23.12). The buffer is represented
as a set of slices, called the sliding window, that occupies part of the circle
at any time.
At the sender site, when a packet is sent, the corresponding slice is
marked. When all the slices are marked, it means that the buffer is full and
no further messages can be accepted from the application layer.
When an acknowledgment arrives, the corresponding slice is unmarked
and the window slides forward. Fig 23.12 shows the sliding window at the
sender. The sequence numbers are in modulo 16 (m = 4) and the size of
the window is 7.
8. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 8
Most protocols show the sliding window using linear representation. Fig 23.13
shows this representation.
10) Congestion Control
An important issue in a packet-switched network, such as the Internet, is
congestion. Congestion in a network may occur if the load on the network
(the number of packets sent to the network) is greater than the capacity of
the network (the number of packets a network can handle).
Congestion control refers to the mechanisms and techniques that control
the congestion and keep the load below the capacity. Congestion in a
network or internetwork occurs because routers and switches have
queues—buffers that hold the packets before and after processing. If a
router cannot process the packets at the same rate at which they arrive,
the queues become overloaded and congestion occurs.
Congestion at the transport layer is actually the result of congestion at the
network layer. TCP implements its own congestion control mechanisms.
9. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 9
23.1.2 Connectionless and Connection-Oriented Protocols
A TL protocol can provide both Connectionless and Connection-oriented service.
1) Connectionless Service:
At the source/client, the Application layer divides message into chunks of
data and gives to TL. The TL treats each chunk independently,
encapsulates and sends it. This may give rise to two types of problems:
Packets may arrive out-of-order at the destination/server & will be
delivered as they arrived to the application process. Also, since no packet
numbering is used, if a packet is lost, receiver TL can’t know about it.
Whichever the chunk it receives, it simply delivers to the application.
So, difficult to implement error/flow/congestion control in Connectionless
service.
Fig. 23.14 illustrates this scenario.
2) Connection-oriented Service:
Here, the client and server needs to establish a logical connection before
any data transfer can happen. After data exchange, connection needs to be
torn down.
At the TL, connection-oriented service involves only the two hosts; the
service is end to end. i.e., we should be able to make a connection-oriented
protocol at the transport layer over either a connectionless or connection-
oriented protocol at the network layer.
Fig. 23.15 shows the connection establishment, data-transfer, and tear-
down phases in a connection-oriented service at the TL.
We can implement flow control, error control, and congestion control in a
connection oriented protocol.
10. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 10
3) Connectionless and Connection-oriented service as FSMs
Fig. 23.16 shows a representation of a transport layer using an FSM. Each
TL (sender or receiver) is considered as a machine with a finite number of
states. The machine is always in one of the states until an event occurs.
Each event is associated with two reactions: defining the list of actions to
be performed and determining the next state. We have used rounded-
corner rectangles to show states, colored text to show events, and regular
black text to show actions. A horizontal line or slash is used to separate
the event from the actions.
• An FSM in a connection oriented transport layer needs to go through 3
states before reaching the established state and before closing the
connection. The machine is in the closed state when there is no
connection.
• It remains in the Closed state until a request for opening the connection
arrives from the local process; the machines sends an open request packet
to the remote transport layer and moves to the open-wait-I state.
• When an acknowledgment received from the other end, the local
FSM moves to the open wait-II state.
11. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 11
• Data and DATA acknowledgement can be exchanged between the
two ends when they are both in the established state. The
established state represents a set of data transfer states.
• To tear down a connection, the application layer sends a close
request message to its local TL. The TL sends a close-request
packet to the other end and moves to close-wait-I state.
• When an acknowledgment is received from the other end, the
machine moves to the close-wait-II state and waits for the close-
request packet from the other end. When this packet arrives, the
machine sends an acknowledgment and moves to the closed
state.
12. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 12
23.2 TRANSPORT-LAYER PROTOCOLS
We discuss general protocols at TL assuming unidirectional (simplex)
transmission
23.2.1 Simple Protocol
It is a connectionless protocol with neither flow nor error control. Sender
continuously sends the packet without checking the receiver, The receiver
can handle any packet as and when packet is received.
The transport layer at the sender gets a message from its application layer,
makes a packet out of it, and sends the packet.
The transport layer at the receiver receives a packet from its network
layer, extracts the message from the packet, and delivers the message to
its application layer.
FSMs
Both Sender and receiver FSM has only one state-the “ready” state. The
sending machine remains in the ready state until a request comes from the
process in the application layer. When this event occurs, the sending machine
encapsulates the message in a packet and sends it to the receiving machine.
The receiving machine remains in the ready state until a packet arrives from the
sending machine. When this event occurs, the receiving machine decapsulates
the message out of the packet and delivers it to the process at the application
layer. Fig 23.18 shows the FSM for the Simple protocol.
13. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 13
23.2.2 Stop-and-Wait protocol
This is a connection-oriented protocol, which uses both flow control and
error control.
Both the sender and the receiver use a sliding window of size 1.
The sender sends one packet at a time and waits for an ACK before
sending the next.
Sender sends each packet with checksum. At the receiver, the checksum is
verified. If the checksum is incorrect, the packet is treated as corrupted
and discarded. No ACK is sent in this case.
Every time the sender sends a packet, it starts a timer. If an ACK arrives
before the timer expires, the timer is stopped and the sender sends the
next packet.
If the timer expires, the sender resends the previous packet, assuming that
the packet was either lost or corrupted. i.e., the sender needs to keep a
copy of the packet until its ACK arrives.
Only one packet and one ACK can be in the channels at any time. Fig. 23.20
illustrates this protocol.
a) Sequence and ACK numbers
To detect duplicate packets, the protocol uses sequence numbers and ACK
numbers.
Packet header has a field of size ‘m’ bits to hold the sequence number. To
minimize header size, ‘m’ should be small.
Assume that, sender has sent a packet with sequence number x. Now, three
things can happen.
i. The packet arrives safely at the receiver site; the receiver sends an ACK.
The ACK arrives at the sender site, causing the sender to send the next
packet numbered x+1.
ii. The packet is corrupted or never arrives at the receiver site; the sender
resends the packet (numbered x) after the time-out. The receiver returns
an ACK.
14. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 14
iii. The packet arrives safely at the receiver site; the receiver sends an ACK,
but the ACK is corrupted or lost. The sender resends the packet
(numbered x) after the time-out but the packet here is a duplicate. The
receiver can check this because it expects packet x+1 but packet x was
received and discards this duplicate packet.
The ACK numbers always announce the sequence number of the next
packet expected by the receiver. For ex, if packet 0 has arrived safely, the
receiver sends an ACK with ACK 1, because receiver expects next packet with
sequence number 1.
Note: We can see that, there is a need for sequence numbers x and x + 1, but no
need for a packet to be numbered x + 2. If x = 0, then x + 1 = 1. So, in Stop-and-
wait protocol, we just need 1-bit sequence number (m=1). This means the
sequence is 0, 1, 0, 1, 0, and so on. This is referred to as modulo-2 arithmetic. In
general, sequence number is Modulo 2m.
b) FSMs
Fig.23.21 shows FSM for stop-and-wait protocol
1) Sender
The sender is initially in the ready state. The variable S is initialized to 0.
Ready state:
Sender is waiting for an event. If a request comes from the application
layer, the sender creates a packet with the sequence number S.
A copy of the packet is stored, and the packet is sent. The sender then
starts the timer and moves to the blocking state.
15. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 15
Blocking state:
When the sender is in this state, three events can occur:
a) If an error-free ACK arrives with the ackNo = (S+1) modulo2, then the
timer is stopped. The window slides, S = (S+1) modulo2 and sender moves
to the ready state.
b) If a corrupted ACK or an error-free ACK with the ackNo ≠ (S+1) modulo2
arrives, the ACK is discarded.
c) If a time-out occurs, the sender resends the only outstanding packet and
restarts the timer.
2) Receiver
The receiver is always in the ready state. Three events may occur:
a) If an error-free packet with seqNo = R arrives, the message in the packet is
delivered to the application layer. The window slides, R=(R+1) modulo2.
An ACK with ackNo = R (new value) is sent to sender.
b) If an error-free packet with seqNo ≠ R arrives, the packet is discarded, but
an ACK with ackNo = R is sent.
c) If a corrupted packet arrives, the packet is discarded.
c) Flow diagram for Stop-and-Wait protocol
16. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 16
Explanation:
Packet0 is sent and acknowledged.
Packet1 is lost and resent after the time-out. The resent packet1 is
acknowledged and the timer stops.
Packet0 is sent and acknowledged, but the ACK is lost. The sender after the
time-out, resends packet0, which is acknowledged. But, since this is a
duplicate packet, it is discarded by receiver.
d) Efficiency
The Stop-and-Wait protocol is very inefficient if channel has a large
bandwidth (high data rate) and the round-trip delay is long.
The product of these two is called the bandwidth-delay product. This is a
measure of the number of bits a sender can transmit through the system
while waiting for an acknowledgment from the receiver. .
e) Pipelining
If a new task is begun before the previous task has ended, 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.
Pipelining improves the efficiency of the transmission if the number of bits
in transition is large with respect to the bandwidth-delay product.
Example 1:
Assume that, in a Stop-and-Wait system, the bandwidth of the line is 1Mbps, and
1-bit takes 20 milliseconds to make around trip. What is the bandwidth-delay
product? If the system data packets are 1000 bits in length, what is the
utilization percentage of the link?
Solution
The bandwidth-delay product is (1 x 106) x (20 x 10-3) = 20000bits.
The system can send 20,000 bits during round trip time. However, the
system sends only 1000 bits. So, link utilization is 1000/20000 = 5%.
Example 2:
What is the utilization percentage of the link in Example1 if we have a protocol
that can send up to 15 packets before waiting for acknowledgments?
Solution
The bandwidth-delay product is 20,000 bits. The system can send upto 15
packets (15000 bits) during a round trip. So, the utilization is 15000/20000 =
75%.
17. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 17
23.2.3 Go-Back-N (GBN) Protocol
To improve the efficiency of transmission and keep the channel busy,
multiple packets must be in transition while the sender is waiting for ACK
i.e., more than one outstanding packet must be in the channel.
There are two approaches: Go-back-N and Selective-Repeat. Both belong
to the category of Sliding-window Protocols.
The key features of Go back N are: several packets can be sent before
receiving ACKs, the receiver can accept only one packet at a time, out-of-
order packets are discarded by the receiver, sender keeps a copy of all
packets sent. Fig.23.23 shows the structure of GBN.
a) Sequence and ACK numbers
The sequence numbers are modulo 2m, where m is the size of the sequence
number field, in bits.
An ackNo is cumulative and defines the sequence number of the next packet
expected, confirming that all previous packets have been received correctly. For
ex, if the ackNo is 7, it means all packets with seq. no. up to 6 have arrived, and
the receiver is expecting the packet with sequence number 7.
b) Send window
The sender window is an imaginary box covering the sequence numbers of the
data packets that can be sent. Fig.23.24
The blue colored region shows the sequence number of packets that have
been sent, but not yet acknowledged. These are called outstanding
packets.
The next white region shows the range of sequence numbers for packets
that can be sent.
Sender uses only one timer (for the first outstanding packet). When this
timer expires, all the outstanding packets are resent.
18. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 18
The window itself is an abstraction with three variables: Sf (seq. no. of the the
first/oldest outstanding packet), Sn (seq. no. of the next packet to be sent), and
Ssize (size of send window).
The send window is an abstract concept defining an imaginary box of
maximum size = 2m − 1 with three variables: Sf, Sn, and Ssize.
Fig.23.25 shows how a send window can slide one or more slots to the right
when an error-free ACK (Sf ≤ ackNo<Sn) arrives from the receiver.
c) Receive window
The size of receive window is 1. So, it ensures that the packets with correct
seq. no only is accepted and any out-of-order packet is discarded. In this
case, sender needs to resend after time-out.
Fig. 23.26 shows the receive window. We need only one variable Rn (seq.
no of the 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.
19. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 19
A packet with a sequence number of value Rn is only accepted and
acknowledged. The window slides by one position. Rn = (Rn + 1) modulo 2m.
Note: Let’s say Sn=7. i.e, sender has sent packets up to sequence no. 6 and Sf=3,
i.e., packets 3 onwards not acknowledged. If timer expires, the sender goes back
and resends packets 3, 4, 5 and 6. So, the name Go-back-N.
d) FSMs
Fig.23. 27 shows the FSM for GBN protocol
i) Sender
The sender starts in the ready st ate with Sf=Sn=0.
Ready state:
Four events may occur when the sender is in ready state.
a) If a request comes from the application layer, the sender creates a packet
with the sequence number Sn. A copy of the packet is stored, Timer is
started and the packet is sent.
The value of Sn is incremented, (Sn=Sn+1) modulo 2m. If the window is full
i.e., Sn = (Sf+Ssize) modulo 2m, the sender goes to the blocking state.
b) If an error-free ACK arrives with ackNo (Sf ≤ ackNo <Sn), the sender slides
the window (set Sf=ackNo).
If all outstanding packets are acknowledged (ackNo=Sn), then the timer is
stopped.
If all outstanding packets are not acknowledged, the timer is restarted.
c) If a corrupted ACK or an error-free ACK with ackNo not related to the
outstanding packet arrives, it is discarded.
d) If a time-out occurs, the sender resends all outstanding packets 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, the sender slides the window(set Sf = ackNo)
if all outstanding packets are acknowledged (ackNo = Sn), then the timer is
stopped.
20. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 20
If all outstanding packets are not acknowledged, the timer is restarted.
The sender then moves to the ready state.
b) If a corrupted ACK or an error free ACK with the ackNo not related to the
outstanding packets arrives, the ACK is discarded.
c) If a time-out occurs, the sender sends all outstanding packets and restarts
the timer.
ii) Receiver
The receiver is always in the ready state. The variable Rn is initialized to 0.
Three events may occur:
a) If an error-free packet with seqNo = Rn arrives, the message in the packet
is delivered to the application layer.
The window then slides, Rn = (Rn+1) modulo 2m. Finally an ACK is sent
with ackNo = Rn.
b) If an error-free packet with seqNo outside the window arrives, the packet
is discarded, but an ACK with ackNo = Rn is sent.
c) If a corrupted packet arrives, it is discarded.
21. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 21
e) Send window size
In GBN, Send window size must be less than 2m. This is illustrated in
Fig.23.28.
Let m=2, i.e., the packet seq.nos are 0, 1, 2, 3, 0, 1, 2 ,… and so on.
Fig.23.28 compares a window size of 3(less than 2m) against a window size
of 4(equal to 2m).
Let the window size be 3 (<2m). Then, different cycles of windows are: {0,
1, 2}, {3, 0, 1} and so on. Say all 3 packets 0, 1, 2 of the first cycle are sent
and received. So, receiver has updated Rn appropriately. Assume all 3
ACKs are lost, the timer expires and all 3 packets are resent starting with
packet 0. The receiver is now expecting packet 3 [because Rn=3], not
packet0, so the duplicate packet is correctly discarded.
Let the window size be 4 (=2m). Then, different cycles of windows are: {0,
1, 2, 3}, { 0, 1, 2, 3} and so on. Say all 4 packets 0, 1, 2, 3 of the first cycle
are sent and received. So, receiver has updated Rn appropriately. Assume
all 4 ACKs are lost, the timer expires and all 4 packets are resent starting
with packet 0. Now the receiver accepts packet 0 (because Rn=0) as a first
packet in the next cycle. But, this is a duplicate packet of cycle 1 which the
receiver is unable to identify. This is an error. So, the size of the send
window must be less than 2m.
Adv of GBN: The receiver is simple, needs to have only one variable, out-of-order
packets are discarded.
Limitations: Each time a single packet is lost or corrupted or timer expires, GBN resends
all the outstanding packets, even though some of them would have arrived safely at the
receiver. Also, if underlying network is noisy, again packets may be lost which leads to
retxn of all packets. This leads to more congestion in the network and is very inefficient
way of communication.
22. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 22
23.2.4 Selective-Repeat protocol
To overcome the limitations of GBN, another protocol was designed called
Selective-Repeat (SR) protocol. As the name implies, it resends only those
packets that are actually lost. (not all the outstanding packets). Fig. 23.31 shows
the schematic structure of SRP.
a) Windows in SR protocol
The SR protocol like GBN uses two windows: a send window and a receive
window. However, there are differences:
First, the maximum size of the send window is 2m-1 (= 2m/2) or half the
max sequence numbers. It is 2m -1 in GBN. Second, the receive window size
is same as that of send window.
Fig. 23.32 depicts Send window for SR protocol.
The sizes of the send window and receive window are the same. So, the
sender can send as many packets as the size of the receive window. Due to
this, the packets may arrive out order at the receiver and stored until
they can be delivered.
23. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 23
However, the receiver TL would reassemble them and deliver in the
correct sequence to the application layer.
Fig.23.33 shows the abstraction of Receive window in SR protocol.
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.
Note: In the Selective-Repeat protocol, an ACK number defines the sequence
number of the error-free packet received.
Example 4
Assume a sender sends 6 packets: packets 0, 1, 2, 3, 4, and 5. The sender
receives an ACK with ackNo=3. What is the interpretation if the system is using
GBN or SR?
Solution
If the system is using GBN, it means that packets 0, 1, and 2 have been received
uncorrupted and the receiver is expecting packet 3. If the system is using SR, it
means that packet 3 has been received uncorrupted. The ACK does not say
anything about other packets.
b) FSMs
Figure 23.34 shows the FSMs for the Selective-Repeat protocol.
1) Sender
The sender starts in the ready state.
Ready state
Four events may occur in this case:
i. If a request comes from the application layer, the sender creates packet
with the sequence number Sn. A copy of the packet is stored, the packet is
sent and 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.
ii. 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. If there are outstanding packets, the timer is restarted; otherwise,
the timer is stopped.
24. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 24
iii. If a corrupted ACK or an error-free ACK with ackNo not related to an
outstanding packet arrives, it is discarded.
iv. 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 slides to the right until the Sf points to the first
acknowledged packet. If the window has moved forward, the sender
moves to 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.
2)Receiver
The receiver is always in the ready state. Three events may occur:
i. If an error-free packet with seqNo in the window arrives, the packet is
stored and an ACK with ackNo=seqNo is sent. Also, if the seqNo=Rn , then
this 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.
25. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 25
ii. 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.
iii. If a corrupted packet arrives, the packet is discarded.
c) Window Sizes
We show that the size of the sender and receiver windows can be max. one-half
of 2m. For ex, we choose m = 2, which means the size of the window is 2m/2 =
2m-1 = 2.
Let m=2, i.e., the packet seq. nos are 0, 1, 2, 3, 0, 1, 2 ,… and so on.
Fig.23.36 compares a window size of 2 (=2m-1) against a window size of 3
(more than 2m-1). Remember that SR protocol can accept out-of-order
packets.
26. Computer Communication Networks 17EC64 MODULE 5
Edited by: Prof. Krishnananda L, Dept of ECE, Govt SKSJTI, Bengaluru Page 26
Let the window size be 2 (=2m-1). Then, different cycles of windows are: {0,
1}, {2, 3}, {0, 1} and so on. Say both packets 0, 1 of the first cycle are sent and
received. Rn also updated. Assume both ACKs are lost, the timer of packet 0
expires and packet 0 is resent. The receiver is now expecting packet 2 or 3
[packets of next cycle], not packet0, so the duplicate packet is correctly
discarded.
Let the window size be 3 (>2m-1). Then, different cycles of windows are: {0,
1, 2}, {3, 0, 1}, {2, 3, 0} and so on. Say all 3 packets 0, 1, 2 of the first cycle are
sent and received. Assume all 3 ACKs are lost, the timer expires and packet 0
is resent. The receiver is now expecting any of the packets {3, 0, 1} in the
next cycle. So, the receiver accepts packet 0 as a packet in the next cycle. But,
this is a duplicate packet of cycle 1 which the receiver is unable to identify.
This is an error. So, the size of the send and receive window must not be
>2m-1.
23.2.5 Bidirectional Protocols: Piggybacking
All the protocols discussed earlier are unidirectional. Data packets flow in only one direction
and ACKs travel in the other direction. However, real-world applications need data and ACKs
to flow in both directions (say client-to-server and server-to-client).
A technique called piggybacking is used to improve the efficiency of the bidirectional
protocols.
When a packet is carrying data from A to B, it can also carry ACK feedback about arrived
packets from B. Similarly, when a packet is carrying data from B to A, it can also carry ACK
feedback about the arrived packets from A.
Fig. 23.37 shows the layout for the GBN protocol implemented bi-directionally using
piggybacking.
The client and server each use two independent windows i.e., send and receive.