Sie sind auf Seite 1von 4

Data Link Layer

The goal of the data link layer is to provide reliable, efficient communication between adjacent
machines connected by a single communication channel. Specifically:
1. Group the physical layer bit stream into units called frames. Note that frames are nothing more
than ``packets'' or ``messages''. By convention, we shall use the term ``frames'' when discussing
DLL packets.
2. Sender calculates the checksum and sends checksum together with data. The checksum
allows the receiver to determine when a frame has been damaged in transit or received
correctly.
3. Receiver recomputes the checksum and compares it with the received value. If they differ, an
error has occurred and the frame is discarded.
4. Error control protocol returns a positive or negative acknowledgment to the sender. A positive
acknowledgment indicates the frame was received without errors, while a negative
acknowledgment indicates the opposite.
5. Flow control prevents a fast sender from overwhelming a slower receiver. For example, a
supercomputer can easily generate data faster than a PC can consume it.
6. In general, data link layer provides service to the network layer. The network layer wants to be
able to send packets to its neighbors without worrying about the details of getting it there in one
piece.

Design Issues
Below are the some of the important design issues of the data link layer:

a). Reliable Delivery:


Frames are delivered to the receiver reliably and in the same order as generated by the sender.
Connection state keeps track of sending order and which frames require retransmission. For
example, receiver state includes which frames have been received, which ones have not, etc.

b). Best Effort: The receiver does not return acknowledgments to the sender, so the sender has
no way of knowing if a frame has been successfully delivered.
When would such a service be appropriate?
1. When higher layers can recover from errors with little loss in performance. That is, when
errors are so infrequent that there is little to be gained by the data link layer performing the
recovery. It is just as easy to have higher layers deal with occasional loss of packet.
2. For real-time applications requiring ``better never than late'' semantics. Old data may be worse
than no data.

c). Acknowledged Delivery


The receiver returns an acknowledgment frame to the sender indicating that a data frame was
properly received. This sits somewhere between the other two in that the sender keeps connection
state, but may not necessarily retransmit unacknowledged frames. Likewise, the receiver may
hand over received packets to higher layer in the order in which they arrive, regardless of the
original sending order. Typically, each frame is assigned a unique sequence number, which the
receiver returns in an acknowledgment frame to indicate which frame the ACK refers to. The
sender must retransmit unacknowledged (e.g., lost or damaged) frames.

d). Framing
The DLL translates the physical layer's raw bit stream into discrete units (messages) called
frames. How can the receiver detect frame boundaries? Various techniques are used for this:
Length Count, Bit Stuffing, and Character stuffing.
e). Error Control
Error control is concerned with insuring that all frames are eventually delivered (possibly in
order) to a destination. To achieve this, three items are required: Acknowledgements, Timers, and
Sequence Numbers.
f). Flow Control
Flow control deals with throttling the speed of the sender to match that of the receiver. Usually,
this is a dynamic process, as the receiving speed depends on such changing factors as the load,
and availability of buffer space.

Framing
Since the physical layer merely accepts and transmits a stream of bits without any regard to
meaning or structure, it is upto the data link layer to create and recognize frame boundaries.
This can be accomplished by attaching special bit patterns to the beginning and end of the
frame. If these bit patterns can accidentally occur in data, special care must be taken to make
sure these patterns are not incorrectly interpreted as frame delimiters. The four framing
methods that are widely used are
Character count
Starting and ending characters, with character stuffing
Starting and ending flags, with bit stuffing

Character Count
This method uses a field in the header to specify the number of characters in the frame. When
the data link layer at the destination sees the character count, it knows how many characters
follow, and hence where the end of the frame is. The disadvantage is that if the count is garbled
by a transmission error, the destination will lose synchronization and will be unable to locate the
start of the next frame. So, this method is rarely used.

Bit stuffing
The third method allows data frames to contain an arbitrary number of bits and allows character
codes with an arbitrary number of bits per character. At the start and end of each frame is a flag
byte consisting of the special bit pattern 01111110 . Whenever the sender's data link layer
encounters five consecutive 1s in the data, it automatically stuffs a zero bit into the outgoing bit
stream. This technique is called bit stuffing. When the receiver sees five consecutive 1s in the
incoming data stream, followed by a zero bit, it automatically destuffs the 0 bit. The boundary
between two frames can be determined by locating the flag pattern.

Character stuffing
In the second method, each frame starts with the ASCII character sequence DLE STX and ends
with the sequence DLE ETX.(where DLE is Data Link Escape, STX is Start of TeXt and ETX is End of
TeXt.) This method overcomes the drawbacks of the character count method. If the destination
ever loses synchronization, it only has to look for DLE STX and DLE ETX characters. If however,
binary data is being transmitted then there exists a possibility of the characters DLE STX and DLE

ETX occurring in the data. Since this can interfere with the framing, a technique called character
stuffing is used. The sender's data link layer inserts an ASCII DLE character just before the DLE
character in the data. The receiver's data link layer removes this DLE before this data is given to
the network layer. However character stuffing is closely associated with 8-bit characters and this
is a major hurdle in transmitting arbitrary sized characters.

Error Control
The bit stream transmitted by the physical layer is not guaranteed to be error free. The data link
layer is responsible for error detection and correction. The most common error control method
is to compute and append some form of a checksum to each outgoing frame at the sender's
data link layer and to recompute the checksum and verify it with the received checksum at the
receiver's side. If both of them match, then the frame is correctly received; else it is erroneous.
The checksums may be of two types:
# Error detecting : Receiver can only detect the error in the frame and inform the sender about
it.
# Error detecting and correcting : The receiver can not only detect the error but also correct it.
Examples of Error Detecting methods:

Parity bit:
Simple example of error detection technique is parity bit. The parity bit is chosen that the
number of 1 bits in the code word is either even( for even parity) or odd (for odd parity). For
example when 10110101 is transmitted then for even parity an 1 will be appended to the data
and for odd parity a 0 will be appended. This scheme can detect only single bits. So if two or
more bits are changed then that can not be detected.
Q1 How does a single-bit error differ from a burst error?
Ans: In a single bit error only one bit of a data unit is corrupted; in a burst error more
than one bit is corrupted (not necessarily contiguous).
Q2. Discuss the concept of redundancy in error detection and correction.
Ans: Redundancy is a technique of adding extra bits to each data unit to determine the
accuracy of transmission.
Q3 Distinguish between forward error correction versus error correction by retransmission.
Ans: In forward error correction, the receiver tries to correct the corrupted codeword; in error
detection by retransmission, the corrupted message is discarded (the sender needs to
retransmit the message).
Q4 What is the Hamming distance? What is the minimum Hamming distance?
Ans: The Hamming distance between two words (of the same size) is the number of
differences between the corresponding bits. The minimum Hamming distance is the smallest
Hamming distance between all possible pairs in a set of words.
Q5 What is the Hamming distance for each of the following codewords:
a. d (10000, 00000)
b. d (10101, 10000)
c. d (11111,11111)
d. d (000, 000)
Ans: a. d (10000, 00000) = 1
b. d (10101, 10000) = 2
c. d (1111, 1111) = 0
d. d (000, 000) = 0

Q6. Answer the following questions:


a. What is the polynomial representation of 10111O?
b. What is the result of shifting 101110 three bits to the left?
c. Repeat part b using polynomials.
d. What is the result of shifting 101110 four bits to the right?
e. Repeat part d using polynomials.
Ans:
101110 x5 + x3 + x2 + x
101110 101110000 (Three 0s are added to the right)
X3 (x5 + x3 + x2 + x) = x8 + x6 + x5 + x4
101110 10 (The four rightmost bits are deleted)
x-4 (x5 + x3 + x3 + x) = x (Note that negative powers are deleted)

Q7 Which of the following CRC generators guarantee the detection of a single bit
error?
a. x3 + x + 1
b. x4 + x2
c. 1
d. x2 + 1
Ans: To detect single bit errors, a CRC generator must have at least two terms and the
coefficient of x0 must be nonzero.
a. x3 + x + 1 It meets both critic.
b. x4 + x2 It meets the first criteria, but not the second.
c. 1 It meets the second criteria, but not the first.
d. x2 + 1 It meets both criteria.
Q8 Assuming even parity, find the parity bit for each of the following data units.
a. 1001011
b. 0001100
c. 1000000
d. 1110111
Ans: