Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Data Link Control: B. R. Chandavarkar CSE Dept., NITK Surathkal

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 37

Data Link Control

B. R. Chandavarkar
CSE Dept., NITK
Surathkal
• The two main functions of the data link layer are data link
control and media access control.
• The first, data link control, deals with the design and
procedures for communication between two adjacent nodes:
node-to-node communication.
• Data link control functions include framing, flow and error
control, and software implemented protocols that provide
smooth and reliable transmission of frames between nodes.
• To implement data link control, we need protocols.
• Each protocol is a set of rules that need to be implemented in
software and run by the two nodes involved in data exchange
at the data link layer.
• We discuss five protocols: two for noiseless (ideal) channels
and three for noisy (real) channels.
Framing
• The data link layer, on the other hand, needs to pack bits
into frames, so that each frame is distinguishable from
another.
• Framing in the data link layer separates a message from one
source to a destination, or from other messages to other
destinations, by adding a sender address and a destination
address.
• The destination address defines where the packet is to go;
the sender address helps the recipient acknowledge the
receipt.
• Although the whole message could be packed in one frame,
that is not normally done. One reason is that a frame can be
very large, making flow and error control very inefficient.
When a message is carried in one very large frame, even a
single-bit error would require the retransmission of the
whole message. When a message is divided into smaller
frames, a single-bit error affects only that small frame.
• Frames can be of fixed or variable size.
• In fixed-size framing, there is no need for defining the
boundaries of the frames; the size itself can be used as a
delimiter.
• An example of this type of framing is the ATM
(Asynchronous Transfer Mode) wide-area network, which
uses frames of fixed size called cells.
• In variable-size framing, we need a way to define the end of
the frame and the beginning of the next.
• Historically, two approaches were used for this purpose: a
character-oriented approach and a bit-oriented approach.
Character-Oriented Protocols
• In a character-oriented protocol, data to be carried are 8-bit
characters from a coding system such as ASCII.
• The header, which normally carries the source and
destination addresses and other control information, and the
trailer, which carries error detection or error correction
redundant bits, are also multiples of 8 bits.
• To separate one frame from the next, an 8-bit (1-byte) flag is
added at the beginning and the end of a frame.
• The flag, composed of protocol-dependent special characters,
signals the start or end of a frame.
• Character-oriented framing was popular when only text was
exchanged by the data link layers.
• The flag could be selected to be any character not used for text
communication.
• Now, however, we send other types of information such as graphs,
audio, and video. Any pattern used for the flag could also be part
of the information.
• If this happens, the receiver, when it encounters this pattern in
the middle of the data, thinks it has reached the end of the frame.
• To fix this problem, a byte-stuffing strategy was added to
character-oriented framing.
• In byte stuffing (or character stuffing), a special byte is added to
the data section of the frame when there is a character with the
same pattern as the flag.
• The data section is stuffed with an extra byte. This byte is usually
called the escape character (ESC), which has a predefined bit
pattern.
• Whenever the receiver encounters the ESC character, it removes
it from the data section and treats the next character as data, not
a delimiting flag.
Bit-Oriented Protocols
• In a bit-oriented protocol, the data section of a frame is a
sequence of bits to be interpreted by the upper layer as text,
graphic, audio, video, and so on.
• However, in addition to headers (and possible trailers), we
still need a delimiter to separate one frame from the other.
• Most protocols use a special 8-bit pattern flag 01111110 as
the delimiter to define the beginning and the end of the
frame.
• That is, if the flag pattern appears in the data, we need to
somehow inform the receiver that this is not the end of the
frame.
• We do this by stuffing 1 single bit (instead of 1 byte) to
prevent the pattern from looking like a flag. The strategy is
called bit stuffing.
• In bit stuffing, if a 0 and five consecutive 1 bits are
encountered, an extra 0 is added. This extra stuffed bit is
eventually removed from the data by the receiver.
• Note that the extra bit is added after one 0 followed by five
1s regardless of the value of the next bit.
• This guarantees that the flag field sequence does not
inadvertently appear in the frame.
Flow and Error Control
• The most important responsibilities of the data link layer
are flow control and error control. Collectively, these
functions are known as data link control.
Flow Control
• Flow control coordinates the amount of data that can be sent
before receiving an acknowledgment and is one of the most
important duties of the data link layer.
• In most protocols, flow control is a set of procedures that
tells the sender how much data it can transmit before it
must wait for an acknowledgment from the receiver.
• The flow of data must not be allowed to overwhelm the
receiver.
• Any receiving device has a limited speed at which it can
process incoming data and a limited amount of memory in
which to store incoming data.
• Error control in the data link layer is often implemented
simply: Any time an error is detected in an exchange,
specified frames are retransmitted. This process is called
automatic repeat request (ARQ).
Simplest Protocol
Stop-and-Wait Protocol
Stop-and-Wait ARQ Protocol
• Assume that, in a Stop-and-Wait ARQ system, the
bandwidth of the line is 1 Mbps, and 1 bit takes 20 ms to
make a round trip. What is the bandwidth-delay product? If
the system data frames are 1000 bits in length, what is the
utilization percentage of the link?
• The bandwidth-delay product is 20,000 bits during the time
it takes for the data to go from the sender to the receiver and
then back again. However, the system sends only 1000 bits.
We can say that the link utilization is only 1000/20,000, or 5
percent. For this reason, for a link with a high bandwidth or
long delay, the use of Stop-and-Wait ARQ wastes the
capacity of the link.
Sliding Window on Sender

Sliding Window on Receiver

LAR – Last Acknowledgment Received


LFS – Last Frame Sent
SWS – Send Window Size
LFR – Last Frame Received
LAF – Largest Acceptable Frame
RWS – Receive Window Size
• When a frame with sequence number SeqNum arrives, the
receiver takes the following action.
– If SeqNum ≤ LFR or SeqNum > LAF, then the frame is outside the
receiver’s window and it is discarded.
– If LFR < SeqNum ≤ LAF, then the frame is within the receiver’s
window and it is accepted.
• Now the receiver needs to decide whether or not to send an
ACK.
• Let SeqNumToAck denote the largest sequence number not
yet acknowledged, such that all frames with sequence
numbers less than or equal to SeqNumToAck have been
received. The receiver acknowledges the receipt of
SeqNumToAck, even if higher-numbered packets have been
received.
• This acknowledgment is said to be cumulative.
• It then sets LFR = SeqNumToAck and adjusts LAF = LFR +
RWS.
• Example:
• Suppose LFR = 5 (i.e., the last ACK the receiver sent was for
sequence number 5), and RWS = 4. This implies that LAF =
9.
• Should frames 7 and 8 arrive, they will be buffered because
they are within the receiver’s window. However, no ACK
needs to be sent since frame 6 is yet to arrive. Frames 7 and
8 are said to have arrived out of order. (Technically, the
receiver could resend an ACK for frame 5 when frames 7 and
8 arrive.)
• Should frame 6 then arrive—perhaps it is late because it was
lost the first time and had to be retransmitted, or perhaps it
was simply delayed—the receiver acknowledges frame 8,
bumps LFR to 8, and sets LAF to 12.
• If frame 6 was in fact lost, then a timeout will have occurred
at the sender, causing it to retransmit frame 6.
• Issue:
– We observe that when a timeout occurs, the amount of data in transit
decreases, since the sender is unable to advance its window until
frame 6 is acknowledged. This means that when packet losses occur,
this scheme is no longer keeping the pipe full. The longer it takes to
notice that a packet loss has occurred, the more severe this problem
becomes.
• Solution:
– The receiver could have sent a negative acknowledgment (NAK) for
frame 6 as soon as frame 7 arrived.
– It would have been legitimate to send additional acknowledgments of
frame 5 when frames 7 and 8 arrived;
– In some cases, a sender can use duplicate ACKs as a clue that a
frame was lost.
– Selective Acknowledgments-The receiver could acknowledge the
receipt of frames 7 and 8. Giving more information to the sender
makes it potentially easier for the sender to keep the pipe full, but
adds complexity to the implementation.
• Design (Sliding Window on Sender and Receiver):
– The sending window size is selected according to how
many frames we want to have outstanding on the link at
a given time; SWS is easy to compute for a given delay×
bandwidth product.
– On the other hand, the receiver can set RWS to whatever
it wants.
– Two common settings are RWS = 1, which implies that
the receiver will not buffer any frames that arrive out of
order, and RWS = SWS, which implies that the receiver
can buffer any of the frames the sender transmits.
– It makes no sense to set RWS > SWS since it’s impossible
for more than SWS frames to arrive out of order.
Go-Back –N ARQ Protocol
• Sliding Window
• Selective Repeat ARQ
• Station A needs to send a message consisting of 9 frames to
Station B using a sliding window (window size 3) and go-
back-n error control strategy. All packets are ready and
immediately available for transmission. If every 5th frame
that A transmits gets lost (but no acks from B ever get lost),
then what is the number of frames that A will transmit for
sending the message to B? Justify your answer with the
timing diagram.
• Window size is 3, so maximum 3 frames can be remained
unacknowledged. In go back ‘n’ if acknowledge for a frame is
not received then frames after that frame is also
retransmitted. Frame sequence for 9 frame is shown below.
1234567567897899

You might also like