21CS52 PPT 1fe14
21CS52 PPT 1fe14
21CS52 PPT 1fe14
Chapter 3
• Data Link Layer Design Issues
• Error Detection and Correction
• Elementary Data Link Protocols
• Sliding Window Protocols
• Example Data Link Protocols
The Data Link Layer
Application
Transport
Network
Link
Physical
• This study deals with algorithms for achieving reliable,
efficient communication of whole units of information called
frames (rather than individual bits, as in the physical layer)
between two adjacent machines
• Responsible for delivering frames of information over a single
link
• Handles transmission errors and regulates the flow of data
• The data link layer uses the services of the physical layer to send
and receive bits over communication channels.
• It has a number of functions, including:
• Frames »
• Possible services »
• Framing methods »
• Error control »
• Flow control »
Frames
Link layer accepts packets from the network layer, and
encapsulates them into frames that it sends using the physical
layer; reception is the opposite process
Network
Link
Virtual data path
• The actual transmission follows the path of Fig. 3-2(b), but it is easier
to think in terms of two data link layer processes communicating
using a data link protocol.
• For this reason, we will implicitly use the model of Fig. 3-2(a)
throughout this chapter
Possible Services
• The data link layer can be designed to offer various services.
•Ethernet is a good example of a data link layer that provides this class
of service.
•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.
•This class of service is appropriate when the error rate is very low, so
recovery is left to higher layers.
Acknowledged connectionless service.
•Reliability is acknowledged connectionless service.
•When this service is offered, there are still no logical connections used,
but each frame sent is individually acknowledged.
•In this way, the sender knows whether a frame has arrived correctly or
been lost.
•The network layer can always send a packet and wait for it to be
acknowledged by its peer on the remote machine.
•It would then take a very long time for the packet to get through.
•The most sophisticated service the data link layer can provide to
the network layer is connection-oriented service.
•With this service, the source and destination machines establish a
connection before any data are transferred.
•Each frame sent over the connection is numbered, and the data
link layer guarantees that each frame sent is indeed received.
•It guarantees that each frame is received exactly once and that all
frames are received in the right order.
•Connection-oriented service thus provides the network layer
processes with the equivalent of a reliable bit stream
When connection-oriented service is used, transfers go through
three distinct phases.
•What the physical layer does is accept a raw bit stream and attempt to
deliver it to the destination.
•If the channel is noisy, as it is for most wireless and some wired links,
the physical layer will add some redundancy to its signals to reduce the
bit error rate to a tolerable level.
•The bit stream received by the data link layer is not guaranteed to be
error free.
•Some bits may have different values and the number of bits received
may be less than, equal to, or more than the number of bits transmitted.
•It is up to the data link layer to detect and, if necessary, correct errors.
•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.
•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 (e.g., discarding the bad frame and possibly also
sending back an error report).
•A good design must make it easy for a receiver to find the start of new
frames while using little of the channel bandwidth.
Framing Methods
• Byte count »
• Flag bytes with byte stuffing »
• Flag bits with bit stuffing »
• Physical layer coding violations
− Use non-data symbol to indicate frame
Framing – Byte count
• The first framing method uses a field in the header to specify the
number of bytes in the frame.
• When the data link layer at the destination sees the byte count, it knows
how many bytes follow and hence where the end of the frame is.
Expected
case
Error
case
• It will then be unable to locate the correct start of the next frame.
•The trouble with this algorithm is that the count can be garbled
by a transmission error.
•It will then be unable to locate the correct start of the next frame.
Framing – Byte stuffing
• Often the same byte, called a flag byte, is used as both the starting
and ending delimiter.
• Two consecutive flag bytes indicate the end of one frame and the start
of the next.
• Thus, if the receiver ever loses synchronization, it can just search for
two flag bytes to find the end of the current frame and the start of the
next frame.
•However, there is a still a problem we have to solve. It may
happen that the flag byte occurs in the data, especially
when binary data such as photographs or songs are being
transmitted.
•This situation would interfere with the framing.
•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.
•A framing flag byte can be distinguished from one in the
data by the absence or presence of an escape byte before
it.
The data link layer on the receiving end removes the
escape bytes before giving the data to the network layer.
This technique is called byte stuffing.
Framing – Byte stuffing
The byte-stuffing scheme depicted is a slight simplification of
the one used in PPP (Point-to-Point Protocol), which is
used to carry packets over communications links.
Frame
format
Need to escape
extra ESCAPE
bytes too!
Stuffing
examples
Framing – Bit stuffing
The third method of delimiting the bit stream gets around a
disadvantage of byte stuffing, which is that it is tied to the use
of 8-bit bytes.
Framing can be also be done at the bit level, so frames can
contain an arbitrary number of bits made up of units of any
size.
It was developed for the once very popular HDLC (Highlevel
Data Link Control) protocol.
Each frame begins and ends with a special bit pattern,
01111110 or 0x7E in hexadecimal.
This pattern is a flag byte.
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.
If the user data contain the flag pattern, 01111110, this flag is transmitted
as 011111010 but stored in the receiver’s memory as 01111110.
•With bit stuffing, the boundary between two frames can
be unambiguously recognized by the flag pattern.
•Thus, if the receiver loses track of where it is, all it has
to do is scan the input for flag sequences, since they
can only occur at frame boundaries and never within the
data.
Framing – Bit stuffing
Data bits
Transmitted bits
with stuffing
Coding Violations
•The last method of framing is to use a shortcut from the physical
layer.
•This redundancy means that some signals will not occur in regular
data.
•For example, in the 4B/5B line code 4 data bits are mapped to 5
signal bits to ensure sufficient bit transitions.
•We can use some reserved signals to indicate the start and end of
frames. In effect, we are using ‘‘coding violations’’ to delimit frames.
• The beauty of this scheme is that, because they are reserved signals,
it is easy to find the start and end of frames and there is no need to
stuff the data.
Error Control
•The usual way to ensure reliable delivery is to provide the sender with
some feedback about what is happening at the other end of the line.
Typically, the protocol calls for the receiver to send back special control
frames bearing positive or negative acknowledgements about the
incoming frames.
•However, if either the frame or the acknowledgement is lost, the timer will
go off, alerting the sender to a potential problem.
•The obvious solution is to just transmit the frame again. However, when
frames may be transmitted multiple times 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.
• This situation can occur when the sender is running on a fast, powerful
computer and the receiver is running on a slow, low-end machine.
•In the first one, feedback-based flow control, the receiver sends
back information to the sender giving it permission to send more data, or
at least telling the sender how the receiver is doing.
In the second one, rate-based flow control, the protocol has a built-
in mechanism that limits the rate at which senders may transmit data,
without using feedback from the receiver.
Error Detection and Correction
•In a block code, the r check bits are computed solely as a function
of the m data bits with which they are associated, as though the m bits
were looked up in a large table to find their corresponding r check bits.
•In a systematic code, the m data bits are sent directly, along with the
check bits, rather than being encoded themselves before they are sent.
In a linear code, the r check bits are computed as a linear function of
the m data bits. Exclusive OR (XOR) or modulo 2 addition is a popular
choice.
•This means that encoding can be done with operations such as matrix
multiplications or simple logic circuits.
•Let the total length of a block be n (i.e., n = m + r). We will
describe this as an (n,m) code.
•An n-bit unit containing data and check bits is referred to as
an n bit codeword.
•The code rate, or simply rate, is the fraction of the
codeword that carries information that is not redundant, or
m/n.
•The rates used in practice vary widely.
•They might be 1/2 for a noisy channel, in which case half of
the received information is redundant, or close to 1 for a high-
quality channel, with only a small number of check bits added
to a large message.
It is necessary to first look closely at what an error really is.
Given any two codewords 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 codewords differ is called the
Hamming distance (Hamming, 1950).
•This code has a distance of 5, which means that it can correct double
errors or detect quadruple errors.
(11, 7) Hamming code adds 4 check bits and can correct 1 error
Error Correction – Convolutional codes
…111 … 0 1 1
1 0 1
Properties:
• Improved error detection over parity bits
• Detects bursts up to N errors
• Detects random errors with probability 1-2N
• Vulnerable to systematic errors, e.g., added zeros
Error Detection – CRCs (1)
Adds bits so that transmitted frame viewed as a polynomial
is evenly divisible by a generator polynomial
Start by adding
0s to frame
and try dividing
Sender waits to for ack after Receiver sends ack after passing
passing frame to physical layer frame to network layer
Stop-and-Wait – Noisy channel (1)
Sender
Receiver
...
One-Bit Sliding Window (2)
...
Wait for frame or timeout
Time
Notation is (seq, ack, frame number). Asterisk indicates frame accepted by network layer .
Chapter 3