25
Chapter 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 1 The Duties of Data Link Layer: The No Monopoly idea and the framing Framing Techniques Error Control Flow Control Classification MAC LCC Q. Framing and Framing Techniques: Data link layer must use the service provided to it by the physical layer. 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 the job of data link layer to detect and, if necessary, correct errors. How to do it? Break the bit stream up into discrete frames and compute the checksum for each frame. 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 o discarding the bad frame and o possibly also sending back an error report. Techniques: 1. Framing by flag byte and stuff using byte stuffing 2. Framing by flag bytes and stuff using bit stuffing 3. Character count with some other mechanisms 4. Physical Layer Coding Violation. A. Flag Byte or Byte Stuffing: Examples “To stop input please enter X and then press a” ~To stop input please enter X and then press a~ “To stop input please enter ~ and then press a” “~To stop input please enter <Esc>~ and then press a~”. “To stop input please enter <Esc>~ and then press <Esc>a, for main menu press <Esc>” “To stop input please enter <Esc><Esc><Esc>~ and then press <Esc><Esc>a, for main menu press <Esc><Esc>” Method: See next figure: (a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after stuffing. The second framing 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 FLAG. 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.

Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 2 Problem

Embed Size (px)

Citation preview

Page 1: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 1

The Duties of Data Link Layer:

The No Monopoly idea and the framing

Framing Techniques

Error Control

Flow Control

Classification

• MAC

• LCC

Q. Framing and Framing Techniques:

Data link layer must use the service provided to it by the physical layer.

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 the job of data link layer to detect and, if necessary, correct errors.

How to do it? Break the bit stream up into discrete frames and compute the checksum for each

frame.

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

o discarding the bad frame and

o possibly also sending back an error report.

Techniques:

1. Framing by flag byte and stuff using byte stuffing

2. Framing by flag bytes and stuff using bit stuffing

3. Character count with some other mechanisms

4. Physical Layer Coding Violation.

A. Flag Byte or Byte Stuffing: Examples

“To stop input please enter X and then press a”

“~To stop input please enter X and then press a~”

“To stop input please enter ~ and then press a”

“~To stop input please enter <Esc>~ and then press a~”.

“To stop input please enter <Esc>~ and then press <Esc>a, for main menu press <Esc>”

“To stop input please enter <Esc><Esc><Esc>~ and then press <Esc><Esc>a, for main menu press

<Esc><Esc>”

Method:

See next figure: (a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and

after stuffing.

The second framing 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 FLAG.

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.

Page 2: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 2

Problem with this method? A serious problem occurs with this method when binary data, such as

object programs or floating-point numbers, are being transmitted.

It may easily happen that the flag byte's bit pattern occurs in the data.

This situation will usually interfere with the framing.

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

Byte sequence delivered after de-stuffing is exactly the same as the original byte sequence.

The byte-stuffing scheme is used in the PPP protocol that most home computers use to communicate

with their Internet service provider.

Disadvantage?

A major disadvantage of using this framing method is that it is closely tied to the use of 8-bit

characters.

UNICODE uses 16-bit characters.

Embedding the character code in the framing mechanism increases obviously the length of frame.

Solution? Bit Stuffing….

B. Bit stuffing:

See next figure, (a) The original data. (b) The data as they appear on the line. (c) The data as they are stored

in receiver’s memory after de-stuffing.

Allows data frames to contain an arbitrary number of bits and allows character codes with an arbitrary

number of bits per character.

Each frame begins and ends with a special bit pattern, 01111110 (in fact, a flag byte).

Page 3: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 3

Sender’s Method: 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.

Receiver’s Method: 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.

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.

11100011 -> unchanged (8-bit input results in 8-bit output).

11111111- > 111110111 (8-bit input results in 9-bit output).

11111011 -> 11110011(8-bit input results in 9-bit output).

01111110 -> 011111010 (8-bit input results in 9-bit output)

stuffed bit is shown as bold

Page 4: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 4

C. Character Count:

This Method Specifies The Number Of Characters That Are Present In particular Frame.

This Information Is specified By using a Special Field In the Header Frame.

The first framing 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.

See fig.

Trouble? The count can be garbled by a transmission error. See (b).

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.

Conclusion: The character count method is rarely used anymore.

D. Physical Layer Coding Violation.

Only applicable to networks in which the encoding on the physical medium contains some

redundancy.

E.g. Some LANs encode 1 bit of data by using 2 physical bits.

1 bit is a high-low pair and a 0 bit is a low-high pair.

Every data bit has a transition in the middle, making it easy for the receiver to locate the bit

boundaries.

Page 5: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 5

The combinations high-high and low-low are not used for data but are used for delimiting frames in

some protocols.

Q. Error Detection and Correction: Topic List

Types of Errors

Error handling

Using redundancy

Error Detection: VRC, LRC, Checksum, CRC

Error correction: Hamming code

Intermediate vs End to End Error handling:

Error-Correcting Codes: include enough redundant information along with each block of data sent, to

enable the receiver to deduce what the transmitted data must have been.

Error-Detecting Codes: include only enough redundancy to allow the receiver to deduce that an error

occurred, but not which error, and have it request a retransmission.

Telephone system has three main parts: Switches, Interoffice Trunks and Local Loops.

First two are converted to digital, rare errors, but still at local loops errors are common.

Conclusion: transmission errors are going to be with us for many years to come.

For highly reliable channels like fibers, use of error detection and retransmission is cheaper and

preferable.

For channels like wireless links make many errors, so its better to add enough redundancy to provide

error correction instead of retransmission which may be again erroneous.

Data can be corrupted during transmission.

Some applications require that errors be detected and corrected.

Page 6: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 6

TYPES OF ERRORS:

In a single-bit error, only 1 bit in the data unit has changed.

In a multi-bit error, more than one bit in the data unit has changed.

A burst error means that 2 or more bits in the data unit have changed.

Single Bit Error:

Multiple-bit error

Burst error:

Page 7: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 7

XORing of two single bits or two words:

To detect or correct errors, we need to send extra (redundant) bits with data.

Q. Error Detection methods:

VRC(Vertical Redundancy Check)

LRC(Longitudinal Redundancy)

CRC(Cyclical redundancy Check)

Checksum

VRC:

VRC(Vertical Redundancy Check)

• A parity bit is added to every data unit so that the total number of 1s(including the parity bit)

becomes even for even-parity check or odd for odd-parity check

• VRC can detect all single-bit errors.

• It can detect multiple-bit or burst errors only the total number of errors is odd.

Even parity VRC concept is given in next fig

Page 8: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 8

LRC:

LRC(Longitudinal Redundancy Check)

Parity bits of all the positions are assembled into a new data unit, which is added to the end of the

data block

Checksum:

Checksum is used by the higher layer protocols

And is based on the concept of redundancy(VRC, LRC, CRC …. Hamming code)

To create the checksum the sender does the following:

• The unit is divided into K sections, each of n bits.

• Section 1 and 2 are added together using one’s complement.

• Section 3 is added to the result of the previous step.

• Section 4 is added to the result of the previous step.

• The process repeats until section k is added to the result of the previous step.

Page 9: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 9

• The final result is complemented to make the checksum.

CRC:

Calculation of the polynomial code checksum

The algorithm for computing the checksum 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 xrM(x).

2. Divide the bit string corresponding to G(x) into the bit string corresponding to xrM(x), using

modulo 2 division.

3. Subtract the remainder (which is always r or fewer bits) from the bit string corresponding to

xrM(x) using modulo 2 subtraction.

The result is the check summed frame to be transmitted.

Call its polynomial T(x).

Certain polynomials have become international standards. The one used in IEEE 802 is

x32

+ x26

+ x23

+ x22

+ x16

+ x12

x + x11

+ x12

+ x8

+ x7 + x

5 + x

4 + x

2 + x

1 + 1

Page 10: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 10

Page 11: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 11

Polynomial Representation:

101 -> 22

+ 20 -> x

2 + x

0

100100111 -> x8

+ x5

+ x2

+ x1 + x

0.

Sender sends 10101010

Receiver receives 10101111

p(x) is x7 + x

5 + x

3 + x

1

q(x) is x7 + x

5 + x

3 + x

2 + x

1 + x

0

|p(x) - q(x)| is x2 + x

0 or 101.

q(x) is exactly divisible by r(x) if p(x) + e(x) is exactly divisible by r(x) (divisor)

We have to check the divisibility of e(x)

Case 1: one bit e(x) = xi

Requirement: more than one term in divisor

Case 2: two bit x64

+ x1 (i.e. 2

64 + 2

1) =2(2

63 + 1) Requirement: divisor does not divide for x

k + 1

Case 3 : odd number of bits in error

Q. Error Correction: Hamming Code:

Redundancy is needed for error handling

m data bits and r redundant bits

for m + r bits only one correct value of r for a given m

one correct bit pattern requires m + r incorrect patterns

m + r + 1 < 2m + r

7 bit data 4 bit redundant bits makes it 11

R1 represents the parity of M1, M2, M4, M5, and M7 = M1 + M2 + M4 + M5 + M7 =

1 + 0 + 0 + 1 + 0 + 0 = 0

Page 12: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 12

R2 represents the parity of M1, M3, M4, M6, and M7 = 1 + 1 + 0 + 0 =0

R3 represents the parity of M2, M3, and M4=1

R4 represents the parity of M5, M6, and M7=0

Method can be handled in two ways:

when an error is discovered, the receiver can have the sender retransmit the entire data unit.

a receiver can use an error-correcting code, which automatically corrects certain errors.

Hamming Code ~ developed by R.W. Hamming

positions of redundancy bits in Hamming code, lets see how.

each r bit is the VRC bit for one combination of data bits

r1 = bits 1, 3, 5, 7, 9, 11

r2 = bits 2, 3, 6, 7, 10, 11

r4 = bits 4, 5, 6, 7

r8 = bits 8, 9, 10, 11

Note: Do it the way I taught you in lecture. Follow lecture notes.

Hamming code handles burst error in following manner.

Q. The Duties of Data Link Layer:

Framing

Error Detection and Correction

Flow Control.

Interfacing with network and physical layers

First two we have already covered, now lets see next two.

Page 13: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 13

Interfacing with network and Physical Layers:

Q. For Flow Control, The Duties of Data Link Layer:

Local machine level addressing

Multiplexing and demultiplexing

The Protocols

The Sender and Receiver concept

The acknowledgement

Timers and the time out event

Q. What is Local Machine Level Addressing? What is ARP?

Every Ethernet Card that we buy contains a unique 10 digit number called Ethernet Address / Local

Address / Physical Address / MAC Address associated with it.

This number is to be entered in specific configuration tables when the network is being set up.

IP Address is example of Network Layer address, where as Ethernet Address is an example of Data Link

Layer address.

Sender is aware of IP address of recipient and network layer finds out the physical address from IP

address using protocol called ARP – Address Resolution Protocol.

Q. Data Link Layer Functionalities:

Sending and Receiving windows

Sequence and Acknowledgement Numbers

Retransmission

Duplicate frames

Go Back N

Selective Repeat

Prerequisites for coding protocols

Page 14: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 14

Acknowledgements: Every time a receiver receives a correct frame, the receiver acknowledges by sending

an acknowledgement. Acknowledgement is popularly known as ack.

Segment

no.

ACK in

scheme 1

Starting

byte

Last

byte

Sequence

no.

Length ACK in scheme

2

1 1 (frame

no)

0 999 2500 1000 3500 (next byte

expected)

2 2 1000 2499 3500 1500 5000

3 3 2500 3499 5000 1000 6000

Piggybacking: When the ack is sent as a value in field (and not as separate frame) in the reverse traffic, it is

known as piggybacking ack.

Separate ACK frame sent:

Piggybacked Frames:

Timers and Time Out Events: Timers are software routines which can increment or decrement the time

value they have stored. They can set interrupts when deadline is over. Decrement values, once reached 0,

generate interrupt.

Sender and receiver windows: A window which advances automatically when either the ack is received

(sender) or the upper layer reads received frame (receiver). Sender saves the frame in buffer after

transmitting it to receiver until the ACK is received. If ACK doesn’t receive until time out, can resend the

frame. Window size can be from 0 to 8.

Page 15: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 15

Cumulative Acknowledgement: When sender receives an ACK of Nth frame, it understands that all

preceding frames till n are already received. This is known as Cumulative Acknowledgement.

Ambiguous Acknowledgement: Cumulative ACK may confuse the sender. See Next 2 figures. F2’s ACK

is lost. Sender sends F3 and F4. But receiver sends only F1 ACK repeatedly. Here, sender can not determine

that after F1 how many frames are received successfully. This is referred as Ambiguous Acknowledgement.

Solution to the problem is, resend all the frames after F1.

Page 16: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 16

Sliding Window: The sender and receiver windows with values sliding in positive direction are known as

sliding window. The sender’s window shows frames which are send but not acknowledged, while the

receiver’s window indicate frames received but not read by the application yet. See next figure.

Sequence Number: A unique number to unambiguously indentify a sent frame helping receiver organize

data received is known as Sequence Number. Important characteristic of Sequence Number is, they can

Page 17: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 17

wrap around after following some sequence. Length of field “sequence number” determines the value of

wrap around. Eg. Sequence Number starts with 000, 001,.... 111,000,001... Sequence Number and speed of

transmission has relationship. It is important in Go-Back-N.

Retransmission: Resending the frame again is retransmission. This happens when ACK is not received and

time out, it is assumed that frame is lost which then calls for Retransmission of that frame. Retransmission is

possible if sender saves the frame in buffer until it is ACked by receiver.

Duplicate Frames: In the case of ACK lost at receiver’s end, sender assumes that packet sent by sender is

lost, hence, retransmit the frame. This result to duplicate frame arrival at receiver’s end. How to handle it?

Solution: Drop the frame so that there is no confusion at organizing sequence and send the

acknowledgement again to sender so that sender does not get trapped into infinite resend procedure of same

frame when timer times out for ACK of that frame. See above figure.

Q. ARQ (Automatic Repeat Request)Protocols:

Stop N Wait

Sliding Window Go Back N

Sliding Window Selective Repeat

Q. Stop N Wait:

Protocols in which the sender sends one frame and then waits for an acknowledgement before

proceeding are called stop-and-wait. Here we restrict the ability of the receiving network layer to process incoming data infinitely quickly and

infinite amount of buffer space.

The communication channel is still assumed to be error free however, and the data traffic is still simplex.

How to prevent the sender from flooding the receiver with data faster than the latter is able to process

them.

Page 18: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 18

If the receiver requires a time ∆t to execute from_physical_layer plus to_network_layer, the sender must

transmit at an average rate less than one frame per time ∆t.

We assume that no automatic buffering and queuing are done within the receiver's hardware, the sender

must never transmit a new frame until the old one has been fetched by from_physical_layer, as the new

one overwrite the old one.

If the network designers can calculate the worst-case behaviour of the receiver, they can program the

sender to transmit so slowly that even if every frame suffers the maximum delay, there will be no

overruns.

The trouble with this approach is that it is too conservative.

It leads to a bandwidth utilization that is far below the optimum, unless the best and worst cases are

almost the same (i.e., the variation in the data link layer's reaction time is small).

More general solution? Have the receiver provide feedback to the sender.

However, this protocol entails a strict alternation of flow: first the sender sends a frame, then the receiver

sends a frame, then the sender sends another frame, then the receiver sends another one, and so on. A

half- duplex physical channel would suffice here.

The only difference between receiver1 and receiver2 is that after delivering a packet to the network

layer, receiver2 sends an acknowledgement frame back to the sender before entering the wait loop again.

Q. Sliding Window Protocol:

Duplex.

At any instant of time, the sender maintains a set of sequence numbers corresponding to frames it is

permitted to send.

This includes:

o – frames not yet sent

o – Frames sent but not yet acknowledged .. May have to be sent again.

This corresponds to the sender’s window.

Sender Window: When a packet comes from the Network Layer ..it is appended in the window and

when an ack arrives for a frame..it is deleted from the buffer(and from the window).

Receiver Side: Similarly, the receiver also maintains a set of sequence numbers corresponding to

frames it is permitted to accept.

When a frame arrives, its seq number is checked..if it falls in the window it is accepted else

discarded .. Once an ack is sent for a frame it is deleted from the window

Advantage? so that duplicate frames are not accepted

Page 19: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 19

Q. Go Back N: Throw away all the subsequent frames and go back and start resending from the damaged

frame. This corresponds to size 1 window in the receiver.

Go Back N has an issue of Sequence Number. See next figure.

Page 20: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 20

Limitations of Stop and Wait: It is inefficient when propagation delay is larger than the packet

transmission time

Can only send one packet per round-trip time

Go Back N allows the transmission of new packets before earlier onesare acknowledged

Go back N uses a window mechanism where the sender can send packets that are within a “window”

(range) of packets

The window advances as acknowledgements for earlier packets are received.

Window size = N

Sender cannot send packet i+N until it has received the ACK for packet i

Page 21: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 21

Receiver operates just like in Stop and Wait.

Receive packets in order

Receiver cannot accept packet out of sequence

Send Receiving Seq. No = i + 1 => ACK for all packets up to and including i

Use of piggybacking

When traffic is bi-directional RN’s are piggybacked on packets going in the other direction.

Requires no buffering of packets at the receiver

Sender must buffer up to N packets while waiting for their ACK

Sender must re-send entire window in the event of an error

Receiver can only accept packets in order because,

o Receiver must deliver packets in order to higher layer

Page 22: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 22

o Cannot accept packet i+1 before packet i

o This removes the need for buffering

o This introduces the need to re-send the entire window upon error

Disadvantage: The major problem with Go Back N is this need to re-send the entire window when an

error occurs. This is due to the fact that the receiver can only accept packets in order.

Q. Selective Repeat:

Page 23: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 23

Selective Repeat Sequence Number Problem:

Page 24: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 24

Solution:

Buffer the subsequent frames and wait for the damaged frame to be resent, once that comes,

handover the frames in proper order to the Network Layer.

Trade off between the bandwidth utilization(advantage) and the buffer space(disadvantage).

Increases the efficiency of use of bandwidth.

Sender retransmits only that frame which is erroneous.

Unlike Go Back N, does not discard all frames until expected is received.

Receiver sends NAK for frame which had error and retransmitted by sender.

If, frame has k bit sequence number then sequence number of frames will range between 0 to 2K-1.

Eg: if K = 2 (22 = 4 – 1 = 3) then sequence number range from 0 to 3, eg. 012301230.....n.

And Size of sender and receiver window would be 2k/2 i.e 4/2 = 2 or it can be 2

k-1. i.e 2

2+1

Its duplex channel, so sender and receiver has to do the job of receiver and sender both.

Selective Repeat is one of the automatic repeat-request (ARQ) techniques like Go Back N.

ARQ: Error control schemes that involve error detection and retransmission of lost or corrupted

frames are referred to as Automatic Repeat Request (ARQ) error control.

Sender only retransmits frames for which a NAK is received.

Advantage over Go-Back-N:

o Fewer Retransmissions.

Disadvantages:

o More complexity at sender and receiver

o Each frame must be acknowledged individually (no cumulative acknowledgements)

o Receiver may receive frames out of sequence

Page 25: Chapter 5: Data Link Layer - WordPress.com 5: Data Link Layer By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: bhargavigoswami@gmail.com Page 2 Problem

Chapter 5: Data Link Layer

By: Bhargavi Goswami, Sunshine Group of Institutions, Rajkot. Sub: FON, Email: [email protected] Page 25

University Question List:

1. Explain relationship between Packets and Frames.[2]

2. List the service provided by Data Link Layer.[1]

3. Explain Framing. Explain each framing techniques in detail.[7]

4. Explain Error Control and Flow Control with respect to DLL [2].

5. Explain error correction and detection. Also explain types of errors. List error detecting and

correcting methods.[3]

6. List error detecting and correcting methods. Explain VRC, LRC, Block coding and Checksum in

detail.[4]

7. Explain CRC by taking one valid example in polynomial code.[2]

8. Explain Hamming Code. Take proper example and feed erroneous code to detect error. Correct it.

State advantages and disadvantages.[7]

9. Differentiate between elementary data link layer protocol and sliding window protocol. What is the

difference of data structure used in both the protocols type.[2]

10. Explain stop and wait protocol in detail.[3]

11. Explain the concept of sliding window protocol in detail. Show advantages of sliding window

protocol over elementary control protocol.[2]

12. Explain one bit sliding window protocol in detail. Write its advantages.[3]

13. Explain difference between one bit sliding window protocol and go back n protocol.[2]

14. Explain difference between go back n protocol and selective repeat protocol.[2]

15. Explain Go back n protocol. Also state its merits and demerits. [3]

16. Explain Selective Repeat protocol. Also state its merits and demerits. [3]

17. Explain piggybacking[1]

18. Write a short note on Error Detection and error correction.[7]

19. What is the use of acknowledgement and timer in data link layer protocols?[2]

20. Compute the Hamming code for the bit pattern 1100001[5]

21. What is the advantage of Piggybacking? [2]

22. In the Stop-and-Wait protocol, the sender sends one frame, stops until it receives confirmation from

the receiver, and then sends the next frame. True or False? [1]

23. Both Go-Back-N and Selective-Repeat protocols use a sliding window. True or False? [1]

24. In CRC a value used for error detection, is formed by adding data units using one’s complements

arithmetic and then complementing the result. True or False? [1]

25. In ________ protocol, we can send several frames before receiving acknowledgements, improving

the efficiency of transmission. [1]

26. What is sliding window protocol? How it is different from normal protocol?[3]

27. Generate CRC for frame 1101011011 using generator 10011.[5]

28. For a data bit pattern 10000101111 sketch the wave form for each of the following signal encoding

schemes (i) Binary (ii) Manchester[3]

29. Explain byte stuffing with example.[2]

30. Frequency division multiplexing[1]