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)
QUIZ: T1 Prove that the T1 carrier has a total (gross) data rate of 1.544 Mbps
Solution Prove that the T1 carrier has a total data rate of 1.544 Mbps (8 24 + 1) 2 4000 = 1.544 Mbps
QUIZ: OC-1 Prove that the OC1 carrier has a total (gross) data rate of 51.84 Mbps
Solution Prove that the OC-1 carrier has a total data rate of 51.84 Mbps (9 90) 8 2 4000 = 51.84 Mbps
Chapter 3 The Data Link Layer (L2)
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.
Functions of the Data Link Layer Provide 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
L2 Design Issues Services Provided to L3 (Network) Framing Error Control Flow Control Bit reordering
Services Provided by L2 to L3 (a) Virtual communication. (b) Actual communication.
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 layers Might 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:
Problem 1/251 A 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:
Problem 1/251 A 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.8 10 = 0.107
Problem 1/251 A 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) =?
Problem 1/251 A 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-1 p Plot source: https://en.wikipedia.org/wiki/geometric_distribution
Problem 1/251 A 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-1 p What is the expected value (a.k.a. mean, average) of a geometric distribution?
Problem 1/251 A 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-1 p Expected 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) +
Problem 1/251 A 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-1 p E[X] = 1/p
Problem 1/251 A 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-1 p E[X] = 1/p E[X] = 1/0.107 = 9.32 times (What does it mean?)
QUIZ For a GEOMETRIC distribution, write the formulas for: P(X=k) E[X]
QUIZ for individual work: Designing L2 fragmentation 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 k 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 to retransmit entire pkts. The probability for one frame to make it to Host 2 w/o errors is p=0.85 (85%). What is the maximum fragmentation that can be used? (Ignore all overhead, e.g. headers, trailers) Hint: What is the probability that an entire packet be transmitted without errors?
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.
Services Provided by L2 to L3 (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??
QUIZ Which Data Link type of service should we choose in the 4 cases below? Low error probability High error probability Short propagation delay Long propagation delay
QUIZ Which Data Link type of service should we choose in the 4 cases below? Short propagation delay Long propagation delay Low error probability Unacknowledged connectionless Unacknowledged connectionless High error probability Acknowledged connectionless Acknowledged connection-oriented
L2 framing Stream of bits in L1 (PHYSICAL) Relationship between packets, frames and bits. Unlike packets, frames usually have a strict max. length (for hardware optimization).
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?
Framing 5 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=lohi, use hi-hi or lo-lo as flags Needs redundancy on L1 Goes against idea of modularity!
Framing with byte count A character stream. (a) Without errors. (b) With one error.
Framing with Flag Bytes (e.g. PPP) What to do if the flag itself is inside the data stream? Byte stuffing (a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after stuffing.
Extra-credit:
Framing with Flag Bytes Problem: 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?
Framing with Bit Stuffing (e.g. HDLC) Flag is 0111 1110 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.
QUIZ Problem 2/252 The following character encoding is used in a L2 protocol: A: 0100 0111 B: 1110 0011 FLAG:0111 1110 ESC: 1110 0000 The 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
Framing - conclusion Most existing L2 protocols use a combination of methods for reliability, e.g. byte stuffing and count field. EOL1
QUIZ For a GEOMETRIC distribution, write the formulas for: P(X=k) E[X]
QUIZ In 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? Hint: Use a Geometric distribution!
Flow Control Does not need negotiation Needs negotiation Feedback-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
3.2 Error Control Error-Correcting Codes Error-Detecting Codes
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
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 independent What is the probability that a frame has errors?
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?
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: # of bits x BER Result:?? How can we tell this method is wrong?
QUIZ There are 1000 bits in a frame Errors are independent, with BER = 10-3 Calculate the following: P[exactly one errror in a given frame] =? P[exactly two errrors in a given frame] =? Out of many frames (say 10, 000), what fraction contain: Exactly one error? Exactly two errors?
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
codeword m + r = n m < n 2 m < 2 n Hamming distance between two codewords = # of different bits Cubes and hyper-cubes
Let s apply probability to codewords! Assume: Independent errors BER = 10-3 The codeword 000 was transmitted Calculate: 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):
Hamming distance of a code = minimum of the Hamming distance between all pairs of legal codewords. What is the Hamming distance of the code below? What is the maximum # of errors that can be detected with the code below? Corrected?
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?
handout
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?
Conclusion: To detect d errors, we need a code with Hamming distance at least d+1. QUIZ: 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?
Error-Correcting Codes a.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.
Why 2 c + 1? Basins of attraction
Each of 2 m 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.
3.2.2 Error-Correcting Codes Mathematical treatment of prev. slide: To correct single errors, each of 2 m legal messages needs n+1 codewords assigned (n+1) 2 m 2 n (m+r+1) 2 n-m (m+r+1) 2 r Take log on both sides log 2 (m+r+1) r log 2 (m) r We say that r has a lower bound which is logarithmic in m In asymptotic notation: r is W(log 2 m)
r is W(log 2 m) 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!
Hamming code redundant bits Initial message (11 information bits): 0 1 0 1 0 0 1 0 1 0 1 Make room for redundant bits in positions that are powers of 2: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 0 1 0 0 1 0 1 0 1 r 1 r 2 r 4 r 8
How to calculate the values of the redundant bits Message with check bits 1 2 3 4 567 8 9.15 inserted in power-of-two positions: r 1 r 2 0 r 4 101 r 8 0010101 Set of bits associated with r 1 : r 1 r 2 0 r 4 101 r 8 0010101 To make the set even, r 1 is made 1: 1 r 2 0 r 4 101 r 8 0010101 Set of bits associated with r 2 : 1 r 2 0 r 4 101 r 8 0010101 To make the set even, r 2 is made 1: 1 1 0 r 4 101 r 8 0010101 Set of bits associated with r 4 : 1 1 0 r 4 101 r 8 0010101 To make the set even, r 4 is made 0: 1 1 0 0 101 r 8 0010101 Set of bits associated with r 8 : 1 1 0 0 101 r 8 0010101 To make the set even, r 8 is made 1: 1 1 0 0 101 1 0010101
QUIZ Hamming code The 12 data bits to be coded are: 1110 1010 0100 Calculate the codeword Hint: Start by inserting the redundant bits
Hamming code extra-credit question
Hamming code error correction Message with check bits 1 2 3 4 56 7 8 9. 15 inserted in power-of-two positions: r 1 r 2 0 r 4 101 r 8 0010101 Codeword 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? r 8, r 4 and r 1 8+4+0+1 = 13. What happens if the corrupted bit is one of the check bits?
Hamming code lingo: What is the syndrome? Perform the parity calculations for all check bits Which check bits have wrong parity? r 8, r 4 and r 1 8+4+1 = 13. Parity bit r 8 r 4 r 2 r 1 Has error? yes yes no yes Syndrome 1 1 0 1 If we convert the syndrome to base 10 we have 8+4+0+1 = 13.
Hamming code error correction Message with check bits 1 2 3 4 56 7 8 9. 15 inserted in power-of-two positions: r 1 r 2 0 r 4 101 r 8 0010101 Codeword 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? r 8, r 4 and r 1 8+4+0+1 = 13. What happens if the corrupted bit is one of the check bits?
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.
This is the end of the material required for the midterm Tuesday lecture: review Wednesday lab: exam Recommended problems for Ch.3: 1, 2, 9 (end of chapter) Solve in notebook before the review! EoL2