CN Unit-2 Part 1

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

DATA LINK LAYER

Presented by
P. Anusha,
Asst Prof, CSE(AIML)
INTRODUCTION TO DATA LINK LAYER

 The data link layer uses the services of the physical layer to send and receive bits
over node-to-node communication channels. It has a number of functions,
including:
1. Providing a well-defined service interface to the network layer.
2. Dealing with error-free transmission of information
3. Regulating the flow of data so that slow receivers are not swamped by fast
senders.
 Specific responsibilities of the data link layer include framing, addressing, flow
control, error control, and media access control.
 To accomplish these goals, 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,
 Frame management forms the heart of what the data link layer does.
DESIGN ISSUES IN DLL
The following are the data link layer design issues
1. Services Provided to the Network Layer
2. Framing
3. Error Control
4. Flow Control
Where reliability is an overall goal, and it is achieved when all the layers work together.
Services Provided to the Network Layer
 The main function of the data link layer is to provide services to the network layer by
transferring data from the network layer on the source machine to the network layer
on the destination machine.
 The DLL can be designed to offer various services, that are offered vary from
protocol to protocol. Three reasonable possibilities that we will consider in turn are:
1. Unacknowledged connectionless service (Eg: Ethernet)
2. Acknowledged connectionless service (Eg: WiFi)
3. Acknowledged connection-oriented service (Eg: Satellite
channel)
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
 The usual approach is 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.
 Breaking up the bit stream into frames is more difficult than it at first appears.
The following are the four methods in framing:
1. Byte count
2. Flag bytes with byte stuffing
3. Flag bits with bit stuffing
4. Physical layer coding violations
Byte count
 This 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.

Error free Byte


stream

With error Byte


stream
Flag bytes with byte stuffing
 This framing method gets around the problem of resynchronization
after an error by having each frame start and end with special bytes.
 A flag byte (FLAG), is used as both the starting and ending delimiter.
 A special escape byte (ESC) is used just before each ‘‘accidental’’ flag
byte in the data.
Flag bits with bit stuffing
 The 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.
 Each frame begins and ends with a special bit pattern, 01111110 or 0x7E in
hexadecimal.
 In Bit stuffing, whenever the sender’s data link layer encounters five
consecutive 1’s in the data, it automatically stuffs a 0 bit into the
outgoing bit stream.
Physical layer coding violations
 With both bit and byte stuffing, a side effect is that the length of a frame
now depends on the contents of the data it carries.
 The last method of framing is to use a shortcut from the physical layer.
 In effect, we are using ‘‘coding violations’’ to delimit frames.
 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 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.
Error Control
 Error control is the technique of checks the reliability of data in from of
frames delivered to the network layer at the destination and in the proper
order.
 Typically, the protocol calls for the receiver to send back special control
frames bearing positive or negative acknowledgements about the
incoming frames using feedback.
 This possibility is dealt with by introducing timers in DLL. When the sender
transmits a frame, it generally also starts a timer.
 The obvious solution is to just transmit the frame again.
Flow Control
 The other important design issue that occurs is what to do with a sender that
systematically wants to transmit frames faster than the receiver can accept them
which is running on a slow, low-end machine.
 Clearly, something has to be done to prevent this situation two approaches were
used like
- feedback-based flow control
- rate-based flow control,
ERROR DETECTION & CORRECTION
 There are many reasons such as noise, cross-talk etc., which may help data to
get corrupted during transmission. The upper layers are not aware of actual
hardware data processing and expect error-free transmission between the
systems.
 Network designers have developed two basic strategies for dealing with
errors. Both add redundant information to the data that is sent.
Types of Errors
Error correcting codes (ECC)
 Error-correcting codes are seen in the physical layer, particularly for noisy
channels, and in higher layers, particularly for real-time media and content
distribution.
 We will examine four different error-correcting codes:
1. Hamming codes
2. Binary convolutional codes
3. Reed-Solomon codes
4. Low-Density Parity Check codes
• Hamming Codes − It is a block code that is capable of detecting
up to two simultaneous bit errors and correcting single-bit errors.
• Binary Convolution Code − Here, an encoder processes an input
sequence of bits of arbitrary length and generates a sequence of
output bits.
• Reed - Solomon Code − They are block codes that are capable of
correcting burst errors in the received data block.
• Low-Density Parity Check Code − It is a block code specified
by a parity-check matrix containing a low density of 1s. They are
suitable for large block sizes in very noisy channels.
 This is the relationship between data bits and redundancy bits
to correct a single-bit error. A-frame consists of m data bits
and r redundant bits. Suppose the total length of the frame be
N An n-bit unit containing data and the check bit
is often referred to as an n-bit codeword.
 Thus, each of the 2m legal messages requires n + 1 bit
patterns dedicated to it. Since the total number of bit patterns
is 2n, we must have (n + 1)2m ≤ 2n. Using n = m + r, this
requirement becomes
Error Detecting codes (EDC)
 Error-correcting codes are widely used on wireless links, which are notoriously
noisy and error prone when compared to optical fibers.
 Error detection and retransmission is usually more efficient there for dealing
with the occasional error.
 We will examine three different error-detecting codes
1. Parity
2. Checksums
3. Cyclic Redundancy Checks (CRCs)
Parity Check
 One extra bit is sent along with the original bits to make number of 1s either even
in case of even parity, or odd in case of odd parity.
 It works as:
- 1 is added to the block if it contains an odd number of 1’s, and
- 0 is added if it contains an even number of 1’s.
 Sender's End − While creating a frame, the sender counts the number of 1s in it
and adds the parity bit in following way:
 In case of even parity − If number of 1s is even, parity bit value is 0. If number of
1s is odd, parity bit value is 1.
 In case of odd parity − If number of 1s is odd, parity bit value is 0. If number of 1s
is even, parity bit value is 1
 Receiver's End − On receiving a frame, the receiver counts the number of 1s in it. In
case of even parity check, if the count of 1s is even, the frame is accepted, otherwise it
is rejected. In case of odd parity check, if the count of 1s is odd, the frame is accepted,
otherwise it is rejected.
Checksum
 Checksum error detection is a method used to identify errors in transmitted
data. The process involves dividing the data into equally sized segments
and using a 1’s complement to calculate the sum of these segments.
 The calculated sum is then sent along with the data to the receiver. At the
receiver’s end, the same process is repeated and if all zeroes are obtained in
the sum, it means that the data is correct.
Cyclic Redundancy Checks (CRCs)
 In CRC, a sequence of redundant bits, called cyclic redundancy check bits, are
appended to the end of the data unit so that the resulting data unit becomes
exactly divisible by a second, predetermined binary number.
 At the destination, the incoming data unit is divided by the same number. If at
this step there is no remainder, the data unit is assumed to be correct and is
therefore accepted.
 A remainder indicates that the data unit has been damaged in transit and therefore
must be rejected.
 An error detection technique using a polynomial to generate a series of two 8-bit
block check characters that represent the entire block of data. These block check
characters are incorporated into the transmission frame and then checked at the
receiving end.
ELEMENTARY DATA LINK
PROTOCOLS
 Protocols in the data link layer are designed so that this layer can perform its basic
functions: framing, error control and flow control.
 Protocols are generally responsible to simply ensure and confirm that the bits and
bytes that are received are identical to the bits and bytes being transferred.

Data Link Protocols

For noise-less
For noisy channels
channels

Unrestricted Simplex A Simplex Stop-and-wait A Simplex Stop-and-wait


Protocol Protocol for noiseless (ARQ) Protocol for noisy
channel channel
Utopian Unrestricted Simplex Protocol
 Our first protocol is a simple protocol for noiseless channels with
neither error control nor flow control.
 It is hypothetical protocol designed for unidirectional data
transmission over an ideal channel.
 The sender simply sends all its data available onto the channel as soon
as they are available its buffer. The receiver is assumed to process all
incoming data instantly.
 Assuming that receiver can immediately handle any number of
incoming frames while ignoring the processing time with infinite buffer
space.
 And best of all, the communication channel between the
data link layers never damages or loses frames.
A Simplex Stop-and-wait Protocol for noiseless
channel
 This protocol provides unidirectional data transmission without any
error control facilities.
 However, it provides for flow control so that a fast sender does not
drown a slow receiver.
 The receiver has a finite buffer size with finite processing speed.
 Sender sends data frame, waits for Acknowledgement(ACK) from
receiver before proceeding to transmit next frame.
This simple flow control will break down if ACK gets lost or error
occur.
A Simplex Stop-and-wait (ARQ) Protocol
for noisy channel
 Stop– and – wait Automatic Repeat reQuest (Stop – and – Wait ARQ)
is a variation of the previous protocol with added error control
mechanisms, appropriate for noisy channels.
 The sender keeps a copy of the sent frame. It then waits for a finite time
to receive a positive acknowledgement from receiver.
 If the timer expires or a negative acknowledgement is received, the frame
is retransmitted.
 If a positive acknowledgement is received then the next frame is sent
SLIDING WINDOW PROTOCOLS
 Slidingwindow protocols are data link layer protocols for reliable and
sequential delivery of data frames. The sliding window is also used in
Transmission Control Protocol.
 The use of Stop-and-Wait ARQ wastes the capacity of the link with high
bandwidth delay.
 In this protocol, multiple frames can be sent by a sender at a time before
receiving an acknowledgment from the receiver. The term sliding window
refers to the imaginary boxes to hold frames.
 Sliding window method is also known as windowing.
Working Principle for sliding window
 In these protocols, the sender has a buffer called the sending
window and the receiver has buffer called the receiving window.
 The size of the sending window determines the sequence number of
the outbound frames. If the sequence number of the frames is an n-
bit field, then the range of sequence numbers that can be assigned is
0 to 2𝑛−1. Consequently, the size of the sending window is 2 𝑛−1.
 Thus in order to accommodate a sending window size of 2 𝑛−1, a n-
bit sequence number is chosen.
• The sliding window protocol uses a mechanism of sequence numbers.
• The sequence number also helps the receiver identify the loss of
damaged packets.
• When the receiver receives the frame, it sends back an ACK
(acknowledgment) to the sender. The ACK lets the sender know that a
particular frame is received by the receiver correctly.
Go – Back – N ARQ Protocol
 To improve the efficiency of transmission (filling the pipe), multiple
frames must be in transition while waiting for acknowledgment.
 Go – Back – N ARQ provides for sending multiple frames before
receiving the acknowledgment for the first frame
 The frames are sequentially numbered and a finite number of frames
are sent. If the acknowledgment of a frame is not received within the
time period, all frames starting from that frame are retransmitted.
 In the Go-Back-N Protocol, the sequence numbers are modulo 2 power
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.
 Thesend window is an abstract concept defining an imaginary
box of size 2m − 1 with three variables: Sf, Sn, and Ssize.
 Thesend window can slide one or more slots when a valid
acknowledgment arrives
 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
Case where the forward channel is reliable, but the
reverse is not (ACK lost)
Selective Repeat ARQ Protocol
 In Go-Back-N ARQ, The receiver keeps track of only one variable, and there
is no need to buffer out-of- order frames; they are simply discarded.
However, this protocol is very inefficient for a noisy link.
 This resending uses up the bandwidth and slows down the transmission
 For noisy links, there is another mechanism that does not resend frames
when just one frame is damaged; only the damaged frame is resent. This
mechanism is called Selective Repeat ARQ.
 It is more efficient for noisy links, but the processing at the receiver is more
complex
 A technique called Piggybacking is used to improve the efficiency of the
bidirectional protocols
Example Data Link Protocols

 Data link protocols found on point-to-point lines in the Internet


in two common situations.
 1. Packets sent over SONET
 2. ADSL links

A standard protocol called PPP (Point-to-Point Protocol) is


used to send packets over these links.
Packets sent over SONET
 SONET (Synchronous Optical Network), is the physical layer
protocol that is most commonly used over the wide-area
optical fiber links that make up the backbone of
communications networks, including the telephone system.
 To carry packets across these links, some framing mechanism
is needed in which they are transported. PPP runs on IP
routers to provide this mechanism.
 With a wide set of options, PPP provides three main features:
 Link Control Protocol
 Network Control Protocol
 High level Data Link Control
ADSL (Asymmetric Digital Subscriber
Loop)
 ADSL connects millions of home subscribers to the Internet at
megabit/sec rates over the same telephone local loop that is used for
plain old telephone service.
 It sends bits over the local loop to a device called a DSLAM (DSL
Access Multiplexer).
 In between ADSL and PPP new protocol ATM (Asynchronous
Transfer Mode) was designed that promised a network technology
which solve the world’s telecommunications problems by merging
voice, data, cable television, telegraph, carrier pigeon, tin cans
connected by strings, and everything

You might also like