• 沒有找到結果。

DATA LINK LAYER DESIGN ISSUES

N/A
N/A
Protected

Academic year: 2022

Share "DATA LINK LAYER DESIGN ISSUES "

Copied!
99
0
0

加載中.... (立即查看全文)

全文

(1)

CHAPTER 3 THE DATA LINK LAYER

CHAPTER 3 THE DATA LINK LAYER (数据链路层)

• Data Link Layer Design Issues

E D t ti d C ti

• Error Detection and Correction

• Elementary Data Link Protocols

• Sliding Window Protocols

• Example Data Link ProtocolsExample Data Link Protocols

(2)

DATA LINK LAYER DESIGN ISSUES

• Services provided to the network layerp y

• Framing

• Framing

• Error control

• Flow control

(3)

Data Link Layer Design Issues Data Link Layer Design Issues

• Functions

Providing a well defined service interface to the – Providing a well-defined service interface to the

network layer;

Dealing with transmission errors;

– Dealing with transmission errors;

– Regulating data flow so that slow receivers are not swamped by fast senders

swamped by fast senders.

• Relationship between packets and frames

(4)

Data Link Layer Design Issues Data Link Layer Design Issues

(a) Virtual communication.

(b) l i i

(b) Actual communication.

(5)

Data Link Layer Design Issues: Services Data Link Layer Design Issues: Services

• Three types of services:

– Unacknowledged connectionless service, – Acknowledged connectionless service, – Acknowledged connection-oriented service.

• Unacknowledged connectionless service (无确认的无连 接服务)

接服务)

– No connection is established beforehand or released afterward

afterward.

– The source sends frames; the destination does not acknowledge. No attempt is made to recover any lost acknowledge. No attempt is made to recover any lost frames in the data link layer.

– Appropriate when the error rate is very low.

Appropriate for real-time traffic (Ethernet)

(6)

Data Link Layer Design Issues: Services Data Link Layer Design Issues: Services

• Acknowledged connectionless service (有确认的无连 接服务)

接服务)

– No connection

E h f t i k l d d

– Each frame sent is acknowledged.

– Useful for unreliable channels, such as wireless systems (WIFI)

systems. (WIFI)

• Acknowledged connection-oriented service (有确认的

面向连接服务)

面向连接服务)

– A connection is established before transmission.

– Each frame sent over the connection is numberedEach frame sent over the connection is numbered and acknowledged.

– Each frame is received exactly once and that all frames are received in the right order.

(7)

Data Link Layer Design Issues: Framing (成帧) Data Link Layer Design Issues: Framing (成帧)

• The physical layer  the data link layer  the network p y y y layer

• The physical layer accepts a raw bit stream and attemptsThe physical layer accepts a raw bit stream and attempts to deliver it to the destination. This bit stream is not

guaranteed to be error free.

guaranteed to be error free.

• The data link layer transforms an unreliable channel into a reliable one and do flow control

a reliable one and do flow control

– The data link layer breaks the bit stream up into

di t f (帧) d t th h k f

discrete frames (帧) and compute the checksum for each frame.

– When a frame arrives at the destination, the checksum is recomputed. If OK, fine; otherwise deal with errors.

(8)

Data Link Layer Design Issues: Framing Data Link Layer Design Issues: Framing

• How to break the bit stream up into frames – Byte count

– Flag bytes with byte stuffingg y y g – Flag bits with bit stuffing

– Physical layer encoding violationPhysical layer encoding violation.

(9)

Data Link Layer Design Issues: Framing Data Link Layer Design Issues: Framing

• Byte count: to use a field in the header to specify the number of characters in the frame.

– Count can be garbled by a transmission error.

– Resynchronization problem.

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

(10)

Data Link Layer Design Issues: Framing Data Link Layer Design Issues: Framing

• Using flag bytes with byte stuffing (a) A frame delimited by flag bytes.

( ) y g y

(b) Examples of byte sequences before and after stuffing.

(11)

Data Link Layer Design Issues: Framing Data Link Layer Design Issues: Framing

• Using flag bits with bit stuffing. Ex: flag bits 01111110 ( ) Th i i l d

(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 destuffing.g

(12)

Data Link Layer Design Issues: Framing Data Link Layer Design Issues: Framing

• To use physical layer coding violationsp y y g

– For example, some LANs encode 1 bit of data by using 2 physical bits.

using 2 physical bits.

• Normally, a 1 bit is a high-low pair and a 0 bit is low high pair  Every data bit has a transition in low-high pair.  Every data bit has a transition in the middle, making it easy for the receiver to

locate the bit boundaries locate the bit boundaries.

• The combinations high-high and low-low are not

d f d t b t d f d li iti f i

used for data but are used for delimiting frames in some protocols.

(13)

Data Link Layer Design Issues: Framing Data Link Layer Design Issues: Framing

• To use a combination of a byte count with one of the y other methods for extra safety.

– When a frame arrives, the count field is used toWhen a frame arrives, the count field is used to locate the end of the frame.

– If the appropriate delimiter is present at that position – If the appropriate delimiter is present at that position

and the checksum is correct, the frame is accepted as valid

as valid.

– Otherwise, the input stream is scanned for the next d li it

delimiter.

– Ex: preamble + byte count in Ethernet and 802.11

(14)

Data Link Layer Design Issues: Error control Data Link Layer Design Issues: Error control

• Ensure reliable frame delivery: every frame arrives y y without damaging, frames arrive in order.

– To provide the sender with some feedbackTo provide the sender with some feedback

• Positive acknowledgement (ACK)

N ti k l d t (NAK)

• Negative acknowledgement (NAK) – To provide timeout timers

• Resend as necessary – To number framesTo number frames

• To distinguish retransmissions from originals

(15)

Data Link Layer Design Issues: Flow control Data Link Layer Design Issues: Flow control

What to do with a sender that systematically wants to y y

transmit frames faster then the receiver can accept them.

• To introduce flow control to throttle the sender intoTo introduce flow control to throttle the sender into

sending no faster than the receiver can handle the traffic.

• Flow control protocol contains well defined rules about

• Flow control protocol contains well-defined rules about when a sender may transmit the next frame.

T h

• Two approaches

– Feedback-based flow control (used at DLL)

– Rate-based flow control (not suitable for DLL)

(16)

ERROR DETECTION AND ERROR DETECTION AND

CORRECTION 差错检测与纠正 差错检测与纠正

E ti d

• Error-correcting codes

• Error-detecting codes

(17)

Error Detection and Correction Error Detection and Correction

• Transmission errors are going to be a fact of life for t

many years to come:

– The local loops in the PSTN (trunks and switching elements are digital)

elements are digital)

– Wireless communication.

• Error types:

• Error types:

– isolated errors, – burst errors

– burst errors.

• Two approaches: to send the data and some extra data for detecting or correcting errors.

for detecting or correcting errors.

– Error detection;

– Error correction.Error correction.

(18)

Error Detection and Correction: Hamming di

distance

• n-bit codeword: m message bits + r redundant bits.

n=m+r

• Hamming distance of two codeword: the # of bit positions in which two codeword differ

• Hamming distance of complete code

– In most data transmission apps, all 2m possible data messages are legal, not all 2n possible codewords are used

– It is possible to construct a complete list of legal codewords, and from this list find two codewords

whose Hamming distance is minimum. This distance

i th H i di t f th l t d

is the Hamming distance of the complete code

(19)

Error Detection and Correction:

Hamming distance

Error Detection and Correction:

Hamming distance The error-detection and error-correcting properties of a code depend on its Hamming distance

a code depend on its Hamming distance.

To detect d errors:

To detect d errors:

• you need d+1 Hamming distance code. (Because with such a code there is no way that d single bit errors can such a code there is no way that d single-bit errors can change a valid code into another valid codeword).

• A simple example of an error detecting code: a code in

• A simple example of an error-detecting code: a code in which a single parity bit is appended to the data.

For example For example,

10110101011010 0; 10110001011000 1.

A code with a single parity bit has a distance 2 so it can A code with a single parity bit has a distance 2 so it can be used to detect single errors.

(20)

Error Detection and Correction:

Hamming distance

Error Detection and Correction:

Hamming distance To use Hamming distance to correct d errors:

• you need 2d+1 Hamming distance code. (Because that way the legal codewords are so far apart that even with d

changes, the original codeword A is still closer to B than any other codeword C, so it can be uniquely determined.)

• A simple example of an error-correcting code, consider a code with only 4 valid codewords: 0000000000,

0000011111 1111100000 d 1111111111 0000011111, 1111100000, and 1111111111.

– This code has a distance 5, can detect 2 errors. If

0000000111 i th i k th t th i i l

0000000111 arrives, the receive know that the original must have been 0000011111.

If t i l h 0000000000 i t 0000000111 – If a triple error changes 0000000000 into 0000000111,

the error will not be corrected properly.

(21)

Error Detection and Correction:

i d

Error correction codes

• To design a code with m message bits and r check bits

th t ill ll ll i l t b t d

that will allow all single errors to be corrected:

– Each of the 2m legal messages has n illegal

codewords at a distance 1 from it Thus each of the codewords at a distance 1 from it. Thus each of the 2m legal messages requires n+1 bit patterns

dedicated to it.

– The total number of bit patterns is 2n: (m + r + 1) 2m <= 2n = 2 m+r

 (m+r+1) < 2r

– Given m, this puts a lower limit on the number of check bits needed to correct single errors.

– This theoretical limit can be achieved using a th d d t H i (1950)

method due to Hamming (1950).

(22)

Error Detection and Correction:

i d

Error correction codes

• Hamming code for single error:

– The bits of the codeword are numbered consecutively, starting with bit 1 at the left end.

– The bits that are powers of 2 (1,2,4,8, etc) are check bits.

The rest (3, 5,6,7,etc) are filled up with the m data bits.

– Each check bit forces the parity of some collection of bits, including itself, to be even (or odd). A bit may be

included in several parity computations.

– To see which check bits the data bit in position k

contributes to, rewrite k as a sum of powers of 2. For example, 11=1+2+8 and 29=1+4+8+16. A bit is

h k d b j t th h k bit i i it

checked by just those check bits occurring in its expansion (e.g., bit 11 is checked by bits 1, 2, and 8).

(23)

Error Detection and Correction:

i d

Error correction codes

• Hamming codes for single error:

– When a codeword arrives, the receiver initializes a counter to zero.

– It then examines each check bit, k (k=1,2,4,8,...) to see if it has the correct parity. If not, it adds k to the counter.

– If the counter is zero after all the check bits have

been examined, the codeword is accepted as valid. If the counter is nonzero, it contains the position of the

i t bit

incorrect bit.

– For example, if check bits 1, 2, and 8 are in error, the

i t d bit i 11 b it i th l h k d

inverted bit is 11, because it is the only one checked by bits 1, 2, 8.

(24)

Error Detection and Correction:

i d

Error correction codes

• Hamming codes can be used to correct burst errors indirectly.

– A sequence of k consecutive codewords are arranged as a matrix, one codeword per row.

– Transmit the matrix by one column at a time.

– When the frame arrives at the receiver, the matrix is reconstructed, one column at a time.

– If a burst error of length k occurs, at most 1 bit in each of the k codewords will have been affected, but the

Hamming code can correct one error per codeword, so the entire block can be restored.

– This method uses kr check bits to make blocks of km data bits immune to a single burst error of length k or less.

(25)

Error Detection and Correction: Error correction codes

• Hamming codes to correct burst errors

(26)

Error Detection and Correction:

i d

Error correction codes

• Other codes

– Binary Convolutional Codes – Reed-Solomon Codes

– Low-Density Parity Check Codes (LDPC)Low Density Parity Check Codes (LDPC)

(27)

Error Detection and Correction:

d i d

Error detection codes

• Error detection is less expensive than error ti

correction.

– Given a channel with the error rate as 10-6 per bit.

Let the block size be 1000 bits Let the block size be 1000 bits.

– To provide single error correcting, 10 check bits are need; a megabit of data would require 10,000 check need; a megabit of data would require 10,000 check bits.

– To merely detect a block with a single 1-bit error, y g one parity bit per block will suffice. Once every 1000 blocks an extra block (1001 bits) will have to be transmitted The total overhead for the error

be transmitted. The total overhead for the error

detection + retransmission method is 2001 bits per megabit of data, versus 10,000 bits for a Hamming code.

(28)

Error Detection and Correction:

d i d

Error detection codes

• Parity

• Checksum

• CRCCRC

(29)

Error Detection and Correction:

d i d

Error detection codes

• To detect single error by using parity bitg y g p y

– Append parity bit to the block to detect the possible single error

single error

• To detect a single burst of length k by using parity bit.

T t t th d t bl k t i bit id d k

– To treat the data block as a matrix n bits wide and k bits high. To append every row with a parity bit;

– To transmit the block one column at a time;

– To check the parity bit.

(30)

Error Detection and Correction:

Error detection codes (Checksum)

• Checksum treats data as N-bit words and adds N check bits that are the modulo 2N sum of the words

– Ex: Internet 16-bit 1 complement checksum

• Properties:Properties:

– Improved error detection over parity bits

V l bl t t ti dd d

– Vulnerable to systematic errors, e.g., added zeros

(31)
(32)

Error Detection and Correction:

d i d

Error detection codes

• Polynomial code or CRC (Cyclic Redundancy Check)y ( y y ) – To treat bit strings as representations of polynomials

with coefficients of 0 and 1 only.

with coefficients of 0 and 1 only.

– A k-bit frame is regarded as the coefficient list for a polynomial with k terms ranging from xk-1 to x0

polynomial with k terms, ranging from x to x . – For example, 110001  x5 + x4 +x0.

– Polynomial arithmetic is done modulo 2, according to the rules of algebraic field theory. There are no carries for addition or borrows for subtraction. Both addition and subtraction are identical to exclusive OR.

(33)

Error Detection and Correction:

d i d

Error detection codes

• Polynomial code or CRC (Cyclic Redundancy Check)y ( y y ) – The sender and receiver agree upon a generator

polynomial, G(x).

polynomial, G(x).

– Let M(x) be the polynomial corresponding to some frame with m bits

frame with m bits.

– The polynomial T(X) represented by the

h k d f i di i ibl b G( )

checksummed frame is divisible by G(x).

– When the receiver gets the checksummed frame, it tries dividing it by G(x). If there is a remainder, there has been a transmission error.

(34)

Error Detection and Correction:

d i d

Error detection codes

• Polynomial code or CRC (Cyclic Redundancy Check)y ( y y ) – Let r be the degree of G(x).

– Divide the bit string corresponding to G(x) into the – Divide the bit string corresponding to G(x) into the

bit string corresponding to M(x)xr, using modulo 2 division i e M(x)xr / G(x)

division, i.e. M(x)x / G(x)

– Subtract the remainder from the bit string

di t M( ) r i d l 2 bt ti

corresponding to M(x)xr using modulo 2 subtraction.

The result is the checksummed frame to be t itt d C ll it l i l T( )

transmitted. Call its polynomial T(x).

– Clearly, T(x) is divisible (modulo 2) by G(x).

(35)
(36)

Error Detection and Correction:

d i d

Error detection codes

• Polynomial code or CRC (Cyclic Redundancy Check)y ( y y ) – Imagine that a transmission error occurs, so that

instead of the bit string for T(x) arriving, T(x) + E(x) instead of the bit string for T(x) arriving, T(x) E(x) arrives.

– Each 1 bit in E(x) corresponds to a bit that has been – Each 1 bit in E(x) corresponds to a bit that has been

inverted.

If th k 1 bit i E( ) k i l bit

• If there are k 1 bits in E(x), k single-bit errors have occurred.

• A single burst error is characterized by an initial 1, a mixture of 0s and 1s, and a final 1, with all other bits being 0.

(37)

Error Detection and Correction:

d i d

Error detection codes

• Polynomial code or CRCy

– [T(X)+E(X)] / G(X) = E(X)/G(X)

– Those errors that happen to correspond to – Those errors that happen to correspond to

polynomials containing G(X) as a factor will slip by;

all other errors will be caught all other errors will be caught

– All single errors can be detected as long as G(X) has

th t

more than one term

– All double errors can be detected as long as G(X)

k i j

does not divide xk+1 for some k. E(X) = xi+xj

= xj(xi-j +1). Ex: x15+x14+1 will not divide xk+1 for any value of k below 32768

(38)

Error Detection and Correction:

d i d

Error detection codes

• Polynomial code or CRCy

– All errors with an odd # of bits can be detected as long as G(X) has x+1 as its factor

long as G(X) has x 1 as its factor

– A polynomial code with r check bits will detect all burst errors of length <= r

burst errors of length <= r.

– If the burst length is r+1, the remainder of the

di i i b G( ) ill b iff th b t i id ti l division by G(x) will be zero iff the burst is identical to G(x). This probability is 1/2r-1

– When an error burst longer than r+1 bits occurs, or several shorter bursts occur, the probability of a bad frame getting through unnoticed is 1/2r

(39)

Error Detection and Correction:

d i d

Error detection codes

(40)

ELEMENTARY DATA LINK PROTOCOLS

• A Utopian Simplex ProtocolA Utopian Simplex Protocol

A Si l S d W i P l

• A Simplex Stop-and-Wait Protocol

• A Simplex Protocol for a Noisy Channel

(41)

Elementary Data Link Protocols: y

Possible

Implementation

(42)

Elementary Data Link Protocols: y

Some Assumptions

• The physical layer data link layer and network

• The physical layer, data link layer, and network layer are independent processes that

i b i b k d

communicate by passing messages back and forth.

• Machine A wants to send a long stream of data to machine B using a reliable connection

to machine B using a reliable, connection- oriented service.

• Machines do not crash.

(43)

Elementary Data Link Protocols:

Sending and Receiving Frames

T d f

• To send a frame

– To accept a packet passed from the network layer

l h k i f b ddi d li k

– To encapsulate the packet in a frame by adding data link header and trailer to it

T t it it t th d t li k l th th hi – To transmit it to the data link layer on the other machine

• To receive a frame

I iti ll th i h j t it f t()

– Initially, the receiver has just wait_for_event()

– When something has happened, the procedure returns

If f i th HW t th h k

– If a frame arrives, the HW computes the checksum – If OK, it checks the control information in the header

If hi i ll i h i h k h k

– If everything is all right, it passes the packet to the network layer

(44)

Elementary Data Link Protocols:protocol h

Elementary Data Link Protocols:protocol.h

(45)

Elementary Data Link Protocols: protocol h

Elementary Data Link Protocols: protocol.h

(46)

Elementary Data Link Protocols: protocol h

Elementary Data Link Protocols: protocol.h

(47)

Elementary Data Link Protocols: Protocol 1 Elementary Data Link Protocols: Protocol 1

A Utopian simplex protocol

• Data are transmitted in one direction only.

• The communication channel never damages or loses frames.

• Both the transmitting and receiving network layers areBoth the transmitting and receiving network layers are always ready.

• Processing time can be ignoredProcessing time can be ignored.

• Infinite buffer space is available.

(48)

Elementary Data Link Protocols: Protocol 1

Elementary Data Link Protocols: Protocol 1

(49)

Elementary Data Link Protocols: Protocol 1

Elementary Data Link Protocols: Protocol 1

(50)

Elementary Data Link Protocols: Protocol 2 Elementary Data Link Protocols: Protocol 2

A simplex stop-and-wait protocol

• Data traffic is still simplex

• Data traffic is still simplex.

• The communication channel is assumed to be error free.

• The sender is always ready The receiver is NOT alwaysThe sender is always ready. The receiver is NOT always ready or the receiver has limited buffer space.

– The sender simply inserts a delay into protocol 1 to slow

it d ffi i tl t k f i th i

it down sufficiently to keep from swamping the receiver.

 low utilization of bandwidth.

– The receiver provides feedback to the sender, permitting p , p g the sender to transmit the next frame.

• Protocol (p2) ensures sender can’t outpace receiver:(p ) p

– Receiver returns a dummy frame (ack) when ready – Only one frame out at a time – called stop-and-waitOnly one frame out at a time called stop and wait – We added flow control!

(51)

Stop and Wait(Normal) Stop-and-Wait(Normal)

Data

A B

ACK Data next

ACK Data following

Data following

(52)

Elementary Data Link Protocols: Protocol 2

Elementary Data Link Protocols: Protocol 2

(53)

Elementary Data Link Protocols: Protocol 2

Elementary Data Link Protocols: Protocol 2

(54)

Elementary Data Link Protocols: Protocol 3 Elementary Data Link Protocols: Protocol 3

A simplex protocol for a noisy channel

• Data traffic is still simplex.

• The communication channel is NOT free of errors

• The communication channel is NOT free of errors.

• The receiver is NOT always ready.

• The possible solutions:

Protocol 2 + timer  duplicate packets – Protocol 2 + timer  duplicate packets – Protocol 2 + timer + to number the frame

• Protocols in which the sender waits for a positive

• Protocols in which the sender waits for a positive

acknowledgement before advancing to the next data item are often called PAR (Positive Acknowledgement with ( g Retransmission) or ARQ (Automatic Repeat reQuest)

(55)

Elementary Data Link Protocols:

Protocol 3

• ARQ (Automatic Repeat reQuest) adds error control – Receiver acks frames that are correctly deliveredy – Sender sets timer and resends frame if no ack

• For correctness frames and acks must be numbered

• For correctness, frames and acks must be numbered – Else receiver can’t tell retransmission (due to lost

k l ti ) f f

ack or early timer) from new frame

– For stop-and-wait, 2 numbers (1 bit) are sufficient

(56)

Stop and Wait(Data Error) Stop-and-Wait(Data Error)

Data

A B

NAK Data(Retransmission)

ACK Data next

Data next

(57)

Stop and Wait(Data Lost) Stop-and-Wait(Data Lost)

Data

A B

Data(Retransmission) Time Out

ACK Data next

Data next

(58)

Stop and Wait(ACK Lost) Stop-and-Wait(ACK Lost)

Data

A B

ACK Data(Retransmission)

Time Out Discard this Data

ACK Data next

Data next

(59)

Elementary Data Link Protocols: Protocol 3

Elementary Data Link Protocols: Protocol 3

(60)

Elementary Data Link Protocols: Protocol 3

Elementary Data Link Protocols: Protocol 3

(61)

Utlization of Stop and wait Utlization of Stop-and-wait

T

A B

Tframe Data

ACK Tprop

Utilization = Tframe

---------

2 T + T

ACK Data next

Tprop =

Distance 2 Tprop + Tframe

ACK

Distance ---

Speed of Signal

Tprop/ Tframe Tframe =

Frame size ---

Bi

 Tprop / Tframe

Utilization = 1 / (2  + 1) Bit rate

(62)

Utilization Sample Utilization Sample

S t llit Li k P ti D l t 270

• Satellite Link: Propagation Delay t

prop

= 270 ms

– Frame Size = 4000 bits

D t t 56 kb t 4/56 71

– Data rate = 56 kbps tframe = 4/56 = 71 ms

= t

prop

/t

frame

= 270/71 = 3.8

U 1/( +1) 0 12 – U = 1/( +1) = 0.12

• Short Link(1 km) : t

prop

= 5 s

Frame Size 4000 bits – Frame Size= 4000 bits

– Data rate=10 Mbps tframe = 4k/10M= 400  s

 = t /t =5/400=0 012

 = tprop /tframe =5/400=0.012 – U = 1/(+1) = 0.98

(63)

Sliding Window Protocols Sliding Window Protocols

Data 1

A B

ACK 1 Data 2

Data 3

ACK 2

Data 4 ACK 3

Data 5

Data 6 ACK 4

Data 6

ACK 5 ACK 6

(64)

Utlization of Sliding window Utlization of Sliding-window

A B

Tframe

A B

Data 1

Tprop Data …

Data N

Utilization = N Tframe

---------

Data Data

2 Tprop + Tframe

Data Utilization =

N / (2  + 1)

1 (if N > (2  + 1))

(65)

Sliding Window Sliding Window

• Window = Set of sequence numbers to send/receive

• Sender window

S d i d i h k i d

– Sender window increases when ack received – Packets in sender window must be buffered at

Source

– Sender window may grow in some protocolsy g p

(66)

Piggybacking Piggybacking

Data 1

A B

Data 2 Data 3

ACK +Data Data ACK 1

(67)

Sliding Window (Transmitter) Sliding Window (Transmitter)

6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5

Frames may be transmitted Frames already transmitted

6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5

F

F Last

Frame

Transmitted

Window shrinks from trailing edge as frames are sent

Window expands from leading edge as acknowledgments

i d Frame

Sequence Number Frame Sequence Number

are received

6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5

(68)

Sliding Window (Receiver) Sliding Window (Receiver)

6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5

Frames may be received Frames already received

6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5

F

F Last

Frame

acknowledged

Window shrinks from trailing edge as frames are received

Window expands from leading edge as acknowledgments Frame

Sequence Number Frame Sequence Number

g are sent

(69)

Sliding Window Example

Sliding Window Example

(70)

Sliding Window

(71)

SLIDING WINDOW PROTOCOLS (滑动窗口协议) SLIDING WINDOW PROTOCOLS (滑动窗口协议)

• Protocol 4: A one-bit sliding window protocol

• Protocol 5: A protocol using go back Np g g

l l i l i

• Protocol 6: A protocol using selective repeat

(72)

Sliding Window Protocols: Protocol 4

Sliding Window Protocols: Protocol 4

(73)

Sliding Window Protocols: Protocol 4

Sliding Window Protocols: Protocol 4

(74)

Sliding Window Protocols: Protocol 4 Sliding Window Protocols: Protocol 4

• No combination of lost frames or premature timeouts p can cause the protocol to deliver duplicate packets to either network layer, or skip a packet, or to get into a y p p g deadlock.

• A peculiar situation arises if both sides simultaneously send an initial packet

send an initial packet.

(75)

Sliding Window Protocols: Protocol 4 Sliding Window Protocols: Protocol 4

The notation is (seq, ack, info). An asterisk * indicates where a

network layer accepts a packet. (a) Normal case. (b)Abnormal case. y p p ( ) ( )

(76)

Go back N ARQ(Data Error) Go-back-N ARQ(Data Error)

Data 1

A B

1 buffer

ACK 1 Data 2

Data 3 Discard 2

Discard 3

Time

Data 4 Discard 3

Resend Data 2 R d D t 3

Discard 4 ACK 2

Out

Resend Data 3 ACK 2

ACK 3

(77)

Go Back N ARQ

Go-Back-N ARQ

(78)

Window Size of Go Back N Window Size of Go-Back-N

• Receive Window Size=1Receive Window Size 1

• Send Window Size <= MAX_SEQ (0…N)

0 1

0 1 1

2 3

1 2 3 4

Time

4 5

ACK 5

4 5

ACK 5

Out

lost

0

ACK 5

0 resend

new Send to discard

Network layer

(79)

Selective Repeat ARQ

Selective Repeat ARQ

(80)

Window Size of Selective Repeat ARQp Q

• Send Window Size <= (MAX_SEQ+1)/2

• Receive Window Size = Send Window Size

• Receive Buffer Number = Window Size

A k ll l t

Time out resend Send 7 packets

Ack all lost

Get 7 packets Is new or resend?

Init window New window

(81)

GBN vs SR GBN vs. SR

• Note that reliable data communication is also important for the Transport layerp p y

I TCP GBN SR?

• Is TCP GBN or SR?

• TCP uses GBN with buffers which has

i d f th GBN

improved performance than pure GBN

(82)

EXAMPLE DATA LINK PROTOCOLS

• Packet over SONET

• ADSL (Asymmetric Digital Subscriber Loop)

(83)

Example Data Link Protocols:

Example Data Link Protocols:

Packet over SONET

• Packet over SONET.

(a) A protocol stack.

(b) Frame relationships

(84)

Example Data Link Protocols:

Example Data Link Protocols:

Packet over SONET

• PPP provides three features

• PPP provides three features

– A framing method that unambiguously delineates the end of one frame and the start of the next one The

end of one frame and the start of the next one. The frame format also handles error detection.

– A link control protocol (链路控制协议) for bringing p ( ) g g lines up, testing them, negotiation options, and bring them down again gracefully when they are no longer needed

needed.

– A way to negotiate network-layer options in a way that is independent of the network layer protocol to that is independent of the network layer protocol to be used. The method chosen is to have a different

NCP (Network Control Protocol, 网络控制协议) for

h t k l t d

each network layer supported.

(85)

Example Data Link Protocols:

Example Data Link Protocols:

Packet over SONET

• The PPP full frame format for unnumbered mode operation

• Delimiters: 01111110

• Address: 11111111

• Control: 00000001

l ll h ki d f k i i h l d fi ld

• Protocol: To tell what kind of packet is in the Payload field.

• Payload: of variable length, up to some negotiated maximum.

Ch k CRC h k

• Checksum: CRC checksum.

(86)

Example Data Link Protocols:

Example Data Link Protocols:

Packet over SONET

State diagram for bringing a PPP link up and down

(87)

Example Data Link Protocols:

PPP over SONET

• Typical Scenario (establishing a connection)

– The PC first calls the ISP’s router via a modem. The router’s modem answers the phone and establish a physical connection

physical connection.

– The PC sends the router a series of LCP packets in the payload field of one or more PPP frames. These the payload field of one or more PPP frames. These packets and their responses select the PPP

parameters to be used.

– Once the parameters have been agreed upon, a series of NCP packets are sent to configure the network

layer (DHCP NAT) layer. (DHCP, NAT)

– Now, the PC is an Internet host and can send/receive IP packets.

IP packets.

(88)

Example Data Link Protocols:

PPP over SONET

• Typical Scenario (releasing a connection)

• Typical Scenario (releasing a connection)

– When the user is finished, NCP tears down the

k l i d f h IP dd

network layer connection and frees up the IP address.

– Then LCP shuts down the data link layer connection.

– Finally, the computer tells the modem to hang up the phone, releasing the physical layer connection.

p , g p y y

(89)

Example Data Link Protocols:

Example Data Link Protocols:

ADSL

ADSL protocol stacks.

(90)

Example Data Link Protocols:

Example Data Link Protocols:

ADSL

AAL5 frame carrying PPP data

(91)

E l D t Li k P t l

Example Data Link Protocols:

PPP:

Packet over SONET

(92)

E l D t Li k P t l

Example Data Link Protocols:

PPP:

ADSL(Asymmetric Digital Subscriber Loop)

(93)

E l D t Li k P t l

Example Data Link Protocols:

PPP:

ADSL(Asymmetric Digital Subscriber Loop)

(94)

Homework Homework

2.The following character encoding is used in a data link protocol:

A 01000111 B 11100011 FLAG 01111110 ESC 11100000 A: 01000111 B: 11100011 FLAG: 01111110 ESC: 11100000

Show the bit sequence transmitted(in binary) for the four-character frame A B ESC FLAG when each of the following framing methods frame A B ESC FLAG when each of the following framing methods is used:

(a) Byte count (a) Byte count.

(b) Flag bytes with byte stuffing.

(c) Starting and ending flag bytes with bit stuffing (c) Starting and ending flag bytes with bit stuffing.

(95)

Homework Homework

7. In the textbook, the authors show that for a channel with error rate 10^-6, error detecting based retransmission is more efficient than error correcting (see 27th slide). Please give ranges of the channel error rate in which error correcting is more efficient considering only for blocks in which error correcting is more efficient, considering only for blocks (1000 bits) with at most 1 bit error.

8. Hamming code is an effective way for error correcting. Show that the # of check bits(i.e. r) in the Hamming codes described in the

the # of check bits(i.e. r) in the Hamming codes described in the textbook(e.g., Fig.3-6) (almost) achieves the low bound of Eq (3-1).

(96)

Homework

9. Suppose you have the following 12-bit message: 010100111111

Homework

(a) Numbering bits from right to left (ie least-significant bit on the right) insert check bits according to to Hamming’s 1-bit error

right), insert check bits according to to Hamming s 1 bit error

correction system. Indicate which bits are check bits and which are message bits.

(b) Hamming’s scheme only corrects 1-bit errors. Since it’ s a di t 3 d it ld l b d t d t t 2 bit

distance 3 code, it could also be used to detect 2-bit errors.

Describe a 3-bit error (3 *1-bit errors) in the above codeword affecting only message bits

affecting only message bits

(not check bits) that would be undetected (and of course

uncorrected). Be sure to describe how and why the algorithm fails.

(97)

Homework Homework

16.Consider an original frame 110111011011. The generator

polynomial x^4+x+1, show the converted frame after appending the CRC.

22.A 3000-km-long T1 trunk is used to transmit 64-byte frames. How

bit h ld th b b f t l 5 d t l

many bits should the sequence numbers be for protocol 5 and protocol 6 respectively? The propagation speed is 6usec/km.

(98)

Homework Homework

32.Frames of 1000 bits are sent over a 1-Mbps channel using a

geostationary satellite whose propagation time from the earth is 270 msec Acknowledgements are always piggybacked onto data frames msec. Acknowledgements are always piggybacked onto data frames.

The headers are very short. Three-bit sequence numbers are used.

What is the maximum achievable channel utilization for (a) Stop-and-wait?

(b) Protocol 5?

(b) otoco 5?

(c) Protocol 6?

(99)

Homework Homework

33.Compute the fraction of the useful data bandwidth for protocol 6 h il l d d 50 kb t llit h l ith d t f

on a heavily loaded 50-kbps satellite channel with data frames

consisting of 40 header and 3960 data bits. Assume that the signal propagation time from the earth to the satellite is 270 msec ACK propagation time from the earth to the satellite is 270 msec. ACK frames never occur. NAK frames are 40 bits. The error rate for data frames is 1%, and the error rate for NAK frames is negligible. The sequence numbers are 3 bits.

參考文獻

相關文件

Central lab was done for toxicity check yet the sampling time is not within the allowable range as stated in protocol. Central lab data was reviewed prior to

When the ship clearing from alongside, the crews who retract safety net, gangway, and check the ship's forward and aft draft need to comply with following

Bell’s theorem demonstrates a quantitative incompatibility between the local realist world view (à la Einstein) –which is constrained by Bell’s inequalities, and

enough to pin down parameter space of dark matter candidates. ● Can check if those models are allowed by

To complete the “plumbing” of associating our vertex data with variables in our shader programs, you need to tell WebGL where in our buffer object to find the vertex data, and

Following the supply by the school of a copy of personal data in compliance with a data access request, the requestor is entitled to ask for correction of the personal data

Responsible for providing reliable data transmission Data Link Layer from one node to another. Concerned with routing data from one network node Network Layer

Discovering the City by Mining Diverse and Multimodal Data Streams – IBM Grand Challenge: New York City 360. §  Exploring and Integrating Multiple Contents and Sources for