Chapter 8 - Data Link Layer
Chapter 8 - Data Link Layer
The function of the data link layer is to provide services to the network layer. The
principal service is transferring data from the network layer on the source machine to
the network layer on the destination machine.
On the source machine the network layer gives some bits to the data link layer for
transmission to the destination.
The job of the Data link layer is to transmit the bits to the destination machine so they
can be handed over to the network layer there, as shown in figure (a) below.
But the actual transmission follows the path as shown in figure (b) below.
Service Provided by DLL to the Network Layer :
There are mainly three types of services provided by DLL to NL :
The data link layer has to detect and, if necessary, correct errors in the bit stream
received by the physical layer of receiver.
One way to do this is to break the bit stream up into discrete frames and computer the
checksum for each frame.
When a frame arrives at the destination, the checksum is recomputed. If the newly-
computed checksum is different from the one contained in the frame, the data link
layer knows that an error has occurred and asks transmitter to retransmit the bad
frame.
The problem with this algorithm is that if the count is changed by a transmission error,
then the destination will get out of synchronization and will not be able to locate the
start of the next frame.
So, character count method is rarely used anymore.
2. Flag Bytes with Byte Stuffing
Here, each frame starts and ends with special bytes, called a flag byte.
If the receiver ever loses synchronization, it can just search for the flag byte to find the
end of the current frame.
Two consecutive flag bytes indicate the end of one frame and start of the next one.
If the flag byte’s bit pattern occurs in the data, then sender’s data link layer insert a
special escape byte (ESC) just before flag byte in the data.
The data link layer on the receiving end removes the escape byte before the data are
given to the network layer.
This technique is called byte stuffing or character stuffing.
If an escape byte occurs in the data, then that it too, is stuffed with an escape byte.
Disadvantages: It can be used with 8-bit characters coding scheme only. Not all
character codes use 8-bit characters.
3. Flag Bits with Bit Stuffing
Each frame begins and ends with special bit pattern, 01111110.
If the user data contain the flag pattern, 01111110, it automatically stuffs a 0 bit into
the out going bit stream after five 1s. So, it is transmitted as 011111010.
Two consecutive flag bytes indicate the end of one frame and start of the next one.
Error Control :
The next problem is how to make sure all frames are delivered to the network layer at
the destination and in the proper order.
One way to ensure reliable delivery is for the receiver to send back special control
frames bearing positive or negative acknowledgements about the incoming frames.
If the sender receives a positive acknowledgement about a frame, it knows the frame
has arrived safely. On the other hand, a negative acknowledgement means that
something has gone wrong, and the frame must be transmitted again.
In this scheme, a Timer is required at the data link layer. When the sender transmits a
frame, it starts a timer. The timer is set to expire after an interval long enough for the
frame to reach the destination, be processed there, and have the acknowledgement
propagate back to the sender. When the frame will be correctly received and the
acknowledgement will get back before the timer runs out, in which case the timer will
be canceled.
If the acknowledgement is not received before timer goes off then sender transmits
the frame again.
There is a danger that the receiver will accept the same frame two or more times and
pass it to the network layer more than once.
To solve this problem DLL assigns sequence numbers to outgoing frames.
Any time an error is detected in an exchange, specified frames are retransmitted. This
process is called automatic repeat request (ARQ).
Flow Control :
Another important design issue is what to do with a sender that transmits frames
faster than the receiver can accept them.
This situation can easily occur when the sender is running on a fast (or lightly loaded)
computer and the receiver is running on a slow (or heavily loaded) machine.
Initially, the receiver has nothing to do. It just sits around waiting for something
to happen.
In the example protocols we will indicate that the data link layer is waiting for
something to happen by the function call wait_for_event (&event). This
procedure only returns when something has happened (e.g., a frame has
arrived). Upon return, the variable event tells what happened
A frame header is made up of four fields :
A frame is composed of four fields: kind, seq, ack, and info, the first three of which
contain control information and the last of which may contain actual data to be
transferred.
These control fields are collectively called the frame header.
The kind field tells whether there are any data in the frame, because some of the
protocols distinguish frames containing only control information from those containing
data as well.
The seq and ack fields are used for sequence numbers and acknowledgements,
respectively
The info field of a data frame contains a single packet; the info field of a control frame is
not used.
Kind – Type of frame (Data frame or acknowledgement frame)
Seq - Frame sequence number
Ack - Acknowledgement sequence number
Info - actual data to be transferred (a packet)
Protocols:
Utopian/Unrestricted simplex protocol :
Key assumptions:
As reply is not coming from the receiver our sender will be continuously waiting for
the acknowledgement
The solution to this is to add a timer which times out after some span of time.
Hence if acknowledgment is not received in that time interval then eventually timer
will stop and A will again send the copy of the frame to B.
2. Acknowledgement is destroyed in between
The network layer on A gives packet 1 to its data link layer. The packet is correctly
received at B and passed to the network layer on B. B sends an acknowledgement frame
back to A.
The acknowledgement frame gets lost completely. It just never arrives at all.
The data link layer on A eventually times out. Not having received an acknowledgement,
it (incorrectly) assumes that its data frame was lost or damaged and sends the frame
containing packet 1 again.
The duplicate frame also arrives at the data link layer on B perfectly and is unwittingly
passed to the network layer there. If A is sending a file to B, part of the file will be
duplicated (i.e., the copy of the file made by B will be incorrect and the error will not
have been detected).
The solution to this problem is that the sender put a sequence number in the header of
each frame it sends. Then the receiver can check the sequence number of each arriving
frame to see if it is a new frame or a duplicate to be discarded.
Sliding window protocol :
In the previous protocols, data frames were transmitted in one direction only. In most
practical situations, there is a need for transmitting data in both directions.
A better idea is to use the same circuit for data in both directions.
In this model the data frames from A to B are intermixed with the acknowledgement
frames from A to B.
By looking at the kind field in the header of an incoming frame, the receiver can tell
whether the frame is data or acknowledgement.
The technique of temporarily delaying outgoing acknowledgements so that they can be
hooked onto the next outgoing data frame is known as piggybacking.
The principal advantage of using piggybacking over having distinct acknowledgement
frames is a better use of the available channel bandwidth.
The ack field in the frame header costs only a few bits, whereas a separate frame would
need a header, the acknowledgement, and a checksum.
Sliding window protocol :
The essence of all sliding window protocols is that at any instant of time, the sender
maintains a set of sequence numbers corresponding to frames it is permitted to send.
These frames are said to fall within the sending window. Similarly, the receiver also
maintains a receiving window corresponding to the set of frames it is permitted to
accept.
The sender’s window and the receiver’s window need not have the same lower and
upper limits or even have the same size. In some protocols they are fixed in size, but in
others they can grow or shrink over the course of time as frames are sent and received.
One-bit Sliding window protocol :