G Unit-Ii
G Unit-Ii
UNIT-II
Data link layer:
Data-Link Layer has responsibility of transferring frames
from one node to adjacent node over a link
DATA LINK LAYER DESIGN ISSUES:
Data link layer has a number of specific functions to carry
out. These functions include
Provides a well-defined service interface to the network layer.
Determines how the bits of the physical layer are grouped into
frames (framing).
Deals with transmission errors (CRC and ARQ).
Systems which automatically request the
retransmission of missing packets or packets with
errors are called Automatic Repeat reQuest (ARQ)
Regulates the flow of frames.
Data link layer-Introduction
The data link layer takes the packets it gets from the network layer
and encapsulates them into frames for transmission .
Each frame contains frame header ,a payload field for holding the
packet ,and a frame trailer
1 2 3 4 5
1) character count
Bit stuffing
(a) The original data.
(b) The data as they appear on the line.
(c) The data as they are stored in receiver’s memory after
destuffing.
• Framing: Coding violation
– Redundancy in the encoding on medium is
required
– e.g. Manchester encoding: transition in the middle of a
slot
violation
20
Error Control:
The protocol calls for the receiver to send back special control
frames bearing positive and negative acknowledgements about
the incoming frames
Error Control:
For e.g.
On a reliable medium : Error Detection is sufficient where
the error rate is low and asking for retransmission after
Error Detection would work efficiently
In contrast, on an unreliable medium : Retransmission after
Error Detection may result in another error and still
another and so on. Hence Error Correction is desirable.
Error Detection and Correction
• Types of Errors
• Error-Correcting Codes
• Error-Detecting Codes
Types of Errors
Single-Bit Error:
Burst Error:
(a)
(b)
Redundancy
All error detection/correction methods are based on redundancy
Error detecting Codes:
Polynomial code or CRC( Cyclic Redundancy Check )
Beginning with the most significant bit in the original message and for each
bit position that follows, look at the c+1 bit remainder:
If the most significant bit of the remainder is a one, the divisor is said to
divide into it. If that happens (just as in any other long division) it is
necessary to indicate a successful division in the appropriate bit position
in the quotient and to compute the new remainder. In the case of
modulo-2 binary division, we simply:
Set the appropriate bit in the quotient to a one, and
XOR the remainder with the divisor and store the result back into the
remainder
Otherwise (if the first bit is not a one):
The final value of the remainder is the CRC of the given message.
CRC
Why polynomials?
Standard polynomials:
(IEEE 802)
CRC
r bits
r+1 bits
r bits
Checksum
At the sender
24=16>=12+4+1
16>=17
Take n=5
25=32>=12+5+1=18
11 10 9 8 7 6 5 4 3 2 1
1 1 0 r 1 1 1 r 0 r r
11 10 9 8 7 6 5 4 3 2 1
1 1 0 r 1 1 1 r 0 r r
Express all bit positions that contains a 1 as four bit number and xor them together.
Bit position binary number
5 0101
6 0110
Xor 0011
7 0111
xor 0100
10 1010
xor 1110
11 1011
0101
Error correcting codes:
11 10 9 8 7 6 5 4 3 2 1
1 1 0 r 1 1 1 r 0 r r
1 1 0 0 1 1 1 1 0 0 1
Error correcting codes:
11 10 9 8 7 6 5 4 3 2 1
1 1 0 0 1 1 1 1 0 0 1
packet
frame
Continued
Some definitions needed in the protocols to follow.
These are located in the file protocol.h.
Protocol
Definitions
(ctd.)
Some definitions
needed in the
protocols to follow.
These are located in
the file protocol.h.
unrestricted simplex protocol
Data are transmitted in one direction only.
Both the transmitting and receiving network layers are always
ready
processing time can be ignored
Infinite buffer space is available
The protocol consists of two distinct procedures, a sender and
a receiver. The sender runs in the data link layer of the source
machine and the receiver runs in the data link layer of the
destination machine.
MAX-SEQ is not used because No sequence numbers and
Acknowledgements are used here.
The only event type possible is frame-arrival (i.e. an arrival of
undamaged frame)
Noiseless Channels: Simplest Protocol
Simplest protocol with no flow or error control
Flow diagram for Noiseless Channels: Simplest Protocol
11.66
A simplex stop-and-wait protocol:
If data frames arrives at the receiver side faster than
they can be processed, the frames must be stored until
their use
Normally ,the receiver does not have enough storage
space ,especially if it is receiving data from many
sources
This may result in the discarding frames
To prevent this there must be feedback from the
receiver to the sender.
A simplex stop-and-wait protocol:
Def : Protocol in which the sender sends one frame
and then waits for acknowledgement before
proceeding is called stop-and-wait.
Flow Diagram:
A B
Request
Frame
Arrival
Ack
Arrival
Frame
Request Ack
Arrival
Stop-and-Wait Protocol
Simple tokens of ACK and flow control added
Stop-and-Wait Protocol: Example
A simplex stop-and-wait protocol:
Receiver 2 is that after delivering a packet to the network
layer, receiver 2 sends an acknowledgement frame back to the
sender before entering the wait loop again. because the only
arrival of the frame back at the sender is important. the
receiver need not put any particular information on it.
points:
1) sender start out fetching a packet from the network layer,
using it to construct a frame and sending it on its way.
2)sender must wait until an acknowledgement frame
arrives before looping back and fetching the next packet
from the network layer
A simplex protocol for a Noisy Channel
The channel is noisy, frames may be damaged or lost
Good scene : data frame reaches intact, ack sent back and
received, next frame sent
Bad scene :
Data frame damaged or lost ..hence no ack – sender times
A positive
acknowledg
ement with
retransmissi
on protocol.
A simplex protocol for a Noisy Channel
source Destination
Ack(frame1)+Frame2
• When a data frame arrives, instead of immediately sending a separate
control frame, the receiver restrains itself and waits until the network layer
passes it the next packet.
• The acknowledgement is attached to the outgoing data frame
• Disadv: This technique is temporarily delaying outgoing
acknowledgements.
• If the datalinklayer waits longer than the senders timeout period, the
frame will be retransmitted.
Sliding window protocols:
Rule: sender waiting a fixed number of milliseconds. If a
new packet arrives quickly the acknowledgement is
piggybacked onto it. other wise if no new packet has arrived
by the end of this time period ,the data link layer just sends a
separate acknowledgement frame.
In sliding window protocol each frame contains a sequence
number ranging from 0 up to some maximum.
The maximum is usually 2n-1 so the sequence number fits
nicely in an n-bit field.
The stop-and-wait sliding window protocol uses n=1
restricting the sequence numbers 0 and 1.
The sender must keep all these frames in its memory for
possible retransmission
Sliding window protocols:
Thus if the maximum window size is n, the sender needs n
buffers to hold the unacknowledged frames
3 bit field -000
001
010..etc
here n=3 i.e. 23-1=7
window size is 0 to 7
Sliding window :: sender has a window of frames and maintains a
list of consecutive sequence numbers for frames that it is
permitted to send without waiting for ACKs.
receiver has a window that is a list of frame sequence numbers it is
permitted to accept.
Note – sending and receiving windows do NOT have to be the same
size.
Sliding window protocols:
NRM
ABM
FRAMES
• Control field: 1-or 2-bytes segment used for flow and error control
(interpretation depends on the frame type).
• Information field: contains the user’s data from the network layer or
management information(its length vary from one network to another)