17
Lecture 3: Error Handling CSE 123: Computer Networks Alex C. Snoeren

Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Lecture 3:Error Handling

CSE 123: Computer NetworksAlex C. Snoeren

Page 2: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Lecture 3 Overview! Framing wrap-up

u Clock-based framing

! Error handling through redundancy

! Hamming Distanceu When we can detectu When we can correct

! Parity-based schemes

CSE 123 – Lecture 3: Error Handling 2

Page 3: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Framing/Bit Stuffing (HDLC) Review

Given the above received string of bits (HLDC framing sequences highlighted), how many stuffed bits are there?A. 0B. 3C. 5D. 7

CSE 123 – Lecture 2: Links and Signaling 3

0111 1110 1110 1100 0101 1101 0000 1100 0011 1110 0111 01111100 0001 0111 1101 1011 1001 0111 0000 1011 1111 0110 00001100 1111 1100 0010 0111 1100 0000 0011 1110 0111 0111 1110

Page 4: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Framing/Bit Stuffing (HDLC) Review

Given the above received string of bits (HLDC framing sequences highlighted), how many stuffed bits are there?A. 0B. 3C. 5 (highlighted in yellow above)D. 7

CSE 123 – Lecture 2: Links and Signaling 4

0111 1110 1110 1100 0101 1101 0000 1100 0011 1110 0111 01111100 0001 0111 1101 1011 1001 0111 0000 1011 1111 0110 00001100 1111 1100 0010 0111 1100 0000 0011 1110 0111 0111 1110

Page 5: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Byte Stuffing! Same as bit stuffing, except at byte (character) level

u Generally have two different flags, STX and ETXu Found in PPP, DDCMP, BISYNC, etc.

! Need to stuff if either appears in the payloadu Prefix with another special character, DLE (data-link escape)u New problem: what if DLE appears in payload?

! Stuff DLE with DLE!u Could be as bad as 50% efficient to send all DLEs

CSE 123 – Lecture 3: Error Handling 5

ETX

STX ETXPayloadHEADER

0x48 0x69 ETXDLE 0x690x48

Page 6: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Clock-Based Framing! So far, we’ve based framing on what’s on the wire

u Any bit errors may throw off our framingu What happens with missed flag? Spurious flag?

! An alternative is to base framing on external clocku This is what SONET does, among others

! Significant engineering tradeoffsu No extra bits needed in the data stream itself, but…u Need tight clock synchronization between sender and receiver

CSE 123 – Lecture 3: Error Handling 6

Page 7: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

When Things Go Wrong! Clock drift may confuse frame boundaries

u Read the end of one frame and beginning of the next

! What happens if there are bit errors on channel?u We might misinterpret sentinels as data or vice versau What will the frames look like?

! In general, need some way to make sure we’re OKu Error detection—and perhaps correction

CSE 123 – Lecture 3: Error Handling 7

Page 8: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Per-Frame Detection Codes

! Want to add an error detection code per frameu Frame is unit of transmission; all or nothing.u Computed over the entire frame—including header! Why?

! Receiver checks EDC to make sure frame is validu If frame fails check, throw it away

! We could use error-correcting codesu But they are less efficient, and we expect errors to be rareu Counter example: satellite communication

CSE 123 – Lecture 3: Error Handling 8

PayloadHeader EDC

Page 9: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Error-Detecting Codes! Implemented at many layers

u We’ll mainly focus on link-layer techniques today

CSE 123 – Lecture 3: Error Handling 9

Page 10: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Basic Idea: Coding! The problem is data itself is not self-verifying

u Every string of bits is potentially legitimateu Hence, any errors/changes in a set of bits are equally legit

! The solution is to reduce the set of potential bitstringsu Not every string of bits is allowableu Receipt of a disallowed string of bits means the original bits were garbled in transit

! Key question: which bitstrings are allowed?

CSE 123 – Lecture 3: Error Handling 10

Page 11: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Codewords! Let’s start simple, and consider fixed-length bitstrings

u In practice, we likely want to do it for a whole frameu For now, let’s reduce our discussion to n-bit substrings (e.g, 8 bits at a time)

! We call an allowable sequence of n bits a codewordu Not all strings of n bits are codewords!u The remaining n-bit strings are “space” between codewords

! Rephrasing previous question: how many codewords with how much space between them?

CSE 123 – Lecture 3: Error Handling 11

Page 12: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Hamming Distance

! Distance between legal codewordsu Measured in terms of number of bit flips

! Efficient codes are of uniform Hamming Distanceu All codewords are equidistant from their neighbors

CSE 123 – Lecture 3: Error Handling 12

000000 000001 000011 000111 001111 011111 111111

Hamming Distance = 3

Is this code efficient?

A. YesB. NoC. I’m not sure

Page 13: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

2d+1 Hamming Distance! Can detect up to 2d bit flips

u The next codeword is always 2d+1 bit flips awayu Any fewer is guaranteed to land in the middle

! Can correct up to d bit flipsu We just move to the closest codewordu Unfortunately, no way to tell how many bit flips

CSE 123 – Lecture 3: Error Handling 13

000000 000001 000011 000111 001111 011111 111111

2d+1

d d

Page 14: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Encoding! We’re going to send only codewords

u Non-codewords indicate errors to receiver

! But we want to send any set of stringsu Need to embed arbitrary input into sequence of codewords

CSE 123 – Lecture 3: Error Handling 14

Page 15: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Simple Detection: Parity

! Add extra bit to ensure odd(even) number of onesu Code has a rate of 2/3 (need three bits to encode two)u Note: Even parity is simply XOR

CSE 123 – Lecture 3: Error Handling 15

000

100

010

110

011

111

001

101

00

11

01

10

What is the Hamming Distance of parity?A. 0B. 1C. 2D. I’m not sure

Page 16: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

Simple Correction: Voting

! Simply send each bit n (3 in this example) timesu Code with Hamming Distance 3 (d=1)

! Straightforward duplication is extremely inefficientu We can be much smarter about this

CSE 123 – Lecture 3: Error Handling 16

0 1000

100

010

001

111

011

101

110

How many bit flips can this code correct?A. 0B. 1C. 3D. I’m not sure

Page 17: Lecture 3: Error Handling - University of California, San Diego · 2021. 1. 9. · B.3 C.5 D.7 CSE 123–Lecture 2: Links and Signaling 3 0111 1110 1110 1100 0101 1101 0000 1100 0011

For Next Class

! We’ll finish error detection and talk about reliable transport on Monday

! Read 1.5 and 2.5 in P&D

! Take a look at Project 1a

CSE 123 – Lecture 3: Error Handling 17