89
QUIZ : oversubscription A telco provider sells 5 Mpbs DSL service to 50 customers in a neighborhood. The DSLAM connects to the central office via one T3 and two T1 lines. What is the oversubscription factor? (Ignore overhead)

The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZ : oversubscriptionA telco provider sells 5 Mpbs DSL service to 50 customers in a neighborhood. The DSLAM connects to the central office via one T3 and two T1 lines. What is the oversubscription factor? (Ignore overhead)

Page 2: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZ: T1

Prove that the T1 carrier has a total (gross) data rate of 1.544 Mbps

Page 3: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Prove that the T1 carrier has a total data rate of 1.544 Mbps

(8·24 + 1) · 2 · 4000 = 1.544 Mbps

Solution

Page 4: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZ: OC-1

Prove that the OC1 carrier has a total (gross) data rate of 51.84 Mbps

Page 5: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Prove that the OC-1 carrier has a total data rate of 51.84 Mbps

(9·90) · 8 · 2 ·4000 = 51.84 Mbps

Solution

Page 6: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

The Data Link Layer (L2)

Chapter 3

Page 7: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

The Data Link Layer (L2)fundamental characteristics

A. Whereas L1 is concerned with Tx/Rx of individual bits, L2 works with multi-bit frames.

B. Transmission is over one “wirelike” channel, i.e. a channel which delivers the bits in the same order in which they are sent.As a consequence, L2 does not have to provide any reordering function.

Page 8: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Functions of the Data Link LayerProvide service interface to L3 (Network)

Deal w/transmission errors on L1 (Physical)• L2 “hides” the errors that occur in the real transmission, so

L3 and higher don’t have to worry about them

Regulate the flow of data • Slow receivers should not be swamped by fast senders

Page 9: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

L2 Design IssuesServices Provided to L3 (Network)FramingError ControlFlow ControlBit reordering

Page 10: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Services Provided by L2 to L3(a) Unacknowledged connectionless:

– Used when error rate is low (e.g. LAN → Ethernet), or when there are stringent timing requirements (e.g. VoIP)

– Recovery is left to higher layersMight be bad b/c one L3 pkt. can be mapped to multiple L2 frames.

L3 does not know about it, so it is wasting bandwidth by requiring entire pkt. to be retransmitted.

Example:

Page 11: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Problem 1/251A L3 pkt. is split into 10 frames, each of which has an 80% chance

of arriving undamaged. L2 does not do any error control. How many times on average will L3 send the pkt. before it makes it?

1. Calculate the probability p that one send is successful:

Page 12: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Problem 1/251A L3 pkt. is split into 10 frames, each of which has an 80% chance

of arriving undamaged. L2 does not do any error control. How many times on average will L3 send the pkt. before it makes it?

1. Calculate the probability p that one send is successful:

p = 0.8 ∙ 0.8 ∙ … ∙ 0.8 = 0.810 = 0.107

Page 13: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Problem 1/251A L3 pkt. is split into 10 frames, each of which has an 80% chance

of arriving undamaged. L2 does not do any error control. How many times on average will L3 send the pkt. before it makes it?

2. What are the possible numbers of sends?P(1 send ) = ?P(2 sends) = ?…P(n sends) = ?…

Page 14: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Problem 1/251A L3 pkt. is split into 10 frames, each of which has an 80% chance

of arriving undamaged. L2 does not do any error control. How many times on average will L3 send the pkt. before it makes it?

Conclusion: GEOMETRIC distribution!P(X = k) = (1-p)k-1p

Plot source: https://en.wikipedia.org/wiki/Geometric_distribution

Page 15: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Problem 1/251A L3 pkt. is split into 10 frames, each of which has an 80% chance

of arriving undamaged. L2 does not do any error control. How many times on average will L3 send the pkt. before it makes it?

GEOMETRIC distribution: P(X = k) = (1-p)k-1pWhat is the expected value (a.k.a. mean, average) of a

geometric distribution?

Page 16: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Problem 1/251A L3 pkt. is split into 10 frames, each of which has an 80% chance

of arriving undamaged. L2 does not do any error control. How many times on average will L3 send the pkt. before it makes it?

GEOMETRIC distribution: P(X = k) = (1-p)k-1pExpected value (a.k.a. mean, average): weight (multiply) each value

of X by the corresponding probability:E[X] = 1∙P(X=1) + 2∙P(X=2) + … k∙P(X=k) + …

Page 17: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Problem 1/251A L3 pkt. is split into 10 frames, each of which has an 80% chance

of arriving undamaged. L2 does not do any error control. How many times on average will L3 send the pkt. before it makes it?

GEOMETRIC distribution: P(X = k) = (1-p)k-1pE[X] = 1/p

Page 18: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Problem 1/251A L3 pkt. is split into 10 frames, each of which has an 80% chance

of arriving undamaged. L2 does not do any error control. How many times on average will L3 send the pkt. before it makes it?

GEOMETRIC distribution: P(X = k) = (1-p)k-1pE[X] = 1/p

E[X] = 1/0.107 = 9.32 times (What does it mean?)

Page 19: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZFor a GEOMETRIC distribution, write the formulas for:

•P(X=k)

•E[X]

The number of k-1 failures and

one success

Page 20: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

The Network layer of Host 1 receives a 512-Byte packet every 20 ms, to be sent to Host 2.The Data Link layer fragments each packet into f frames for transmission, and sends out the

frames using unacknowledged, connectionless service over a T1 link. This way, error correction is left entirely to Network, who needs toretransmit entire packets.

The probability for one frame to make it toHost 2 w/o errors is p=0.85 (85%).What is the maximum fragmentation k thatcan be used?(Ignore all overhead, e.g. headers, trailers)

Individual work for next time (in notebook!): Designing L2 fragmentation

Plan:1. Consider f a constant. Calculate the probability that an entire packet be

transmitted without errors (function of f).2. Use the Geometric distribution to find the average # of retransmissions

(function of f).3. Make sure all the retransmissions fit within the 20 ms at T1 speed. Now

you can solve for f.Solution at end

Page 21: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Types of Services Provided by L2 to L3(b) Acknowledged connectionless:

– Each frame individually ACK-ed, timers, retransmissions– Used when error rate is high (e.g. wireless→802.11 WiFi)

What if the ACK frame itself gets lost?The ghost frame problem.

Page 22: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

(c) Acknowledged and connection-oriented:– Used in long, error-prone links (e.g. satellite)– Connection established, frames are numbered– Eliminates the “ghost packet problem”– Makes an unreliable (error-prone) L1 “look” reliable to L3.

We say that L3 “sees” a reliable bit-stream at L1.

(d) Unacknowledged connection-oriented??

Types of Services Provided by L2 to L3

Page 23: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZWhich Data Link type of service should we choose in the 4 cases below?

Longpropagation

delay

Shortpropagation

delay

Low error probability High error probability

Page 24: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

SolutionWhich Data Link type of service should we choose in the 4 cases below?

Unacknowledged connectionless

Acknowledged connectionless

Unacknowledged connectionless

Acknowledgedconnection-oriented

Longpropagation

delay

Shortpropagation

delay

Low error probability High error probability

Page 25: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

L2 framing

Relationship between packets, frames and bits.Unlike packets, frames usually have a strict max. length (for hardware

optimization).

Stream of bits in L1 (PHYSICAL)

Page 26: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Why framing?To control errors and flow

Unfortunately, framing introduces its own problem:How does the receiver recognize the beginning and end of a

frame?

Page 27: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Framing5 methods for recognizing frames:• Fixed timing (frame-gap-frame-gap …) → hard to sync.• Character count → counter can be garbled (next slide)• Flag bytes w/Byte stuffing• Flag bytes w/bit stuffing• L1 (PHY layer) coding violations → e.g. 1=hi-lo, 0=lo-

hi, use hi-hi or lo-lo as flags• Needs redundancy on L1• Goes against idea of modularity!

Page 28: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Framing with byte count

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

Page 29: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Framing with Flag Bytes (e.g. PPP)

(a) A frame delimited by flag bytes.(b) Four examples of byte sequences before and after stuffing.

What to do if the flag itself is inside the data

stream?

“Byte stuffing”

Extra-credit …

Page 30: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Framing with Flag BytesProblem: Requires 8-bit characters, otherwise the FLAG

boundaries cannot be detected!

What do we do if we want Unicode (16 bit)?

Solution: Have the FLAG byte contain a pattern of bits not encountered anywhere else in the data!

0111 1110

So what if the pattern does occur in the data?

Page 31: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Framing with Bit Stuffing (e.g. HDLC)

Bit stuffing(a) The original data.(b) The data as they are transmitted on the line.(c) The data as they are stored in receiver’s memory after de-stuffing.

Flag is 0111 1110

Page 32: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZProblem 2/252The following character encoding is used in a L2 protocol:A: 0100 0111 B: 1110 0011FLAG:0111 1110 ESC: 1110 0000The payload (actual data) in the frame is: A B ESC FLAG

Show the frame for each of these framing methods:• Byte count• Flag bytes w/byte stuffing• Flag bytes w/bit stuffing

Page 33: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Framing - conclusion

Most existing L2 protocols use a combination of methods for reliability, e.g. byte stuffing and count field.

EOL1

Page 34: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZFor a GEOMETRIC distribution, write the formulas for:

•P(X=k)

•E[X]

The number of k-1 failures and

one success

Page 35: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZIn a certain dry area in the world, the probability for a

rainy day is 0.01. How many days do we have to wait on the average for the next rainy day?

In a certain multiple-access protocol, the probability for a collision in a time slot is 0.01. How many time slots do we have to wait on the average for the next collision?

Hint: Use a Geometric distribution!

Page 36: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Flow ControlFeedback-based: receiver sends

back explicit messages:• “Send me more”• “Stop sending”

Rate-based:• Mostly used in higher layers

(e.g. L4→TCP)• Modern Ethernet cards can

switch among 10/100/1000 Mbps

Does not need negotiation

Needs negotiation

Page 37: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

3.2 Error Control

• Error-Correcting Codes• Error-Detecting Codes

Page 38: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Error Control Simple model for errors: bits are affected independently.Closer to real-life: Errors come in bursts• Good: at the same average error rate, less frames are

affected• Bad:

• Adjacent errors are harder to detect/correct than isolated ones.

• An entire frame may disappear!

Mathematical treatment of errors → probability theory

Page 39: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Error Control Mathematical treatment of errors → probability theory

Three basic rules:• The probabilities of complementary events add up to 1• The probabilities of mutually exclusive events add up• The probabilities of independent events multiply

Example on p.203: 1000 bits in a frame, BER = 10-3 , errors independentWhat is the probability that a frame has errors?

Hints follow

Page 40: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Error Control Three basic rules:• The probabilities of complementary events add up to 1• The probabilities of mutually exclusive events add up• The probabilities of independent events multiply

1000 bits in a frame, BER = 10-3 , errors independent• P[no errors in a given frame] = ?• P[at least 1 error in a given frame] = ?• Out of many frames (say 10, 000), how many contain errors

on average?

Page 41: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Error Control Three basic rules:• The probabilities of complementary events add up to 1• The probabilities of mutually exclusive events add up• The probabilities of independent events multiply

1000 bits in a frame, BER = 10-3 , errors independent

Instructive mistake: P[frame has errors] = # of bits x BERResult: ??How can we tell that this method is wrong?

# of bits x BER means the average # of errors in the frame!

Page 42: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

3.2.1 Principles of Error Detection and Correction

Any mechanism for detecting or correcting errors needs redundancy, a.k.a. overhead

m data bits + r redundant bits = n-bit codeword

m + r = n

Page 43: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

m + r = n → m < n ⇒ 2m < 2n

Hamming distance between two codewords = # of different bits

Visualizing the code space: squares, cubes and hyper-cubes

Length of a codeword

Page 44: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Let’s apply probability to codewords!Assume:• Independent errors• BER = 10-3

• The codeword 000 was transmittedCalculate:• P[001 is received]• P[010 is received]• P[100 is received]• P[011 is received]• P[111 is received]

Conclusion (in terms of Hamming distance):

Continued

Page 45: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Hamming distance of a code = minimum of the Hamming distance between all pairs of legal codewords.

What is the Hamming distance of this code?

What is the maximum # of errors that can be detected with the code below?

Corrected?

Page 46: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Conclusion: To detect d errors, we need a code with Hamming distance at least d+1.

Example:• Select the codewords that have even-parity-bit.• How many data bits does a codeword have?• What is the Hamming distance of this code?• How many errors can be detected?

Page 47: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

handout

Page 48: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Conclusion: To detect d errors, we need a code with Hamming distance at least d+1.

QUIZ:• Select the codewords that have odd-parity-bit.• How many data bits does a codeword have?• What is the Hamming distance of this code?• How many errors can be detected?

Page 49: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Conclusion: To detect d errors, we need a code with Hamming distance at least d+1.

QUIZ for home:• Select the codewords that are palindromes.• How many data bits does a codeword have?• What is the Hamming distance of this code?• How many errors can be detected?

Page 50: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Error-Correcting Codesa.k.a. forward error correction

To detect d errors, a code with Hamming distance d+1 (or higher) is needed.

New result: To correct c errors, a code with Hamming distance

2·c + 1 (or higher) is needed.

Visual “proof” on next slide

Page 51: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Why 2·c + 1? “Basins of attraction”

Explanation on next slide

Page 52: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Each of 2m legal messages needs n+1 codewords assigned

Why n+1? B/c each “good” code needs n “insulating” neighbors at Hamming distance 1 (Basin of attraction).In the image you have an example for n = 7.

Page 53: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Error-Correcting CodesMathematical treatment of prev. slide: To correct single errors, each of 2m legal messages needs n+1 codewords

assigned.

(n+1) 2m ≤ 2n ⇒ (m+r+1) ≤ 2n-m ⇒ (m+r+1) ≤ 2r

Take log on both sides ⇒ log2(m+r+1) ≤ r⇒ log2(m) ≤ r

We say that r has a lower bound which is logarithmic in mIn asymptotic notation: r ∈ Ω(log2m)

The basin of attraction must contain (at least) n+1 codewords!

Page 54: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

r ∈ Ω(log2m)The Hamming code is a method of attaining this bound:• Number the n bits in the codeword starting at 1.• The power-of-two bits (1, 2, 4, 8 …) are check bits, the rest are

data.• A data bit in position k contributes to the check bits corresponding

to the 1s in the binary expansion of k• Usually the check bits implement even parity

At the receiver:• Check the parity of all check bits.• If all parities are OK (even), conclude that no errors have ocurred.• If the parities of some check bits are not OK, add up the values k of

the incorrect check bits. This is the position of the bit in error. Correct that bit, i.e. flip it!

Page 55: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Hamming code redundant bitsInitial message (11 information bits):

Make room for redundant bits in positions that are powers of 2:0 1 0 1 0 0 1 0 1 0 1

0 1 0 1 0 0 1 0 1 0 11 2 3 4 5 6 7 8 9 10 11 12 13 14 15

r1 r2 r4 r8

Page 56: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

How to calculate the values of the redundant bits

Message with check bits 1 2 3 4 567 8 9 …….15inserted in power-of-two positions: r1 r2 0 r4 101 r8 0010101

Set of bits associated with r1: r1 r2 0 r4 101 r8 0010101To make the set even, r1 is made 1: 1 r2 0 r4 101 r8 0010101Set of bits associated with r2: 1 r2 0 r4 101 r8 0010101To make the set even, r2 is made 1: 1 1 0 r4 101 r8 0010101Set of bits associated with r4: 1 1 0 r4 101 r8 0010101To make the set even, r4 is made 0: 1 1 0 0 101 r8 0010101Set of bits associated with r8: 1 1 0 0 101 r8 0010101To make the set even, r8 is made 1: 1 1 0 0 101 1 0010101

Page 57: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZ Hamming code

The 12 data bits to be coded are: 1110 1010 0100Calculate the codewordHint: Start by inserting the redundant bits

Page 58: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Hamming code extra-credit question

Page 59: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Hamming code error correctionMessage with check bits 1 2 3 4 56 7 8 9 ……. 15

inserted in power-of-two positions: r1 r2 0 r4 101 r8 0010101Codeword transmitted: 1 1 0 0 101 1 0010101

Assume that bit 13 is corrupted in transmission, so the receiver gets:1 1 0 0 101 0 0010001

Perform the parity calculations for all check bits

Which check bits have wrong parity? r8, r4 and r1 → 8+4+0+1 = 13.

What happens if the corrupted bit is one of the check bits?

Page 60: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Hamming code lingo: syndromePerform the parity calculations for all check bits

Which check bits have wrong parity? r8, r4 and r1 → 8+4+1 = 13.

Parity bit r8 r4 r2 r1

Has error? yes yes no yesSyndrome 1 1 0 1

If we convert the syndrome to base 10 we have → 8+4+0+1 = 13.

Page 61: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Hamming code error correctionMessage with check bits 1 2 3 4 56 7 8 9 ……. 15

inserted in power-of-two positions: r1 r2 0 r4 101 r8 0010101Codeword transmitted: 1 1 0 0 101 1 0010101

Assume that bit 13 is corrupted in transmission, so the receiver gets:1 1 0 0 101 0 0010001

Perform the parity calculations for all check bits

Which check bits have wrong parity? r8, r4 and r1 → 8+4+0+1 = 13.

What happens if the corrupted bit is one of the check bits?

Page 62: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Important:Many Hamming Code Calculators are available on the Web. Their use in this class is not allowed (except for checking results).All work has to be shown, step by step, in the manner presented in our text and the previous slides.Answers without work receive no credit!

Page 63: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Hamming codes can also correct burst of errors

by using iterleaving

To correct bursts of length k, transmit groups of k codewords by columns→ the burst will affect at most 1 bit in each codeword.

What is a downside of this method?

k

Page 64: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

To solve in notebook for next time:

EoL2

End of chapter problems 1, 2, 9.

Page 65: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

handout (2 slides)

Page 66: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

handout (2 slides)

Page 67: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Error Correction – Convolutional codesOperates on a stream of bits, keeping internal state

– Internal state = S1 S2 … S6– Output stream is a function of all preceding input bits– Sums are XOR

Popular NASA binary convolutional code, now used in 802.11

… 1 1 1 0 1 11 0 1…

Page 68: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Error Correction – Convolutional codesRate: r = ½ • Each input bit generates two output bitsConstraint length: k = 7• If a given bit is at the input, it takes 7 CLK cycles until it

is out (i.e. until it does not affect the output anymore)

… 1 1 1 0 1 11 0 1…

Page 69: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZ: Convolutional codesThe states S1 – S6 are all initialized with zeroes.Assume the following sequence of bits (right-to-left): 1101Show the two output bit streams

… 1 1 1 0 1 11 0 1…1101

Page 70: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Convolutional codes – how about decoding?

Viterbi algorithm (not covered in our text)• See Sec. 3.6.6 of Computer Architecture text (Null & Lobur)• Estimate what sequence of inputs is more likely to have

generated the outputs• Allows soft-decision decoding, i.e. the individual bits are

assigned probabilities of being 0 or 1, and the final decision is made only after examining an entire sequence

• By delaying the decision, we can exploit correlation info!• It is possible to correct bursts of errors!

• Error correction is achieved naturally: the correct sequence is the most likely one!

Page 71: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Hamming

Convolutional

SKIP:Reed-SolomonLow-Density Parity Check (LDPC)

Recap. of error-correcting codes

Page 72: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

3.2.2 Error-Detecting CodesOld method: parity bit(s)

Assume one parity bit per codeword:

• What is the Hamming distance of such a code?

• Accordingly, how many errors can such a code

• Detect?

• Correct?

What if there are multiple errors in the codeword, e.g. a burst of consecutive errors?

• It all depends on whether the length of the burst is odd or even!

• Detection probability is 0.5 (!)

Page 73: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZ

Problem 8: To provide more reliability than a single parity bit, a code uses one parity bit for all even-numbered bits, and one for all odd-numbered bits.

What is the Hamming distance of this code?

Page 74: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZ: Parity bits

Problem 8: To provide more reliability than a single parity bit, a code uses one parity bit for all even-numbered bits, and one for all odd-numbered bits.

What is the Hamming distance of this code?

How many errors can it reliably• Detect?• Correct?

To detect d errors, a code with Hamming distance d+1 (or higher) is needed.

To correct c errors, a code with Hamming distance 2·c + 1 (or higher) is needed.

2

Page 75: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZ: Parity bits

Problem 8: To provide more reliability than a single parity bit, a code uses one parity bit for all even-numbered bits, and one for all odd-numbered bits.

What is the Hamming distance of this code?

How many errors can it reliably• Detect?• Correct?

2

01 Wait a second: So the

additional parity bit did not have any impact??

Page 76: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Error Detection: parity bit(s)

How to deal with bursts of errors?

Use interleaving, as in Hamming codes!Not all bits

are flipped in a burst!

Page 77: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Error Detection: Checksums They are a variation of interleaved parity bits

Checksum treats data as N-bit words and adds N check bits at the end of the entire frame

• The bits are the modulo 2N sum of the words

Example: Internet 16-bit 1’s complement checksum• Use 4 bits for this quick example (from L to R):1110 0110 0111 →

Page 78: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

ExampleAdd two words at a time, any carry-out from MSB propagates as carry-in for the LSB.

Page 79: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Error Detection: Checksums An N-bit checksum has improved error detection over the

simple parity bits:– Reliably detects bursts up to N errors– Protects the high-order end of the codeword– Detects random errors with probability 1-2N

Con:– Vulnerable to systematic errors, commonly

introduced by buggy Tx software– e.g. added or removed zeroes– Improvement: Fletcher’s checksum (FYI)

Page 80: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Error Detection: polynomial codes (CRC)A sequence of k bits is interpreted as binary polynomial of degree k-1

Polynomial arithmetic reduces to XOR. (No carries or borrows!)

Generator polynomial G(x) of degree r, agreed upon by sender and receiver

• Both MSB and LSB of G(x) must be 1

Algorithm for sender (see next slide):

• M(x) → 2rM(x) by appending r zeroes

• Checksum is remainder of division of 2rM(x) by G(x)

• Add (subtract) checksum to 2rM(x) → checksummed message is divisible by G(x)

Algorithm for receiver: divide message by G(x) and check if remainder is 0.

Page 81: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Unlike regular division, only the MSBs are checked to decide if quotient bit is 0 or 1.Here the quotient bit is 1, even though G is larger!

Page 82: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZ: Find the CRC bits

Page 83: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZ: CRC

First step

Continue …

Page 84: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s
Page 85: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

CRC conclusionTypes of errors reliably detected by any CRC:

• Single-bit

• Two isolated single-bit

• Any odd number of single-bits

• All bursts of length less than r

•The probability of a burst of length r+1

to go undetected is (1/2)r-1

Can be easily implemented in the hardware, with only XOR gates and shift registers.

Put these on your cheat-

sheet!

Page 86: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

CRC conclusionThe IP protocol (L3) uses a CRC32:

Page 87: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Detection vs. Correction

• Detection (coupled w/retransmission) is better at low error rates

• Correction is better at high error rates

EOL3

Page 88: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

QUIZ: Error handling

List:•The 2 error-correction codes we studied:

••

•The 3 error-detection codes we studied:•••

Page 89: The Data Link Layer...B. Transmission is over one “ wirelike” channel, i.e. a channel which . delivers the bits in the same order in ... The data as they are stored in receiver’s

Solution to fragmentation quiz