0% found this document useful (0 votes)
5 views

Data link layer

The Data Link Layer is responsible for functions such as line discipline, error control, and flow control, facilitating communication between devices. It offers three types of services: unacknowledged connectionless, acknowledged connectionless, and acknowledged connection-oriented, each with different error handling and connection management. Framing methods like fixed-size framing, flag bytes with byte stuffing, and bit stuffing are employed to ensure proper data transmission and synchronization.

Uploaded by

Waste Material
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Data link layer

The Data Link Layer is responsible for functions such as line discipline, error control, and flow control, facilitating communication between devices. It offers three types of services: unacknowledged connectionless, acknowledged connectionless, and acknowledged connection-oriented, each with different error handling and connection management. Framing methods like fixed-size framing, flag bytes with byte stuffing, and bit stuffing are employed to ensure proper data transmission and synchronization.

Uploaded by

Waste Material
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 174

Data Link Layer

Dr. Kumkum Saxena


Data Link Layer

Data Link Layer Functions

Line Discipline Error Control Flow Control

Dr. Kumkum Saxena Data Link Layer page 2


Line Discipline
ENQ/ACK:
Line Discipline Used in peer-to-peer.
communication.

ENQ/ACK SELECT/POLL

SELECT/POLL:
Used in Primary ands
Secondary Devices.
Dr. Kumkum Saxena Data Link Layer page 3
Line Discipline
ENQ (Enquiry)
◼ Used in peer –peer communication
◼ Enquire whether there is a required link between two devices
◼ Check whether the intended device is capable to receive
ACK (Acknowledgment)
◼ Used in Primary secondary communication
◼ The intended device will acknowledge about its status to the
receiver

Dr. Kumkum Saxena Data Link Layer page 4


Line Discipline :ENQ/ACK

Dr. Kumkum Saxena Data Link Layer page 5


Line Discipline : Select/Poll

Dr. Kumkum Saxena Data Link Layer page 6


Line Discipline : Select

Select

It is used
whenever the
primary device
with primary
secondary
relationship.

Dr. Kumkum Saxena Data Link Layer page 7


Line Discipline : Poll

Poll
▪The polling function is used by the primary device to Select
transmissions from the secondary devices.
▪If the primary device is ready to receive data , It ask each
device in turn if it has anything to send.

Dr. Kumkum Saxena Data Link Layer page 8


Poll

Dr. Kumkum Saxena Data Link Layer page 9


Functions of data link layer
1. Provides a well defined service interface to the network layer.
The data link layer offers three types of services.
Unacknowledged connectionless service
 Here, the data link layer of the sending machine sends
independent frames to the data link layer of the receiving
machine.
 The receiving machine does not acknowledge receiving the
frame.
 No logical connection is set up between the host machines.
 Error and data loss is not handled in this service.
 This is applicable in Ethernet services and voice
communications.

Dr. Kumkum Saxena Data Link Layer page 10


Functions of data link layer
Acknowledged connectionless service
◼ Here, no logical connection is set up between the host machines,
but each frame sent by the source machine is acknowledged by
the destination machine on receiving.
◼ If the source does not receive the acknowledgment within a
stipulated time, then it resends the frame. This is used in Wifi
(IEEE 802.11) services.
Acknowledged connection-oriented service
◼ This is the best service that the data link layer can offer to the
network layer.
◼ A logical connection is set up between the two machines and the
data is transmitted along this logical path.
◼ The frames are numbered, that keeps track of loss of frames and
also ensures that frames are received in correct order.

Dr. Kumkum Saxena Data Link Layer page 11


Functions of data link layer
The service has three distinct phases −
◼ Set up of connection – A logical path is set up between the
source and the destination machines. Buffers and counters are
initialized to keep track of frames.
◼ Sending frames – The frames are transmitted.
◼ Release connection – The connection is released, buffers and
other resources are released.
It is appropriate for satellite communications and long-distance
telephone circuits.

Dr. Kumkum Saxena Data Link Layer page 12


Functions of data link layer
2. Determines how the bits of the physical layer are grouped into
frames (framing)
The Data Link Layer is the second layer in the OSI model,
above the Physical Layer, which ensures that the error free data
is transferred between the adjacent nodes in the network. It
breaks the datagram passed down by above layers and converts
them into frames ready for transfer. This is called Framing.

Dr. Kumkum Saxena Data Link Layer page 13


Framing
2 types of framing
Fixed-Size Framing
◼ Frames can be of fixed or variable size.
◼ In fixed-size framing, there is no need for defining the boundaries of
the frames; the size itself can be used as a delimiter
Variable size framing
◼ The contents of each frame are encapsulated between a pair of
reserved characters or bytes for frame synchronization.
There are four methods:
1. Character count.
2. Flag bytes with byte stuffing.
3. Starting and ending flags, with bit stuffing.
4. Physical layer coding violations.

Dr. Kumkum Saxena Data Link Layer page 14


Framing
1. Character count
◼ The first framing method that is 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 also
can come to know where the frame will end.
◼ There are four frames in this figure with size 5, 5, 8 and 8. The
first frame has data A, H, 7 and 8…..

◼ There is one problem with this method. The count can be


garbled by a transmission error

Dr. Kumkum Saxena Data Link Layer page 15


Functions of data link layer
◼ If the character count of 5 in the second frame becomes 7, the
destination will get out of synchronization and will be unable to
locate the start of the next frame.
◼ For this reason the character count method is rarely used
nowadays.

Dr. Kumkum Saxena Data Link Layer page 16


Alternative to character count

Dr. Kumkum Saxena Data Link Layer page 17


Framing
2. Flag bytes with byte stuffing.
◼ The second framing method is flag bytes insertion using byte
stuffing. This is also referred to as character stuffing.
◼ ASCII characters are used as framing delimiters for example
DLE STX (start of the frame) and DLE ETX(End of the frame).
◼ If however, binary data is being transmitted then there exists a
possibility of the characters DLE STX and DLE ETX occurring in
the data. Since this can interfere with the framing, a technique called
character stuffing is used. The sender's data link layer inserts an
ASCII DLE character just before the DLE character in the data. The
receiver's data link layer removes this DLE before this data is given
to the network layer. However character stuffing is closely
associated with 8-bit characters and this is a major hurdle in
transmitting arbitrary sized characters. The problem occurs when
these character patterns occur within the data.
Dr. Kumkum Saxena Data Link Layer page 18
Framing
◼ This framing mechanism uses the special ASCII characters 0x10
(called DLE or Data Link Escape), 0x02 (STX, Start of Text), 0x03
(ETX, End of Text). Each packet is framed as between "DLE STX"
and "DLE ETX" as follows:
0123456789012345
| DLE | STX | Payload (DLEs byte-stuffed) | ... | DLE | ETX |
◼ So, when sending a packet on a stream, just transmit "DLE STX",
then the payload of bytes (the content of the packet), and finally
"DLE ETX".
◼ When sending the payload data, each DLE character in the data
must be doubled (i.e., DLE becomes DLE DLE).

Dr. Kumkum Saxena Data Link Layer page 19


Framing
◼ Solution to this problem is to stuff an extra DLE into the
data stream just before each occurrence of an “accidental”
DLE in the data stream. The data link layer on the
receiving end unstuffs the DLE before giving the data to
the network layer as shown in this figure. The flag byte
DLE and STX are inserted at the start and DLE ETX bytes
are inserted in the end.

Dr. Kumkum Saxena Data Link Layer page 20


Framing
◼ If you want to transmit the payload "0x10“.
◼ The final packet is 0x10 0x02 0x10 0x10 0x10 0x03 (or DLE
STX DLE DLE DLE ETX).
◼ A receiver must therefore look for packet start (i.e. DLE STX),
read the payload and remove the second DLE if two consecutive
ones are received (de-stuffing), and continue buffering until
DLE ETX is found.

Dr. Kumkum Saxena Data Link Layer page 21


Framing

Dr. Kumkum Saxena Data Link Layer page 22


Framing
3. Bit Stuffing
◼ In this method each frame begins and ends with a special bit
pattern called a flag byte which is 01111110.
◼ In this technique also there is a possibility that this
particular pattern of 01111110 may appear in data itself.
◼ In order to take care of this problem, whenever sender
data link layer encounters five consecutive ones in the
data stream, it automatically stuff a 0 bit into the
outgoing stream.
◼ When the receiver sees five consecutive incoming ones
followed by a 0 bit , it automatically destuffs the 0 bit
before sending the data to the network layer.
Dr. Kumkum Saxena Data Link Layer page 23
Framing
◼ Eg :1

Dr. Kumkum Saxena Data Link Layer page 24


Framing
Eg:2

Dr. Kumkum Saxena Data Link Layer page 25


Framing
◼ Eg: 3

Dr. Kumkum Saxena Data Link Layer page 26


Bit-Oriented Framing

◼ Consider the frame to be sent and received


by the devices.
◼ The 8 bits added at the start and end of the
frame in this protocol are 01111110
◼ Frame
011111100101000111111001111110

Dr. Kumkum Saxena Data Link Layer page 27


Bit-Oriented Framing

011111100101000111111001111110
ie.
011111100101000111111001111110
In Bit Stuffing, stuff a pattern of bits of
arbitrary length in the message to differentiate
from the delimiter.

Dr. Kumkum Saxena Data Link Layer page 28


Bit-Oriented Framing
◼ whenever the sender device finds the frame
consisting of five consecutive 1’s, it will
stuff a ‘0’ bit.
0111111001010001111101001111110.
When the receiving device receives this
frame and encounters a ‘0’ after five
consecutive bits, it will remove it to maintain
the original frame.
◼ High-Level Data Link Control (HDLC) is a
data link layer protocol.

Dr. Kumkum Saxena Data Link Layer page 29


Byte-Oriented Approach

◼ Frames as a collection of bytes(8 bits), also


known as a character (Character Oriented
Approach)
There are three Byte-Oriented Protocols:
1. Binary Synchronous Communication
Protocol (BISYNC)
2. Digital Data Communication Message
Protocol (DDCMP)
3. Point-to-Point Protocol(PPP).

Dr. Kumkum Saxena Data Link Layer page 30


HDLC

Dr. Kumkum Saxena Data Link Layer page 31


High-Level Data Link
Control (HDLC)
▪ a bit - oriented protocol
▪ each frame contains up to six fields.
The fields of a HDLC frame are −
◼ Flag − It is an 8-bit sequence that marks the beginning
and the end of the frame. The bit pattern of the flag is
01111110.
◼ Address − It contains the address of the receiver.
◼ If the frame is sent by the primary station, it contains
the address(es) of the secondary station(s).
◼ If it is sent by the secondary station, it contains
the address of the primary station.
◼ The address field may be from 1 byte to several
bytes.

Dr. Kumkum Saxena Data Link Layer page 32


High-Level Data Link
Control (HDLC)
◼ Control − It is 1 or 2 bytes containing flow
and error control information.
◼ Payload − This carries the data from the
network layer. Its length may vary from one
network to another.
◼ FCS − It is a 2 byte or 4 bytes frame check
sequence for error detection. The standard
code used is CRC (cyclic redundancy code)

Dr. Kumkum Saxena Data Link Layer page 33


Types of HDLC Frames

◼ There are three types of HDLC frames. The


type of frame is determined by the control
field of the frame.
1.I-Frame
2.S-Frame
3.U-Frame

Dr. Kumkum Saxena Data Link Layer page 34


◼ I-frame −
Information frames carry user data from the
network layer.
include flow and error control information
The first bit of control field of I-frame is 0.
◼ S-frame −
Supervisory frames do not contain information
field.
used for flow and error
The first two bits of control field of S-frame is 10.
◼ U-frame −
Un-numbered frames are used for miscellaneous
functions, like link management.
It may contain an information field, if required.
The first two bits of control field of U-frame is 11.

Dr. Kumkum Saxena Data Link Layer page 35


Binary Synchronous
Communication Protocol (BISYNC)

◼ Also known as Basic Mode Protocol


◼ It is a sentinel approach.
◼ frame format

Dr. Kumkum Saxena Data Link Layer page 36


Binary Synchronous
Communication Protocol (BISYNC)

▪ SYN: Special starting character,


▪ SOH: Start of the Header,
▪ STX: Start of the text,
▪ ETX: End of the text.
The STX and ETX guard the data part of the
portion.
To avoid the framing error problem, Byte Stuffing is
used. This is used when the frames consist of
characters.
A byte is stuffed in the message to differentiate
from the delimiter.

Dr. Kumkum Saxena Data Link Layer page 37


Point-to-Point Protocol(PPP)

◼ It is a wide area network protocol that runs


over internet links.
◼ mainly used in broadband communication
that deals with high speed and heavy loads.
◼ The frame format

Dr. Kumkum Saxena Data Link Layer page 38


Point-to-Point Protocol(PPP)
▪ The bit pattern for the flag is 01111110.
▪ The address field is set to 11111111 in case of
broadcast.
▪ The control value is set to a constant value of
11000000.
▪ The protocol consists of 1 or 2 bytes that define
the type of data in the payload section.
▪ The maximum length of this field is 1500 bytes.
▪ The checksum field is used for error detection.
▪ if the flag bits appear in the payload part, the
situation is overcome using character/byte
stuffing.

Dr. Kumkum Saxena Data Link Layer page 39


Clock Based Framing

◼ Mainly used for Optical Networks such as


SONET.
◼ In this approach, a series of repetitive pulses
maintain a constant bit rate and keep the
digital bits aligned in the data stream.

Dr. Kumkum Saxena Data Link Layer page 40


Types of Errors

Dr. Kumkum Saxena Data Link Layer page 41


Single-bit error

Dr. Kumkum Saxena Data Link Layer page 42


Single bit errors are the least likely type of
errors in serial data transmission because the
noise must have a very short duration which is
very rare. However this kind of errors can
happen in parallel transmission.
Example:
◼ If data is sent at 1Mbps then each bit lasts only
1/1,000,000 sec. or 1 μs.
◼ For a single-bit error to occur, the noise must
have a duration of only 1 μs, which is very rare.

Dr. Kumkum Saxena Data Link Layer page 43


Burst error

Dr. Kumkum Saxena Data Link Layer page 44


Dr. Kumkum Saxena Data Link Layer page 45
The term burst error means that two or
more bits in the data unit have changed from
1 to 0 or from 0 to 1.

Burst errors does not necessarily mean


that the errors occur in consecutive bits,
the length of the burst is measured from the
first corrupted bit to the last corrupted bit.
Some bits in between may not have been
corrupted.

Dr. Kumkum Saxena Data Link Layer page 46


◼ Burst error is most likely to happen in serial transmission since
the duration of noise is normally longer than the duration of a bit.
◼ The number of bits affected depends on the data rate and duration of
noise.
Example:
◼ If data is sent at rate = 1Kbps then a noise of 1/100 sec can affect 10
bits.(1/100*1000)

◼ If same data is sent at rate = 1Mbps then a noise of 1/100 sec can
affect 10,000 bits.(1/100*106)

Dr. Kumkum Saxena Data Link Layer page 47


Error detection and correction
 Networks must be able to transfer data from one device
to another with complete accuracy.
 Data can be corrupted during transmission.
 For reliable communication, errors must be detected
and corrected.
 Error detection and correction are implemented either
at the data link layer or the transport layer of the OSI
model.
 Error Detection and Correction method----→ Hamming
Code(single bit error correction and double bit error
detection)
Dr. Kumkum Saxena Data Link Layer page 48
Error Correction

It can be handled in two ways:


◼ receiver can have the sender retransmit the
entire data unit.
◼ The receiver can use an error-correcting
code, which automatically corrects certain
errors.

Dr. Kumkum Saxena Data Link Layer page 49


Single-bit error correction
To correct an error, the receiver reverses the
value of the altered bit. To do so, it must
know which bit is in error.
Number of redundancy bits needed
◼ Let data bits = m
◼ Redundancy bits = r
Total message sent = m+r
The value of r must satisfy the following
relation:
2r ≥ m+r+1
Dr. Kumkum Saxena Data Link Layer page 50
Error Correction

Dr. Kumkum Saxena Data Link Layer page 51


Hamming Code

Dr. Kumkum Saxena Data Link Layer page 52


Hamming Code

Dr. Kumkum Saxena Data Link Layer page 53


Hamming Code

Dr. Kumkum Saxena Data Link Layer page 54


Example of Hamming Code

Dr. Kumkum Saxena Data Link Layer page 55


Single-bit error

Dr. Kumkum Saxena Data Link Layer page 56


Error
Detection

Dr. Kumkum Saxena Data Link Layer page 57


Hamming Code

Dr. Kumkum Saxena Data Link Layer page 58


Example of Hamming Code

Dr. Kumkum Saxena Data Link Layer page 59


Single-bit error

Dr. Kumkum Saxena Data Link Layer page 60


Error
Detection

Dr. Kumkum Saxena Data Link Layer page 61


Hamming code
◼ Eg: 2
◼ Suppose the data to be transmitted is 1011001, the bits will
be placed as follows:

Thus, the data transferred is:

Dr. Kumkum Saxena Data Link Layer page 62


◼ Error detection and correction –
Suppose in the above example the 6th bit is changed from 0 to
1 during data transmission, then it gives new parity values in
the binary number

◼ The bits give the binary number as 0110 whose decimal representation is 6.
Thus, the bit 6 contains an error. To correct the error the 6th bit is changed
from 1 to 0.

Dr. Kumkum Saxena Data Link Layer page 63


Hamming Code
Double bit error detection
◼ The Hamming code can be modified to detect double bit
errors by adding a parity bit as the MSB, which is the XOR
of all other bits.
◼ Suppose that the message 1100101 needs to be encoded
using even parity Hamming code.
◼ Hence, the message sent will be, 11000101100 (after
adding the redundant or parity bits).
◼ After adding P = XOR(1,1,0,0,0,1,0,1,1,0,0) = 1, the new
codeword to be sent will be 111000101100.

Dr. Kumkum Saxena Data Link Layer page 64


Hamming Code
◼ At the receiver’s end, error detection is done as shown in
the following table .
◼ Note : r- value is the binary value obtained after checking
the redundant bit positions
r-value P value Conclusion
r=0 P(sender)=P(receiver) No error
r=0 P(sender)≠P(receiver) Error in P bit, Data can be
sent to the uppers layers after
removing all check bits.
r≠0 P(sender)≠P(receiver) Single bit error occurred that
can be corrected by reversing
the bit value at the bit position
given by value r
r≠0 P(sender)=P(receiver) Double bit error detected that
Dr. Kumkum Saxena cannot be corrected.
Data Link Layer page 65
Hamming Code
Eg :
◼ Suppose that the message 1100101 needs to be encoded
using even parity Hamming code.
◼ Hence, the message sent will be, 11000101100 (after
adding the redundant or parity bits).
◼ After adding P = XOR(1,1,0,0,0,1,0,1,1,0,0) = 1, the new
codeword to be sent will be 111000101100.
◼ Assuming 2 bits are changed(last 2 lsb bits changed to 11)
◼ Received code word – 111000101111
◼ New parity -1
◼ r≠0
◼ Hence Double bit error detected
Dr. Kumkum Saxena Data Link Layer page 66
Error detection

Error detection means to decide whether the


received data is correct or not without having a
copy of the original message.

Error detection uses the concept of redundancy,


which means adding extra bits for detecting
errors at the destination.

Dr. Kumkum Saxena Data Link Layer page 67


Error Detection Methods
Error Detection Methods :
◼ CRC
◼ Checksum

Dr. Kumkum Saxena Data Link Layer page 68


Redundancy

Dr. Kumkum Saxena Data Link Layer page 69


Four types of redundancy checks are used
in data communications

Dr. Kumkum Saxena Data Link Layer page 70


Vertical Redundancy Check
VRC

Dr. Kumkum Saxena Data Link Layer page 71


Vertical Redundancy Check
VRC

▪ The word cute is coded in ASCII as

11000011 1110101 1110100 1100101


c u t e

Using Even Parity checking the sender will send

110000110 11101011 11101000 11001010

If the word is not corrupted during transmission the


receiver will count the 1s in each character and comes up
with(4,6,4,4) - all even numbers.

Dr. Kumkum Saxena Data Link Layer page 72


Vertical Redundancy Check
VRC

▪ If the word is corrupted during transmission


110010110 11101011 11101000 11000010

If the word is corrupted during transmission the


receiver will count the 1s in each character and
comes up with(5,6,4,3) - not all even numbers.

Dr. Kumkum Saxena Data Link Layer page 73


Performance

◼ It can detect single bit error


◼ It can detect burst errors only if the total
number of errors is odd.

Dr. Kumkum Saxena Data Link Layer page 74


Longitudinal Redundancy Check
LRC

Dr. Kumkum Saxena Data Link Layer page 75


Performance
• LRC increases the likelihood of detecting
burst errors.
• If two bits in one data units are damaged
and two bits in exactly the same positions
in another data unit are also damaged, the
LRC checker will not detect an error.

Dr. Kumkum Saxena Data Link Layer page 76


VRC and LRC

Dr. Kumkum Saxena Data Link Layer page 77


Cyclic Redundancy Check
◼ CRC or Cyclic Redundancy Check is a method of detecting errors in
communication channel.
◼ Given a k-bit frame or message, the transmitter generates an n-bit
sequence, known as a frame check sequence (FCS), so that the
resulting frame, consisting of (k+n) bits
◼ Bit sequences can be written as polynomials with the coefficients 0
and 1.
◼ A frame with k bits is considered as a polynomial of degree k−1.
◼ The most significant bit is the coefficient of xk−1 the next bit is the
coefficient of xk−2. . Example: The bit sequence 10011010
corresponds to this polynomial:

◼ Sending and receiving messages can be imagined as an


exchange of polynomials
Dr. Kumkum Saxena Data Link Layer page 78
Cyclic Redundancy Check
◼ The Data Link Layer protocol specifies a generator polynomial
C(x). Generator Polynomial is available on both sender and
receiver side.
◼ C(x) is a polynomial of degree k
◼ If e.g. C(x) = x3 + x2 + x0 = 1101, then k = 3
◼ Therefore, the generator polynomial is of degree 3
◼ The degree of the generator polynomial is equal to the number
of bits minus one.
◼ If for a frame, the CRC need to be calculated, n 0 bits are
appended to the frame
◼ n corresponds to the degree of the generator polynomial

Dr. Kumkum Saxena Data Link Layer page 79


Cyclic Redundancy Check

Dr. Kumkum Saxena Data Link Layer page 80


Cyclic Redundancy Check
Sender Side (Generation of Encoded Data from Data and
Generator Polynomial (or Key)):
◼ The binary data is first augmented by adding n zeros in the
end of the data. (n- degree of the generator polynomial)
◼ Use modulo-2 binary division to divide binary data by the
key and store remainder of division.
◼ Append the remainder at the end of the data to form the
encoded data and send the same.
Receiver Side (Check if there are errors introduced in
transmission)
Perform modulo-2 division again and if remainder is 0,
then there are no errors.
Dr. Kumkum Saxena Data Link Layer page 81
Cyclic Redundancy Check
◼ Modulo 2 Division:
The process of modulo-2 binary division is the same as the
familiar division process we use for decimal numbers. Just
that instead of subtraction, we use XOR here.
◼ In each step, a copy of the divisor is XORed with the n+1
bits of the dividend (or key).
◼ The result of the XOR operation (remainder) is n bits,
which is used for the next step after 1 extra bit is pulled
down to make it n+1 bits long.
◼ When there are no bits left to pull down, we have a result.
The n-bit remainder which is appended at the sender side.

Dr. Kumkum Saxena Data Link Layer page 82


Cyclic Redundancy Check
CRC

Dr. Kumkum Saxena Data Link Layer page 83


◼ CRC generator
uses modular-2 division.

Binary Division
in a
CRC Generator

Dr. Kumkum Saxena Data Link Layer page 84


Binary Division
in a
CRC Checker

Dr. Kumkum Saxena Data Link Layer page 85


Cyclic Redundancy Check
◼ Therefore, the remainder is all zeros. Hence, the data
received has no error.
Example 2: (Error in transmission)
◼ Data word to be sent - 100100
◼ Key - 1101

Dr. Kumkum Saxena Data Link Layer page 86


Cyclic Redundancy Check
◼ Therefore, the remainder is 001 and hence the code word
sent is 100100001.
Receiver Side
◼ Let there be error in transmission media
◼ Code word received at the
◼ receiver side - 100000001

Dr. Kumkum Saxena Data Link Layer page 87


Cyclic Redundancy Check
◼ Since the remainder is not all zeroes, the error is detected
at the receiver side.

Dr. Kumkum Saxena Data Link Layer page 88


Cyclic Redundancy Check
Eg :3

Dr. Kumkum Saxena Data Link Layer page 89


Cyclic Redundancy Check

Dr. Kumkum Saxena Data Link Layer page 90


Cyclic Redundancy Check
◼ Ex:4

Dr. Kumkum Saxena Data Link Layer page 91


Cyclic Redundancy Check

Dr. Kumkum Saxena Data Link Layer page 92


CRC
◼ Ex:
Data bits:
1101011111
Check bits: 100111 1 0 1 0 1 1 1 1 1
C(x)=x4+x1+1
C = 10011
k=4

Dr. Kumkum Saxena Data Link Layer page 93


CRC

Dr. Kumkum Saxena Data Link Layer page 94


Standard Polynomials

Dr. Kumkum Saxena Data Link Layer page 95


Checksum

Dr. Kumkum Saxena Data Link Layer page 96


Checksum

At sender side,
◼ If m bit checksum is used, the data unit to be transmitted is
divided into segments of m bits.
◼ All the m bit segments are added.
◼ The result of the sum is then complemented using 1’s
complement arithmetic.
◼ The value so obtained is called as checksum.
◼ The data along with the checksum value is transmitted to
the receiver.

Dr. Kumkum Saxena Data Link Layer page 97


Checksum
At receiver side,
◼ If m bit checksum is being used, the received data unit is divided
into segments of m bits.
◼ All the m bit segments are added along with the checksum value.
◼ The value so obtained is complemented and the result is checked.
Case-01: Result = 0
◼ Receiver assumes that no error occurred in the data during the
transmission.
◼ Receiver accepts the data.
Case-02: Result ≠ 0
◼ Receiver assumes that error occurred in the data during the
transmission.
◼ Receiver discards the data and asks the sender for retransmission.

Dr. Kumkum Saxena Data Link Layer page 98


Checksum

◼ Eg :

◼ 10110011 10101011 01011010 11010101

Dr. Kumkum Saxena Data Link Layer page 99


Checksum

◼ Eg:2
( at a sender)
Original data : 10101001 00111001
10101001
00111001
--------------
11100010 Sum
00011101 Checksum
10101001 00111001 00011101
Dr. Kumkum Saxena Data Link Layer page 100
Checksum

◼ Example ( at a receiver)
Received data : 10101001 00111001 00011101
10101001
00111001
00011101
---------------
11111111  Sum
00000000  Complement

Dr. Kumkum Saxena Data Link Layer page 101


Checksum

Ex 3
Consider the data unit to be transmitted is-
10011001 11100010 00100100 10000100
Consider 8 bit checksum is used.
◼ Step-01:
◼ At sender side,
◼ The given data unit is divided into segments of 8 bits
as-

Dr. Kumkum Saxena Data Link Layer page 102


Checksum

Now, all the segments are added and the result is obtained as-
10011001 + 11100010 + 00100100 + 10000100 = 1000100011

• Since the result consists of 10 bits, so extra 2 bits are wrapped


around.
• 00100011 + 10 = 00100101 (8 bits)
• Now, 1’s complement is taken which is 11011010.
• Thus, checksum value = 11011010

Dr. Kumkum Saxena Data Link Layer page 103


Performance
◼ The checksum detects all errors involving an odd
number of bits.
◼ It detects most errors involving an even number
of bits.
◼ If one or more bits of a segment are damaged
and the corresponding bit or bits of opposite value
in a second segment are also damaged, the sums
of those columns will not change and the receiver
will not detect a problem.

Dr. Kumkum Saxena Data Link Layer page 104


Flow Control
• Receiver has a limited speed at which it can process
incoming data and a limited amount of memory in
which to store incoming data.
• Receiver must inform the sender before the limits are
reached and request that the transmitter to send fewer
frames or stop temporarily.
• Flow control coordinates the amount of data that can be
sent before receiving acknowledgement
• It is one of the most important functions of data link
layer.
• Flow control is a set of procedures that tells the sender
how much data it can transmit before it must wait for an
acknowledgement from the receiver.
Dr. Kumkum Saxena Data Link Layer page 105
Flow Control

Dr. Kumkum Saxena Data Link Layer page 106


Stop & Wait Protocol
Types of Stop and Wait Protocol:
• An Unrestricted Simplex Protocol
• A Simplex Stop-and-Wait Protocol
• A Simplex Protocol for a Noisy Channel
1. An Unrestricted Simplex Protocol
◼ Data are transmitted in one direction only
◼ The transmitting (Tx) and receiving (Rx) hosts are always
ready
◼ Infinite buffer space is available
◼ No errors occur; i.e. no damaged frames and no lost frames
(perfect channel)
◼ The sender is in an infinite while loop just pumping data
out onto the line as fast as it can.
Dr. Kumkum Saxena Data Link Layer page 107
Stop & Wait Protocol
◼ The body of the loop consists of three actions:
1 Go fetch a packet from the network layer,
2 Construct an outbound frame and
3. Send it on the way.
◼ Only the info field of the frame is used by this protocol,
because the other fields have to do with error and flow
control and there are no errors and flow control restrictions
here.
◼ The receiver waits for something to happen, the only
possibility being the arrival of an undamaged frame.
◼ It passes to the network layer and the data link layer settles
back to wait for the next frame.
Dr. Kumkum Saxena Data Link Layer page 108
Stop & Wait Protocol
2. A simplex stop-and-wait protocol
◼ In this protocol we assume that data are transmitted in one
direction only
◼ No errors occur (perfect channel)
◼ The receiver can only process the received information at a
finite rate
These assumptions imply that the transmitter cannot send
frames at a rate faster than the receiver can process them.

Dr. Kumkum Saxena Data Link Layer page 109


Stop & Wait Protocol
◼ The problem here is how to prevent the sender from
flooding the receiver.
◼ A general solution to this problem is to have the receiver
provide some sort of feedback to the sender.
◼ The process could be as follows:
The receiver send an acknowledge frame back to the sender
telling the sender that the last received frame has been
processed.
Permission to send the next frame is granted. The sender,
after having sent a frame, must wait for the acknowledge
frame from the receiver before sending another frame.
This protocol is known as stop-and-wait.
Dr. Kumkum Saxena Data Link Layer page 110
Stop & Wait Protocol

Dr. Kumkum Saxena Data Link Layer page 111


Stop & Wait Protocol
3.A simplex protocol for a noisy channel
◼ In this protocol the unreal "error free" assumption in
protocol 2 is dropped. Frames may be either damaged or
lost completely.
◼ The sender would send a frame and the receiver would
send an ACK frame only if the frame is received correctly.
If the frame is in error the receiver simply ignores it; the
transmitter would time out and would retransmit it.
◼ One fatal flaw with the above scheme is that if the ACK
frame is lost or damaged, duplicate frames are accepted at
the receiver without the receiver knowing it.

Dr. Kumkum Saxena Data Link Layer page 112


Stop & Wait Protocol
◼ Imagine a situation where the receiver has just sent an ACK
frame back to the sender saying that it correctly received
and already passed a frame to its host.
◼ However, the ACK frame gets lost completely, the sender
times out and retransmits the frame.
◼ There is no way for the receiver to tell whether this frame is
a retransmitted frame or a new frame, so the receiver
accepts this duplicate happily and transfers it to the host.
The protocol thus fails in this aspect.
◼ To overcome this problem it is required that the receiver be
able to distinguish a frame that it is seeing for the first time
from a retransmission.
Dr. Kumkum Saxena Data Link Layer page 113
Stop & Wait Protocol
◼ One way to achieve this is to have the sender put a sequence
number in the header of each frame it sends. The receiver then
can check the sequence number of each arriving frame to see if
it is a new frame or a duplicate to be discarded.
◼ The receiver needs to distinguish only 2 possibilities: a new
frame or a duplicate; a 1-bit sequence number is sufficient. At
any instant the receiver expects a particular sequence number.
Any wrong sequence numbered frame arriving at the receiver is
rejected as a duplicate. A correctly numbered frame arriving at
the receiver is accepted, passed to the host, and the expected
sequence number is incremented by 1

Dr. Kumkum Saxena Data Link Layer page 114


Stop & Wait Protocol
◼ Sender A sends a data frame or packet with sequence
number 0.
◼ Receiver B, after receiving data frame, sends and
acknowledgement with sequence number 1 (sequence
number of next expected data frame or packet)
◼ There is only one bit sequence number that implies that
both sender and receiver have buffer for one frame or
packet only.

Dr. Kumkum Saxena Data Link Layer page 115


◼ Stop & Wait Protocol

Dr. Kumkum Saxena Data Link Layer page 116


Stop-and-Wait , lost frame

When a receiver receives a


damaged frame, it discards it
and keeps its value of R.
After the timer at the sender
expires, another copy of frame
1 is sent.

Dr. Kumkum Saxena Data Link Layer page 117


Stop-and-Wait, lost ACK frame

• If the sender receives a


damaged ACK, it discards it.
• When the timer of the sender
expires, the sender
retransmits frame 1.
• Receiver has already received
frame 1 and expecting to
receive frame 0 (R=0).
Therefore it discards the
second copy of frame 1.

Dr. Kumkum Saxena Data Link Layer page 118


Stop-and-Wait, delayed ACK frame

• The ACK can be delayed at the


receiver or due to some
problem
• It is received after the timer
for frame 0 has expired.
• Sender retransmitted a
copy of frame 0. However, R
=1 means receiver expects
to see frame 1. Receiver
discards the duplicate frame
0.
• Sender receives 2 ACKs, it
discards the second ACK.

Dr. Kumkum Saxena Data Link Layer page 119


Stop & Wait Protocol
Drawback of Stop and wait protocol(A Simplex Stop-and-Wait
Protocol and A Simplex Protocol for a Noisy Channel)
1. Very Inefficient. At a moment , only one frame is in
transition.
2. The sender has to wait at least one round trip time before
sending the next frame.

Dr. Kumkum Saxena Data Link Layer page 120


FSM for the Stop-and-Wait protocol

Dr. Kumkum Saxena Data Link Layer page 121


Sliding window protocol
Assumptions:
1. Data is transmitted in both the directions.
2. Requires full duplex communication channel.
3. No separate ACK sent.
4. Uses the concept of piggybacking.(The technique of
temporarily delaying the outgoing ACK so they can be
hooked onto the next outgoing data frame is known as
piggybacking).
5. Noisy channel.

Dr. Kumkum Saxena Data Link Layer page 122


Sliding window protocol
3 types of sliding window protocol
1.One-bit sliding window protocol
2.Go-back n sliding window protocol
3.Selective repeat sliding window protocol

Dr. Kumkum Saxena Data Link Layer page 123


One bit Sliding window
◼ Sender transmits one frame and waits for it’s ACK, before
sending the next frame
◼ Uses stop & wait .
◼ Window size is 1.
◼ Each end simultaneously acts as both sender and receiver .
◼ Sender sends frames as tuples.
◼ The ack no indicates the last frame received without error.

Dr. Kumkum Saxena Data Link Layer page 124


If one of them goes first

Dr. Kumkum Saxena Data Link Layer page 125


One bit Sliding window
If both send simultaneously
◼ A sends 0,1 B sends 0,1
B gets 0,1 (got 0, but no ack of my 0)
B unnecessarily re-sends 0,0
◼ A gets 0,1 (got 0, but no ack of my 0)
A unnecessarily re-sends 0,0
◼ B gets 0,0 (already have 0, nothing to pass to NB, but this is good ack
of my 0)
B sends 1,0
◼ A gets 0,0 (already have 0, nothing to pass to NA, but this is good ack
of my 0)
A sends 1,0
◼ B gets 1,0 (got 1, but no ack of my 1) B unnecessarily re-sends 1,1
◼ A gets 1,0 (got 1, but no ack of my 1) A unnecessarily re-sends 1,1
◼ B gets 1,1 (already have 1, nothing to pass to NB, but this is good ack
of my 1) B sends 0,1
Dr. Kumkum Saxena Data Link Layer page 126
◼ Problem if both send initial packet at same time.

Duplication of packets
Dr. Kumkum Saxena Data Link Layer page 127
One bit Sliding window
Drawback:
◼ Inefficient- Sender waits until an ACK arrives
from the receiver.
◼ Sends only one frame at a time

Dr. Kumkum Saxena Data Link Layer page 128


Sliding Window
◼ Goal- Keep transmission medium busy.
◼ Proposed scheme
Permit the sender to send more than one frame while waiting for
the first ACK. This technique is called as pipelining.
◼ Sender maintains a sending window.
◼ Receiver maintains a receiving window.
◼ Sending window – Sequence nos of frames that have been sent
but not yet acknowledged.
◼ Receiving window – Sequence nos of frames the receiver can
accept
◼ Eg: 3-bit sequence no- frames are numbered from 0-7. If the
sender has more than 8 frames--→0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
0 1 2……
Dr. Kumkum Saxena Data Link Layer page 129
Sliding Window
◼ Max window size- 2n (n- no of bits in the sequence no)
◼ Eg: 0 1 2 3 4 5 6 7 0 1 2 3….
Sending window
◼ i.e sender can send 2n frames without waiting for an ACK.
◼ When ACK for a frame comes in – Lower edge of the window is
advanced by 1
◼ When a frame is sent upper edge of the window is advanced by 1.
Issue for a noisy channel
◼ Frame in the middle of a long stream is damaged/lost.
◼ What should the receiver do with all the correct frames following the
damaged one ?
◼ Constraint : Receiving Data link layer has to hand packets to the
network layer in sequence
Dr. Kumkum Saxena Data Link Layer page 130
Sliding Window
Two approaches to deal with errors in the presence of pipelining :
1. Go back n
2. Selective Repeat
Go back n:
◼ Discard all subsequent frames following the damaged frames
sending no ACKs.
◼ Eventually the sender times out and retransmits all the
unacknowledged frames in order starting with the damaged or lost
one.
Operation :
Assume no of bits in sequence no 2 .
Window size : 4 frames
Dr. Kumkum Saxena Data Link Layer page 131
Sliding Window(Go back n)
◼ Sending window
0123 0 1 2 3……
◼ Sender has sent 4 frames 0 to 3 and waits for an ACK.
◼ ACK0 and ACK1 received by the sender
2 3 01 2 301

Now sent 0 1
◼ Frame 2 lost not received but received 3 0 1
◼ Receiver discards 3 0 and 1
Note
A receiving station does not acknowledge each received frame
explicitly . If a sending station received an ack for frame j and later
receives an ack for frame k it assumes all frames between j and k have
been received correctly.
Dr. Kumkum Saxena Data Link Layer page 132
Sliding Window(Go back n)
◼ Adv: Reduces no. of acks and lessens the n/w traffic.
◼ What should be the max sender’s and receivers window size ?
◼ Assume k ---→ no. of bits in sequence no.
◼ Frames are numbered from 0 to 2k-1
◼ Window size cannot be larger than 2k
Case1 : Window size larger than 2k
◼ Let k=3
◼ Assume window size =9
◼ Sender’s window---→0 1 2 3 4 5 6 7 0 1 2 3……
◼ Problem --→
Sender receives an ACK0 . Does not know if it was for first/last
frame.
Dr. Kumkum Saxena Data Link Layer page 133
Sliding Window(Go back n)
Window size must be less than or equal to 2k
Case 2 : Window size = 2k
1. At time t1 A sends frames 0-7 to B.
2. B receives each one correctly .
3. At time t2, B sends ACK for the most recent received frame ACK7.
4. ACK gets lost
5. Next frame expected by B is frame numbered 0.
6. A does not receive ACK and hence retransmits frames 0 through 7 at
time t3.
7. At t4 B receives frame 0. Sequence no matches with the one it is
expecting. Hence B accepts it.
Protocol fails(Since B has accepted a duplicate and not a new
frame)

Dr. Kumkum Saxena Data Link Layer page 134


Sliding Window(Go back n)
Reason
◼ 2 consecutive windows contain the same sequence no.
◼ Solution reduce the sender’s window size by 1
Case 3 : Window size less than 2k
Sender’s window -→ 0 1 2 3 4 5 6 7 0 1 2 3 4….
1. A sends frames 0 through 6 at t1.
2. B receives each one correctly .
3. At time t2, B sends ACK for the most recent received frame ACK6.
4. ACK gets lost
5. Next frame expected by B is frame numbered 7.
6. A does not receive ACK and hence retransmits frames 0 through 6
at time t3.
Dr. Kumkum Saxena Data Link Layer page 135
Sliding Window(Go back n)
7. B receives frame 0 through 6 at t4 .
8. B expects frame 7.
9.Hence ignores them.
10. Eventually B sends another ACK6 which A receives and A
advances it’s window to include frame 7 0 1 2 3 4 5 and the
protocol continues
Summary
◼ Sender’s window size – strictly less than 2k
(1 less than MAXSEQ)
◼ What should be the receiver's window size?
Frames are always received in order.
Hence Receiver’s window size should not be grater than 1
Dr. Kumkum Saxena Data Link Layer page 136
Sender Receiver
012 30123…
Send 0 set timer for 0
Send 1 set timer for 1 0 1230123
Send 2 set timer for 2 ACK
.. 0 1 2 3 0 1 2 3
ACK
Cancel timer 0,send 3 ACK 0 1 2 30123
Cancel timer 1,send 0
LOST ACK 0 1 2 3 0123
Cancel timer 2,send 1 0 1 2 3 0 123
Discard 1

Timer 0 expires, resend 0


Timer 1 expires, resend 1
Send 2 set timer for 2

Dr. Kumkum Saxena Data Link Layer page 137


11.5 Go-Back-N
◼ Setup –Receiver sliding window
◼ The size of the receiver window is always 1 and points to the next
expected frame number to arrive
◼ This means that frames should arrive in order
◼ If the expected frame is received without errors, the receiver window
slides over the next sequence number.
◼ Operation
◼ The receiver sends a positive ACK if a frame has arrived without
error and in order (with the expected sequence number )
◼ Receiver does not have to acknowledge each individual frame received
correctly and in order.
◼ Receiver can send cumulative ACK for several frames (ACK 4
acknowledges frames (0,1,2,3,4) )
◼ If the frame is damaged or out-of-order, the receiver discards it (and
stay silent) and also discards all subsequent frames until it receives
the one expected.
◼ In this case, no ACK will be transmitted
◼ If the sender timer expires before receiving an ACK, it will resend
ALL frames beginning with the one expired until the last one sent

Dr. Kumkum Saxena (Go-Back-N).
Data Link Layer page 138
Note

In the Go-Back-N Protocol, the sequence


numbers are modulo 2m, where m is the
size of the sequence number field in bits.

66
Dr. Kumkum Saxena Data Link Layer page 139
Sequence Numbers

• Frames from a sender are numbered sequentially.


• We need to set a limit since we need to include the
sequence number of each frame in the header.
• If the header of the frame allows m bits for
sequence number, the sequence numbers range
from 0 to 2 m – 1. for m = 3, sequence numbers
are: 1, 2, 3, 4, 5, 6, 7.
• We can repeat the sequence number.
• Sequence numbers are:
0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, …

Dr. Kumkum Saxena Data Link Layer page 140


Send window for Go-Back-N

Dr. Kumkum Saxena Data Link Layer page 141


Note

The send window is an abstract concept


defining an imaginary box of maximum
size = 2m − 1 with three variables:
Sf, Sn, and Ssize.

69
Dr. Kumkum Saxena Data Link Layer page 142
Note

The send window can slide one or more


slots when an error-free ACK with ackNo
between Sf and Sn (in modular arithmetic)
arrives.

70
Dr. Kumkum Saxena Data Link Layer page 143
Sliding the s e n d window

Sliding direction

Dr. Kumkum Saxena Data Link Layer page 144


Sender Sliding Window
• At the sending site, to
hold the outstanding
frames until they are
acknowledged, we use
the concept of a window.
• The size of the window is
at most 2m -1 where m is
the number of bits for
the sequence number.
• Size of the window can
be variable, e.g. TCP.
• The window slides to
include new unsent
frames when the correct
ACKs are received

Dr. Kumkum Saxena Data Link Layer page 145


Note

The receive window is an abstract concept


defining an imaginary
box of size 1 with
one single variable Rn.

The window slides when a correct packet


has arrived; sliding
occurs one slot at a time.
73
Dr. Kumkum Saxena Data Link Layer page 146
Receive window for Go-Back-N

Dr. Kumkum Saxena Data Link Layer page 147


Receiver Sliding Window
• Size of the window at
the receiving site is
always 1 in this
protocol.
• Receiver is always
looking for a specific
frame to arrive in a
specific order.
• Any frame arriving
out of order is
discarded and needs
to be resent.
• Receiver window
slides as shown in fig.
Receiver is waiting for
frame 0 in part a.
Dr. Kumkum Saxena Data Link Layer page 148
Control Variables
• Sender has 3 variables: S, S , and S
F L

• S holds the sequence number of recently sent frame


• SF holds the sequence number of the first frame
• SL holds the sequence number of the last frame
• Receiver only has the one variable, R, that holds the sequence
number of the frame it expects to receive. If the seq. no. is the
same as the value of R, the frame is accepted, otherwise
rejected.

Dr. Kumkum Saxena Data Link Layer page 149


Note

In the Go-Back-N protocol, the acknowledgment


number is cumulative and defines the sequence
number of the next packet expected to arrive.

77
Dr. Kumkum Saxena Data Link Layer page 150
Acknowledgement
• Receiver sends positive ACK if a frame arrived safe and in
order.
• If the frames are damaged/out of order, receiver is silent and
discard all subsequent frames until it receives the one it is
expecting.
• The silence of the receiver causes the timer of the
unacknowledged frame to expire.
• Then the sender resends all frames, beginning with the one
with the expired timer.
• For example, suppose the sender has sent frame 6, but the
timer for frame 3 expires (i.e. frame 3 has not been
acknowledged), then the sender goes back and sends frames
3, 4, 5, 6 again. Thus it is called Go-Back-N.
• The receiver does not have to acknowledge each frame
received, it can send one cumulative ACK for several frames.
Dr. Kumkum Saxena Data Link Layer page 151
Go-Back-N , normal operation
• The sender keeps track of the outstanding frames and
updates the variables and windows as the ACKs arrive.

Dr. Kumkum Saxena Data Link Layer page 152


Go-Back-N , lost frame
• Frame 2 is lost
• When the
receiver receives
frame 3, it
discards frame 3
as it is expecting
frame 2
(according to
window).
• After the timer
for frame 2
expires at the
sender site, the
sender sends
frame 2 and 3.
(go back to 2)

Dr. Kumkum Saxena Data Link Layer page 153


Go-Back-N , damaged/lost/delayed ACK

• If an ACK is damaged/lost, we can havetwo


situations:
• If the next ACK arrives before the expirationof any
timer, there is no need for retransmission of frames
because ACKs are cumulative inthis protocol.
• If ACK1, ACK2, and ACk3 are lost, ACK4covers them if
it arrives before the timerexpires.
• If ACK4 arrives after time-out, the last frame and all
the frames after that areresent.
• Receiver never resends an ACK.
• A delayed ACK also triggers the resendingof frames

Dr. Kumkum Saxena Data Link Layer page 154


Note

In the Go-Back-N protocol, the size of the


send window must be less than 2m;
the size of the receive window
is always 1.

82
Dr. Kumkum Saxena Data Link Layer page 155
Dr. Kumkum Saxena Data Link Layer page 156
Go-Back-N , sender window size
• Size of the sender window must be less than 2 m.
Size of the receiver is always 1. If m = 2, window size
= 2 m –1 = 3. Fig compares a window size of 3 and 4.

Accepts
as the 1st
frame in
the next
cycle-an
error
Dr. Kumkum Saxena Data Link Layer page 157
Dr. Kumkum Saxena Data Link Layer page 158
F S M s for t h e Go-Back-N protocol

Dr. Kumkum Saxena Data Link Layer page 159


Selective repeat
Drawback of Go back n
◼ Receiver discards all the correct frames transmitted after the bad
one.
◼ Channel bandwidth wasted on retransmitted frames.
Alternative strategy :
Allow the receiver to accept and buffer the frames following a
damaged/lost one.
Called Selective repeat
◼ Since the receiving station is not required to receive frames in
order, the receiving window size is greater than 1.
◼ Note: A frame arriving out of order can be received as long as it
is in the receiving window.
Dr. Kumkum Saxena Data Link Layer page 160
Selective repeat
◼ If an arriving frame is in the receiving window it is buffered and
not given to the n/w layer until all the predecessor have also
arrived
Ex: Assume a 3-bit sequence no.
◼ Sender sends up to seven frames before waiting for an ACK.
◼ Sender’s window 0 1 2 3 4 5 6 7 0 1 2 3 4….
◼ Receiver’s window 0 1 2 3 4 5 6 7 0 1 2 3 4….
1. Sender transmits frames 0 through 6
2. All 7 frames are correctly received hence receiver sends ACK6
3. Receiver advances it’s window to allow the receipt of next set
of sequence nos. 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0….
4. ACK is lostSender times out and retransmits frame from 0
through 6
Dr. Kumkum Saxena Data Link Layer page 161
Selective repeat
6. Receiver receives frames 0-6 but accepts frames 0 1 2 3 4 5
since it lies within it’s window.
But frames 0-5 being duplicates should have been rejected by the
receiving station.
Hence the protocol fails.
PROBLEM
After the receiver advanced it’s window, the new range of valid
sequence nos. overlapped with the old one.
Consequently the following batch of frames might be either
duplicates
or new ones(if all ACKS were received).
The receiver has no way of distinguishing these 2 cases.
Dr. Kumkum Saxena Data Link Layer page 162
Selective repeat
For a 3 –bit sequence no sending and receiving window should be 4.

◼ Sender Receiver
0123 4 5 6 7 0 1 2 3 4…. 0 1 2 3 4 5 6 7 0 1 2 3 4….

0123 4 5 6 7 0 1 2 3 4…. 0 1 2 3 4 5 6 7 0 1 2 3 4….

ACK 3
ACK 3 Lost
Sender times out and retransmits frames 0 through 3
0123 4567
4 5 6 7 0 1 2 3 4…. 0123 0 1 2 3 4….
0123

Receiver discards frames 0 1 2 3 and sends ACK3


0 1 2 3 4 5 6 7 0 1 2 3 4…. Data Link Layer 0 1 2 3 4 5 6 7 0 1 2 3 4….
Dr. Kumkum Saxena page 163
Selective Repeat , sender and receiver windows
• Go-Back-N simplifies the process at the receiver site. Receiver only
keeps track of only one variable, and there is no need to buffer out-of-
order frames, they are simply discarded.
• However, Go-Back-N protocol is inefficient for noisy link. Itbandwidth
inefficient and slows down the transmission.
• In Selective Repeat , only the damaged frame is resent. More
bandwidth efficient but more complex processing at receiver.
• It defines a negative ACK (NAK) to report the sequence number of a
damaged frame before the timer expires.

Dr. Kumkum Saxena Data Link Layer page 164


Send window for Selective-Repeat

Dr. Kumkum Saxena Data Link Layer page 165


Recei ve w i n d o w for Selective -Repeat protocol

Dr. Kumkum Saxena Data Link Layer page 166


Note

In the Selective-Repeat protocol, an


acknowledgment number defines
the sequence number of the
error-free packet received.

95
Dr. Kumkum Saxena Data Link Layer page 167
Example 3.9
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.

Dr. Kumkum Saxena Data Link Layer page 168


F S M s for S R protocol

Dr. Kumkum Saxena Data Link Layer page 169


Dr. Kumkum Saxena Data Link Layer page 170
Selective-Repeat, window size

Dr. Kumkum Saxena Data Link Layer page 171


Figure 13.35 Selective-Repeat window size

103
Dr. Kumkum Saxena Data Link Layer page 172
Note

In Selective-Repeat, the size of the sender


and receiver window
can be at most one-half of 2m.

104
Dr. Kumkum Saxena Data Link Layer page 173
Sliding Window-Summary

One bit sliding Go back n Selective


window repeat

Max Sender’s 1 2k -1 2k-1


Window size

Max 1 1 2k-1
receiver’s
window size

Dr. Kumkum Saxena Data Link Layer page 174

You might also like