5.Data link layer_1
5.Data link layer_1
NETWORKS
Lec. Onim
EECE, MIST
Outline:
• The data link layer uses the services of the physical layer to send and
receive bits over communication channels.
• Providing a well-defined service interface to the network layer.
• Dealing with transmission errors
• Regulating the flow of data so that slow receivers are not swamped
by fast senders
• Encapsulates the packets into frames.
Service Provided to Network Layer:
o Ethernet is a good example of a data link layer that provides this class of service.
o If a frame is lost due to noise on the line, no attempt is made to detect the loss or recover from it
in the data link layer.
o This class of service is appropriate when the error rate is very low, so recovery is left to higher
layers.
Acknowledged connectionless service:
o Each frame sent is individually acknowledged.
o If it has not arrived within a specified time interval, it can be sent again
o This service is useful over unreliable channels, such as wireless systems. 802.11 (WiFi) is a good
example of this class of service.
Framing
o To provide service to the network layer, the data link layer must use the service provided to it by
o However, the bit stream received by the data link layer is not guaranteed to be error free.
o The usual approach is for the data link layer to break up the bit stream into discrete frames,
compute a short token called a checksum for each frame, and include the checksum in the frame
when it is transmitted.
o 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 takes steps to deal with it.
Breaking up the bit stream into frames has four methods:
1.Byte count
o Uses a field in the header to specify the number of bytes in the frame.
o When the data link layer at the destination sees the byte count, it knows how many bytes
o The trouble with this algorithm is that the count can be garbled by a transmission Error.
o It will then be unable to locate the correct start of the next frame.
o Each frame starts and ends with special bytes called flag byte.
o Consecutive flag bytes indicate the end of one frame and the start of the next.
o If the receiver ever loses synchronization it can just search for two flag bytes to find the end
o Can be problematic as it may happen that the flag byte occurs in the data.
o One way to solve this problem is to have the sender’s data link layer insert a special escape
byte (ESC) just before each ‘‘accidental’’ flag byte in the data.
o Thus, a framing flag byte can be distinguished from one in the data by the absence or
presence of an escape byte before it.
o The data link layer on the receiving end removes the escape bytes before giving the data to
the network layer.
Flag bits with bit stuffing
o Each frame begins and ends with a special bit pattern, 01111110 which is the flag
o Whenever the sender’s data link layer encounters five consecutive 1s in the data, it
automatically stuffs a 0 bit into the outgoing bit stream
o When the receiver sees five consecutive incoming 1 bits, followed by a 0 bit, it
automatically destuffs (i.e., deletes) the 0 bit.
Error control:
o Error control is implemented at the data-link layer to prevent the receiving node from delivering
corrupted packets to its network layer
o Error control at the data-link layer is normally very simple
o Implemented by adding a CRC to the frame header by the sender which is checked by the receiver
Two methods:
o If the frame is corrupted, it is silently discarded; if it is not corrupted, the packet is delivered to the
network layer. This method is used mostly in wired LANs such as Ethernet.
o If the frame is corrupted, it is silently discarded; if it is not corrupted, an acknowledgment is sent (for
the purpose of both flow and error control) to the sender
Error Detection
Error Correction