2. Topics to be Included
1. Services provided to Network layer.
3. Error detection methods: Parity, Checksum, CRC.
4. Data link protocols:
a. A simplex stop and wait protocol.
b. Sliding window protocols.
c. Go back and ARQ.
d. Selective repeat.
3. Data Link Layer:
Devices:- Switch, Bridge.
Services:- Framing, Flow control, Error control.
Functions of Data Link Layer:
Providing a well-defined service interface to the
Dealing with transmission error.
Regulating the flow of data so that slow receivers are
not swamped by fast senders.
4. Services Provided to Network Layer
The principle service is transferring data from the network layer
on the source machine to the network layer on the destination
(a) Virtual communication.
(b) Actual communication.
5. Data Link Layer
Logical Link Control (LLC)
Media Access Control (MAC)
(The LLC is responsible for
flow control, error correction)
(The MAC layer is responsible for
providing a method for station to
gain access to medium)
Framing is the process of breaking the bit stream up into
DDL prepares a frame for transport across the local media by
encapsulating it with a header and trailer.
The data link layer frame includes:
Data: The packet from the network layer.Data: The packet from the network layer.
Header: contains control information (addressing) and located at
the beginning of frame.
Trailer: Contains control information added to the end of the
ӿ In fixed size framing, there is no need for defining the boundaries
of the frames.
ӿ The size of frame itself can be used as a delimiter.
ӿ In variable-size framing, we need a way to define the end of the
frame and the beginning of the frame.
ӿ There are two approaches used for this purpose:
a) A character-oriented approach.
b) A bit-oriented approach.
8. A character-oriented approach
Here, data are 8-bit characters from a coding system such
The header and trailer are also multiples of 8-bits.
To separate one frame from next, an 8-bit flag is added atTo separate one frame from next, an 8-bit flag is added at
the end and beginning of the frame.
The flag, is composed of protocol-dependent special
characters, which signals the start and end of a frame.
A byte-stuffing strategy is used in character-oriented
In this method, Frame starts & end with a special character that
mark the beginning & end of frame.
Each character begins with the ASCII character sequence DLE STX
(data link escape start of text ) and end with ASCII character
sequence DLE ETX (data link escape end of text).
DLE ASTX B DC ETXDLE
Start Of Frame Data End Of Frame
A B DC Data From Network Layer
Starting & Ending Characters Added By Link Layer
11. A bit-oriented approach
In this method, each frame begins & ends with a
special bit pattern 01111110 called flags.
There for each frame starts with 01111110 & also ends
The main problem arises in this method when the flagThe main problem arises in this method when the flag
byte 01111110 appear as data.
This problem is handled by technique called bit
stuffing that is similar to character stuffing.
01 10 0 10 1 11 1 01 1001111110 01111110
01 10 0 10 11 1 01 11 Data from network layer
Starting flag Bit
Ending Flag BIT
01 10 0 10 1 11 1 01 1 Data received by
Network layer On
receiver side After
By data link Layer
13. Flow Control
● One of the most important functions of data link layer.
● A technique for assuring that a transmitting station does not
overwhelm a receiving station with data.
● A set of procedures that tells the sender how much data it can
transmit before it must wait for an acknowledgement from the
●● 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
● Since the rate of processing is often slower than the rate of
transmission, receiver has a block of memory (buffer) for storing
incoming data until they are processed.
14. Stop and Wait Flow Control
Source transmits frame and waits for ACK before sending
Destination receives frame and indicates its willingness to
accept another frame by sending back an acknowledgementaccept another frame by sending back an acknowledgement
with the frame just received.
Destination can stop flow by not sending ACK.
It works well for a few large frames.
It is inadequate for multiple frames for a single message
because only one frame at a time can be in transit.
15. Sliding-window Flow Control(1)
Allow multiple frames to be in transit at a time.
Receiver has allocates buffer space for n frames.
Transmitter can sent up to n frames without ACK.
Frames are numbered by assigning each frame a k-bit sequence
number and the range of sequence no is (0…….2^k-1).number and the range of sequence no is (0…….2^k-1).
ACK includes number of next frame expected.
This ACK announces that receiver is prepared to receive next n
The sequence numbers lists can be thought of as window of
17. How flow control is achieved?
●Receiver can control the size of the sending window.●Receiver can control the size of the sending window.
● By limiting the size of the sending window data flow
from sender to receiver can be limited.
18. Error Control
ӿWhen data is transmitted over a channel, there is always a chance
that some of bits will be changed(corrupted) due to noise, signal
distortion, or attenuation.
ӿMechanisms to detect or correct errors that occur in the transmission
ӿThere is possibility of two types of errors:ӿThere is possibility of two types of errors:
o Lost frame
o Damaged frame
ӿIt allows the receiver to inform the sender if a frame is lost or
damaged during transmission and coordinates the retransmission of
those frames by the sender.
ӿError control includes both error detection and error correction.
19. Error Detection
It allows a receiver to check whether received
data has been corrupted during the
transmission or not.transmission or not.
There three ways to detect errors:
20. Parity Check
Single bit added to the end of the data.
Value of parity bit is such that data and parity have even
(even parity) or odd (odd parity) number of ones.
Typically, even parity is used for synchronous transmission
and odd parity is used for asynchronous transmission.
Even number of bit errors goes undetected.Even number of bit errors goes undetected.
It is example of even parity because
there are even number of 1s.
21. Cyclic Redundancy Check(CRC)
Consider the d-bit piece of data, D, that the sending node wants to send.
The sender and receiver must first agree on r+1 bit pattern, called generator,
which we will denote as G.
G must have the first and last bit equal to 1.
For D, the sender choose r additional bits, R, and append them to D.
The resulting d+r bit pattern is exactly divisible by G using modulo 2
The receiver checks the error by dividing received d+r by G.
• If the remainder is non-zero, there is an error has occurred.
• Otherwise the data is correctly received.
22. Modulo 2 Arithmetic
Polynomial arithmetic is done modulo 2 using the rules of
algebraic field theory.
Both addition and subtraction are identical to exclusive OR.
24. Internet Checksum
The Internet has been using a 16-bit checksum.
The message is divided into 16-bit words.
The value of checksum is set to be 0.
All words including the checksum are added using 1’s complement addition.
The sum is complement and becomes the checksum.
The checksum is sent with the data.
The message, including checksum, is divided into 16-bit words.
All words are added using 1’s complement addition.
The sum is complemented and becomes the new checksum.
If the value of checksum is zero;
The message is accepted.
Otherwise, it is rejected.
25. Error Correction
ӿIt allows a receiver to reconstruct the original
information when it has been corrupted during
ӿWe can control the found errors in two ways:ӿWe can control the found errors in two ways:
Forward Error Correction(FEC):- FEC is accomplished by
adding redundancy to the transmitted information using a
Automatic Repeat Request(ARQ):- In ARQ, the receiver
detects transmission errors in a message and automatically
requests a retransmission from the transmitter. When the
transmitter receives the ARQ, it retransmits the message.
26. Hamming Distance
The number of bit positions in which two codewords differ is
called the Hamming distance between these two codewords.
The Hamming distance between two words( of same size) is the
number of differences between the corresponding bits.
It can easily be found if we apply the XOR operation on the two
words and count the numbers of 1’s in the result.words and count the numbers of 1’s in the result.
It is value greater than 0(zero).
Here Hamming distance = 3
27. Stop and Wait Protocol(1)
Based on the stop-and-wait flow
The source station transmits a single
frame and then must wait for
The frames and ACK are numbered
0 & 1.0 & 1.
If frame 0 is received, ACK1 is sent,
and if frame 1 is received, ACK0 is
If no ACK received then the same
frame is sent again.
The receiver sends only positive ACK
for frame received safe and sound.
28. Stop and Wait Protocol(2)
It is a method to combine a
data frame with an
It is used when both station AIt is used when both station A
and B have data to send.
Here both station A and B send
data frame which also includes
It can save bandwidth of
channel because the data
frame and ACK frame can be
combined into just one frame.
29. Sliding Window Protocols
The basic idea of sliding window protocol is that
both sender and receiver keep a ``window'' of
The sender keeps the value of expectedThe sender keeps the value of expected
acknowledgment; while the receiver keeps the
value of expected receiving frame.
When sender receives an acknowledgment from the
receiver, it advances the window.
When receiver receives the expected frame, then it
advances the window.
30. One-bit sliding window
One bit sliding window protocol is also called
In this protocol, the sender sends out oneIn this protocol, the sender sends out one
frame, waits for acknowledgment before
sending next frame, thus the name Stop-And-
31. Go-Back-N ARQ(1)
Based on sliding-window flow control.
Transmitter may send a series of frames
If no error, receiver sends ACK(RR=
receive ready), as usual, with next frame
Use window to control number ofUse window to control number of
If error, receiver sends a negative
ACK(REJ= reject) for that frame.
Receiver will discard that frame and all
future frames until the frame in error
Transmitter, when it receives REJ, must go
back and retransmit that frame and all
32. Go-Back-N ARQ(2)
Receiver detects error in frame i.
Receiver sends rejection-i.
Transmitter gets rejection-i.
Transmitter retransmits frame i and all subsequent.Transmitter retransmits frame i and all subsequent.
Frame i lost.
Transmitter sends i+1.
Receiver gets frame i+1 out of sequence.
Receiver send reject i.
Transmitter retransmits frame i and all subsequent frames.
33. Go-Back-N ARQ(3)
Frame i lost and no additional frame sent.
Receiver gets nothing and returns neither
acknowledgement nor rejection.acknowledgement nor rejection.
Transmitter times out and sends acknowledgement
frame with P bit set to 1(this is actually a command
for ACK request).
Receiver interprets this as command which it
acknowledges with the number of the next frame it
expects (frame i ).
Transmitter then retransmits frame i.
34. Go-Back-N ARQ(4)
Receiver gets frame i and send acknowledgement (i+1)
which is lost.
Acknowledgements are cumulative, so next
acknowledgement (i+n) may arrive before transmitter times
out on frame i.out on frame i.
If transmitter times out, it sends acknowledgement with P bit
set as before.
This can be repeated a number of times before a reset
procedure is initiated
As for lost frame.
35. Selective Reject ARQ
●Also called selective retransmission.
●Only rejected(negative ACK, or time-out)
frames are retransmitted.
●Minimizes amount of retransmission.
●Subsequent frames are accepted by the
receiver and buffered.
●Receiver must maintain large enough●Receiver must maintain large enough
buffer to save received frames until the
frame in error is retransmitted.
●Receiver must contain logic for
reinserting that frame is the proper
●More complex logic in transmitter
because it is much less used than go-