Transcript
Page 1: EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester 2005 EEC-682: Computer Networks I-Wenbnig Zhao 5 Error-Correcting Codes N-bit codeword–

1

EEC-682/782Computer Networks I

Lecture 6

Wenbing [email protected]

(Lecture nodes are based on materials supplied by Dr. Louise Moser at UCSB and Prentice-Hall)

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 2

Outline

ReviewData Link Layer Design IssuesError Detection and Correction

Data link layerElementary Data Link ProtocolsSliding Window Protocols

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 3

Data Link Layer Design IssuesServices Provided to the Network Layer

Point-to-point, source-to-destination, “wirelike”Framing

Physical bit stream divided up into framesError Control

Acks and nacksSender has timer –within timeout get ack, or send againIf frame transmitted multiple times, receiver may get several copies

Use sequence numbersFlow Control

Sender may transmit frames faster than receiver can receive themThrottle sender so sends no faster than receiver can receive them

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 4

Framing

How does DL layer form frames?Insert time gapes between frames

Too risky, no timing guarantees, not usedCharacter countFlag bytes with byte stuffingStarting and ending flags, with bit stuffingPhysical layer coding violations

Applies only if encoding on medium contain some redundancyExample: encode 1 bit with 2 bits

1 => 100 => 01Can use 00 or 11 to delimit frames

Page 2: EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester 2005 EEC-682: Computer Networks I-Wenbnig Zhao 5 Error-Correcting Codes N-bit codeword–

2

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 5

Error-Correcting CodesN-bit codeword – an n-bit unit containing data and check bits (m bits of data, r bits redundant/check bits)Given any two codewords, it is possible to determine how many corresponding bits differ, using exclusive OR and counting number of 1 bits in the resultHamming distance – number of bit positions in which two codewords differ

If two codewords are a Hamming distance d apart, it will require d single-bit errors to convert one into the other

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 6

Error-Correcting Codes

In general, all 2m possible data messages are legal, but not all 2n

possible codewords are usedGiven the algorithm for computing the check bits, it is possibleto

Construct a complete list of legal codewordsFind two codewords whose Hamming distance is minimumThis distance is the Hamming distance of the complete code

To detect d errors, need a distance d+1 codeNo way that d single-bit errors can change a valid codeword into another valid codeword

To correct d errors, need a distance 2d+1 codeLegal codewords are so far part that even with d changes, orginalcodeword is still closer than any other codeword, so it can be uniquely determined

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 7

Hamming CodeThe bits of codeword are numbered consecutively, starting with bit 1 at the left end, bit 2 to its immediate right and so onThe bits that are powers of 2 (1,2,4,8,16,etc) are check bits

The rest are filled up with the m data bitsEach parity bit calculates the parity for some of the bits in the code word. The position of the parity bit determines the sequence of bits that it alternately checks and skips.

Position 1: check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, etc. (1,3,5,7,9,11,13,15,...)Position 2: check 2 bits, skip 2 bits, check 2 bits, skip 2 bits, etc. (2,3,6,7,10,11,14,15,...)Position 4: check 4 bits, skip 4 bits, check 4 bits, skip 4 bits, etc. (4,5,6,7,12,13,14,15,20,21,22,23,...)Position 8: check 8 bits, skip 8 bits, check 8 bits, skip 8 bits, etc. (8-15,24-31,40-47,...)etc.

Set a parity bit to 1 if the total number of ones in the positions it checks is odd. Set a parity bit to 0 if the total number of ones in the positions it checks is even (assuming even parity is used)

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 8

Hamming Code - Example

Data (character ‘H’): 1001000Create the data word, leaving spaces for the parity bits:

_ _ 1 _ 0 0 1 _ 0 0 0Calculate the parity for each parity bit

Position 1 checks bits 1,3,5,7,9,11: ? _ 1 _ 0 0 1 _ 0 0 0. Even number of 1’s, set position 1 to 0: 0 _ 1 _ 0 0 1 _ 0 0 0

Position 2 checks bits 2,3,6,7,10,11:0 ? 1 _ 0 0 1 _ 0 0 0. Even number of 1’s, set position 2 to 0: 0 0 1 _ 0 0 1 _ 0 0 0

Position 4 checks bits 4,5,6,7:0 0 1 ? 0 0 1 _ 0 0 0. Odd number of 1’s, set position 4 to 1: 0 0 1 1 0 0 1 _ 0 0 0

Position 8 checks bits 8,9,10,11,12:0 0 1 1 0 0 1 ? 0 0 0. Even number of 1’s, set position 8 to 0: 0 0 1 1 0 0 1 0 0 0 0

Code word: 00110010000.

Page 3: EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester 2005 EEC-682: Computer Networks I-Wenbnig Zhao 5 Error-Correcting Codes N-bit codeword–

3

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 9

Hamming Code

When a codeword arrives, Receiver initializes a counter to 0, It then examines each check bit, k, to see if it has the right parity.

If not, adds k to the counter. If counter is 0 after all check bits, the codeword is accepted as valid. If counter is nonzero, it contains the number of the incorrect bit

e.g., if 1, 2, 8 in error, bit in position 11 is invertedCan only correct single-bit error

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 10

Cyclic Redundant Code

Sender and receiver agree on generate polynomial G(x), with high and low bits = 1To compute checksum for some frame with m bits corresponding to M(x)

M > deg G(x) = rAppend checksum to end of frame so polynomial T(x) corresponding to checksummed frame is divisible by G(x)When receiver gets checksummed frame, divides T(x) by G(x)If remainder R(x) != 0, then transmission error

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 11

Algorithm to Compute CRC Checksum

Let m = deg M(x), r = deg G(x)Append r 0 bits to lower-order end of frame to obtain corresponding polynomial xrM(x)Divide bit string corresponding to xrM(x) by bit string corresponding to G(x)Subtract remainder R(x) from bit string corresponding to xrM(x)

Result is checksummed frameLet T(x) be its polynomial

xrM(x) = Q(x)G(x) + R(x)xrM(x) – R(x) = Q(x)G(x) = T(x)

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 12

Elementary Data Link Protocols

An Unrestricted Simplex ProtocolA Simplex Stop-and-Wait ProtocolA Simplex Protocol for a Noisy Channel

Page 4: EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester 2005 EEC-682: Computer Networks I-Wenbnig Zhao 5 Error-Correcting Codes N-bit codeword–

4

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 13

Elementary Data Link Protocols

Initial assumptionsPhysical, data link, network layers are independent processesSender has infinite amount of data ready to send, supplied by network layer“wire-like” service: reliable, source ordered deliveryPacket is treated as pure dataWhen sender accepts packet from NL, it encapsulates in a frame with a header and trailerReceiver waits for arrived of frame, which generates an interruptWhen frame arrives at receiver, hardware computes checksum

If error then DLL informed event = chksum_errElse DLL informed event = frame_arrival

DLL acquires frame from physical layer, checks control info in headerIf ok then passes packet to NL

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 14

Protocol Definitions

Continued

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 15

Protocol Definitions

Unrestricted Simplex Protocol

Additional assumptions

Processing time insignificantInfinite buffer spaceCommunication channel never loses or damages frames

Uses no sequence numbers or acks

Only event type frame_arrival

Page 5: EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester 2005 EEC-682: Computer Networks I-Wenbnig Zhao 5 Error-Correcting Codes N-bit codeword–

5

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 17

Simplex Stop-and-Wait Protocol

Drop assumptionReceiver processing time insignificant, or, equivalently, infinite input buffer at receiver

Main problemTo prevent sender from overwhelming the receiver

If receiver takes t time units to execute from physical layer tonetwork layer, sender must not transmit more than one frame per time tOne solution – too conservative

Restrict sender so transmits so slowly that even if frame undergoes max delay no buffer overflows

Better solutionReceiver provides feedback to sender and gives sender permissionto send next frame

Simplex Stop-and-Wait Protocol

Sender sends frame, stop and wait for ackAlternates between sender and receiver

Half-duplex

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 19

A Simplex Protocol for a Noisy ChannelDrop assumption

Frames not damaged or lostAssumption

If frame is damaged, receiver will detect it when it computes the checksum

Possible solutionReceiver sends ack if receives uncorrupted frame, discards frame if damagedSender sends frame again if doesn’t receive ack before timeout

ProblemReceiver receives uncorrupted frame, sends ackSender times out before receiving ack, sends frame againReceiver receives send copy uncorrupted – has duplicate copies

SolutionUse sequence numbers: 1 bit suffices

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 20

A Simplex Protocol for a Noisy Channel

Further considerationsTimeout must be long enough so sender does not send duplicate when ack is on its wayTimeout must allow

Frame to get to receiverReceiver to process frameAck to get to sender

Acks need to be matched against framesSender remembers next_frame_to_sendReceiver remembers frame_expected

Positive acknowledgement with retransmission (PAR), or, Automatic Repeat reQuest (ARQ)

Page 6: EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester 2005 EEC-682: Computer Networks I-Wenbnig Zhao 5 Error-Correcting Codes N-bit codeword–

6

A Simplex Protocol for a Noisy Channel

A positive acknowledgement with

retransmission protocol.

Continued Spring Semester 2005

EEC-682: Computer Networks I- Wenbing Zhao 22

A Simplex Protocol for a Noisy Channel

A positive acknowledgement with retransmission protocol.

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 23

Sliding Window Protocols

A One-Bit Sliding Window ProtocolA Protocol Using Go Back NA Protocol Using Selective Repeat

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 24

Sliding Window Protocols

Efficiency improvementsUse same circuit for data in both direction: full-duplexInterleave data and ack frames

Use “kind” field to distinguish themB piggybacks its ack for A’s frame onto B’s next frame

Savings of header in separate ack frameIf B sends data frames infrequently, use timeout to determine when B should send ack in separate ack frame

Page 7: EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester 2005 EEC-682: Computer Networks I-Wenbnig Zhao 5 Error-Correcting Codes N-bit codeword–

7

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 25

Sliding Window Protocols

Each frame contains sequence number in ranges 0..2n-1Sending window – list of consecutive sequence numbers of frames that sender is permitted to send

When new packet arrives from NL, it is given next highest sequence number, and upper edge of window is incrementedWhen ack arrives from receiver, lower edge of window is incrementedWithin sending window, frame sent but not acked

Sender must keep those frames for possible retransmissionIf max window size = w, need w buffers

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 26

Sliding Window Protocols

Receiving window – list of consecutive sequence numbers of frames that receiver is permitted to accept

When frame with (seq num = lower edge of window) arrivesFrame is passed to NLAck is generatedWindow slid down by 1 (remains same size as was initially)

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 27

Sliding Window Protocols

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.

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 28

One-Bit Sliding Window Protocol

Sender transmits frame, waits for ack before sending next frame

Next_frame_to_send – which frame sender is trying to sendFrame_expected – which frame receiver is expecting

Sender initiallyGets packet from NLconstructs framesends frame

Page 8: EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester 2005 EEC-682: Computer Networks I-Wenbnig Zhao 5 Error-Correcting Codes N-bit codeword–

8

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 29

One-Bit Sliding Window Protocol

Receiver on arrival of frameChecks if it is duplicateIf expected frame

Passes frame to NLSlides its window upSends ack back to sender indicating last uncorrupted frame it received

Sender on receipt of ackIf ack agrees with seq num of frame it is trying to send

Gets next packet frame NLConstructs frameSends frame

One-Bit Sliding Window Protocol

Continued

One-Bit Sliding Window Protocol

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 32

One-Bit Sliding Window ProtocolNo duplicate, no omissions, no deadlock, but inefficient

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

Page 9: EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester 2005 EEC-682: Computer Networks I-Wenbnig Zhao 5 Error-Correcting Codes N-bit codeword–

9

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 33

Sliding Window ProtocolsDrop assumption

Transmission time is negligible from sending til receiving ackProblem: sender blocks till receives acks (does not send another frame)Solution: pipelining

Allow sender to send up to w frames before blockingProblem: if frame in middle is lost or damaged, what to do with the frames following itSolution: two strategies

Go Back n - all the frames following it are discardedSelective repeat – nack the lost/damaged frame and retransmit that frame

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 34

A Protocol Using Go Back n

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

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 35

Go Back n

Drop assumptionNL has infinite supply of packets

Network_layer_ready event addedMax seq frames outstanding at any instant

Needs multiple timers, on per outstanding frameSender

Stores all frames in output bufferMust get acks in order in which frames are sent

ReceiverDiscards all frames following lost or damaged frame

Works well if transmission errors rare and few retransmissionsIf lot of traffic in both directions

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 36

Go Back n

Continued

Page 10: EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester 2005 EEC-682: Computer Networks I-Wenbnig Zhao 5 Error-Correcting Codes N-bit codeword–

10

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 37

Go Back n

Continued

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 38

Go Back n

Continued

Go Back n

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 40

Simulation of multiple timers in software

Page 11: EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester 2005 EEC-682: Computer Networks I-Wenbnig Zhao 5 Error-Correcting Codes N-bit codeword–

11

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 41

Selective Repeat

Receiver (rather than sender as in Go Back n) accepts and buffers frames following lost or damaged frameBoth sender and receiver maintain windows

Sender’s window starts at 0, grows to MAX SEQReceiver’s window fixed at MAX SEQ

Receiver has buffer reserved for each seq num in its windowWhen frame arrives, receiver checks if seq num in window

If so and if not already received, frame is accepted and storedIf all lower numbered frames delivered to NL, frame is deliveredto NL

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 42

Selective RepeatProblem: non-sequential receive

New range of valid sequence numbers for receiver can overlap old rangeOverlap can contain duplicates

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 43

Problem for Non-Sequential ReceiveScenarios: n = 3bit seq num (8 possible numbers, 0 through 7, back to 0)

Sender sends 0,1,2,3,4,5,6Receiver

receives 0,1,2,3,4,5,6sends ack but ack gets lostAssumes sender gets ack and expects to get 7,0,1,2,3,4,5

Sender times out, retransmits 0,1,2,3,4,5,6Receiver checks 0 is in new window, thinks new 0 because sent ack for old 6, waits for 7Sender receives ack for 0-6, sends 7Receiver receives 7, delivers 7 and old 0 (as new 0 !)Solution:

make sure no overlap when receiver advances its windowMake window size w =1/2 range of seq numbersNote: number buffers at receiver needs = w

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 44

Problem for Non-Sequential Receive

(a) Initial situation with a window size seven.(b) After seven frames sent and received, but not acknowledged.(c) Initial situation with a window size of four.(d) After four frames sent and received, but not acknowledged.

Page 12: EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester 2005 EEC-682: Computer Networks I-Wenbnig Zhao 5 Error-Correcting Codes N-bit codeword–

12

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 45

Selective RepeatIf no reverse traffic before timer goes off, separate ack frame is sentInterrupt due to timer is ack_timedout event

Solves problem of traffic in one direction only and blocking of Go Back n

Further enhancementsWhen receiver suspects error, sends NAK back to sender (request for retransmission)Two circumstances that trigger NAK

Damaged frame arrivesFrame other than expected one arrives, suspect expected one is lostReceiver sends only one NAK for frame expected

Selective Repeat

Continued

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 47

Continued

Selective Repeat Selective Repeat

Continued

Page 13: EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester 2005 EEC-682: Computer Networks I-Wenbnig Zhao 5 Error-Correcting Codes N-bit codeword–

13

Spring Semester 2005EEC-682: Computer Networks I

- Wenbing Zhao 49

Selective Repeat


Recommended