Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Objective:
To familiarize about the Data Link Layer and its significance in the Data
Communication.
Syllabus:
Data Link Layer
Design issues-Services provided to the Network Layer, Framing, Error Detection and Correction,
CRC, Elementary Protocols- Stop and wait, Sliding Window Protocols, A One bit, Go Back n,
Selective Repeat, HDLC, PPP
Learning Outcomes:
Students will be able to
1. Understand the design issues, framing, error detection and correction methodologies
adopted in data transmission
2. Explain the concept of services of Data Link layer to the Upper layers and the protocols
of it.
Learning Material
2.3 Framing:
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.
• Large block of data may be broken up into small frames at the source because:
– limited buffer size at the receiver
– A larger block of data has higher probability of error
• With smaller frames, errors are detected sooner, and only a smaller
amount of data needs to be retransmitted
– On a shared medium, such as Ethernet and Wireless LAN, small frame size can
prevent one station from occupying medium for long periods
• Need to indicate the start and end of a block of data
• Use preamble (e.g., flag byte) and postamble
• If the receiver ever loses synchronization, it can just search for the flag byte.
• Frame: preamble + control info + data + postamble
• Problem: it is possible that the flag byte’s bit pattern occur in the data
• Two popular solutions:
Byte stuffing: The sender inserts a special byte (e.g., ESC) just before each “accidental” flag
byte in the data (like in C language, “ is replaced with \”). The receiver’s link layer removes this
special byte before the data are given to the network layer.
• After solving the marking of the frame with start and end the DLL has to handle eventual
errors in transmission or detection.
– Ensuring that all frames are delivered to the network layer at the destination and
in proper order.
• Unacknowledged connectionless service: it is OK for the sender to output frames
regardless of its reception.
• Reliable connection-oriented service: it is NOT OK.
• Reliable connection-oriented service usually will provide a sender with some feedback
about what is happening at the other end of the line.
– Receiver Sends Back Special Control Frames.
– If the Sender Receives positive Acknowledgment it will know that the frame has
arrived safely.
• Timer and Frame Sequence Number for the Sender is Necessary to handle the case when
there is no response (positive or negative) from the Receiver .
• Error control in the data link layer is based on automatic repeat request, which is the
retransmission of data.
2.5 Flow Control:
• Important Design issue for the cases when the sender is running on a fast powerful
computer and receiver is running on a slow low-end machine.
Two approaches:
I. Feedback-based flow control
II. Rate-based flow control
Feedback-based Flow Control Receiver sends back information to the sender giving it
permission to send more data, or telling sender how receiver is doing.
Rate-based Flow Control built in mechanism that limits the rate at which sender may
transmit data, without the need for feedback from the receiver.
2.6 Error Detection & Correction:
• Network designers have developed two basic strategies for dealing with errors.
• Both add redundant information to the data that is sent.
• One strategy is to include enough redundant information to enable the receiver to deduce
what the transmitted data must have been.
• The other is to include only enough redundancy to allow the receiver to deduce that an
error has occurred (but not which error) and have it request a retransmission. The former
strategy uses error-correcting codes and the latter uses error-detecting codes.
• The use of error-correcting codes is often referred to as FEC (Forward Error
Correction).
1. Hamming codes.
2. Binary convolution codes.
3. Reed-Solomon codes.
4. Low-Density Parity Check codes.
1. Hamming Code:
To understand how errors can be handled, it is necessary to first look closely at what an
error really is. Given any two code words that may be transmitted or received—say, 10001001
and 10110001—it is possible to determine how many corresponding bits differ. In this case, 3
bits differ. To determine how many bits differ, just XOR the two codewords and count the
number of 1 bits in the result.
For example:
10001001
10110001
-----------------
00111000
---------------
The number of bit positions in which two code words differ is called the Hamming distance
(Hamming, 1950). Its significance is that if two code words are a Hamming distance d apart, it
will require d single-bit errors to convert one into the other.
Given the algorithm for computing the check bits, it is possible to construct a complete
list of the legal code words, and from this list to find the two code words with the smallest
Hamming distance.
This distance is the Hamming distance of the complete code. In most data transmission
applications, all 2m possible data messages are legal, but due to the way the check bits are
computed, not all of the 2n possible code words are used.
In fact, when there are r check bits, only the small fraction of 2m /2n or 1/2r of the
possible messages will be legal code words. It is the sparseness with which the message is
embedded in the space of code words that allows the receiver to detect and correct errors.
As a simple example of an error-correcting code, consider a code with only four valid
code words:
0000000000, 0000011111, 1111100000, and 1111111111
This code has a distance of 5, which means that it can correct double errors or detect quadruple
errors. If the codeword 0000000111 arrives and we expect only single- or double-bit errors, the
receiver will know that the original must have been 0000011111. If, however, a triple error
changes 0000000000 into 0000000111, the error will not be corrected properly. Alternatively, if
we expect all of these errors, we can detect them. None of the received code words are legal code
words so an error must have occurred. It should be apparent that in this example we cannot both
correct double errors and detect quadruple errors because this would require us to interpret a
received codeword in two different ways.
Figure 2.5: Example of hamming code correcting a single-bit error.
When the polynomial code method is employed, the sender and receiver must agree upon
a generator polynomial, G(x), in advance.
Both the high- and low order bits of the generator must be 1. To compute the CRC for
some frame with m bits corresponding to the polynomial M(x), the frame must be longer
than the generator polynomial.
The idea is to append a CRC to the end of the frame in such a way that the polynomial
represented by the check summed frame is divisible by G(x). When the receiver gets the
check summed frame, it tries dividing it by G(x). If there is a remainder, there has been a
transmission error.
1. Let r be the degree of G(x). Append r zero bits to the low-order end of the frame so it
now contains m + r bits and corresponds to the polynomial x ^rM(x).
2. Divide the bit string corresponding to G(x) into the bit string corresponding to x rM(x),
using modulo 2 division.
3. Subtract the remainder (which is always r or fewer bits) from the bit string
corresponding to x ^rM(x) using modulo 2 subtraction. The result is the check summed
frame to be transmitted. Call its polynomial T(x).
Figure 2.6: Example calculation of the CRC.
2.7 Elementary DLL protocols
• Protocols are classified into various types depending on different channels. They are:
1) noiseless channel
2) noisy channel
1) noiseless channel:
Protocols for noiseless channel are further classified into two
i) simplest protocol
ii) stop-and-wait protocol
i) simplest protocol:
In simplest protocol, the transmission of data is only in single direction i.e. simplex
duplex transmission methodology is adopted, in this, there are no errors that take
place in physical channel.
The sender/receiver can generate/consume infinite amount of data. The DLL on the
sender side takes the packet from the network layer and then adds the header and
trailer to create frame and transmits it to the physical layer.
The receiver side DLL removes the header from the frame and transmits as packet to
the network layer. In this protocol, the receiver will never flow out i.e. it will never
be overwhelmed.
ii) Stop-and-wait Protocol:
The most impractical limitation used in an unrestricted simplex protocol wouldn’t be
considered here. However, assumption of communication channel is to be error free and
still the data traffic is simplex in this protocol, the major difficulty to be faced is how to
overcome the problem of flooding from the sender’s end and transfer data faster than the
latter from the receiver’s end.
Basically, if the receiver requires a time ∆t to execute from physical to network layer, the
sender need to transmit at an average rate less than one frame per ∆t. additionally, in
receiver’s hardware, assuming that there is no queuing done and no automatic buffering
done then the sender need not transmit a new frame until and unless the old frame has
been fetched by physical layer, because the new one will overwrite the old one.
Generally, to solve this problem, receiver needs to provide feedback to the sender. After
transmitting a packet to network layer, a little dummy frame is sent back to the sender by
the receiver which is turn permits sender to transmit the next frame.
Stop – and –wait protocol is a protocol where sender sends one frame and then waits for
acknowledgement before further proceedings.
The advantage of stop and wait protocol is its simplicity. Each frame is checked and
acknowledged before the next frame is sent.
The disadvantage is its inefficiency. Stop and wait is very slow. Each frame must travel
all the way to the receiver and an acknowledgement must travel all the way back before
the next frame can be transmitted.
In other words, each frame is alone on the line. Each frame sent and received uses the
entire time needed to traverse the link. If the distance between devices is long, the time
spent waiting for ACKs between each frame can add significantly to the total
transmission time.
Figure 2.13: A sliding window of size 1, with a 3-bit sequence number. (a) Initially.
(b) After the first frame has been sent. (c) After the first frame has been
Received. (d) After the first acknowledgement has been received.
Noisy channel protocols: noiseless protocols specify how to control the flow of data,
where as noisy protocols specified how to control the error. Noisy protocols are classified as
follows:
i) Stop and wait automated repeat request (ARQ)
ii) Sliding window protocol using Go-back-n ARQ
iii) Sliding window protocol using selective Repeat ARQ
Figure 2-15. Two scenarios for protocol 4. (a) Normal case. (b) Abnormal case. The notation is
(seq, ack, packet number). An asterisk indicates where a network layer accepts a packet.
In this protocol, both sender and receiver maintain a window of outstanding and
acceptable sequence numbers, respectively.
The sender’s window size starts out at 0 and grows to some predefined maximum. The
receiver’s window, in contrast, is always fixed in size and equal to the predetermined
maximum.
The receiver has a buffer reserved for each sequence number within its fixed window.
Associated with each buffer is a bit (arrived) telling whether the buffer is full or empty.
Whenever a frame arrives, its sequence number is checked by the function between to see
if it falls within the window.
Figure 2-17. (a) Initial situation with a window of size7. (b) After 7 frames have been sent and
received but not acknowledged. (c) Initial situation with a window size of 4. (d) After 4 frames
have been sent and received but not acknowledged.
Non sequential receive introduces further constraints on frame sequence numbers
compared to protocols in which frames are only accepted in order.
We can illustrate the trouble most easily with an example. Suppose that we have a 3-bit
sequence number, so that the sender is permitted to transmit up to seven frames before
being required to wait for an acknowledgement.
Initially, the sender’s and receiver’s windows are as shown in Fig. 2-17(a). The sender
now transmits frames 0 through 6.
The receiver’s window allows it to accept any frame with a sequence number between 0
and 6 inclusive.
All seven frames arrive correctly, so the receiver acknowledges them and advances its
window to allow receipt of 7, 0, 1, 2, 3, 4, or 5, as shown in Fig. 2-17(b). All seven
buffers are marked empty.
It is at this point that disaster strikes in the form of a lightning bolt hitting the telephone
pole and wiping out all the acknowledgements.
The protocol should operate correctly despite this disaster.
The sender eventually times out and retransmits frame 0.
When this frame arrives at the receiver, a check is made to see if it falls within the
receiver’s window.
Unfortunately, in Fig. 2-17(b) frame 0 is within the new window, so it is accepted as a
new frame.
The receiver also sends a (piggybacked) acknowledgement for frame 6, since 0 through 6
have been received.
The sender is happy to learn that all its transmitted frames did actually arrive correctly, so
it advances its window and immediately sends frames 7, 0, 1, 2, 3, 4, and 5.
Frame 7 will be accepted by the receiver and its packet will be passed directly to the
network layer. Immediately thereafter, the receiving data link layer checks to see if it has
a valid frame 0 already, discovers that it does, and passes the old buffered packet to the
network layer as if it were a new packet.
Consequently, the network layer gets an incorrect packet, and the protocol fails.
The essence of the problem is that after the receiver advanced its window, the new range
of valid sequence numbers overlapped the old one.
Consequently, the following batch of frames might be either duplicates (if all the
acknowledgements were lost) or new ones (if all the acknowledgements were received).
The poor receiver has no way of distinguishing these two cases.
The way out of this dilemma lies in making sure that after the receiver has advanced its
window there is no overlap with the original window.
To ensure that there is no overlap, the maximum window size should be at most half the
range of the sequence numbers.
This situation is shown in Fig. 2-17(c) and Fig. 2-17(d). With 3 bits, the sequence
numbers range from 0 to 7.
Only four unacknowledged frames should be outstanding at any instant. That way, if the
receiver has just accepted frames 0 through 3 and advanced its window to permit
acceptance of frames 4 through 7, it can unambiguously tell if subsequent frames are
retransmissions (0 through 3) or new ones (4 through 7). In general, the window size for
protocol 6 will be (MAX SEQ + 1)/2.
In asynchronous balanced mode (ABM), the configuration is balanced. The link is point-to-point,
and each station can function as a primary and a secondary (acting as peers), as shown in Figure .
This is the common mode today.
Figure 2.20: Asynchronous Balanced Mode
Frames
To provide the flexibility necessary to support all the options possible in the modes and
configurations just described, HDLC defines three types of frames: information frames
(I-frames), supervisory frames (S-frames), and unnumbered frames (V-frames).
Each type of frame serves as an envelope for the transmission of a different type of
message. I-frames are used to transport user data and control information relating to user
data (piggybacking). S-frames are used only to transport control information. V-frames
are reserved for system management. Information carried by V-frames is intended for
managing the link itself.
Frame Format
Each frame in HDLC may contain up to six fields, as shown in Figure: a beginning flag
field, an address field, a control field, an information field, a frame check sequence (FCS)
field, and an ending flag field.
In multiple-frame transmissions, the ending flag of one frame can serve as the beginning
flag of the next frame.
Framing
PPP is a byte-oriented protocol. Framing is done according to the discussion of byte oriented
Protocols at the beginning of this chapter.
Frame Format
Figure shows the format of a PPP frame. The description of each field follows:
Flag. A PPP frame starts and ends with a I-byte flag with the bit pattern 01111110. Although
this pattern is the same as that used in HDLC, there is a big difference. PPP is a byte-oriented
protocol; HDLC is a bit-oriented protocol. The flag is treated as a byte, as we will explain
later.
Address. The address field in this protocol is a constant value and set to 11111111 (broadcast
address). During negotiation (discussed later), the two parties may agree to omit this byte.
Control. This field is set to the constant value 11000000 (imitating unnumbered frames in
HDLC). As we will discuss later, PPP does not provide any flow control. Error control is also
limited to error detection. This means that this field is not needed at all, and again, the two
parties can agree, during negotiation, to omit this byte.
Protocol. The protocol field defines what is being carried in the data field: either user data or
other information. We discuss this field in detail shortly. This field is by default 2 bytes long,
but the two parties can agree to use only I byte.
Payload field. This field carries either the user data or other information that we will discuss
shortly. The data field is a sequence of bytes with the default of a maximum of 1500 bytes; but
this can be changed during negotiation. The data field is byte stuffed if the flag byte pattern
appears in this field. Because there is no field defining the size of the data field, padding is
needed if the size is less than the maximum default value or the maximum negotiated value.
FCS. The frame check sequence (FCS) is simply a 2-byte or 4-byte standard CRC.
Byte Stuffing
The similarity between PPP and HDLC ends at the frame format. PPP, as we discussed before, is
a byte-oriented protocol totally different from HDLC. As a byte-oriented protocol, the flag in
PPP is a byte and needs to be escaped whenever it appears in the data section of the frame. The
escape byte is 01111101, which means that every time the flag like pattern appears in the data,
this extra byte is stuffed to tell the receiver that the next byte is not a flag.
Transition Phases
A PPP connection goes through phases which can be shown in a transition phase
Diagram
1. Fragmentation means................... [ ]
A. adding of small packets to form large packet
B. breaking large packet into small packets
C. combining large packets in to a single packet
D. forwarding a packet through different networks
2.An error-detecting code inserted as a field in a block of data to be transmitted is known as
A. Frame check sequence B. Error detecting code [ ]
C. Checksum D. flow control
3.Error detecting code is [ ]
an error-detecting code based on a summation operation performed on the bits to be
a).
checked
b). a check bit appended to an array of binary digits to make the sum of all the binary digits.
d) the ratio of the data units in error to the total number of data units
4. The data link layer takes the packets from _____ and encapsulates them into frames for
transmission. [ ]
A. network layer B. physical layer C. transport layer D. application layer
5. Which one of the following task is not done by data link layer? [ ]
A. framing B. error control C. flow control D. channel coding
7. The technique of temporarily delaying outgoing outgoing acknowledgements so that they can
be hooked onto the next outgoing data frame is called [ ]
A. piggybacking B. cyclic redundancy check
C. fletcher’s checksum D. none of the mentioned
Problems
1. Find out the CRC for message m[x] = 11101101, generator g[x] = 1101.
2. Find out the checksum for the following data from sender’s side 7,11,12,0,6 is to be
transmitted to the receiver side using 1’s complement method.
3. Do character stuffing to the following (using DLE)?
A DLE DLE DLE DLE B
4. Do bit stuffing for 111100000001111111111110001111000111111110011?
5. Using polynomial method, calculate the redundant bits.
M(x)=111110000010 and G(x)=11011
6. Perform the bit stuffing for 011011111111101001.
7. Consider the message 1001111 is transmitted through the channel. Obtain the redundancy
bits and the transmitted unit needed using hamming code. Assume bit 8 has been
changed. How to locate it.
C. Questions testing the analyzing/evaluating/creative ability of students
1. Imagine that you are writing the data link software for a line used to send data to you, but not
from you. The other end uses HDLC, with a 3-bit sequence number and a window size of
seven frames. You would like to buffer as many out-of-sequence frames as possible to enhance
efficiency, but you are not allowed to modify the software on the sending side. Is it possible to
have a receiver window greater than 1, and still guarantee that the protocol will never fail? If
so, what is the largest window that can be safely used?