Top Banner
7/21/2019 Chapter3 DataLink http://slidepdf.com/reader/full/chapter3-datalink 1/112 Computer Networks
112

Chapter3 DataLink

Mar 06, 2016

Download

Documents

rohitpatyal82

l
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 1/112

Computer Networks

Page 2: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 2/112

Computer Networks

Prof. Lin Weiguo 

College of ComputingCopyleft© 2003~2015

[email protected] 

http://icourse.cuc.edu.cn/computernetworks/

Page 3: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 3/112

Attention

The materials below are available for use by others.

Instructors are welcome to use them in their own

courses, download them to their own class' web site,

or modify them to suit. However, you mustacknowledge the source of the original and not

attempt to place your own copyright on this

material.

!  Thanks to:

http://authors.phptr.com/tanenbaumcn4/

3/31/15  [email protected]

Page 4: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 4/112

[email protected] 4

Roadmap

Introduction

Medium Access Sublayer

Network Layer

Transport Layer

Application Layer

Data Link Layer

Physical Layer

3/31/15 

Page 5: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 5/112

The Data Link Layer  

Chapter 3

Page 6: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 6/112

Ch-3 The Data Link Layer  

!  3.1 Data Link Layer Design Issues

3.2 Error detection and correction

!  3.3 Elementary data link protocols

3.4 Sliding window protocols

!  3.5 Example Data Link Protocols

3/31/15  [email protected]

Page 7: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 7/112

What Is Data Link

!  Communication channels that connect adjacentnodes along communication path are links

!  By adjacent, we mean that the two machines are

connected by a communication channel that actsconceptually like a wire.

!  Data-link layer deals with algorithms forachieving reliable, efficient communication of

whole units of information called frames betweentwo adjacent machines.

3/31/15  [email protected]

Page 8: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 8/112

Properties and Limitations for a link

!  Essential Property:

!  The bits are delivered in exactly the same order  inwhich they are sent.

Limitations

Communication circuits make errors occasionally

They have only a finite data rate, and

!  There is a nonzero propagation delay betweenthe time bit sent and the time it is received

3/31/15  [email protected]

Page 9: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 9/112

3.1 DLL Design Issues

!  Functions of the Data Link Layer  !  Providing a well-defined service interface

to the network layer!  Dealing with transmission errors

!  Regulating data flow

•  Slow receivers not swamped by fastsenders 

3/31/15  [email protected] 9

Page 10: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 10/112

Frame

Relationship between packets and frames.

DLL takes the packets it gets from the network layer

and encapsulates them into frames for transmission

3/31/15  [email protected]

Page 11: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 11/112

Reliability is an overall goal

!  The goal is achieved when all the layers work together.

!  Many of the principles we will study in the data

 link layer, such as error control and flow control,

 are found in transport and other protocols as well.

!  In fact, in many networks, these functions are found mostly in the upper layers, with the data

 link layer doing the minimal job that is “good

 enough”.3/31/15

  [email protected] 11

Page 12: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 12/112

Services Provided to the Network Layer

(a) Virtual communication.

(b) Actual communication.

3/31/15  [email protected]

Page 13: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 13/112

Types of Common Services

!  Unacknowledged connectionless service.!  used on low bit error link. ( Ethernet or real-time traffic ) 

!  Acknowledged connectionless service.!  Used on high error rates link (Wireless) 

!  Acknowledged connection-oriented service.!  guarantee that each frame sent is indeed received and

is received exactly once and that all frames arereceived in the right order..

provides the network layer processes with theequivalent of a reliable bit stream 

!  Used on long, unreliable links.(satellite channel)3/31/15

  [email protected]

Page 14: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 14/112

Is Acknowledgement a Must ?

!  Providing acknowledgements in the data link

layer is just an optimization, never a

requirement.

!  Recovery is left to higher layers in many

cases.

E.g.: The network layer can always send a packet and

 wait for it to be acknowledged. If the ack is not forthcoming before the timer expires, the sender can

 just send the entire message again.

3/31/15  [email protected] 14

Page 15: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 15/112

  The DLL translates the physical layer's raw bit stream into

 discrete units (messages) called frames. How can frame be

 transmitted so the receiver can detect frame boundaries? That

 is, how can the receiver recognize the start and end of a frame? We will discuss four ways:

• 

Byte Count 

• 

Flag bytes with byte stuffing 

• 

Flag bits with bit stuffing•

 

Physical layer coding Violations

Framing

3/31/15  [email protected]

Page 16: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 16/112

Byte Count

 A byte stream. (a) Without errors. (b) With one error.

3/31/15  [email protected]

Page 17: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 17/112

Flag bytes with byte stuffing

(a) A frame delimited by flag bytes.

(b) Four examples of byte sequences before and after stuffing.

3/31/15  [email protected]

Page 18: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 18/112

Flag bits with bit stuffing

3/31/15  [email protected]

Bit stuffing bits pattern : 01111110

(a)  The original data.

(b)  The data as they appear on the line.

The data as they are stored in the receiver’s memory after destuffing.

Page 19: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 19/112

Physical layer coding Violations

!  Send a signal that doesn't conform to any legal bitrepresentation. For example, in the 4B/5B line code 4

data its are mapped to 5 signal bits to ensure sufficient

bit transitions. This means that 16 out of 32 signal

possibilities are not used. We can use some reserved

signals to indicate the start and end of frames.

The advantage of encoding violations is that it is easy to

find the start and end of frames and there is no need to

stuff the data.

3/31/15  [email protected]

Page 20: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 20/112

Combination of framing methods

!  Many data link protocols use a combination

of these methods for safety. A common

pattern used for Ethernet and 802.11 is to

have a frame begin with a well-defined

pattern called a preamble. The preamble is

then followed by a length (i.e. count) field in

the header that is used to locate the end ofthe frame.

3/31/15  [email protected]

Page 21: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 21/112

Error Control 

!  Must ensure that all frames are eventually

delivered to the network layer at the

destination and in the proper order.

!  Three components are required to do this:

Acknowledgments

TimersSequence Numbers

3/31/15  [email protected]

Page 22: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 22/112

Acknowledgments 

Reliable delivery is achieved using the"acknowledgments with retransmission"paradigm.

The receiver returns a special acknowledgment (ACK)frame to the sender indicating the correct receipt of aframe.

In some systems, the receiver also returns a negativeacknowledgment (NACK) for incorrectly-receivedframes.

This is only a hint to the sender so that it canretransmit a frame right away without waiting for atimer to expire. 

3/31/15  [email protected]

Page 23: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 23/112

Timers 

One problem that simple ACK/NACK schemes fail to

address is recovering from a frame that is lost, and

as a result, fails to solicit an ACK or NACK.

!  What happens if an ACK or NACK becomes lost?

Retransmission timers are used to resend framesthat don't produce an ACK. When sending a frame,

schedule a timer to expire at some time after the

 ACK should have been returned. If the timer goesoff, retransmit the frame. 

3/31/15  [email protected]

Page 24: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 24/112

Sequence Numbers 

!  Retransmissions introduce the possibility of

duplicate frames.

!  To suppress duplicates, add sequence

numbers to each frame, so that a receiver

can distinguish between new frames and

repeats of old frames.

!  Bits used for sequence numbers depend onthe number of frames that can be outstanding

at any one time. 3/31/15  [email protected]

Page 25: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 25/112

Flow Control 

!  Flow control deals with throttling the speed of

the sender to match that of the receiver.

Usually, this is a dynamic process, as the

receiving speed depends on such changingfactors as the load, and availability of buffer

space.

!  Feedback-based flow control

Rate-based flow control (never used in data link

layer) 

3/31/15  [email protected]

Page 26: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 26/112

3.2 Error Detection and Correction

! Error-Correcting Codes

! Error-Detecting Codes

putting in enough redundancy

 along with the data to be able to detect (and correct) data errors.

3/31/15  [email protected]

Page 27: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 27/112

Errors 

•  In data communication, line noise is a fact

 of life (e.g., signal attenuation, natural

 phenomenon such as lightning, and the

 telephone worker).•  Low error rates: fiber optical

•  High error rates: wireless 

3/31/15  [email protected] 27

Page 28: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 28/112

Error  Correcting/Detecting Codes 

!  Detecting and correcting errors requires

redundancy - sending additional information

along with the data.

!  Two basic strategies:

Error Correcting Codes: Include enough

redundancy to detect and correct errors.

!  Error Detecting Codes(FEC, Forward ErrorCorrection): Include enough redundancy bits to

detect errors and use ACKs and retransmissions

to recover from the errors.3/31/15  [email protected] 28

Page 29: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 29/112

Modeling errors

!  One model is that errors are caused by extreme values of thermal noise that overwhelm the

 signal briefly and occasionally, giving rise to

 isolated single-bit errors.!  Another model is that errors tend to come in

 bursts rather than singly. This model follows

 from the physical processes that generate them

 – such as a deep fade on a wireless channel.

!  Both models matter in practice, and they have

 different trade-offs.3/31/15  [email protected] 29

Page 30: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 30/112

Error-Correcting Codes

1.  Hamming codes.

2.  Binary convolutional codes.

3.  Reed-Solomon codes.

4.  Low-Density Parity Check codes.

3/31/15  [email protected] 30

Codeword (n,m): n bits=m bits data + r  bits redundant

Code rate: m/n 

Page 31: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 31/112

Hamming Distance 

!  Given any two codewords, we can determine

how many of the bits differ by Exclusive OR

(XOR) of the two words. The number of 1 bits

in the result is the Hamming Distance.

If two codewords are d bits apart, d errors

are required to convert one to the other.3/31/15  [email protected]

1000100110110001

---------------------

00111000

Page 32: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 32/112

 Hamming Distance 

In general, all 2m possible data words are legal.

However, by choosing check bits carefully, the

resulting codeword will have a large Hamming

Distance. The larger the Hamming distance, thebetter the codes are able to detect errors.

To detect d 1-bit errors requires having a Hamming

Distance of at least d + 1 bits.

!  To correct d errors requires distance of 2d + 1 bits.Intuitively, after d errors, the garbled messages is

still closer to the original message than any other

legal codeword.3/31/15  [email protected]

Page 33: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 33/112

Correcting errors

!   As an example, consider a 10-bit code used to represent 4 possiblevalues:

"00000 00000", "00000 11111", "11111 00000", and "11111 11111". 

Its Hamming distance is 5, and we can correct 2 single-bit errors.

Example: "10111 00010" becomes "11111 00000" by changing onlytwo bits.

However, if the sender transmits "11111 00000" and the receiver

sees "00011 00000", the receiver will not correct the errorproperly.

Finally, in this example we are guaranteed to catch all 2-bit errors,but we might do better: if "00111 00111" contains 4 single-biterrors, we will reconstruct the block correctly.

3/31/15  [email protected]

Page 34: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 34/112

Hamming code

3/31/15  [email protected] 34

Example of an (11, 7) Hamming codecorrecting a single-bit error.

Page 35: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 35/112

Convolutional code

3/31/15  [email protected] 35

The NASA binary convolutional code used in 802.11.

Page 36: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 36/112

Error-Detecting Codes

!  Linear, systematic block codes

1.  Parity.

2.  Checksums.

3. 

Cyclic Redundancy Checks (CRCs).

3/31/15  [email protected] 36

Page 37: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 37/112

Parity Bits 

!   A single parity bit is appended to each data block (e.g.

each character in ASCII systems) so that the number

of 1 bits always adds up to an even (odd) number.

1000000(1) 1111101(0)

!  The Hamming Distance for parity is 2, and it cannot

correct even single-bit errors (but can detect single-biterrors).

3/31/15  [email protected]

Page 38: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 38/112

Interleaving of parity bits

3/31/15  [email protected] 38

Interleaving of parity bits to detect a burst error.

Page 39: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 39/112

Checksum

!  Checksum means a group of check bits associated with a message, regardless of how

 they are calculated.

!  The checksum is usually placed at the end of the message, as the complement of the sum function. So errors may be detected by

 summing the entire received codeword, both

 data and checksum. If the result comes out to

 be zero, no error has been detected.

16bit Internet checksum3/31/15  [email protected] 39

Page 40: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 40/112

Cyclic Redundancy Check 

!  The most popular error detection code at the link layer is based on polynomial code, also known

 as Cyclic Redundancy Check .

!  Allows us to acknowledge correctly received frames and to discard incorrect ones.

[email protected] 40

Page 41: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 41/112

Cyclic Redundancy Check

Detects!   All single bit errors

!   All double-bit errors if C(x) has a factor with at least 3 terms

!   Any odd number of errors, if (x+1) divides C(x)

!   Any burst error of length < length of FCS

!  Most large burst errors

!  Three polynomials are in common use they are:!  CRC-16 = x16+x15+x2+1 (used in HDLC)

!  CRC-CCITT = x16+x12+x5+1

!  CRC-32 = x32+x26+x23+ x22+x16+x12+ x11+x10+x8+ x7+x5+x4+

x2+x1+1 (used in Ethernet)

3/31/15  [email protected]

Page 42: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 42/112

Example calculation of the CRC

3/31/15  [email protected] 42

Page 43: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 43/112

 

A hardware implementation for a 16-bit CRC(Shift Register  Sequences)

 

Cyclic Redundancy Check 

3/31/15  [email protected]

Page 44: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 44/112

3.3 Elementary Data Link Protocols

!  Utopian Simplex Protocol

!  Simplex Stop-and-Wait Protocol

!  Error-Free Channel

!  Simplex Stop-and-Wait Protocol

!  Noisy Channel

3/31/15  [email protected]

Page 45: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 45/112

Services to Network Layer  

Data handed to a DLL by a Network Layer on one module, are

handed to the Network Layer on another module by that DLL.

!  The remote Network Layer peer should receive the identicalmessage generated by the sender (e.g., if the data link layer adds

control information, the header information must be removed beforethe message is passed to the Network Layer).

The Network Layer may want to be sure that all messages it sends,

will be delivered correctly (e.g., none lost, no corruption). Note that

arbitrary errors may result in the loss of both data and control

frames.!  The Network Layer may want messages to be delivered to the

remote peer in the exact same order as they are sent.

3/31/15  [email protected]

Page 46: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 46/112

Implementation of Layers 

3/31/15  [email protected]

Implementation of the physical, data link, and network layers.

Page 47: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 47/112

Key Assumptions

!  Physical Layer, data link layer, and network layerare independent processes that communicate bypassing messages back and forth.

!  Machine A wants to send a long stream of datato machine B, using a reliable, connection-oriented service.

!  A is assumed to have an infinite supply of data

ready to send and never has to wait for data tobe produce.

!  Machines do not crash

3/31/15  [email protected]

Page 48: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 48/112

Protocol Definitions

Some definitions needed in the protocols to follow.

These are located in the file protocol.h.

3/31/15  [email protected]

. . .

Page 49: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 49/112

Protocol

Definitions

(ctd.)

Some definitions

needed in the

 protocols to follow.

These are located in

the file protocol.h.

3/31/15  [email protected]

Page 50: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 50/112

Utopian Simplex Protocol

!  Assumptions:

!  Data transmission in one direction only (simplex).

!  No errors take place on the physical channel.

The sender/receiver can generate/consume an

infinite amount of data.

 Always ready for sending/receiving.

3/31/15  [email protected]

Page 51: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 51/112

Utopian Simplex Protocol -1

3/31/15  [email protected] 51

Page 52: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 52/112

Utopian Simplex Protocol -2

3/31/15  [email protected] 52

A Si l S d W i P l

Page 53: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 53/112

A Simplex Stop and Wait Protocol

for an Error-Free Channel

Assumptions:!

 

No longer assume receiver can process incoming

data infinitely fast.

Sender ships one frame and then waits for

acknowledgment (stop and wait.)

The contents of the acknowledgment frame are

unimportant.

Data transmission is one directional, but must

have bi-directional line. A half-duplex (one

direction at a time) physical channel would suffice.3/31/15  [email protected]

Page 54: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 54/112

A Simplex Stop and Wait Protocol for 

 an Error-Free Channel -1

3/31/15  [email protected] 54

 A simplex stop-and-wait protocol.

Page 55: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 55/112

A Simplex Stop and Wait Protocol for 

 an Error-Free Channel -2

3/31/15  [email protected] 55

Si l St d W it P t l

Page 56: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 56/112

Simplex Stop-and-Wait Protocol

for a Noisy Channel 

Assumptions:!  The channel is noisy and we can lose

frames (they never arrive).

!  Simple approach:!

 

add a timer to the sender so if no ACK aftera certain period, it retransmits the frame.

3/31/15  [email protected]

Page 57: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 57/112

Particular Scenario 

!  Scenario of a bug that could happen if we’re not careful: 

!   A transmits frame one

B receives A1

!  B generates ACK

!   ACK is lost

 A times out, retransmits

!  B gets duplicate copy of A1 (and sends it on to network layer.)

(another duplicate copy is caused by long delay)

3/31/15  [email protected]

Page 58: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 58/112

Sequence number

!  Use a sequence number:

!  Have the sender put sequence number in the header

of each frame it sends. Then the receiver can check

the sequence number of each arriving frame to see ifit is new frame or a duplicate to be discarded.

!  The minimum number of bits needed for SEQ

!  The only ambiguity in this protocol is between a

frame, m, and its direct successor, m+1.!  1-bit is sufficient for this simple case because only

concerned about two successive frames.

3/31/15  [email protected]

Page 59: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 59/112

ARQ 

!  Positive Acknowledgment with Retransmission (PAR)/ Automatic Repeat reQuest (ARQ): 

!  Sender waits for positive acknowledgment before

advancing to the next data item. 

3/31/15  [email protected]

Simplex Stop and Wait Protocol

Page 60: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 60/112

Simplex Stop-and-Wait Protocol

for a Noisy Channel -1 

A positive acknowledgement with retransmission protocol.

Continued" 

3/31/15  [email protected]

Simplex Stop and Wait Protocol

Page 61: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 61/112

Simplex Stop-and-Wait Protocol

for a Noisy Channel -2

3/31/15  [email protected] 61

. . .

S S

Page 62: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 62/112

Simplex Stop-and-Wait Protocol

for a Noisy Channel -3 

A positive acknowledgement with retransmission protocol.

3/31/15  [email protected]

Page 63: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 63/112

Efficiency Problem 

Problem with stop and wait protocols is that sender can onlyhave one unACKed frame outstanding.

Example: Long Fat Network 

Short frame length: 1000 bit frames

High bandwidth: 1 Mbps channel (satellite)Long transit time: 270 ms propagation delay 

Frame takes 1msec ( 1000 bits/(1,000,000 bits/sec) = 0.001 sec= 1 msec ) to send. With propagation delay the ACK is not seenat the sender again until time 541msec. Very poor channelutilization.

!  We can use larger frames, but the maximum size is limited by the

bit error rate of the channel. The larger the frame, the higher theprobability that it will become damaged during transmission. 

3/31/15  [email protected]

Page 64: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 64/112

Performance evaluation

Performance evaluation!  F = frame size (bits)

C = channel capacity (Bandwidth in bits/second)

!  I = propagation delay plus processor service time (second) 

Time to transmit a single frame= F/C

Total Delay= 2I

In Stop and wait the line is busy for F/C and idle for 2I, giving

line utilization=F/(F+2CI) < 50% if F<2CI

a network is considered an LFN if its bandwidth-delay  product is significantly larger than 105 bits (~12 kB). 

3/31/15  [email protected]

Page 65: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 65/112

3.4 Sliding Window Protocols

Assumptions:! 

Use more realistic two-way communication

Use a separate link for data in both directions

the reverse channel has the same capacity as the forward channeland is almost entirely wasted.

!  Interleave two kinds of frames on the same link(containing a "kind" field):#  Data frame

Control frame:# 

 ACK ( containing sequence number of last correctly receivedframe). 

3/31/15  [email protected]

Page 66: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 66/112

Piggybacking 

Piggybacking ! 

The technique of temporarily delaying outgoingacks so that they can be hooked onto the next

outgoing data frame.!  The principal advantage :

!  a better use of the available channel bandwidth.

Piggybacking issue:! 

For better use of bandwidth, how long should wewait for outgoing data frame before sending the ACK on its own. 

3/31/15  [email protected]

Page 67: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 67/112

Sliding Window Protocols

3 bidirectional protocols

!  A One-Bit Sliding Window Protocol

!  A Protocol Using Go Back N

!  A Protocol Using Selective Repeat

Differ in terms of

!  efficiency, complexity, and buffer

requirements 

3/31/15  [email protected] 67

Page 68: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 68/112

Sending/Receiving Window 

The sender maintains a set of sequencenumbers  corresponding to frames it ispermitted to send. These frames are said to fallwithin the sending window.

!  Similarly, the receiver also maintains areceiving window corresponding to the set offrames it is permitted to accept.

!  The two windows need not have the same lower

and upper limits or even have the same size. And need not have the fixed size, they can growor shrink over the course of time as frames aresent and received.

3/31/15  [email protected]

Page 69: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 69/112

Example of a sliding window protocol

For stop-and-wait sliding windowprotocol,!  MaxSeq = 2n – 1, n>=1

!  Window size = 1.

!  Protocol works, all frames delivered incorrect order.!  Easy to implement

!  Requires little buffer space.

!  Poor line utilization due to stop-and-wait. (Tobe solved in next example.) 

3/31/15  [email protected] 69

Page 70: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 70/112

An Example of size 1

 A sliding window of size 1, with a 3-bit sequence number.

(a) Initially.(b) After the first frame has been sent.

(c) After the first frame has been received.

(d) After the first acknowledgement has been received.

3/31/15  [email protected]

The sequence numbers within the sender's window represent frames that havebeen sent or can be sent but are as yet not acknowledged.

Page 71: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 71/112

Sender’s Window

!  Since frames currently within the sender’s

window may be lost or damaged in transit,

the sender must keep all those frames in its

memory for possible retransmission.!  If the max window size is n, the sender needs

n buffers (at least) to hold the unacked

frames. If the window ever grows to its maxsize, the sending DLL must shut off the

network layer until another buffer free.

3/31/15  [email protected]

Page 72: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 72/112

Receiver’s window

The receiver’s window corresponds to theframes it may accept. Any frame fallingoutside the window is discarded.

!  When a frame whose seq num is equal to thelower edge of the window is received, it ispassed to the network layer, an ack isgenerated and the window is rotated by one.

!  Note that a receiver’s window size of 1means that the DLL only accepts frames inorder, but for larger windows this is not so.

3/31/15  [email protected]

A One-Bit Sliding Window

Page 73: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 73/112

A One Bit Sliding Window

Protocol

Continued" 

3/31/15  [email protected]

A One-Bit Sliding Window

Page 74: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 74/112

A One-Bit Sliding Window

Protocol (ctd.)

3/31/15  [email protected]

Page 75: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 75/112

A peculiar situation

Two scenarios for protocol 4. (a) Normal case. (b)  Abnormal case. The notation is (seq, ack, packet number ). Anasterisk indicates where a network layer accepts a packet.

3/31/15  [email protected]

Page 76: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 76/112

Pipelining Strategies

!  Allow multiple frames to be in transmission

 simultaneously.

Sender does not wait for each frame to be

 ACK'ed. Rather it sends many frames with the assumption that they will arrive. Must still get

 back ACKs for each frame.

Provides more efficient use of transmit bandwidth,

 but error handling is more complex.

3/31/15  [email protected] 76

Page 77: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 77/112

Problem and Solution

!  What if 20 frames transmitted, and the 2nd

 has an error.

Frames 3-20 will be ignored at receiver side?

Sender will have to retransmit.! 

What are the possibilities?

!  Two strategies for receive Window size:

!  Go back n

Selective repeat

3/31/15  [email protected] 77

A P t l U i G B k N

Page 78: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 78/112

A Protocol Using Go Back NGo back n - equivalent to receiver's window size of one.If receiver sees bad frames or missing sequence numbers,

 subsequent frames are discarded.No ACKs for discarded frames. 

3/31/15  [email protected]

Pipelining and error recovery. Effect on an error when(a)Receiver’s window size is 1.

S l ti R t

Page 79: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 79/112

Selective Repeat

Selective repeat - receiver's window size larger than one.Store all received frames after the bad one.ACK only last one received in sequence. 

3/31/15  [email protected]

Pipelining and error recovery. Effect on an error when(b) Receiver’s window size is large.

Page 80: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 80/112

!  These two alternative approaches are tradeoffbetween bandwidth and data link layer bufferspace on the receiver side. 

!  In either case will need buffer space on the sender

side. Cannot release until an ACK is received.! 

Use a timer for each unACK'ed frame that has beensent. 

Must be able to enable/disable network layer because

may not be able to handle more send data if there aremany unACK’d frames 

Bandwidth & buffer space 

3/31/15  [email protected]

Page 81: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 81/112

MAX Seq No. vs. Window Size 

!  MaxSeq is 7 (Valid Seq No. 0~7) . How big can

window size be?

consider the following scenario: 

The sender sends frames 0 through 7. ! 

 A piggybacked acknowledgement for frame 7

eventually comes back to the sender. 

!  The sender sends another eight frames, again with

sequence numbers 0 through 7. !  Now another piggybacked acknowledgement for

frame 7 comes in. 

3/31/15  [email protected]

Page 82: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 82/112

Max Sending Window Size = MAX_SEQ 

The question is this: Did all eight framesbelonging to the second batch arrive

successfully, or did all eight get lost (counting

discards following an error as lost)?!

  In both cases the receiver would be sendingframe 7 as the acknowledgement. The sender

has no way of telling. For this reason the

maximum number of outstanding frames must

be restricted to MAX_SEQ (not MAX_SEQ+1). 

3/31/15  [email protected]

Page 83: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 83/112

Sliding

Window Protocol

Using Go

Back N

Continued" 

3/31/15  [email protected]

Sliding Window Protocol Using Go

Page 84: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 84/112

g g

Back N

Continued" 

3/31/15  [email protected]

Sliding Window Protocol Using Go

Page 85: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 85/112

Sliding Window Protocol Using Go

Back N

Continued" 

3/31/15  [email protected]

Sliding Window Protocol Using Go

Page 86: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 86/112

Sliding Window Protocol Using Go

Back N

3/31/15  [email protected]

Page 87: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 87/112

timers

Simulation of multiple timers in software.

3/31/15  [email protected]

A Sliding Window Protocol Using Selective Repeat

Page 88: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 88/112

A Sliding Window Protocol Using Selective Repeat

Continued " 

3/31/15  [email protected]

A Sliding Window Protocol Using Selective Repeat (2)

Page 89: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 89/112

Continued " 

g g p ( )

3/31/15  [email protected]

A Sliding Window Protocol Using Selective Repeat (3)

Page 90: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 90/112

Continued " 3/31/15  [email protected]

A Sliding Window Protocol Using Selective Repeat (4)

Page 91: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 91/112

A Sliding Window Protocol Using Selective Repeat (4)

3/31/15  [email protected]

Page 92: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 92/112

Nonsequential receiving problems

(a) Initial situation with a window size 7.

(b) After seven frames sent and received, but not acknowledged.

(acks all lost, sender times out and resend f0, 0 is within the newwindow[7,0,1,2,3,4,5])

(c) Initial situation with a window size of four.

(d) After four frames sent and received, but not acknowledged.

3/31/15  [email protected]

round-ribbon buffer space

window  new window

Page 93: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 93/112

Max Receiving Window Size = (MAX_SEQ + 1)/2 

Nonsequential receive introduces certainproblems not present in protocols in whichframes are only accepted in order.

!  The essence of the problem is that after thereceiver advanced its window, the new rangeof valid sequence numbers overlapped theold one.

!  the max window size for selective repreat willbe (MAX_SEQ + 1)/2. Thus, for 3-bitsequence numbers, the window size is 4. 

3/31/15  [email protected]

Page 94: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 94/112

Windows size

Protocol WS: Sending Window WR: Receiving Window

Stop-N-Wait 1 1

Go back n >1 ( <= 2m-1 ) 1

Selective Repeat >1 >1 ( <=2m-1 )

3/31/15  [email protected] 94

Sequence No. is m bits,

WS >= WR, and WS +WR<=2m

Page 95: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 95/112

Problem fixed: light reverse traffic 

!  Ack is piggybacked onto the next outgoingdata frame in Goback n protocol (assume the

channel is heavily loaded)

What if the reverse traffic is light:!

 

 After an in-squence data frame arrives, anauxiliary timer is started by start_ack_time. If no

reverse traffic has presented itself before this

timer expires, a separate acknowledgement frameis sent.

!   An Interrupt due to the auxiliary timer is called anack_timeout event.

3/31/15  [email protected]

More efficient strategy for

Page 96: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 96/112

error dealing

!  NAK (Negative acknowledgement) frame!  Whenever the receiver has reason to suspect that

an error has occurred, it sends a NAK frame back

to the sender. such a frame is a request for

retransmission of the frame specified in the NAK.!   A damaged frame arrived

 A frame other than the expected on arrived( potential

lost frame)

!  If the NAK gets lost, no real harm is done, sincethe sender will eventually time out and retransmit

the missing frame anyway.

3/31/15  [email protected]

Page 97: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 97/112

Timer administration ?

!  Sender:

!  The time required for a frame to propagate to thedestination, be processed there, and have the

 ACK come back is constant, timer is set to be justslightly larger than the normal time interval

expected between sending a frame and receiving

its ACK.

!  Reverse traffic is light ?

!  Variable processing time?

3/31/15  [email protected]

Performance

Page 98: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 98/112

Performance

Channel utilization: bits-transmitted/capacity. Now we’ll do it again with a bit more precision.

What is the channel efficiency of a stop-and-wait protocol?

F = frame size = D + H = data bits + header bits 

C = channel capacity (bps)I = propagation delay plus processor service time (seconds) 

A = ack size (bits)Time between frames: Time to get frame on wire + Propagation

 time for frame + Time to get ACK on wire + Propagation time for ACK = F/C + I + A/C + I

Time spent sending data (doing useful stuff): D/C

Efficiency:D/C D D

--------------------- = ------------------------ = ------------------------F/C + 2I + A/C F + 2IC + A D + H + 2IC + A3/31/15  [email protected]

Page 99: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 99/112

3.5 Example Data Link Protocols

1.  Packet over SONET

2. 

 ADSL (Asymmetric Digital Subscriber Loop)

3/31/15  [email protected]

Page 100: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 100/112

Packet over SONET

!  IP (Internet Protocol)

!  PPP(Point to Point Protocol)

!  SONET (Synchronous Optical Network)

3/31/15  [email protected] 100

Packet over SONET. (a) A protocol stack. (b) Frame relationships

PPP Features

Page 101: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 101/112

 

PPP Features

!  Separate frames, error detection

 A framing method that unambiguously delineates the end of one

frame and the start of the next one. The frame format also

handles error detection

!  LCP (Link Control Protocol)! 

 A link control protocol for bringing lines up, testing them,negotiating options, and bringing them down again gracefully

when they are no longer needed.

!  NCP (Network Control Protocol)

!   A way to negotiate network-layer options in a way that

is independent of the network layer protocol to beused. 

3/31/15  [email protected]

Compare to HDLC

Page 102: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 102/112

(High-Level Data Link Control) 

!  Similar to HDLC, but is byte-oriented.

!  PPP doesn’t provide reliable datatransfer by default.

!  Reliable data transfer can be requested as anoption (as part of LCP). However it is rarelydone in practice

3/31/15  [email protected]

Page 103: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 103/112

point-to-point communication 

Internet

Backbone

leased lines 

!  all connections to the outside world go

through one or two routers that have point-to-

point leased lines to distant routers.

3/31/15  [email protected]

Page 104: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 104/112

PPP frame format 

3/31/15  [email protected]

The PPP full frame format for unnumbered mode operation

(connectionless unacknowledged service)

Page 105: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 105/112

The Protocol field 

!  Its job is to tell what kind of packet is in the Payload field.

Protocols starting with a 0 bit are network layer protocols

such as IP v4, IP v6 or other protocols : IPX, appletalk

!  Codes starting with a 1 bit are used for PPPconfiguration protocols, including LCP and a different

NCP for each network layer protocol supported.

The default size of the Protocol field is 2 bytes, but it canbe negotiated down to 1 byte using LCP.

3/31/15  [email protected]

Page 106: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 106/112

State Machine

3/31/15  [email protected]

State diagram for bringing a PPP link up and down

Page 107: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 107/112

ADSL

!  Asymmetric Digital Subscriber Loop

3/31/15  [email protected] 107

A typical ADSL equipment

Page 108: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 108/112

[email protected] 108

configuration.(Ch-2)

NID (Network Interface Device)

DSLAM (Digital Subscriber Line Access Multiplexer )

3/31/15 

ADSL P l S k

Page 109: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 109/112

ADSL Protocol Stacks

3/31/15  [email protected] 109

ATM Ad t ti L 5

Page 110: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 110/112

ATM Adaptation Layer 5

3/31/15  [email protected] 110

 AAL5 frame carrying PPP data

Page 111: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 111/112

What We Have Learned

!  Converting raw bit stream into frame stream: charactercount, bit stuffing, character stuffing

Error detection and correction: parity, checksum, CRC

Flow control: keeping the pace of sender and receiver

DLL protocols: sliding window

Specification and Verification: correctness, completeness,reachability analysis, failure cases

3/31/15  [email protected]

Page 112: Chapter3 DataLink

7/21/2019 Chapter3 DataLink

http://slidepdf.com/reader/full/chapter3-datalink 112/112

!  End Ch3