Unit 3
Unit 3
39
UNIT- III
Simplest Protocol
It is very simple. The sender sends a sequence of frames without even thinking about the receiver. Data are
transmitted in one direction only. Both sender & receiver always ready. Processing time can be ignored.
Infinite buffer space is available. And best of all, the communication channel between the data link layers
never damages or loses frames. This thoroughly unrealistic protocol,which we will nickname ‘‘Utopia,’’
.The utopia protocol is unrealistic because it does not handle either flow control or error correction
Stop-and-wait Protocol
It is still very simple. The sender sends one frame and waits for feedback from the receiver. When the ACK
arrives, the sender sends the next frame
It is Stop-and-Wait Protocol because the sender sends one frame, stops until it receives confirmation from
the receiver (okay to go ahead), and then sends the next frame. We still have unidirectional
communication for data frames, but auxiliary ACK frames (simple tokens of acknowledgment) travel from
the other direction. We add flow control to our previous protocol.
NOISY CHANNELS
Although the Stop-and-Wait Protocol gives us an idea of how to add flow control to its predecessor,
noiseless channels are nonexistent. We can ignorethe error (as we sometimes do), or we need to add error
control to ourprotocols. We discuss three protocols in this section that use error control.
In Stop-and-Wait ARQ, we use sequence numbers to number the frames. The sequence numbers are
based on modulo-2 arithmetic.
In Stop-and-Wait ARQ, the acknowledgment number always announces in modulo-2 arithmetic the
sequence number of the next frame expected.
Bandwidth Delay Product:
Assume that, in a Stop-and-Wait ARQ system, the bandwidth of the line is 1 Mbps, and 1 bit takes 20 ms
to make a round trip. What is the bandwidth-delay product? If the system data frames are 1000 bits in
length, what is the utilization percentage of the link?
The link utilization is only 1000/20,000, or 5 percent. For this reason, for a link with a high bandwidth or long delay, the use
of Stop-and-Wait ARQ wastes the capacity of the link.
To improve the efficiency of transmission (filling the pipe), multipleframes must be in transition
while waiting for acknowledgment. In other words, we need to let more than one frame be outstanding to
keep thechannel busy while the sender is waiting for acknowledgment.
The first is called Go-Back-N Automatic Repeat. In this protocol we cansend several frames
before receiving acknowledgments; we keep a copy ofthese frames until the acknowledgments arrive.
In the Go-Back-N Protocol, the sequence numbers are modulo 2m, where m is the size of the
sequence number field in bits. The sequence numbers range from 0 to 2 power m- 1. For example, if m is
4, the only sequence numbers are 0 through 15 inclusive.
The sender window at any time divides the possible sequence numbers into four regions.
The first region, from the far left to the left wall of the window, defines the sequence numbers
belonging to frames that are already acknowledged.The sender does not worry about these frames and
keeps no copies of them.
The second region, colored in Figure (a), defines the range of sequencenumbers belonging to the
frames that are sent and have an unknown status. The sender needs to wait to find out if these frames have
been received or were lost. We call these outstanding frames.
The third range, white in the figure, defines the range of sequencenumbers for frames that can be
sent; however, the corresponding data packets have not yet been received from the network layer.
Finally, the fourth region defines sequence numbers that cannot be used until the window slides
The send window is an abstract concept defining an imaginary box ofsize 2m − 1 with three
variables: Sf, Sn, and Ssize. The variable Sf definesthe sequence number of the first (oldest) outstanding
frame. The variable Snholds the sequence number that will be assigned to the next frame to be sent.Finally, the
variable Ssize defines the size of the window.
Figure (b) shows how a send window can slide one or more slots to the right when an
acknowledgment arrives from the other end. The acknowledgments in this protocol are cumulative,
meaning that more than one frame can be acknowledged by an ACK frame. In Figure, frames 0, I, and 2 are
acknowledged, so the window has slide to the right three slots. Note that thevalue of Sf is 3 because frame 3
is now the first outstanding frame.The send window can slide one or more slots when a valid
acknowledgment arrives.
The receive window is an abstract concept defining an imaginary box of size 1with one single variable Rn.
The window slides when a correct frame has arrived; sliding occurs one slot at a time
Fig: Receiver window (before sliding (a), After sliding (b))
Timers
Although there can be a timer for each frame that is sent, in our protocol weuse only one. The reason is that
the timer for the first outstanding frame always expires first; we send all outstanding frames when this timer
expires.
Acknowledgment
The receiver sends a positive acknowledgment if a frame has arrived safe andsound and in order. If a frame is
damaged or is received out of order, the receiver is silent and will discard all subsequent frames until it
receives the one it is expecting. The silence of the receiver causes the timer of the unacknowledged frame
at the sender side to expire. This, in turn, causes thesender to go back and resend all frames, beginning with
the one with the expired timer. The receiver does not have to acknowledge each framereceived. It can send
one cumulative acknowledgment for several frames.
Resending a Frame
When the timer expires, the sender resends all outstanding frames. For example, suppose the sender has
already sent frame 6, but the timer for frame 3 expires. This means that frame 3 has not been
acknowledged; the sender goes back and sends frames 3,4,5, and 6 again. That is why the protocol is
called Go-Back-N ARQ.
Below figure is an example(if ack lost) of a case where the forward channel isreliable, but the reverse is not.
No data frames 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
Below figure is an example(if frame lost)
Stop-and-Wait ARQ is a special case of Go-Back-N ARQ in which the size of the send window is 1.
Sender Window (explain go-back N sender window concept (before & after sliding.) The only difference in
sender window between Go-back N and Selective Repeat is Window size)
Receiver window
The receiver window in Selective Repeat is totally different from the one in Go Back-N. First, the size of
the receive window is the same as the size of thesend window (2m-1).
The Selective Repeat Protocol allows as many frames as the size of the receiver window to arrive out of
order and be kept until there is a set of in- order frames to be delivered to the network layer. Because
the sizes of thesend window and receive window are the same, all the frames in the sendframe can
arrive out of order and be stored until they can be delivered. However the receiver never delivers packets
out of order to the network layer. Above Figure shows the receive window. Those slots inside the window
that are colored define frames that have arrived out of order and are waiting for their neighbors to arrive
before delivery to the network layer.
In Selective Repeat ARQ, the size of the sender and receiver window must be at most one-half of 2m
Flow Diagram
Differences between Go-Back N & Selective Repeat
One main difference is the number of timers. Here, each frame sent or resent needs a timer, which
means that the timers need to be numbered (0, 1,2, and 3). The timer for frame 0 starts at the first request,
but stops when the ACK for this frame arrives.
There are two conditions for the delivery of frames to the network layer: First, a set of consecutive
frames must have arrived. Second, the set starts from the beginning of the window. After the first
arrival, there was only one frame and it started from the beginning of the window. After the last arrival,
there are three frames and the first one starts from the beginning of the window.
Another important point is that a NAK is sent.
The next point is about the ACKs. Notice that only two ACKs are sent here. The first one
acknowledges only the first frame; the second one acknowledgesthree frames. In Selective Repeat, ACKs are
sent when data are delivered tothe network layer. If the data belonging to n frames are delivered in one shot,
only one ACK is sent for all of them.
Piggybacking
A technique called piggybacking is used to improve the efficiency of thebidirectional protocols. When a
frame is carrying data from A to B, it can also carry control information about arrived (or lost) frames
from B; when a frameis carrying data from B to A, it can also carry control information about the arrived
(or lost) frames from A.
FRAMING:
To provide service to the network layer, the data link layer must use the service provided to it by
the physical layer. What the physical layer does is accept a raw bit stream and attempt to deliver it to the
destination. This bit stream is not guaranteed to be error free. The number of bits received may be less
than, equal to, or more than the number of bits transmitted, and theymay have different values. It is
up to the data link layer to detect and, if necessary, correct errors. The usual approach is for the data
link layer to break the bit stream up into discrete frames and compute the checksum for each frame
(framing). When a frame arrives at the destination, the checksum is recomputed. If the newly
computed checksum is different fromthe one contained in the frame, the data link layer knows that an
error has occurred and takes steps to deal with it (e.g., discarding the bad frame and possibly also sending
back an error report).We will look at four framing methods:
1. Character count.
2. Flag bytes with byte stuffing.
3. Starting and ending flags, with bit stuffing.
4. Physical layer coding violations.
Character count method uses a field in the header to specify the number of characters in the frame. When
the data link layer at the destination sees the character count, it knows how many characters follow and
hence where the end of the frame is. This technique is shown in Fig. (a) For four frames of sizes 5, 5, 8, and
8 characters, respectively.
(a) A frame delimited by flag bytes (b) Four examples of byte sequences
before and after byte stuffing
It may easily happen that the flag byte's bit pattern occurs in the data. This situation will usually
interfere with the framing. One way to solve this problem is to have the sender's data link layer insert a
special escape byte (ESC) just before each ''accidental'' flag byte in the data. The data link layeron the
receiving end removes the escape byte before the data are given tothe network layer. This technique
is called byte stuffing or character stuffing.
Thus, a framing flag byte can be distinguished from one in the data by the absence or presence of an
escape byte before it.
What happens if an escape byte occurs in the middle of the data? The answer is that, it too is stuffed
with an escape byte. Thus, any single escapebyte is part of an escape sequence, whereas a doubled one
indicates that asingle escape occurred naturally in the data. Some examples are shown in Fig. (b). In all
cases, the byte sequence delivered after de stuffing is exactlythe same as the original byte sequence.
A major disadvantage of using this framing method is that it is closelytied to the use of 8-bit
characters. Not all character codes use 8-bit characters. For example UNICODE uses 16-bit characters,
so a new technique had to be developed to allow arbitrary sized characters
Starting and ending flags, with bit stuffing allows data frames to contain an arbitrary number of bits
and allows character codes with an arbitrary number of bits per character. It works like this. Each frame
begins and endswith a special bit pattern, 01111110 (in fact, a flag byte). Whenever the sender's data link
layer encounters five consecutive 1s in the data, it automatically stuffs a 0 bit into the outgoing bit stream.
This bit stuffing is analogous to byte stuffing, in which an escape byte is stuffed into the outgoing character
stream before a flag byte in the data.
When the receiver sees five consecutive incoming 1 bits, followed by a 0 bit, it automatically de-
stuffs (i.e., deletes) the 0 bit. Just as byte stuffing is completely transparent to the network layer in
both computers, so is bit stuffing. If the user data contain the flag pattern, 01111110, this flag is
transmitted as 011111010 but stored in the receiver's memory as 01111110.
Fig:Bit stuffing. (a) The original data. (b) The data as they appear on the line.
(c) The data as they are stored in the receiver's memory after destuffing.
With bit stuffing, the boundary between two frames can be unambiguously recognized by the flag pattern.
Thus, if the receiver loses track of where it is, all it has to do is scan the input for flag sequences, since
they can only occurat frame boundaries and never within the data.
Physical layer coding violations method of framing is only applicable to networks in which the encoding
on the physical medium contains some redundancy. For example, some LANs encode 1 bit of data by using
2 physicalbits. Normally, a 1 bit is a high-low pair and a 0 bit is a low-high pair. The scheme means that
every data bit has a transition in the middle, making it easy for the receiver to locate the bit boundaries.
The combinations high-high and low-low are not used for data but are used for delimiting frames in
some protocols.
As a final note on framing, many data link protocols use combination of a character count with one of the
other methods for extra safety. When a frame arrives, the count field is used to locate the end of the frame.
Only if the appropriate delimiter is present at that position and the checksum is correct isthe frame
accepted as valid. Otherwise, the input stream is scanned for the next delimiter
The upper sub layer that is responsible for flow and error control is called the logical link control (LLC)
layer; the lower sub layer that is mostly responsiblefor multiple access resolution is called the media
access control (MAC) layer. When nodes or stations are connected and use a common link, called a
multipoint or broadcast link, we need a multiple-access protocol to coordinate access to the link.
leads to a collision between the frames from station A and station B. The end of B's frame collides with the
beginning of A's frame. On the other hand, suppose that station C sends a frame between t andt + Tfr .
Here, there is a collision between frames from station A and station C. The beginning of C's frame collides
with the end of A's frame
Looking at Figure, we see that the vulnerable time, during which a collisionmay occur in pure ALOHA, is
2 times the frame transmission time. Pure ALOHA vulnerable time = 2 x Tfr
throughput is 250 × 0.152 = 38. Only 38 framesout of 250 will probably survive.
2 Slotted ALOHA
Pure ALOHA has a vulnerable time of 2 x Tfr . This is so because there is no rule that defines when the
station can send. A station may send soon after another station has started or soon before another station
has finished. Slotted ALOHA was invented to improve the efficiency of pure ALOHA.
In slotted ALOHA we divide the time into slots of Tfr s and force the station to send only at the
beginning of the time slot. Figure 3 shows an example offrame collisions in slotted ALOHA
FIG:3
Because a station is allowed to send only at the beginning of the synchronizedtime slot, if a station misses this
moment, it must wait until the beginning ofthe next time slot. This means that the station which started at the
beginningof this slot has already finished sending its frame. Of course, there is still thepossibility of collision
if two stations try to send at the beginning of the sametime slot. However, the vulnerable time is now reduced
to one-half, equal toTfr Figure 4 shows the situation
Below fig shows that the vulnerable time for slotted ALOHA is one-half that ofpure ALOHA. Slotted
ALOHA vulnerable time = Tfr
The throughput for slotted ALOHA is S = G × e−G . The maximumthroughput Smax = 0.368 when G = 1.
A slotted ALOHA network transmits 200-bit frames using a shared channel witha 200- Kbps bandwidth. Find
the throughput if the system (all stations together) produces
a. 1000 frames per second b. 500 frames per second c. 250 frames per second
Solution
This situation is similar to the previous exercise except that the network isusing slotted ALOHA instead
of pure ALOHA. The frame transmission time is200/200 kbps or 1 ms.
a. In this case G is 1. So S =G x e-G or S =0.368 (36.8 percent). This means that the throughput is 1000 x
0.0368 =368 frames. Only 368 out of 1000 frames will probably survive. Note that this is the maximum
throughput case,percentagewise.
b. Here G is 1/2 In this case S =G x e-G or S =0.303 (30.3 percent). This means that the throughput is
500 x 0.0303 =151. Only 151 frames out of 500 will probably survive.
c. Now G is 1/4. In this case S =G x e-G or S =0.195 (19.5 percent). This means that the throughput
is 250 x 0.195 = 49. Only 49 frames out of 250will probably survive
Comparison between Pure Aloha & Slotted Aloha
Carrier Sense Multiple Access (CSMA)
To minimize the chance of collision and, therefore, increase the performance, the CSMA method was developed. The chance
of collision can be reduced if a station senses the medium before trying to use it. Carrier sense multiple access (CSMA) requires that
each station first listen to the medium (or check the state of the medium) before sending. In other words, CSMA is based on the
principle "sense before transmit" or "listen before talk."
CSMA can reduce the possibility of collision, but it cannot eliminate it. The reason for this is shown in below Figure. Stations
are connected to a shared channel (usually a dedicated medium).
The possibility of collision still exists because of propagation delay; station may sense the medium and find it idle, only because the
first bit sent by another station has not yet been received.
At time tI' station B senses the medium and finds it idle, so it sends a frame. At time t2 (t2> tI)' station C senses the medium
and finds it idle because, at this time, the first bits from station B
have not reached station C. Station C also sends a frame. The two signals collide and both frames are destroyed.
Space/time model of the collision in CSMA
Vulnerable Time
The vulnerable time for CSMA is the propagation time Tp . This is the time needed for a signal to propagate from one end of the
medium to the other. When a station sends a frame, and any other station tries to send a frameduring this time, a collision
will result. But if the first bit of the frame reaches the end of the medium, every station will already have heard the bit and will
refrain from sending
Vulnerable time in CSMA
Persistence Methods
What should a station do if the channel is busy? What should a station do if the channel is idle? Three methods have been devised
to answer these questions:the 1-persistent method, the non-persistent method, and the p-persistent method
1-Persistent: In this method, after the station finds the line idle, it sends its frame immediately (with probability 1). This method has
the highest chance of collision because two or more stations may find the line idle and send their frames immediately.
Non-persistent: a station that has a frame to send senses the line. If the lineis idle, it sends immediately. If the line is not idle, it
waits a random amount of time and then senses the line again. This approach reduces the chance of collision because it is unlikely
that two or more stations will wait the same amount of time and retry to send simultaneously. However, this method reduces the
efficiency of the network because the medium remains idle when there may be stations with frames to send.
p-Persistent: This is used if the channel has time slots with a slot duration equal to or greater than the maximum propagation time.
The p-persistent approach combines the advantages of the other two strategies. It reduces the chance of collision and improves
efficiency.
In this method, after the station finds the line idle it follows these steps:
1. With probability p, the station sends its frame.
2. With probability q = 1 - p, the station waits for the beginning of the next time slot and checks the line again.
a. If the line is idle, it goes to step 1.
b. If the line is busy, it acts as though a collision has occurred and uses the backoff procedure.
a.
Carrier Sense Multiple Access with Collision Detection (CSMA/CD)
The CSMA method does not specify the procedure following a collision. Carrier sense multiple access with collision
detection (CSMA/CD) augments the algorithm to handle the collision.
In this method, a station monitors the medium after it sends a frame to see if the transmission was successful. If so, the station
is finished. If, however,there is a collision, the frame is sent again.
To better understand CSMA/CD, let us look at the first bits transmitted by the two stations involved in the collision. Although
each station continues to send bits in the frame until it detects the collision, we show what happens as the first bits collide. In below
Figure, stations A and C are involved in the collision.
Collision of the first bit in CSMA/CD
At time t 1, station A has executed its persistence procedure and starts sending the bits of its frame. At time t2, station C has not yet
sensed the firstbit sent by A. Station C executes its persistence procedure and starts sendingthe bits in its frame, which propagate both
to the left and to the right. The collision occurs sometime after time t2.Station C detects a collision at time t3when it receives the first
bit of A's frame. Station C immediately (or after a short time, but we assume immediately) aborts transmission.
Station A detects collision at time t4 when it receives the first bit of C's frame; it also immediately aborts transmission. Looking at
the figure, we see that A transmits for the duration t4 - tl; C transmits for the duration t3 - t2.
We need to avoid collisions on wireless networks because they cannot bedetected. Carrier sense multiple access with collision
avoidance (CSMAlCA)was invented for wirelesss network. Collisions are avoided through the use of CSMA/CA's three strategies:
the inter frame space, the contention window, and
Timing in CSMA/CA
Inter frame Space (IFS)
First, collisions are avoided by deferring transmission even if the channelis found idle. When an idle channel is found, the
station does not send immediately. It waits for a period of time called the inter frame space or IFS.
Even though the channel may appear idle when it is sensed, a distant station may have already started transmitting. The distant
station's signal has not yet reached this station. The IFS time allows the front of the transmitted signal by the distant station to reach
this station. If after the IFS time the channel is still idle, the station can send, but it still needs to wait a time equal to the contention
time. The IFS variable can also be used to prioritize stationsor frame types. For example, a station that is assigned shorter IFS has
a higher priority.
In CSMA/CA, the IFS can also be used to define the priority of a station or a frame.
Contention Window
The contention window is an amount of time divided into slots. A station that is ready to send chooses a random number of
slots as its wait time. The number of slots in the window changes according to the binary exponential back-off strategy. This means
that it is set to one slot the first time and then doubles each time the station cannot detect an idle channel after the IFS time. This is
very similar to the p-persistent method except that a random outcome defines the number of slots taken by the waiting station.
One interesting point about the contention window is that the stationneeds to sense the channel after each time slot. However,
if the station finds the channel busy, it does not restart the process; it just stops the timer and restarts it when the channel is sensed as
idle. This gives priority to the station with the longest waiting time.
In CSMA/CA, if the station finds the channel busy, it does not restart the timer of the contention window; it stops the timer
and restarts it when the channel becomes idle.
Acknowledgment
With all these precautions, there still may be a collision resulting in destroyed data. In addition, the data may be corrupted
during the transmission. The positive acknowledgment and the time-out timer can help guarantee that the receiver has received the
frame.
This is the CSMA protocol with collision avoidance.
The station ready to transmit, senses the line by using one of the persistentstrategies.
As soon as it finds the line to be idle, the station waits for an IFS (Inter frame
space) amount of time.
If then waits for some random time and sends the frame.
After sending the frame, it sets a timer and waits for the acknowledgementfrom the receiver.
If the acknowledgement is received before expiry of the timer, then the
transmission is successful.
But if the transmitting station does not receive the expectedacknowledgement before
the timer expiry then it increments the back off
parameter, waits for the back off time and re senses the line
Flow Control or TCP Sliding Window
TCP uses a sliding window, to handle flow control. The sliding window protocol used by TCP, however, is something between the Go-
Back-N andSelective Repeat sliding window.
The sliding window protocol in TCP looks like the Go-Back-N protocol because it does not use NAKs;
it looks like Selective Repeat because the receiver holds the out-of-order segments until the missing ones arrive.
There are two big differences between this sliding window and the onewe used at the data link layer.
1 the sliding window of TCP is byte-oriented; the one we discussed in thedata link layer is frame-oriented.
2 the TCP's sliding window is of variable size; the one we discussed inthe data link layer was of fixed size
Sliding window
The window is opened, closed, or shrunk. These three activities, as we willsee, are in the control of the receiver (and depend on
congestion in the network), not the sender.
The sender must obey the commands of the receiver in this matter. Opening a window means moving the right wall to the right.
This allowsmore new bytes in the buffer that are eligible for sending.
Closing the window means moving the left wall to the right. This meansthat some bytes have been acknowledged and the sender
need not worry about them anymore.
Shrinking the window means moving the right wall to the left.
The size of the window at one end is determined by the lesser of two values: receiver window (rwnd) or congestion window (cwnd).
The receiver window is the value advertised by the opposite end in a segment containing acknowledgment. It is the number of bytes the
other end can accept before its buffer overflows and data are discarded.
The congestion window is a value determined by the network to avoid congestion
Window management in TCP
When the window is 0, the sender may not normally send segments, with twoexceptions.
1) urgent data may be sent, for example, to allow the user to kill the processrunning on the remote machine.
2) the sender may send a 1-byte segment to force the receiver to reannounce the next byte expected and the window size. This packet is
called a window probe.
The TCP standard explicitly provides this option to prevent deadlock if a window update ever gets lost.
Senders are not required to transmit data as soon as they come in from the application. Neither are receivers required to send
acknowledgements as soon as possible.
For example, in Fig. when the first 2 KB of data came in, TCP, knowing that ithad a 4-KB window, would have been completely correct in
just buffering the data until another 2 KB came in, to be able to transmit a segment with a 4-KBpayload. This freedom can be used to improve
performance
3.
send echo of character
and/or output 2.
interpret
character
1.
send character Host with Telnet
Host with server
Telnet client
Remote terminal applications (e.g., Telnet) send characters to a server.
The server interprets the character and sends the output at the serverto the client.
Although delayed acknowledgements reduce the load placed on the network by the receiver, a sender that sends multiple short
packets (e.g., 41-byte packets containing 1 byte of data) is still operating inefficiently. A way to reduce this usage is known as Nagle’s
algorithm (Nagle, 1984).