32
DATA LINK LAYER TOPIC: Error control & Flow control 1 | Page

Report on data link layer

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Report on data link layer

DATA

LINK

LAYER

TOPIC: Error control & Flow control

Submitted to : Submitted by:

Prof Manraj Singh Pattar Alisha Korpal

Nancy Jain

Nivea Jain

1 | P a g e

Page 2: Report on data link layer

Sharuti Jain

INDEX

S no Topic Page no1 Introduction to data link layer 32 Services provided to network layer 43 Services 64 Framing 75 Error detection 86 Error correction 157 Flow control 168 Error control 199 References 24

2 | P a g e

Page 3: Report on data link layer

INTRODUCTION

Data Link Layer Design Issues

The data link layer has a number of specific functions it can carry out. These functions

include

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.

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.

3 | P a g e

Page 4: Report on data link layer

Services Provided to the Network Layer

The function of the data link layer is to provide services to the network layer. The principal

service is transferring data from the network layer on the source machine to the network layer

on the destination machine. On the source machine is an entity, call it a process, in the

network layer that hands some bits to the data link layer for transmission to the destination.

The job of the data link layer is to transmit the bits to the destination machine so they can be

handed over to the network layer there.

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. 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

that 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. Most LANs use unacknowledged connectionless

service in the data link layer.

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. 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.

4 | P a g e

Page 5: Report on data link layer

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. With

connectionless service, in contrast, it is conceivable that a lost acknowledgement causes a

packet to be sent several times and thus received several times. Connection-oriented service,

in contrast, provides the network layer processes with the equivalent of a reliable bit stream.

5 | P a g e

Page 6: Report on data link layer

SERVICES

1. Framing

2. Error control

3. Flow control

4. Access Control

5. Physical Addressing

6 | P a g e

Page 7: Report on data link layer

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. (Checksum algorithms will be discussed later in

this chapter.) 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).

Breaking the bit stream up into frames is more difficult than it at first appears. One way to

achieve this framing is to insert time gaps between frames, much like the spaces between

words in ordinary text. However, networks rarely make any guarantees about timing, so it is

possible these gaps might be squeezed out or other gaps might be inserted during

transmission. Since it is too risky to count on timing to mark the start and end of each frame,

other methods have been devised. In this section we will look at four methods:

1. Character count.

2. Flag bytes with byte stuffing.

3. Starting and ending flags, with bit stuffing.

4. Physical layer coding violations.

7 | P a g e

Page 8: Report on data link layer

Error Control

Having solved the problem of marking the start and end of each frame, we come to the next

problem: how to make sure all frames are eventually delivered to the network layer at the

destination and in the proper order. Suppose that the sender just kept outputting frames

without regard to whether they were arriving properly. This might be fine for

unacknowledged connectionless service, but would most certainly not be fine for reliable,

connection-oriented service.

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. 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.

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. 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

Error Detection

Error Correction

8 | P a g e

Page 9: Report on data link layer

Error Detection

When data is being transmitted from one machine to another, it may possible that data

become corrupted on its way. Some of the bits may be altered, damaged or lost during

transmission. Such a condition is known as error.

The error may occur because of noise on line, attenuation and delay distortion. For reliable

communication, it is important that errors are detected and corrected.

Types of errors

Single bit error

Burst error

Single bit error

It means only one bit of data unit is changed from 1 to 0 or from 0 to 1. Single bit error can

happen in parallel transmission where all the data bits are transmitted using separate wires.

Single bit error is least likely type of errors in serial transmission.

Burst Error

It means two or more bits in data unit are changed from 1 to 0 or from 0 to 1. In burst error, it

is not necessary that only consecutive bits are changed. The length of burst error is measured

from first changed bit to last changed bit.

9 | P a g e

Page 10: Report on data link layer

Techniques

Error detection means inspecting the data so as to check whether or not data is changed

during the transmission. An error detection system is needed at the receiver end that should

check the incoming data and report the number and type’s errors that define have occurred.

The most common technique used for error detection is redundancy.

Redundancy

Redundancy is the method in which some extra bits are added to the data so as to

check whether the data contain error or not.

These redundant bits are added by the sender and removed by the receiver as soon as

the accuracy of the transmission has been determined

These redundant bits are then added to the data and data + redundant bits are

transmitted to the receiver

Types

1. Vertical Redundancy check/parity check

2. Longitudinal Redundancy check

3. Cyclic Redundancy check

4. Checksum

10 | P a g e

Page 11: Report on data link layer

Vertical Redundancy Check/Parity Check

This method is also known as parity check. In this method, a redundant bit called parity bit is

added to each data unit. This method may include even parity or odd parity. Even parity

means that total number of 1are even. Odd parity means the total no of 1 are odd.

Example

If source wants to transmit a data unit 1100111 using even parity to the destination. The

source will first pass this unit to even parity generator.

The parity generator will count the number of 1 in data and will add parity bit. In this

example, since the number of 1 in data unit is five, the parity generator appends a parity bit 1

to this data unit making the total number of 1 even.

1 1 0 0 1 1 1

VRC can detect all single bit error

It can also detect burst error but only in those cases where number of bits changed is

odd.

The major disadvantage of this method is that it is not able to detect burst error if the

numbers of bits are even.

11 | P a g e

1 1 0 0 1 1 1 1

Even Parity generator

(Counts 1 in data)1

Page 12: Report on data link layer

Longitudinal Redundancy Check

In this method block of bits is divided into table or matrix of rows and columns.

In order to detect the error, a redundant row of bits is added to the whole block and this

block is transmitted to the receiver.

The receiver uses this redundant row to detect error. After checking the data for errors,

receivers accept the data and discard the redundant row of bits.

When this data reaches the destination, receiver uses LRC to detect error in data.

LRC is used to detect burst errors. For e.g. suppose 32 bit data plus LRC that was being

transmitted is hit by burst error of length five and some bits are corrupted.

12 | P a g e

11001010 10101010 11001100 11100011

11001010

10101010

11001100

11100011

01001111

11001010 10101010 11001100 11100011 01001111

Receiver data

Sender data

Page 13: Report on data link layer

Cyclic Redundancy Check

CRC is more powerful than VRC and LRC in detecting errors.

It is not based on binary addition like VRC and LRC. Rather it is based on binary

division.

At the sender side, the data unit to be transmitted is divided by a predetermined

divisor (binary number) in order t obtain the remainder. This remainder is called

CRC.

The CRC has one bit less than the divisor. It means that if CRC is of n bits, divisor is

of n+ 1 bit.

The sender appends this bit CRC to the end of data unit such that the resulting data

unit becomes exactly divisible by predetermined divisor i.e. remainder become zero.

13 | P a g e

1011

1011

10010001011

0100

0000

1000

1011

0110

0000

110

Page 14: Report on data link layer

Checksum

Checksum is the error detection method used by upper layer protocols and is

considered to be more reliable than LRC, VRC & CRC.

This method makes use of checksum generator on the sender side &checksum checker

on the receiver side.

At the sender side, checksum generator divides the data into equal subunits of n bit

length. This length is generally of 16 bits.

For example

If the data unit to be transmitted is 10101001 00111001, the following procedure is

used at the sender & receiver site.

Sender site:

14 | P a g e

10101001 (subunit 1)

00111001 (subunit 2)

11100010 (sum using 1 compliment)

00011101 check sum (compliment of sum )

10101001 00111001 00011101

DATA Checksum

10101001 subunit 1

00111001 subunit 2

00011101 checksum

11111111 sum

00000000 sum compliment

Receiver site:

Page 15: Report on data link layer

Error Correction

Error correction means rectifying all the bits that have been altered or changed during the

transmission of data. Error correction can be done as follows:

By retransmission of data from sender to receiver.

By the use of error correction code at the receiver side.

Hamming Code

Hamming code is a technique developed by R.W. hamming for error correction. This method

corrects the error by finding the state at which the error has occurred.

15 | P a g e

Page 16: Report on data link layer

Flow Control

Another important design issue that occurs in the data link layer (and higher layers as well) is

what to do with a sender that systematically wants to transmit frames faster than the receiver

can accept them. This situation can easily occur when the sender is running on a fast (or

lightly loaded) computer and the receiver is running on a slow (or heavily loaded) machine.

The sender keeps pumping the frames out at a high rate until the receiver is completely

swamped. Even if the transmission is error free, at a certain point the receiver will simply be

unable to handle the frames as they arrive and will start to lose some. Clearly, something has

to be done to prevent this situation.

Two approaches are commonly used. 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. In this chapter we will study feedback-based flow

control schemes because rate-based schemes are never used in the data link layer.

Methods

Stop and Wait

Sliding window

16 | P a g e

Page 17: Report on data link layer

Stop and Wait

In this method of flow control, the sender sends a single frame to receiver and waits

for an acknowledgment.

The next frame is send by sender only when acknowledgment of previous frame is

received.

This process of sending a frame & waiting for an acknowledgment continues as long

as sender has data to send.

To end up the transmission sender transmits EOT frame

The main advantage is its accuracy. Next frame is transmitted only when the

acknowledged is received.

So no chance of frame being lost

17 | P a g e

Sender Receiver

DATA

ACK

DATA

EOT

Page 18: Report on data link layer

Sliding Window

In sliding window method, multiple frames are sent by sender at a time before needing an

acknowledgment. Multiple frames sent by source are acknowledged by receiver using a

single ACK frame. Sliding window refers to an imaginary boxes that hold the frames on both

sender and receiver side. It provides the upper limit on the number of frames that can be

transmitted before requiring an acknowledgment. Frames may be acknowledged by receiver

at any point even window is not full on receiver side. Frames may be transmitted by source

even when window is not yet full on sender side.

6 7 0 1 2 3 4 5

18 | P a g e

Window

Page 19: Report on data link layer

Error Control

Error control function of data link layer detects the error in transmitted frames and

retransmits all the erroneous frames. Therefore error control function of data link layer helps

in dealing with data frames that are damaged in transmit, data frame lost in transmit and the

acknowledgment frame that are lost in transmission. The method is used for error control is

called Automatic Repeat Request (ARQ).

Automatic Repeat Request (ARQ)

If an error is detected in any frame, the receiver sends a negative acknowledgement (NAK)

back to source and the specific frame is retransmitted.

ARQ techniques:

Stop and Wait ARQ

Sliding window ARQ

Go - back - n

Selective – reject

19 | P a g e

Page 20: Report on data link layer

Stop and Wait

The sending device keeps a copy of the last frame transmitted until it receives an

acknowledgment for that frame. Keeping this copy helps the sender in retransmission

of lost or damaged frames later on.

Both data frames and ACK frames are numbered alternately 0 and 1 for identification

purpose.

Criteria used by stop and wait ARQ method:

Damaged data frames

Lost data frames

Lost acknowledged frames

20 | P a g e

Page 21: Report on data link layer

Damaged data frames

If a data frame received by a receiver contains an error, it returns NAK frame to the

sender. On receiving NAK frame, sender retransmits the last data frame.

21 | P a g e

Page 22: Report on data link layer

Lost data frames

Every sending device is equipped with timer.

The sender starts this timer when it transmits data frame.

If a data frame is lost on its way, it will not be received by receiver. As a result the

receiver can never acknowledge it, positively or negatively.

The sending device waits for an ACK and NAK frame until timer goes of.

22 | P a g e

Page 23: Report on data link layer

Lost acknowledgment frames

When any data frame reaches the destination, the receiver acknowledges it either

with ACK or with NAK.

If ACK or NAK frame returned by the receiver is lost in transmit, sending device

retransmit the data frame that has not been acknowledged

23 | P a g e

Page 24: Report on data link layer

References

http://docs.google.com/viewer?a=v&q=cache:g0kc6om7ALEJ:www.cis.temple.edu/

~latecki/Courses/CIS617-04/slides/Ch3DataLink.ppt+data+link+layer+-

+error+control&hl=en&gl=in&pid=bl&srcid=ADGEESh7iihVLjzfFbz0gre7MU026m

n1tthMC-nrjVDOhmlFyqp-

EpbPP18Dz7PJTOo3lto10Jrgl1nkhxfKGMHEko4l92TcpWhWdwZ6NWFLwcgt8vL

1Rflnm2flNelUYRNLV8E9V-H&sig=AHIEtbR0cwRF6qCblrz1ZzC5FkQnUHZegA

http://www.google.co.in/search?q=data+link+layer+-

+error+control&hl=en&biw=1280&bih=869&prmd=ivns&ei=x5yqTduNEIXqrAfs2Z

ioCA&start=10&sa=N

http://docs.google.com/viewer?a=v&q=cache:_jvDqkVmAswJ:people.du.ac.in/

~ngupta/CS204/Data%2520Link%2520Layer.ppt+data+link+layer+-

+erroe+control&hl=en&gl=in&pid=bl&srcid=ADGEESjvzCW9EVWHSCgLuNEgY

rLN8SnUvi-OQgDHzumZNNbPe-08mHhM4hLYqcxF960wte5mZHm1vae0-

qOmWu71x0w7bOq8M4iogycqPZP23VkXGkvzE3lb5FJDHjBjJf5funeJkYit&sig=A

HIEtbTruvMLqEm3DYW-JmR6GPILqmFx_g

http://docs.google.com/viewer?a=v&q=cache:pXaIC8VehawJ:www.cs.virginia.edu/

~zaher/classes/CS457/lectures/flow-control.pdf+data+link+layer+-

+erroe+control&hl=en&gl=in&pid=bl&srcid=ADGEEShXOPBrrzZXuk9J4MVuSzC

UNdgifCxHo6B7UQHf_g49Cl6wsZ2gdb0dO-

MsM0hcZzEE62PlsGcupxyd5Mh7676xNqU7MxtrutxhVWykBIypsiEu9Q1E1BZ87x

8Kup4M5pyJkV-F&sig=AHIEtbQIRNWpmfHTwyXPybAvYx5rs3G7YA

http://docs.google.com/viewer?a=v&q=cache:li73YI_zh7EJ:eeweb.poly.edu/el536/

datalink_control.pdf+data+link+layer+-

+error+control&hl=en&gl=in&pid=bl&srcid=ADGEESglDES4xEYhroZ5oQpGK5A

_dK7xynEbzeK23jLHPHyZj7W1KkOe_2ef_zUDjgG6v12ovMiaazeR9y9tikfCvRoE

KQWLbnHnmlIyaMQmT-oX-0r60nw-

dk8hhac3xKoK_iRy12cv&sig=AHIEtbQScSEyKt6bSxqC_02VfzUXFYWRew

24 | P a g e