of 13 /13
1 EEC-682/782 Computer Networks I Lecture 6 Wenbing Zhao [email protected] (Lecture nodes are based on materials supplied by Dr. Louise Moser at UCSB and Prentice-Hall) Spring Semester 2005 EEC-682: Computer Networks I - Wenbing Zhao 2 Outline Review Data Link Layer Design Issues Error Detection and Correction Data link layer Elementary Data Link Protocols Sliding Window Protocols Spring Semester 2005 EEC-682: Computer Networks I - Wenbing Zhao 3 Data Link Layer Design Issues Services Provided to the Network Layer Point-to-point, source-to-destination, wirelikeFraming Physical bit stream divided up into frames Error Control Acks and nacks Sender has timer within timeout get ack, or send again If frame transmitted multiple times, receiver may get several copies Use sequence numbers Flow Control Sender may transmit frames faster than receiver can receive them Throttle sender so sends no faster than receiver can receive them Spring Semester 2005 EEC-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 used Character count Flag bytes with byte stuffing Starting and ending flags, with bit stuffing Physical layer coding violations Applies only if encoding on medium contain some redundancy Example: encode 1 bit with 2 bits 1 => 10 0 => 01 Can use 00 or 11 to delimit frames

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–

  • Author
    others

  • View
    0

  • Download
    0

Embed Size (px)

Text of EEC-682/782 Computer Networks I - Cleveland State University · 2005. 2. 18. · 2 Spring Semester...

Microsoft PowerPoint - lecture6.pptWenbing Zhao [email protected]
(Lecture nodes are based on materials supplied by Dr. Louise Moser at UCSB and Prentice-Hall)
Spring Semester 2005 EEC-682: Computer Networks I
- Wenbing Zhao 2
Review Data Link Layer Design Issues Error Detection and Correction
Data link layer Elementary Data Link Protocols Sliding Window Protocols
Spring Semester 2005 EEC-682: Computer Networks I
- Wenbing Zhao 3
Data Link Layer Design Issues Services Provided to the Network Layer
Point-to-point, source-to-destination, “wirelike” Framing
Physical bit stream divided up into frames Error Control
Acks and nacks Sender has timer –within timeout get ack, or send again If frame transmitted multiple times, receiver may get several copies
Use sequence numbers Flow Control
Sender may transmit frames faster than receiver can receive them Throttle sender so sends no faster than receiver can receive them
Spring Semester 2005 EEC-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 used Character count Flag bytes with byte stuffing Starting and ending flags, with bit stuffing Physical layer coding violations
Applies only if encoding on medium contain some redundancy Example: encode 1 bit with 2 bits
1 => 10 0 => 01 Can use 00 or 11 to delimit frames
2
- Wenbing Zhao 5
Error-Correcting Codes N-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 result Hamming 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 2005 EEC-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 used Given the algorithm for computing the check bits, it is possible to
Construct a complete list of legal codewords Find two codewords whose Hamming distance is minimum This distance is the Hamming distance of the complete code
To detect d errors, need a distance d+1 code No way that d single-bit errors can change a valid codeword into another valid codeword
To correct d errors, need a distance 2d+1 code Legal codewords are so far part that even with d changes, orginal codeword is still closer than any other codeword, so it can be uniquely determined
Spring Semester 2005 EEC-682: Computer Networks I
- Wenbing Zhao 7
Hamming Code The bits of codeword are numbered consecutively, starting with bit 1 at the left end, bit 2 to its immediate right and so on The bits that are powers of 2 (1,2,4,8,16,etc) are check bits
The rest are filled up with the m data bits Each 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 2005 EEC-682: Computer Networks I
- Wenbing Zhao 8
Hamming Code - Example
Data (character ‘H’): 1001000 Create the data word, leaving spaces for the parity bits:
_ _ 1 _ 0 0 1 _ 0 0 0 Calculate 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.
- 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 inverted Can only correct single-bit error
Spring Semester 2005 EEC-682: Computer Networks I
- Wenbing Zhao 10
Cyclic Redundant Code
Sender and receiver agree on generate polynomial G(x), with high and low bits = 1 To compute checksum for some frame with m bits corresponding to M(x)
M > deg G(x) = r Append 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 2005 EEC-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 frame Let 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 2005 EEC-682: Computer Networks I
- Wenbing Zhao 12
An Unrestricted Simplex Protocol A Simplex Stop-and-Wait Protocol A Simplex Protocol for a Noisy Channel
4
- Wenbing Zhao 13
Elementary Data Link Protocols
Initial assumptions Physical, data link, network layers are independent processes Sender has infinite amount of data ready to send, supplied by network layer “wire-like” service: reliable, source ordered delivery Packet is treated as pure data When sender accepts packet from NL, it encapsulates in a frame with a header and trailer Receiver waits for arrived of frame, which generates an interrupt When frame arrives at receiver, hardware computes checksum
If error then DLL informed event = chksum_err Else DLL informed event = frame_arrival
DLL acquires frame from physical layer, checks control info in header If ok then passes packet to NL
Spring Semester 2005 EEC-682: Computer Networks I
- Wenbing Zhao 14
- Wenbing Zhao 15
Uses no sequence numbers or acks
Only event type frame_arrival
- Wenbing Zhao 17
Simplex Stop-and-Wait Protocol
Main problem To prevent sender from overwhelming the receiver
If receiver takes t time units to execute from physical layer to network layer, sender must not transmit more than one frame per time t One solution – too conservative
Restrict sender so transmits so slowly that even if frame undergoes max delay no buffer overflows
Better solution Receiver provides feedback to sender and gives sender permission to send next frame
Simplex Stop-and- Wait Protocol
Sender sends frame, stop and wait for ack Alternates between sender and receiver
Half-duplex
- Wenbing Zhao 19
Frames not damaged or lost Assumption
If frame is damaged, receiver will detect it when it computes the checksum
Possible solution Receiver sends ack if receives uncorrupted frame, discards frame if damaged Sender sends frame again if doesn’t receive ack before timeout
Problem Receiver receives uncorrupted frame, sends ack Sender times out before receiving ack, sends frame again Receiver receives send copy uncorrupted – has duplicate copies
Solution Use sequence numbers: 1 bit suffices
Spring Semester 2005 EEC-682: Computer Networks I
- Wenbing Zhao 20
A Simplex Protocol for a Noisy Channel
Further considerations Timeout must be long enough so sender does not send duplicate when ack is on its way Timeout must allow
Frame to get to receiver Receiver to process frame Ack to get to sender
Acks need to be matched against frames Sender remembers next_frame_to_send Receiver remembers frame_expected
Positive acknowledgement with retransmission (PAR), or, Automatic Repeat reQuest (ARQ)
6
A positive acknowledgement with
A positive acknowledgement with retransmission protocol.
Spring Semester 2005 EEC-682: Computer Networks I
- Wenbing Zhao 23
Sliding Window Protocols
A One-Bit Sliding Window Protocol A Protocol Using Go Back N A Protocol Using Selective Repeat
Spring Semester 2005 EEC-682: Computer Networks I
- Wenbing Zhao 24
Sliding Window Protocols
Efficiency improvements Use same circuit for data in both direction: full-duplex Interleave data and ack frames
Use “kind” field to distinguish them B piggybacks its ack for A’s frame onto B’s next frame
Savings of header in separate ack frame If B sends data frames infrequently, use timeout to determine when B should send ack in separate ack frame
7
- Wenbing Zhao 25
Sliding Window Protocols
Each frame contains sequence number in ranges 0..2n-1 Sending 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 incremented When ack arrives from receiver, lower edge of window is incremented Within sending window, frame sent but not acked
Sender must keep those frames for possible retransmission If max window size = w, need w buffers
Spring Semester 2005 EEC-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) arrives Frame is passed to NL Ack is generated Window slid down by 1 (remains same size as was initially)
Spring Semester 2005 EEC-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 2005 EEC-682: Computer Networks I
- Wenbing Zhao 28
Sender transmits frame, waits for ack before sending next frame
Next_frame_to_send – which frame sender is trying to send Frame_expected – which frame receiver is expecting
Sender initially Gets packet from NL constructs frame sends frame
8
- Wenbing Zhao 29
One-Bit Sliding Window Protocol
Receiver on arrival of frame Checks if it is duplicate If expected frame
Passes frame to NL Slides its window up Sends ack back to sender indicating last uncorrupted frame it received
Sender on receipt of ack If ack agrees with seq num of frame it is trying to send
Gets next packet frame NL Constructs frame Sends frame
One-Bit Sliding Window Protocol
- Wenbing Zhao 32
One-Bit Sliding Window Protocol No 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.
9
- Wenbing Zhao 33
Sliding Window Protocols Drop assumption
Transmission time is negligible from sending til receiving ack Problem: sender blocks till receives acks (does not send another frame) Solution: pipelining
Allow sender to send up to w frames before blocking Problem: if frame in middle is lost or damaged, what to do with the frames following it Solution: two strategies
Go Back n - all the frames following it are discarded Selective repeat – nack the lost/damaged frame and retransmit that frame
Spring Semester 2005 EEC-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 2005 EEC-682: Computer Networks I
- Wenbing Zhao 35
Go Back n
Network_layer_ready event added Max seq frames outstanding at any instant
Needs multiple timers, on per outstanding frame Sender
Stores all frames in output buffer Must get acks in order in which frames are sent
Receiver Discards all frames following lost or damaged frame
Works well if transmission errors rare and few retransmissions If lot of traffic in both directions
Spring Semester 2005 EEC-682: Computer Networks I
- Wenbing Zhao 36
Go Back n
- Wenbing Zhao 37
Go Back n
- Wenbing Zhao 38
Go Back n
- Wenbing Zhao 40
11
- Wenbing Zhao 41
Selective Repeat
Receiver (rather than sender as in Go Back n) accepts and buffers frames following lost or damaged frame Both sender and receiver maintain windows
Sender’s window starts at 0, grows to MAX SEQ Receiver’s window fixed at MAX SEQ
Receiver has buffer reserved for each seq num in its window When frame arrives, receiver checks if seq num in window
If so and if not already received, frame is accepted and stored If all lower numbered frames delivered to NL, frame is delivered to NL
Spring Semester 2005 EEC-682: Computer Networks I
- Wenbing Zhao 42
Selective Repeat Problem: non-sequential receive
New range of valid sequence numbers for receiver can overlap old range Overlap can contain duplicates
Spring Semester 2005 EEC-682: Computer Networks I
- Wenbing Zhao 43
Problem for Non-Sequential Receive Scenarios: n = 3bit seq num (8 possible numbers, 0 through 7, back to 0)
Sender sends 0,1,2,3,4,5,6 Receiver
receives 0,1,2,3,4,5,6 sends ack but ack gets lost Assumes sender gets ack and expects to get 7,0,1,2,3,4,5
Sender times out, retransmits 0,1,2,3,4,5,6 Receiver checks 0 is in new window, thinks new 0 because sent ack for old 6, waits for 7 Sender receives ack for 0-6, sends 7 Receiver receives 7, delivers 7 and old 0 (as new 0 !) Solution:
make sure no overlap when receiver advances its window Make window size w =1/2 range of seq numbers Note: number buffers at receiver needs = w
Spring Semester 2005 EEC-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.
12
- Wenbing Zhao 45
Selective Repeat If no reverse traffic before timer goes off, separate ack frame is sent Interrupt due to timer is ack_timedout event
Solves problem of traffic in one direction only and blocking of Go Back n
Further enhancements When receiver suspects error, sends NAK back to sender (request for retransmission) Two circumstances that trigger NAK
Damaged frame arrives Frame other than expected one arrives, suspect expected one is lost Receiver sends only one NAK for frame expected
Selective Repeat
- Wenbing Zhao 47
- Wenbing Zhao 49