0% found this document useful (0 votes)
32 views11 pages

cnnnNOTES 4

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

cnnnNOTES 4

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

UNIT- II

DATA LINK LAYER FUNCTIONS (SERVICES)


1. Providing services to the network layer:
1 Unacknowledged connectionless service.
Appropriate for low error rate and real-time traffic. Ex: Ethernet
2. Acknowledged connectionless service.
Useful in unreliable channels, WiFi. Ack/Timer/Resend
3. Acknowledged connection-oriented service.
Guarantee frames are received exactly once and in the right order.
Appropriate over long, unreliable links such as a satellite channel or a long-
distance telephone circuit
2. Framing: Frames are the streams of bits received from the network layer
into manageable data units. This division of stream of bits is done by Data
Link Layer.
3. Physical Addressing: The Data Link layer adds a header to the frame in
order to define physical address of the sender or receiver of the frame, if
the frames are to be distributed to different systems on the network.
4. Flow Control: A receiving node can receive the frames at a faster rate
than it can process the frame. Without flow control, the receiver's buffer
can overflow, and frames can get lost. To overcome this problem, the data
link layer uses the flow control to prevent the sending node on one side of
the link from overwhelming the receiving node on another side of the link.
This prevents traffic jam at the receiver side.
5. Error Control: Error control is achieved by adding a trailer at the end of
the frame. Duplication of frames are also prevented by using this
mechanism. Data Link Layers adds mechanism to prevent duplication of
frames.
Error detection: Errors can be introduced by signal attenuation and noise.
Data Link Layer protocol provides a mechanism to detect one or more
errors. This is achieved by adding error detection bits in the frame and then
receiving node can perform an error check.
Error correction: Error correction is similar to the Error detection, except
that receiving node not only detects the errors but also determine where
the errors have occurred in the frame.
6. Access Control: Protocols of this layer determine which of the devices has
control over the link at any given time, when two or more devices are
connected to the same link.
7. Reliable delivery: Data Link Layer provides a reliable delivery service,
i.e., transmits the network layer datagram without any error. A reliable
delivery service is accomplished with transmissions and
acknowledgements. A data link layer mainly provides the reliable delivery
service over the links as they have higher error rates and they can be
corrected locally, link at which an error occurs rather than forcing to
retransmit the data.
8. Half-Duplex & Full-Duplex: In a Full-Duplex mode, both the nodes can
transmit the data at the same time. In a Half-Duplex mode, only one node
can transmit the data at the same time.

FRAMING:
To provide service to the network layer, the data link layer must use the
service provided to it by the physical layer. What the physical layer does is
accept a raw bit stream and attempt to deliver it to the destination. This bit
stream is not guaranteed to be error free. The number of bits received may be
less than, equal to, or more than the number of bits transmitted, and they
may have different values. 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 the bit stream up into discrete frames and compute the checksum for
each frame (framing). 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).We will look at four framing
methods:
1. Character count.
2. Flag bytes with byte stuffing.
3. Starting and ending flags, with bit stuffing.
4. Physical layer coding violations.
Character count 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. This technique is shown in Fig. (a) For four frames of sizes 5, 5,
8, and 8 characters, respectively.
A character stream. (a) Without errors. (b) With one error
The trouble with this algorithm is that the count can be garbled by a
transmission error. For example, if the character count of 5 in the second
frame of Fig. (b) becomes a 7, the destination will get out of synchronization
and will be unable to locate the 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 characters to skip over to get to the start of the
retransmission. For this reason, the character count method is rarely used
anymore.

Flag bytes with byte stuffing method gets around the problem of
resynchronization after an error by having each frame start and end with
special bytes. In the past, the starting and ending bytes were different, but in
recent years most protocols have used the same byte, called a flag byte, as
both the starting and ending delimiter, as shown in Fig. (a) as FLAG. In this
way, if the receiver ever loses synchronization, it can just search for the flag
byte to find the end of the current frame. Two consecutive flag bytes indicate
the end of one frame and start of the next one.

(a) A frame delimited by flag bytes (b) Four examples of byte sequences
before and after byte stuffing

It may easily happen that the flag byte's bit pattern occurs in the data.
This situation will usually 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. The data link layer
on the receiving end removes the escape byte before the data are given to
the network layer. This technique is called byte stuffing or character stuffing.
Thus, a framing flag byte can be distinguished from one in the data by the
absence or presence of an escape byte before it.
What happens if an escape byte occurs in the middle of the data? The
answer is that, it too is stuffed with an escape byte. Thus, any single escape
byte is part of an escape sequence, whereas a doubled one indicates that a
single escape occurred naturally in the data. Some examples are shown in
Fig. (b). In all cases, the byte sequence delivered after de stuffing is exactly
the same as the original byte sequence.
A major disadvantage of using this framing method is that it is closely
tied to the use of 8-bit characters. Not all character codes use 8-bit
characters. For example UNICODE uses 16-bit characters, so a new technique
had to be developed to allow arbitrary sized characters
Starting and ending flags, with bit stuffing allows data frames to
contain an arbitrary number of bits and allows character codes with an arbitrary
number of bits per character. It works like this. Each frame begins and ends
with a special bit pattern, 01111110 (in fact, 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. 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.
When the receiver sees five consecutive incoming 1 bits, followed by a 0 bit,
it automatically de- stuffs (i.e., deletes) the 0 bit. Just as byte stuffing is
completely transparent to the network layer in both computers, so is bit
stuffing. If the user data contain the flag pattern, 01111110, this flag is
transmitted as 011111010 but stored in the receiver's memory as 01111110.

Fig:Bit stuffing. (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 destuffing.
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.
Physical layer coding violations method of framing is only applicable to
networks in which the encoding on the physical medium contains some
redundancy. For example, some LANs encode 1 bit of data by using 2 physical
bits. Normally, a 1 bit is a high-low pair and a 0 bit is a low-high pair. The
scheme means that every data bit has a transition in the middle, making it
easy for the receiver to locate the bit boundaries. The combinations high-
high and low-low are not used for data but are used for delimiting frames in
some protocols.

As a final note on framing, many data link protocols use combination of a


character count with one of the other methods for extra safety. When a frame
arrives, the count field is used to locate the end of the frame. Only if the
appropriate delimiter is present at that position and the checksum is correct is
the frame accepted as valid. Otherwise, the input stream is scanned for the
next delimiter

ELEMENTARY DATA LINK PROTOCOLS

Simplest Protocol
It is very simple. The sender sends a sequence of frames without even thinking
about the receiver. Data are transmitted in one direction only. Both sender &
receiver always ready. Processing time can be ignored. Infinite buffer space is
available. And best of all, the communication channel between the data link
layers never damages or loses frames. This thoroughly unrealistic protocol,
which we will nickname ‘‘Utopia,’’ .The utopia protocol is unrealistic because it
does not handle either flow control or error correction
Stop-and-wait Protocol

It is still very simple. The sender sends one frame and waits for feedback from
the receiver. When the ACK arrives, the sender sends the next frame
It is Stop-and-Wait Protocol because the sender sends one frame, stops until it
receives confirmation from the receiver (okay to go ahead), and then sends
the next frame. We still have unidirectional communication for data frames,
but auxiliary ACK frames (simple tokens of acknowledgment) travel from the
other direction. We add flow control to our previous protocol.

NOISY CHANNELS
Although the Stop-and-Wait Protocol gives us an idea of how to add flow
control to its predecessor, noiseless channels are nonexistent. We can ignore
the error (as we sometimes do), or we need to add error control to our
protocols. We discuss three protocols in this section that use error control.
Sliding Window Protocols:
1 Stop-and-Wait Automatic Repeat
Request

2 Go-Back-N Automatic Repeat


Request

3 Selective Repeat Automatic Repeat Request

1 Stop-and-Wait Automatic Repeat Request


To detect and correct corrupted frames, we need to add redundancy bits
to our data frame. When the frame arrives at the receiver site, it is checked
and if it is corrupted, it is silently discarded. The detection of errors in this
protocol is manifested by the silence of the receiver.
Lost frames are more difficult to handle than corrupted ones. In our
previous protocols, there was no way to identify a frame. The received frame
could be the correct one, or a duplicate, or a frame out of order. The solution is
to number the frames. When the receiver receives a data frame that is out of
order, this means that frames were either lost or duplicated
The lost frames need to be resent in this protocol. If the receiver does not
respond when there is an error, how can the sender know which frame to
resend? To remedy this problem, the sender keeps a copy of the sent frame. At
the same time, it starts a timer. If the timer expires and there is no ACK for the
sent frame, the frame is resent, the copy is held, and the timer is restarted.
Since the protocol uses the stop-and-wait mechanism, there is only one
specific frame that needs an ACK
Error correction in Stop-and-Wait ARQ is done by keeping a copy of the sent
frame and retransmitting of the frame when the timer expires

In Stop-and-Wait ARQ, we use sequence numbers to number the


frames. The sequence numbers are based on modulo-2 arithmetic.

In Stop-and-Wait ARQ, the acknowledgment number always announces


in modulo-2 arithmetic the sequence number of the next frame
expected.
Bandwidth Delay Product:
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 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.

2. Go-Back-N Automatic Repeat Request

To improve the efficiency of transmission (filling the pipe), multiple


frames must be in transition while waiting for acknowledgment. In other
words, we need to let more than one frame be outstanding to keep the
channel busy while the sender is waiting for acknowledgment.
The first is called Go-Back-N Automatic Repeat. In this protocol we can
send several frames before receiving acknowledgments; we keep a copy of
these frames until the acknowledgments arrive.
In the Go-Back-N Protocol, the sequence numbers are modulo 2 m,
where m is the size of the sequence number field in bits. The sequence
numbers range from 0 to 2 power m- 1. For example, if m is 4, the only
sequence numbers are 0 through 15 inclusive.

The sender window at any time divides the possible sequence numbers
into four regions.
The first region, from the far left to the left wall of the window, defines
the sequence numbers belonging to frames that are already acknowledged.
The sender does not worry about these frames and keeps no copies of them.
The second region, colored in Figure (a), defines the range of sequence
numbers belonging to the frames that are sent and have an unknown status.
The sender needs to wait to find out if these frames have been received or
were lost. We call these outstanding frames.
The third range, white in the figure, defines the range of sequence
numbers for frames that can be sent; however, the corresponding data
packets have not yet been received from the network layer.
Finally, the fourth region defines sequence numbers that cannot be used
until the window slides
The send window is an abstract concept defining an imaginary box of
size 2m − 1 with three variables: Sf, Sn, and Ssize. The variable Sf defines
the sequence number of the first (oldest) outstanding frame. The variable Sn
holds the sequence number that will be assigned to the next frame to be sent.
Finally, the variable Ssize defines the size of the window.
Figure (b) shows how a send window can slide one or more slots to the
right when an acknowledgment arrives from the other end. The
acknowledgments in this protocol are cumulative, meaning that more than one
frame can be acknowledged by an ACK frame. In Figure, frames 0, I, and 2 are
acknowledged, so the window has slide to the right three slots. Note that the
value of Sf is 3 because frame 3 is now the first outstanding frame.The send
window can slide one or more slots when a valid acknowledgment
arrives.

Receiver window: variable Rn (receive window, next frame expected) .


The sequence numbers to the left of the window belong to the frames already
received and acknowledged; the sequence numbers to the right of this window
define the frames that cannot be received. Any received frame with a
sequence number in these two regions is discarded. Only a frame 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. When a correct
frame is received (and a frame is received only one at a time), the window
slides.( see below figure for receiving window)

The receive window is an abstract concept defining an imaginary box of size 1


with one single variable Rn. The window slides when a correct frame has
arrived; sliding occurs one slot at a time

Fig: Receiver window (before sliding (a), After sliding (b))


Timers
Although there can be a timer for each frame that is sent, in our protocol we
use only one. The reason is that the timer for the first outstanding frame
always expires first; we send all outstanding frames when this timer expires.
Acknowledgment
The receiver sends a positive acknowledgment if a frame has arrived safe and
sound and in order. If a frame is damaged or is received out of order, the
receiver is silent and will discard all subsequent frames until it receives the
one it is expecting. The silence of the receiver causes the timer of the
unacknowledged frame at the sender side to expire. This, in turn, causes the
sender to go back and resend all frames, beginning with the one with the
expired timer. The receiver does not have to acknowledge each frame
received. It can send one cumulative acknowledgment for several frames.
Resending a Frame
When the timer expires, the sender resends all outstanding frames. For
example, suppose the sender has already sent frame 6, but the timer for
frame 3 expires. This means that frame 3 has not been acknowledged; the
sender goes back and sends frames 3,4,5, and 6 again. That is why the
protocol is called Go-Back-N ARQ.

Below figure is an example(if ack lost) of a case where the forward channel is
reliable, but the reverse is not. No data frames are lost, but some ACKs are
delayed and one is lost. The example also shows how cumulative
acknowledgments can help if acknowledgments are delayed or lost

Below figure is an example(if frame lost)

You might also like