0% found this document useful (0 votes)
19 views74 pages

Design Issue

Uploaded by

kalepriyaramani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views74 pages

Design Issue

Uploaded by

kalepriyaramani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Unit 3:Part 1 Data Link Control

Data Link Layer: Data link layer Design Issues,


Framing, Error Detection and Correction,
Flow Control, Sliding Window Protocols
DATA LINK LAYER DESIGN ISSUES
THE DATA LINK LAYER Design issues
• 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:
– 1. Providing a well-defined service interface to the network
layer.
– 2. Dealing with transmission errors.
– 3. Regulating the flow of data so that slow receivers are not
swamped by fast senders.
Design issues
• The data link layer takes the packets it gets from the network layer and
encapsulates them into frames for transmission.
• Each frame contains a frame header, a payload field for holding the packet,
and a frame trailer
Services Provided to the Network Layer
• The job of the data link layer is to transmit the bits received from
network layer to the destination machine so they can be handed over to
the network layer
Design issues

• The data link layer can be designed to offer


various services.
– 1. Unacknowledged connectionless service.
– 2. Acknowledged connectionless service.
– 3. Acknowledged connection-oriented service.
Unacknowledged connectionless service
• Unacknowledged connectionless service consists of having the source machine
send independent frames to the destination machine without having the
destination machine acknowledge them.
• Ethernet is a good example of a data link layer that provides this class of service.
– No logical connection is established beforehand or released afterward.
– 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.
• It is also appropriate for real-time traffic, such as voice, in which late data are
worse than bad data.
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 received
correctly or been lost.
• If it has not arrived within a specified time interval, it can be sent
again.
• This service is useful over unreliable channels, such as wireless
systems. 802.11 (WiFi) is a good example of this class of service.
Some issues A B
C
• What if ACK is lost?
• Should we give ACK frame to received ACK
frame again to inform ACK received?
– If yes how long we should do it?
• It is mirror in front of mirror
– If No then what we should do for lost ACK?
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.
• Furthermore, 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.
• It is appropriate over long, unreliable links such as a satellite channel or a long-distance
telephone circuit.
• If acknowledged connectionless service were used, it is conceivable that lost
acknowledgements could cause a frame to be sent and received several times, wasting
bandwidth.
connection-oriented service cont.
• When connection-oriented service is used, transfers go through
three distinct phases.
• In the first phase, the connection is established by having both
sides initialize variables and counters needed to keep track of
which frames have been received and which ones have not.
• In the second phase, one or more frames are actually transmitted.
• In the third and final phase, the connection is released, freeing up
the variables, buffers, and other resources used to maintain the
connection.
Marking the start and end of each frame

FRAMING
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.
• 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 takes steps to deal with it (e.g., discarding the bad frame and
possibly also sending back an error report).
Framing cont.
• A good design must make it easy for a receiver
to find the start of new frames while using little
of the channel bandwidth.
– 1. Byte count.
– 2. Flag_bytes with byte stuffing.
– 3. Flag_bits with bit stuffing.
– 4. Physical layer coding violations.
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.
Byte count

• For example, if the byte count of 5 in the second frame of Fig. (b)
becomes a 7 due to a single bit flip, the destination will get out of
synchronization.
• It will then be unable to locate the correct start of the next frame.
• Even if the checksum is incorrect so the destination knows that the
frame is bad, it still has no way of telling where the next frame starts.
• Sending a frame back to the source asking for a retransmission does
not help either, since the destination does not know how many bytes
to skip over to get to the start of the retransmission.
• For this reason, the byte count method is rarely used by itself.
Flag bytes with byte stuffing
• Each frame start and end with special bytes called a
flag byte 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.
Byte stuffing
• 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.
• Thus, 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.
a) A frame delimited by flag bytes
b) Four examples of byte sequences before and after byte stuffing.
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 (High level 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.
Bit stuffing cont.
• When ever the sender’s data link layer encounters five consecutive 1s in the data, it automatically
stuffs a 0 bit into the outgoing bit stream.
• This bit stuffing is analogous to byte stuffing, in which an escape byte is stuffed into the outgoing
character stream before a flag byte in the data.
• It also ensures a minimum density of transitions that help the physical layer maintain
synchronization.
• USB (Universal Serial Bus) uses bit stuffing for this reason.

(a) The original data.


(b) The data as they appear on the
line.
(c) The data as they are stored in
the receiver’s memory after
de-stuffing.
Drawbacks
• The length of a frame now depends on the
contents of the data it carries (consecutive 1s
in bit stream shall add 0s and there by frame
length shall be increased).
• With bit stuffing, the increase would be
roughly 12.5% as 1 bit is added to every byte.
Preamble
• A common pattern used for Ethernet and 802.11 is to have
a frame begin with a well-defined pattern called a
preamble.
• This pattern might be quite long (72 bits is typical for
802.11) to allow the receiver to prepare for an incoming
packet.
• The preamble is then followed by a length (i.e., count) field
in the header that is used to locate the end of the frame.
what to do with a sender that systematically wants to transmit frames
faster than the receiver can accept them?

FLOW CONTROL
ACK-NACK from receiver
• To ensure reliable delivery is to provide the sender with some
feedback about what is happening at the other end of the line.
• The protocol calls 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.
Some issues
• An additional complication comes from the possibility that hardware
troubles may cause a frame to vanish completely (e.g., in a noise burst).
• In this case, the receiver will not react at all, since it has no reason to
react.
• Similarly, if the acknowledgement frame is lost, the sender will not
know how to proceed.
• It should be clear that a protocol in which the sender transmits a frame
and then waits for an acknowledgement, positive or negative, will hang
forever if a frame is ever lost due to, for example, malfunctioning
hardware or a faulty communication channel.
Solution: Timer
• When the sender transmits a frame, it generally also 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.
• Normally, 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.
Problem: Duplicate 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.
Solution: Sequence No.
• To prevent this from happening, it is generally
necessary to assign sequence numbers to outgoing
frames, so that the receiver can distinguish
retransmissions from originals.
• The whole issue of managing the timers and sequence
numbers so as to ensure that each frame is ultimately
passed to the network layer at the destination exactly
once
Problem
• Even if the transmission is error free, the
receiver may be unable to handle the frames
as fast as they arrive and will lose some.
Solution: Flow control
a. 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 (at Data link Layer).
b. 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.(as part of the transport layer)
A Simplex Stop-and-Wait Protocol for an Error-Free Channel

• The communication channel is assumed to be error free, however, and the


data traffic is still simplex.
• After having passed a packet to its network layer, the receiver sends a little
dummy frame back to the sender which, in effect, gives the sender
permission to transmit the next frame.
• After having sent a frame, the sender is required by the protocol to bide its
time until the little dummy (i.e., acknowledgement) frame arrives. This delay
in sending dummy frame is a simple example of a flow control protocol.
• Protocols in which the sender sends one frame and then waits for an
acknowledgement before proceeding are called stop-and-wait.
A Simplex Stop-and-Wait Protocol for a Noisy Channel N

• Assume communication channel that makes errors


• The sender could send a frame, but the receiver would only send an
acknowledgement frame if the data were correctly received.
• If a damaged frame arrived at the receiver, it would be discarded.
• After a while the sender would time out and send the frame again.
• This process would be repeated until the frame finally arrived intact.
• Protocols in which the sender sends one
frame and then waits (using timer) for an
acknowledgement before proceeding are
called stop-and-wait.
• Retransmit after timer expires
• What if ACK is lost?
• 1. 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.
• 2. The acknowledgement frame gets lost completely. It just
never arrives at all.
• 3. 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.
• 4. The duplicate frame also arrives intact at the data link layer on B
and is unintentionally 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). In other words, the protocol will fail.
• 5. The obvious way to achieve this is to have 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.
• A 1-bit sequence number (0 or 1) is sufficient.
Piggybacking: better use of the available channel
bandwidth
• In most practical situations, there is a need to transmit data in both directions.
• Each link is then comprised of a ‘‘forward’’ channel (for data) and a ‘‘reverse’’
channel (for acknowledgements).
• When a data frame arrives, instead of immediately sending a separate control
frame, the receiver restrains itself and waits until the network layer passes it the
next packet.
• The acknowledgement is attached to the outgoing data frame (using the ack field
in the frame header).
• The technique of temporarily delaying outgoing acknowledgements so that they
can be hooked onto the next outgoing data frame is known as piggybacking.
Advantage
• 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.
issues
• How long should the data link layer wait for a
packet onto which to piggyback the
acknowledgement?
• If the data link layer waits longer than the
sender’s timeout period, the frame will be
retransmitted, defeating the whole purpose of
having acknowledgements.
Sliding window protocol
• It is a bidirectional flow control protocol
• Each outbound (Out going) frame contains a
sequence number, ranging from 0 up to some
maximum.
• The maximum is usually 2n − 1 so the sequence
number fits exactly in an n-bit field
• 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.
Pointer
• In some protocols both window sizes are fixed, but in others they can grow
(open) or shrink (close) over the course of time as frames are sent and
received.
• physical communication channel is ‘‘wire-like,’’ that is, it must deliver all frames
in the order sent.
• window represent frames that have been sent or can be sent but are as yet not
acknowledged
• Lower
When anmoves
edge acknowledgement
right comes in, the lower edge is advanced by one.
when ACK received
Upper edge
moves right
when frame is
sent
Window
opened by
1 due to
packet
transmit
with out
Ack

Window Window
opened closed by
by 2 1 due to
receipt of
Ack for
packet 0

• Circular sliding window


• Linear sliding window
Go-Back-N Protocol
• To improve the efficiency of transmission (fill
the pipe), multiple packets must be in
transition while the sender is waiting for
acknowledgment.
– In other words, we need to let more than one
packet be outstanding to keep the channel busy
while the sender is waiting for acknowledgment.
• The key to Go-back-N is that we can send several packets before
receiving acknowledgments, but the receiver can only buffer one packet.
• We keep a copy of the sent packets until the acknowledgments arrive.
• Acknowledgment number in this protocol is
cumulative/ increases and defines the sequence
number of the next packet expected.
• For example, if the acknowledgment number (ackNo)
is 7, it means all packets with sequence number upto
6 have arrived, safe and sound, and the receiver is
expecting the packet with sequence number 7.
• The send window is an imaginary box covering the sequence numbers
of the data packets that can be in transit or can be sent.
• In each window position, some of these sequence numbers define the
packets that have been sent; others define those that can be sent.

• Sf :send window, the first


outstanding packet
• Sn: send window, the next packet to
be sent
• Ssize: send window, size
Why window
slided?
Receive Window
• The receiver is always looking for the arrival of a
specific packet.
• Any packet arriving out of order is discarded and
needs to be resent.
• Note that we need only one variable Rn (receive
window, next packet expected) to define this
abstraction.
• The sequence numbers to the left of the window belong to the packets
already received and acknowledged; the sequence numbers to the right
of this window define the packets that cannot be received.
– Any received packet with a sequence number in these two regions is discarded.
– Only a packet with a sequence number matching the value of Rn is accepted and
acknowledged.
– The receive window also slides, but only one slot at a time.

Receiver side
Timers
• Although there can be a timer for each packet
that is sent, in our protocol we use only one.
• The reason is that the timer for the first
outstanding packet always expires first.
• We resend all outstanding packets when this
timer expires.
Resending packets
• When the timer expires, the sender resends all outstanding
packets. For example, suppose the sender has already sent packet
6 (Sn, Next packet to be sent = 7), but the only timer expires.
• If Sf, firtst sent packet = 3, this means that packets 3, 4, 5, and 6
have not been acknowledged; the sender goes back and resends
packets 3, 4, 5, and 6.
• That is why the protocol is called Go-Back-N.
• On a time-out, the machine goes back N locations and resends all
packets.
ERROR DETECTION AND CORRECTION

ERROR CONTROL
• While transmitting the data errors occurs due to noise
• Two basic strategies for dealing with errors
1. Include enough redundant information to enable the receiver to deduce
what the transmitted data must have been using error-correcting codes.
– Used for (unreliable) wireless channel
– particularly for real-time media
2. Enough redundancy to allow the receiver to detect that an error has
occurred, using error-detecting codes
– Used in reliable channel (Optical fiber, Coaxial cables, STP, UTP )
– commonly used in link, network (to detect error in header), and transport layers (to
detect errors in pay load ie data)
Error-Correcting Codes
1. Hamming codes.
2. Binary convolutional codes.
3. Reed-Solomon codes.
4. Low-Density Parity Check codes.
• All of these codes add redundancy to the information that
is sent.
• A frame consists of m data (i.e., message) bits and r
redundant (i.e. check) bits.
Error-Detecting Codes
1. Parity: a single parity bit is appended to the
data
2. Checksums.
3. Cyclic Redundancy Checks (CRCs).
• The parity bit is chosen so that the number of 1 bits in the
codeword is even (or odd).
• Doing this is equivalent to computing the (even) parity bit as the
modulo 2 sum or XOR of the data bits.
• For example, when 1011010 is sent in even parity, a bit is added
to the end to make it 10110100.
• With odd parity 1011010 becomes 10110101.
• One difficulty with this scheme is that a single parity bit can only
reliably detect a single-bit error in the block.
• we can compute the parity bits over the data in a different order than the order
in which the data bits are transmitted. Doing so is called interleaving
• This transmission order is shown in Fig. for n = 7 and k = 7.
• n= parity bits, k= no. of n bit words

Computed parity at
receiver

Miss
1000000
Received parity match
bits Error Detected
• In Fig. when a burst error of length n=7occurs, the bits that are in
error are spread across different columns.
• (A burst error does not imply that all the bits are wrong; it just
implies that at least the first and last are wrong.
• In Fig. four bits were flipped over a range of 7 bits.)
• At most 1bit in each of then columns will be affected, so the parity
bits on those columns will detect the error.
• This method uses n parity bits on blocks of k*n data bits to detect
a single burst error of length n or less.
checksum
• The checksum is usually placed at the end of the
message, as the complement of the sum function.
• Errors may be detected by summing the entire
received code word, both data bits and checksum.
• If the result comes out to be zero, no error has
been detected.
modulo 2 arithmetic
• Polynomial arithmetic is done modulo 2
• It does not have carries for addition or borrows for subtraction.
• Both addition and subtraction are identical to exclusive OR
Example of checksum
• 1100 • 1100
Modulo 2 sum
• 1010 transmitted along • 1010
with data
• 1110 • 1110
Modulo 2 sum
• 1101 received along • 1101
with data
• 0101 • 0101 All zeros,
Modulo 2 sum No error in
along with data
and received
• 0000 received
data

check sum
Example of checksum
• 1100 • 1100
Modulo 2 sum
• 1010 transmitted along • 1000
with data
• 1110 • 1110
Modulo 2 sum
• 1101 received along • 1101
with data
• 0101 • 0101 No all
zeros,
Modulo 2 sum error in
along with data
and received
• 0010 received
data
check sum
Cyclic Redundancy Check
• The sender and receiver must agree upon a generator polynomial, G(x), in
advance.
• Both the high- and low order bits of the generator polynomial 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 checksummed frame is divisible by G(x).
• When the receiver gets the checksummed frame, it tries dividing it by G(x).
• If there is a remainder, there has been a transmission error.
G(x)= x4+x1+x0=10011, r=4
• The algorithm for computing the CRC is as follows:
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
M(x).
2. Divide the bit string corresponding to G(x) into the bit string
corresponding to M(x), using modulo 2 division.
3. Subtract the remainder (which is always r or fewer bits) from the bit
string corresponding to M(x) using modulo 2 subtraction.
• The result is the check-summed frame to be transmitted.
• Call it a polynomial T(x).
• Upon receiving the check-summed frame, the
receiver divides it by G(x); that is, it computes
[T(x) + E(x)]/G(x).
– E(X) is an error vector, T(X): original data
• T(x)/G(x) is 0, so the result of the computation
is simply E(x)/G(x).
modulo 2 arithmetic
• Polynomial arithmetic is done modulo 2
• It does not have carries for addition or borrows for subtraction.
• Both addition and subtraction are identical to exclusive OR
G(x)

Being degree of
G(x) is 4

Frame with 4 bit reminder


appended to data
Zero reminder, No error

You might also like