Data link layer
Data link layer
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
Select
It is used
whenever the
primary device
with primary
secondary
relationship.
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.
011111100101000111111001111110
ie.
011111100101000111111001111110
In Bit Stuffing, stuff a pattern of bits of
arbitrary length in the message to differentiate
from the delimiter.
◼ If same data is sent at rate = 1Mbps then a noise of 1/100 sec can
affect 10,000 bits.(1/100*106)
◼ 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.
Binary Division
in a
CRC Generator
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.
◼ Eg :
◼ 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
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-
Now, all the segments are added and the result is obtained as-
10011001 + 11100010 + 00100100 + 10000100 = 1000100011
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
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)
66
Dr. Kumkum Saxena Data Link Layer page 139
Sequence Numbers
69
Dr. Kumkum Saxena Data Link Layer page 142
Note
70
Dr. Kumkum Saxena Data Link Layer page 143
Sliding the s e n d window
Sliding direction
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.
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
◼ 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….
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
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.
103
Dr. Kumkum Saxena Data Link Layer page 172
Note
104
Dr. Kumkum Saxena Data Link Layer page 173
Sliding Window-Summary
Max 1 1 2k-1
receiver’s
window size