The Data Link Layer

8,983 views
8,832 views

Published on

Lecture slides from the 3rd-year module on Computer Networks at the University of Birmingham, UK.

This presentation covers the Data-Link layer of the networks stack, primarily Error Control, Flow Control and Framing.

Published in: Education, Technology, Business
1 Comment
10 Likes
Statistics
Notes
No Downloads
Views
Total views
8,983
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
645
Comments
1
Likes
10
Embeds 0
No embeds

No notes for slide

The Data Link Layer

  1. 1. Computer Networks (06-05933) The Data-Link Layer Rob Minson, rm. 134 [email_address]
  2. 2. Data Link Layer Overview
  3. 3. Data Link Layer Overview <ul><li>Error Control </li></ul><ul><ul><li>Correction and Detection Schemes </li></ul></ul><ul><ul><li>Framing </li></ul></ul><ul><ul><li>Flow Control </li></ul></ul><ul><li>Medium Access </li></ul>
  4. 4. Errors in the Physical Layer <ul><li>Noise </li></ul>
  5. 5. Errors in the Physical Layer <ul><li>Noise </li></ul><ul><ul><li>Near End Cross-Talk (NEXT) </li></ul></ul>=
  6. 6. Errors in the Physical Layer <ul><li>Attenuation </li></ul><ul><ul><li>Can we distinguish between power levels with enough accuracy? </li></ul></ul>
  7. 7. Errors in the Physical Layer <ul><li>Attenuation </li></ul>
  8. 8. Errors in the Physical Layer <ul><li>Distortion </li></ul>
  9. 9. Error Control Correction and Detection Schemes
  10. 10. Error Control <ul><li>Split binary data stream in to words </li></ul><ul><ul><li>Each word is m bits long </li></ul></ul><ul><ul><li>Add r extra bits in special, known positions </li></ul></ul><ul><ul><li>The r bits can be examined by the receiver to </li></ul></ul><ul><ul><ul><li>Detect if bits have been incorrectly flipped </li></ul></ul></ul><ul><ul><ul><li>Locate and correct the flipped bits </li></ul></ul></ul><ul><ul><li>The r bits are then removed and the m -bit data word is delivered </li></ul></ul>
  11. 11. Error Detection with Parity Bits <ul><li>A Parity Bit makes the number of 1’s in a word even, e.g. if m = 3 and r = 1 </li></ul>000 001 010 011 100 101 111 000 0 001 1 010 1 011 0 100 1 101 0 111 1 110 110 0
  12. 12. Error Detection with Parity Bits <ul><li>A Parity Bit makes the number of 1’s in a word even, e.g. if m = 3 and r = 1 </li></ul>001 1 parity check OK 000 001 010 011 100 101 111 000 0 001 1 010 1 011 0 100 1 101 0 111 1 110 110 0
  13. 13. Error Detection with Parity Bits <ul><li>A Parity Bit makes the number of 1’s in a word even, e.g. if m = 3 and r = 1 </li></ul>011 1 error detected! parity check not OK 000 001 010 011 100 101 111 000 0 001 1 010 1 011 0 100 1 101 0 111 1 110 110 0
  14. 14. Error Detection with Parity Bits <ul><li>A Parity Bit makes the number of 1’s in a word even, e.g. if m = 3 and r = 1 </li></ul>111 1 error missed!!! parity check OK 000 001 010 011 100 101 111 000 0 001 1 010 1 011 0 100 1 101 0 111 1 110 110 0
  15. 15. Error Detection with Parity Bits <ul><li>Parity Bits detect single-bit errors in a given data word </li></ul><ul><ul><li>m can be arbitrarily large </li></ul></ul><ul><ul><li>But if 2 bits are flipped instead of one the parity check will pass and an error will be missed </li></ul></ul><ul><ul><li>Larger m increases likelihood of this </li></ul></ul>
  16. 16. Hamming Theory <ul><li>For any values of m and r we can say some things about a given hypothetical code </li></ul><ul><ul><li>A scheme produces 2 m+r receivable words </li></ul></ul><ul><ul><li>2 m will be valid words </li></ul></ul><ul><ul><li>2 m+r – 2 m will be invalid words </li></ul></ul><ul><li>An error detection scheme can tell the difference between a valid and an invalid word </li></ul><ul><li>An error correction scheme can work out which of the 2 m valid words an invalid word must have been upon transmission. </li></ul>
  17. 17. Hamming Theory <ul><li>Some number of bit-flips = d will change a valid word in to another valid word </li></ul><ul><ul><li>d is the hamming distance of the code </li></ul></ul><ul><ul><li>e.g. Our 4-bit parity scheme required just two flips to go from one valid word to another, d = 2 </li></ul></ul><ul><ul><li>An error detection scheme to detect ≤ d errors must have a hamming distance = d+1 </li></ul></ul><ul><ul><li>Why…? </li></ul></ul>
  18. 18. Hamming Theory <ul><li>An error detection scheme to detect ≤ d errors must have a hamming distance = d+1 </li></ul>with distance 2, if 1 error occurs we will always receive an invalid word 000 0 001 1 010 1 011 0 100 1 101 0 111 1 110 0 000 1 001 0 010 0 011 1 100 0 101 1 111 0 110 1
  19. 19. Hamming Theory <ul><li>To correct single errors, an m -bit scheme must have r bits such that: </li></ul><ul><li>(m + r + 1)2 m ≤ 2 m+r </li></ul><ul><li>Why? </li></ul>
  20. 20. Hamming Theory <ul><li>Explanation 1 (Reserve Invalid Words): </li></ul><ul><ul><li>We have 2 m valid words (see our 4-bit parity code) </li></ul></ul><ul><ul><li>For each one, take each bit in turn and flip it </li></ul></ul><ul><ul><li>This generates m+r invalid words </li></ul></ul>0000 1 000 0 1 00 00 1 0 000 1
  21. 21. Hamming Theory <ul><li>Explanation 1 (Reserve Invalid Words): </li></ul><ul><ul><li>In total there are 2 m+r - 2 m invalid words </li></ul></ul><ul><ul><li>Each has distance = 1 from a valid original </li></ul></ul><ul><ul><li>The receiver will always be able to correct to the valid original if it receives one of these words, because no other valid word is within distance = 1 </li></ul></ul><ul><ul><li>(This is the fundamental principle of error correcting codes) </li></ul></ul>
  22. 22. Hamming Theory <ul><li>Explanation 1 (Reserve Invalid Words): </li></ul><ul><ul><li>Because we need to keep this property, each valid word ‘reserves’ m+r invalid words </li></ul></ul><ul><ul><li>The total number of possible words is 2 m+r </li></ul></ul><ul><ul><li>Therefore: </li></ul></ul><ul><ul><li>2 m + (m+r)2 m ≤ 2 m+r </li></ul></ul>the words invalid words reserved by them all valid words + total words available ≤ 2m + (m+r)2m = (m+r+1)2m
  23. 23. Hamming Theory <ul><li>Explanation 2 (Encode Enough Positions) </li></ul><ul><ul><li>Start by rearranging the equation a bit: </li></ul></ul><ul><ul><ul><li>(m+r+1)2 m ≤ 2 m+r </li></ul></ul></ul><ul><ul><ul><li>(m+r+1) ≤ 2 r (divide both sides by 2 m ) </li></ul></ul></ul><ul><ul><li>2 r is the number of distinct words we can make out of the r parity bits. </li></ul></ul><ul><ul><li>In order to correct errors, the parity word must tell us both </li></ul></ul><ul><ul><ul><li>if an error has occurred </li></ul></ul></ul><ul><ul><ul><li>if one has, which bit position is wrong </li></ul></ul></ul>
  24. 24. Hamming Theory <ul><li>Explanation 2 (Encode Enough Positions) </li></ul><ul><ul><li>To do this, we need to have ‘parity words’ for </li></ul></ul><ul><ul><ul><li>No error, </li></ul></ul></ul><ul><ul><ul><li>Error in position 1 </li></ul></ul></ul><ul><ul><ul><li>Error in position 2 </li></ul></ul></ul><ul><ul><ul><li>… </li></ul></ul></ul><ul><ul><ul><li>Error in position m+r </li></ul></ul></ul><ul><ul><li>Therefore 2 r must be able to express this many positions, and so </li></ul></ul><ul><ul><li>(m+r) + 1 ≤ 2 r </li></ul></ul><ul><ul><li>(That is, we must have enough parity ‘words’ to express ‘error’ in each bit position + 1 word for ‘no errors’) </li></ul></ul>
  25. 25. Hamming Codes <ul><li>Optimal error correction for single-bit errors </li></ul><ul><ul><li>Use multiple parity bits ( r > 1) </li></ul></ul><ul><ul><li>Each parity bit checks a subset of the data bits </li></ul></ul><ul><ul><li>Cross check which parities are wrong to determine which data bit has been flipped </li></ul></ul><ul><li>Central idea: </li></ul><ul><ul><li>The set of parity bits describe the position of the incorrect bit </li></ul></ul>
  26. 26. Hamming Codes <ul><li>A Simple Code </li></ul><ul><ul><li>m = 4 </li></ul></ul><ul><ul><li>r = 3 </li></ul></ul><ul><ul><ul><li>r 1 checks m1, m2, m3 </li></ul></ul></ul><ul><ul><ul><li>r 2 checks m2, m3, m4 </li></ul></ul></ul><ul><ul><ul><li>r 3 checks m1, m2, m4 </li></ul></ul></ul>0 0 0 0 0 0 0 r 1 m 1 m 2 r 2 m 3 m 4 r 3
  27. 27. Hamming Codes <ul><li>An Example: </li></ul><ul><ul><li>For the given data bits ‘0011’ </li></ul></ul><ul><ul><li>What should our 3 parity bits be? </li></ul></ul>r 1 m 1 m 2 m 3 r 3 m 1 m 2 m 4 r 2 m 2 m 3 m 4 ? 0 0 ? 1 1 ? r 1 m 1 m 2 r 2 m 3 m 4 r 3
  28. 28. Hamming Codes <ul><li>Another Example: </li></ul><ul><ul><li>For the given data bits ‘1010’ </li></ul></ul><ul><ul><li>What should our 3 parity bits be? </li></ul></ul>r 1 m 1 m 2 m 3 r 3 m 1 m 2 m 4 r 2 m 2 m 3 m 4 ? 1 0 ? 1 0 ? r 1 m 1 m 2 r 2 m 3 m 4 r 3
  29. 29. Hamming Codes <ul><li>An Example: </li></ul><ul><ul><li>Flip any one data bit and at least two parity bits will be incorrect </li></ul></ul><ul><ul><li>Each data bit is checked by a different set of parity bits, so we always know which one was flipped </li></ul></ul>r 1 m 1 m 2 m 3 r 3 m 1 m 2 m 4 r 2 m 2 m 3 m 4 0 1 0 1 1 0 1 r 1 m 1 m 2 r 2 m 3 m 4 r 3
  30. 30. Hamming Codes <ul><li>An Example: </li></ul><ul><ul><li>The pattern of correct/incorrect in the parity bits form parity words </li></ul></ul><ul><ul><li>Each unique parity word describes the position of the error in the data word </li></ul></ul>r 1 r 2 r 3 error bit m 1 m 2 m 3 m 4 r 1 m 1 m 2 m 3 r 3 m 1 m 2 m 4 r 2 m 2 m 3 m 4
  31. 31. Hamming Codes <ul><li>But isn’t there a problem here…? </li></ul><ul><ul><li>r 1 checks m 1 , m 2 , m 3 </li></ul></ul><ul><ul><li>r 2 checks m 2 , m 3 , m 4 </li></ul></ul><ul><ul><li>r 3 checks m 1 , m 2 , m 4 </li></ul></ul>0 0 0 0 0 0 0 r 1 m 1 m 2 r 2 m 3 m 4 r 3
  32. 32. Hamming Codes <ul><li>But isn’t there a problem here…? </li></ul><ul><ul><li>r 1 checks m 1 , m 2 , m 3 </li></ul></ul><ul><ul><li>r 2 checks m 2 , m 3 , m 4 </li></ul></ul><ul><ul><li>r 3 checks m 1 , m 2 , m 4 … </li></ul></ul><ul><ul><li>…so who checks r 1,2,3 ? </li></ul></ul>0 0 0 0 0 0 0 r 1 m 1 m 2 r 2 m 3 m 4 r 3
  33. 33. Hamming Codes w/ Logarithmic Parity <ul><li>In a real Hamming code, the r bits are in positions 2 0 , 2 1 , 2 2 ,…,2 i </li></ul><ul><li>They check the data bits, but they also check each other … </li></ul>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 r 1 r 2 m 1 r 3 m 2 m 3 m 4 r 4 m 5 m 6 m 7 m 8 m 9 m 10 m 11 r 5 m 12
  34. 34. Hamming Codes w/ Logarithmic Parity <ul><li>Each bit has its position expressed as a sum of powers of 2 </li></ul><ul><ul><li>e.g. m 4 in position 7 = 4 + 2 + 1 = 2 2 + 2 1 + 2 0 </li></ul></ul><ul><ul><li>A position is checked by the parity bits in the positions used to calculate its sum </li></ul></ul>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 r 1 r 2 m 1 r 3 m 2 m 3 m 4 r 4 m 5 m 6 m 7 m 8 m 9 m 10 m 11 r 5 m 12
  35. 35. Hamming Codes w/ Logarithmic Parity 0 0 0 0 0 0 0 0 0 0 0 0 r 1 r 2 m 1 r 3 m 2 m 3 m 4 r 4 m 5 m 6 m 7 m 8 1 2 3 4 5 6 7 8 9 10 11 12 r 4 (8) r 3 (4) r 2 (2) r 1 (1) 12 11 10 9 8 7 6 5 4 3 2 1
  36. 36. Hamming Codes w/ Logarithmic Parity ? ? 0 ? 0 1 0 ? 1 1 0 0 r 1 r 2 m 1 r 3 m 2 m 3 m 4 r 4 m 5 m 6 m 7 m 8 1 2 3 4 5 6 7 8 9 10 11 12 r 4 (8) r 3 (4) r 2 (2) r 1 (1) 12 11 10 9 8 7 6 5 4 3 2 1
  37. 37. Hamming Codes w/ Logarithmic Parity 1 0 0 1 0 1 0 0 1 1 0 0 r 1 r 2 m 1 r 3 m 2 m 3 m 4 r 4 m 5 m 6 m 7 m 8 1 2 3 4 5 6 7 8 9 10 11 12 r 4 (8) r 3 (4) r 2 (2) r 1 (1) 12 11 10 9 8 7 6 5 4 3 2 1
  38. 38. Hamming Codes w/ Logarithmic Parity 1 0 0 1 1 1 0 0 1 1 0 0 r 1 r 2 m 1 r 3 m 2 m 3 m 4 r 4 m 5 m 6 m 7 m 8 1 2 3 4 5 6 7 8 9 10 11 12 <ul><li>error in m 2 … </li></ul><ul><li>… parity incorrect for r 1 and r 3 </li></ul>r 4 (8) r 3 (4) r 2 (2) r 1 (1) 12 11 10 9 8 7 6 5 4 3 2 1
  39. 39. Hamming Codes w/ Logarithmic Parity 1 0 0 1 0 1 0 0 1 0 0 0 r 1 r 2 m 1 r 3 m 2 m 3 m 4 r 4 m 5 m 6 m 7 m 8 1 2 3 4 5 6 7 8 9 10 11 12 <ul><li>error in m 6 … </li></ul><ul><li>… parity incorrect for r 2 and r 4 </li></ul>r 4 (8) r 3 (4) r 2 (2) r 1 (1) 12 11 10 9 8 7 6 5 4 3 2 1
  40. 40. Hamming Codes w/ Logarithmic Parity <ul><li>error in r 4 … </li></ul><ul><li>… parity incorrect for r 4 </li></ul>r 4 (8) r 3 (4) r 2 (2) r 1 (1) 12 11 10 9 8 7 6 5 4 3 2 1 1 0 0 1 0 1 0 1 1 1 0 0 r 1 r 2 m 1 r 3 m 2 m 3 m 4 r 4 m 5 m 6 m 7 m 8 1 2 3 4 5 6 7 8 9 10 11 12
  41. 41. Hamming codes w/ Logarithmic Parity <ul><li>General case… </li></ul><ul><ul><li>Iterate over each parity bit… </li></ul></ul><ul><ul><li>If the bit is not in correct parity, add the value of its position to a counter… </li></ul></ul><ul><ul><li>At the end… </li></ul></ul><ul><ul><ul><li>…if the counter == 0 there are no errors </li></ul></ul></ul><ul><ul><ul><li>…else, the counter’s value indicates the incorrect position </li></ul></ul></ul><ul><ul><ul><li>Why? </li></ul></ul></ul><ul><ul><ul><ul><li>Because it is a sum of the incorrect parity positions </li></ul></ul></ul></ul><ul><ul><ul><ul><li>NOTE! Each position is described by a unique sum </li></ul></ul></ul></ul>
  42. 42. Hamming codes w/ Logarithmic Parity <ul><li>Example: </li></ul><ul><li>Iterate over each parity bit… </li></ul><ul><li>If the bit is not in correct parity, add the value of its position to a counter… </li></ul><ul><li>At the end… </li></ul><ul><ul><li>… if the counter == 0 there are no errors </li></ul></ul><ul><ul><li>… else, the counter’s value indicates the incorrect position </li></ul></ul>1 = 1 2 = 2 3 = 1 + 2 4 = 4 5 = 4 + 1 6 = 4 + 2 7 = 4 + 2 + 1 0 1 0 1 0 1 0 r 1 r 2 m 1 r 3 m 2 m 3 m 4 1 2 3 4 5 6 7
  43. 43. Hamming codes w/ Logarithmic Parity <ul><li>Example: </li></ul><ul><li>Iterate over each parity bit… </li></ul><ul><li>If the bit is not in correct parity, add the value of its position to a counter… </li></ul><ul><li>At the end… </li></ul><ul><ul><li>… if the counter == 0 there are no errors </li></ul></ul><ul><ul><li>… else, the counter’s value indicates the incorrect position </li></ul></ul>1 = 1 2 = 2 3 = 1 + 2 4 = 4 5 = 4 + 1 6 = 4 + 2 7 = 4 + 2 + 1 0 0 0 1 0 0 1 r 1 r 2 m 1 r 3 m 2 m 3 m 4 1 2 3 4 5 6 7
  44. 44. Hamming Code Summary <ul><li>Hamming codes correct single bit errors in a given data word </li></ul><ul><ul><li>Embed r parity bits at positions 2 0 , 2 1 , 2 2 , … </li></ul></ul><ul><ul><li>Each parity bit checks a unique subset of the other bit positions (and itself) </li></ul></ul><ul><ul><li>If a single bit error occurs a unique combination of the parity bits will be incorrect </li></ul></ul><ul><ul><li>This unique combination is used to locate and correct the flipped bit </li></ul></ul>
  45. 45. Cyclic Redundancy for Error Detection <ul><li>Based on factorisation of numbers </li></ul><ul><ul><li>M /G = P + R/G </li></ul></ul><ul><ul><ul><li>A division produces a result P and a remainder R </li></ul></ul></ul><ul><ul><li>M÷G = R </li></ul></ul><ul><ul><ul><li>The modulo operation gives just R </li></ul></ul></ul><ul><ul><ul><li>e.g. 26÷8 = 2 </li></ul></ul></ul><ul><ul><li>(M-R)/G = P + 0/B </li></ul></ul><ul><ul><ul><li>The difference between a dividend and a remainder can always be factorised by the divisor </li></ul></ul></ul><ul><ul><ul><li>e.g. (26-(26÷8))/8 = (26-2)/8 = 24/8 = 3 + 0/8 </li></ul></ul></ul><ul><ul><ul><li>Therefore, (M-R)÷G = 0 </li></ul></ul></ul>
  46. 46. Cyclic Redundancy for Error Detection <ul><li>Based on modulo operation </li></ul><ul><ul><li>Choose any other value for R in the formula (M-R)/G </li></ul></ul><ul><ul><ul><li>What is the probability of the result having a 0 remainder? </li></ul></ul></ul><ul><ul><ul><ul><li>(26-3)/8 = 23/8 = 2 + 7/8 </li></ul></ul></ul></ul><ul><ul><ul><ul><li>(26-1)/8 = 25/8 = 3 + 1/8 </li></ul></ul></ul></ul><ul><ul><ul><ul><li>(26-10)/8 = 16/8 = 2 + 0/8 </li></ul></ul></ul></ul><ul><ul><ul><li>i.e. How far do we have to change M to get to another number that can be factorised by G ? </li></ul></ul></ul>
  47. 47. Cyclic Redundancy for Error Detection <ul><li>How does CRC use this idea? </li></ul><ul><ul><li>Agree a value of G beforehand </li></ul></ul><ul><ul><li>For a given data frame M </li></ul></ul><ul><ul><ul><li>Calculate R = M÷G </li></ul></ul></ul><ul><ul><ul><li>Send M – R </li></ul></ul></ul><ul><ul><li>If the received frame has a non-zero remainder when divided by G , errors have occurred </li></ul></ul>
  48. 48. Error Detection with CRC <ul><li>Cyclic Redundancy Checking (CRC) </li></ul><ul><ul><li>Uses polynomial division instead of binary </li></ul></ul><ul><ul><li>Binary string represents a polynomial </li></ul></ul><ul><ul><li>arithmetic is performed modulo 2 </li></ul></ul>0 1 1 0 0x 3 + 1x 2 – 1x 1 + 0x 0 = 1 0 1 0 0 1 1x 5 + 0x 4 - 1x 3 + 0x 2 + 0x 1 - 1x 0 = <ul><ul><li>NOTE! the arithmetic is modulo 2 so 0 = 0, 1 = 1, 2 = 1, 3 = 0….but also -1 = 1, -2 = 0, etc… </li></ul></ul>
  49. 49. Error Detection with CRC <ul><li>Subtraction of two polynomials == binary XOR operation: </li></ul>0 1 1 0 - 0 1 1 1 = 0 0 0 1 0x 3 + 1x 2 - 1x 1 + 0x 0 - 0x 3 + 1x 2 - 1x 1 + 1x 0 = 0x 3 + 0x 2 + 0x 1 - 1x 0 = 1 0 1 0 0 1 - 0 0 1 1 0 0 = 1 0 0 1 0 1 1x 5 + 0x 4 - 1x 3 + 0x 2 + 0x 1 - 1x 0 - 0x 5 + 0x 4 + 1x 3 + 1x 2 + 0x 1 + 0x 0 = 1x 5 + 0x 4 - 2x 3 - 1x 2 + 0x 1 - 1x 0 = <ul><ul><li>NOTE! because arithmetic is modulo 2, the -2x 4 above becomes a 0 in the binary representation… everything is simple xOR </li></ul></ul>
  50. 50. Error Detection with CRC <ul><li>Division of two polynomials = binary division (with XOR subtraction) </li></ul>
  51. 51. Error Detection with CRC <ul><li>Division of two polynomials </li></ul><ul><ul><li>Complicated process (which you do not need to learn) </li></ul></ul><ul><li>Two important points: </li></ul><ul><ul><li>Produces a Result and a Remainder (just like decimal) </li></ul></ul><ul><ul><li>Remainder is always same length as Divisor </li></ul></ul>remainder result divisor dividend
  52. 52. Error Detection with CRC <ul><li>CRC Algorithm: the sending end </li></ul><ul><ul><li>Agree a generator divisor G of length r </li></ul></ul><ul><ul><li>Append r zeroes to the M data bits producing x r M </li></ul></ul><ul><ul><li>Calculate x r M ÷ G = R </li></ul></ul><ul><ul><li>Calculate x r M – R = T </li></ul></ul><ul><ul><ul><li>Equivalent to just appending R to M </li></ul></ul></ul>1 1 1 0 0 0 1 0 1 1 1 1 0 0 0 ÷ 1 0 1 = 0 1 1 1 1 1 0 0 0 – 0 1 1 = 1 1 1 0 1 1
  53. 53. Error Detection with CRC <ul><li>What is sent? </li></ul>1 1 1 0 1 1 T ( (x r M – R)/G which is divisible by G with 0 remainder) M (original data) M (original data) R (remainder of x r M / G )
  54. 54. Error Detection with CRC <ul><li>CRC Algorithm: the receiving end </li></ul><ul><ul><li>Divide the received bits by G </li></ul></ul><ul><ul><li>If the remainder = 0, remove first r bits and continue </li></ul></ul><ul><ul><li>If the remainder is ≠ 0 an error has occurred </li></ul></ul>M = 1 1 1 1 1 1 0 1 1 / 0 1 1 = 0 0 0 0
  55. 55. Error Detection with CRC <ul><li>Why Polynomial Division? </li></ul><ul><ul><li>Very fast in hardware </li></ul></ul><ul><ul><li>The remainder is always same number of bits as the divisor </li></ul></ul><ul><ul><li>Produces very good hamming distance </li></ul></ul><ul><ul><ul><li>why? </li></ul></ul></ul>
  56. 56. Error Detection with CRC <ul><li>Analysis of CRC </li></ul><ul><ul><li>If T/G ≠ 0 then T was actually T` = T+E </li></ul></ul><ul><ul><li>For example: </li></ul></ul>T = 1 1 1 0 1 1 T` = T + E = 1 1 0 0 1 1 E = 0 0 1 0 0 0 transmission error
  57. 57. Error Detection with CRC <ul><li>Analysis of CRC </li></ul><ul><ul><li>If T/G != 0 then T was actually T` = T+E </li></ul></ul><ul><ul><li>We only miss errors if E/G = 0 </li></ul></ul><ul><ul><li>When will this DEFINITELY NOT happen? </li></ul></ul><ul><ul><ul><li>If G has exactly two 1’s in it… </li></ul></ul></ul><ul><ul><ul><ul><li>and only a single bit is flipped </li></ul></ul></ul></ul><ul><ul><ul><li>If G has a 1 in the right-most bit… </li></ul></ul></ul><ul><ul><ul><ul><li>and any odd number of flips occurs </li></ul></ul></ul></ul><ul><ul><ul><li>If G is of length r … </li></ul></ul></ul><ul><ul><ul><ul><li>and a string of bits of length ≤ r is flipped (a ‘burst’) </li></ul></ul></ul></ul>
  58. 58. Error Detection with CRC <ul><li>Analysis of CRC </li></ul><ul><ul><li>A real value of G </li></ul></ul>= 100000100110000010001110110110111 <ul><ul><li>802 standard CRC32 (Ethernet) </li></ul></ul><ul><ul><li>Detects all bursts < 32 bits </li></ul></ul><ul><ul><li>Detects all odd numbers of bit flips </li></ul></ul>
  59. 59. Error Detection with CRC <ul><li>Analysis of CRC </li></ul><ul><ul><li>The valid words of a parity-bit scheme are any words with an even number of 1’s </li></ul></ul><ul><ul><li>What are the valid words of a CRC scheme with a generator = G ? </li></ul></ul>
  60. 60. Error Detection with CRC <ul><li>Analysis of CRC </li></ul><ul><ul><li>For further analysis see: </li></ul></ul><ul><ul><ul><li>Tannenbaum (pages 198 + 199) </li></ul></ul></ul><ul><ul><ul><ul><li>theoretical limits of detection </li></ul></ul></ul></ul><ul><ul><ul><li>Forouzan (pages 284-291) </li></ul></ul></ul><ul><ul><ul><ul><li>hardware implementation techniques </li></ul></ul></ul></ul>
  61. 61. Bursty Error Control <ul><li>Isolated Errors </li></ul><ul><ul><li>Parity bits, hamming codes and CRC are very good at detecting/correcting single bit errors </li></ul></ul>
  62. 62. Bursty Error Control <ul><li>Burst Errors </li></ul><ul><ul><li>In the real world, noise and attenuation result in isolated long sequences of errors known as bursts </li></ul></ul>
  63. 63. Bursty Error Control <ul><li>Block Sending </li></ul><ul><ul><li>Don’t send one frame at a time, send a small portion of several frames each frame </li></ul></ul><ul><ul><li>Receiver pieces the frames back together </li></ul></ul>
  64. 64. Bursty Error Control <ul><li>Block Sending </li></ul><ul><ul><li>If a burst error of length n wipes out a frame this will be felt as a single bit error in n consecutive frames (each easy to detect/correct) </li></ul></ul>
  65. 65. Error Control Design Choices <ul><li>Detection vs. Correction </li></ul><ul><ul><li>We can detect errors using far fewer control bits (e.g. parity bit vs. hamming code) </li></ul></ul><ul><ul><li>When should we use one or the other? </li></ul></ul><ul><li>Block vs. Linear Sending </li></ul><ul><ul><li>We can guard against burst errors by sending frames in blocks and reconstructing them </li></ul></ul><ul><ul><li>For what applications is this inappropriate? </li></ul></ul>
  66. 66. Error Control Summary <ul><li>The physical layer is error-prone </li></ul><ul><ul><li>Noise, attenuation, distortion </li></ul></ul><ul><li>Data Link Layer must deal with this </li></ul><ul><ul><li>Split outgoing binary stream in to frames </li></ul></ul><ul><ul><li>Each frame contains m data bits and r check bits </li></ul></ul><ul><li>Error Detection can detect a corrupted frame </li></ul><ul><ul><li>Parity bit, CRC </li></ul></ul><ul><li>Error Correction can correct the flipped bits </li></ul><ul><ul><li>Hamming codes </li></ul></ul>
  67. 67. Framing
  68. 68. Framing <ul><li>Error control relies on the ability to break the binary stream in to chunks </li></ul><ul><ul><li>How do we now where a chunk begins and ends? </li></ul></ul><ul><ul><li>How can we keep track of the chunks themselves in an error-rich environment? </li></ul></ul>
  69. 69. Character Count Framing <ul><li>Each frame contains a header with the number of characters in the frame </li></ul>
  70. 70. Character Count Framing <ul><li>Problem: </li></ul><ul><ul><li>if the header is corrupted the count will be wrong and the next header will be missed </li></ul></ul>
  71. 71. Flag-Byte Framing <ul><li>General problem: how do we denote the end of one frame and start of another? </li></ul><ul><ul><li>FLAG bytes: 01111110 </li></ul></ul>usually a sequence number usually error control <ul><li>What happens if the payload contains a FLAG? </li></ul>
  72. 72. FLAG-bytes with Byte Stuffing <ul><li>Escape all FLAG bytes in the payload </li></ul><ul><li>Analogous to the Java expression </li></ul><ul><ul><li>String s = ”An ”escaped” String” </li></ul></ul><ul><li>Also need to escape all ESC bytes in the payload </li></ul><ul><li>Analogous to the Java expression </li></ul><ul><ul><li>String s = ”An escape character: </li></ul></ul>
  73. 73. FLAG-bytes with Bit Stuffing <ul><li>Escaping a byte with an entire byte is wasteful </li></ul><ul><ul><li>Instead just escape the character in the binary stream directly </li></ul></ul><ul><li>Whenever 5 1’s are seen, insert a 0 in to the output stream (FLAG = 6 1’s) </li></ul><ul><li>Identical to technique used in RLL coding </li></ul>
  74. 74. Putting it all together… DATA a chunk of network-layer binary data
  75. 75. Putting it all together… ESC DATA ESC bytes or 0 bits stuffed
  76. 76. Putting it all together… CTRL ESC DATA Control information such as sender/receiver/seq. number/etc... (see Flow Control and MAC sub-layer) Control information such as sender/receiver/seq. number/etc... (see Flow Control and MAC sub-layer)
  77. 77. Putting it all together… CRC ESC DATA CRC checksum or other error-control information CTRL
  78. 78. Putting it all together… FLAG FLAG CTRL CRC ESC DATA FLAG bytes mark start and end of frame (note, these are not CRC-protected) <ul><li>A complete data-link frame </li></ul>FLAG bytes mark start and end of frame (note, these are not CRC-protected)
  79. 79. Flow Control
  80. 80. Flow Control Overview <ul><li>Flow Control Protocols deal with how to send sequences of DLL frames </li></ul><ul><li>They have two jobs: </li></ul><ul><ul><li>Recover from lost frames </li></ul></ul><ul><ul><li>Prevent buffer overflows </li></ul></ul><ul><li>Network Layer must receive same set of frames in the same order they were sent </li></ul>
  81. 81. Unrestricted <ul><li>Sender sends </li></ul><ul><li>Receiver waits to receive </li></ul>
  82. 82. Unrestricted <ul><li>Problem: receiver’s buffers may fill up </li></ul>
  83. 83. Stop-and-Wait <ul><li>Sender sends, waits for ACK </li></ul><ul><li>Receiver receives, sends ACK </li></ul>
  84. 84. Stop-and-Wait <ul><li>Problem: lost frame = wait forever </li></ul>
  85. 85. Stop-and-Wait <ul><li>What, exactly, is a lost frame ? </li></ul>
  86. 86. Stop-and-Wait with Timeouts <ul><li>Sender sends, waits for ack </li></ul><ul><ul><li>Stops waiting after t seconds and re-sends </li></ul></ul>
  87. 87. Stop-and-Wait with Timeouts <ul><li>Problem: we are assuming errors only occur in one direction… </li></ul>sender receiver errors no errors
  88. 88. Stop-and-Wait with Timeouts <ul><li>Lost ack = duplicate frame </li></ul><ul><li>When else will a duplicate be received? </li></ul>
  89. 89. ARQ: Automatic Repeat Request <ul><li>Use sequence numbers to identify frames </li></ul><ul><li>Sender sends SEQ n </li></ul><ul><ul><li>Start timer </li></ul></ul><ul><ul><li>If ack received, n = n+1, if timeout, resend n </li></ul></ul><ul><li>Receiver receives n </li></ul><ul><ul><li>If expecting n, send ack for n </li></ul></ul><ul><ul><li>If expecting n+1 then ack for n was lost </li></ul></ul><ul><ul><ul><li>re-send ack for n </li></ul></ul></ul><ul><ul><ul><li>await delivery of n+1 </li></ul></ul></ul>
  90. 90. ARQ: Automatic Repeat Request <ul><li>Always ACK the latest frame number we received </li></ul>
  91. 91. ARQ: Automatic Repeat Request <ul><li>Only acknowledge latest sequence number we expected to receive and did </li></ul><ul><li>Sender will never send a frame without the ACK for the previous one </li></ul><ul><li>Receiver will never accept a frame it has already seen </li></ul>
  92. 92. ARQ: Automatic Repeat Request <ul><li>Functionally ARQ is a complete protocol </li></ul><ul><ul><li>Frame losses are detected </li></ul></ul><ul><ul><li>Duplicate frames are detected </li></ul></ul><ul><ul><li>Protocol will never deadlock </li></ul></ul><ul><li>This does not mean it is foolproof: </li></ul><ul><ul><li>The checksum, data and SEQ fields could all change pathologically </li></ul></ul><ul><ul><li>In general the more changes needed to break a protocol the lower the chance of it happening </li></ul></ul>
  93. 93. Sliding Window: Go-Back-N <ul><li>ARQ performance is bad because the sender spends most of the time waiting for a timeout or an ACK </li></ul><ul><li>Relationship to channel volume: </li></ul><ul><ul><li>Latency = L , Data Rate = R , Frame Size = F </li></ul></ul><ul><ul><li>L * R = Volume </li></ul></ul><ul><ul><li>L * 2 = Round Trip Time </li></ul></ul><ul><ul><li>F / R = Time to Send 1 Frame </li></ul></ul><ul><ul><li>L * 2 – (F/R) ≈ Idle Time per-Frame </li></ul></ul>
  94. 94. Sliding Window: Go-Back-N <ul><li>How can we improve the channel utilisation of an ARQ protocol? </li></ul><ul><li>Answer: Pipelining </li></ul><ul><ul><li>assume operation i is successful </li></ul></ul><ul><ul><li>perform operations i+1,2,3… up to a max n </li></ul></ul><ul><ul><li>be prepared to go back up to n operations if one or more were incorrect </li></ul></ul><ul><li>Also found in… </li></ul><ul><ul><li>Microprocessing architectures </li></ul></ul><ul><ul><li>Higher-level network protocols (e.g. http 1.1) </li></ul></ul>
  95. 95. Sliding Window: Go-Back-N <ul><li>Based on valid window of SEQs at sender </li></ul><ul><li>Any frame in window can be sent </li></ul><ul><li>Receiver uses same logic as ARQ </li></ul><ul><ul><li>ACK latest SEQ we saw and expected to see </li></ul></ul><ul><ul><li>Discard all others </li></ul></ul>
  96. 96. Sliding Window: Go-Back-N <ul><li>Normal Operation… </li></ul>
  97. 97. Sliding Window: Go-Back-N <ul><li>Lost Frame… </li></ul>
  98. 98. Sliding Window: Go-Back-N <ul><li>Lost ACK… </li></ul>
  99. 99. Sliding Window: Go-Back-N <ul><li>Frame and ACK errors solved with timeout (defined in frames, not real time) </li></ul><ul><li>e.g. window size of 7 </li></ul>
  100. 100. Sliding Window: Go-Back-N <ul><li>For a k -bit SEQ field, 2 k sequence numbers are used, window must be 2 k -1 in size…why? </li></ul>
  101. 101. Sliding Window: Go-Back-N <ul><li>Two adjacent windows must be unique to prevent ambiguity in ACKs </li></ul><ul><li>For any window, the ACK tells the sender how many were successfully received: </li></ul><ul><ul><li>[0,6] 6 = all, 7 = ack corrupted, 0 = one, 1 = two… </li></ul></ul><ul><ul><li>[7,5] 5 = all, 6 = ack corrupted, 7 = one, 0 = two… </li></ul></ul><ul><ul><li>[6,4] 4 = all, 5 = ack corrupted, 6 = one, 7 = two… </li></ul></ul><ul><ul><li>etc… </li></ul></ul><ul><li>i.e. must always have at least 1 un-used SEQ </li></ul>
  102. 102. Sliding Window: Go-Back-N <ul><li>Problem: retransmission overhead is large </li></ul>
  103. 103. Sliding Window: Selective Repeat <ul><li>Receiver keeps an array of frame buffers </li></ul><ul><li>Now accepts any frame in the window </li></ul>
  104. 104. Sliding Window: Selective Repeat <ul><li>Send Negative ACK (NAK) if a frame is skipped over </li></ul><ul><li>ACK for frame n implicitly acknowledges all frames ≤ n </li></ul>
  105. 105. Sliding Window: Selective Repeat <ul><li>For a k -bit SEQ field window cannot be > 2 k-1 </li></ul><ul><ul><li>e.g. if SEQ field = 3 bits and window is size 5: </li></ul></ul>
  106. 106. Duplex Sliding Window <ul><li>Method to optimise sliding window protocols </li></ul><ul><ul><li>Assume both sides have data frames to send and both want to receive </li></ul></ul><ul><ul><li>Since ACK/NAK is a small amount of data, include it as an optional field in all frames (piggybacking) </li></ul></ul><ul><li>Utilisation and throughput are now functions of what? </li></ul>
  107. 107. Real DLL protocols: HDLC <ul><li>Bit-Oriented (FLAG + bit-stuffing) </li></ul><ul><li>3-bit selective-repeat [0-7] + piggybacking </li></ul>(if piggybacked) (otherwise)
  108. 108. Real DLL protocols: LLC (802.2) <ul><li>Identical to HDLC (bit-oriented, 3-bit SR) </li></ul><ul><li>No Addressing </li></ul><ul><li>No Error Control </li></ul>
  109. 109. Further Reading… <ul><li>Tannenbaum’s code examples are great if you’re familiar (enough) with c </li></ul><ul><li>The java applets on the web page (under ‘additional material -> Data Link Layer -> Simulations’) should help you visualise these algorithms (but they are hideous). </li></ul><ul><li>You WILL be asked what-if questions about these algorithms in the exam. </li></ul>
  110. 110. Flow Control Summary <ul><li>Serves two functional purposes </li></ul><ul><ul><li>Prevent buffer overruns </li></ul></ul><ul><ul><li>Recover from lost frames </li></ul></ul><ul><li>Simple schemes achieve this </li></ul><ul><ul><li>e.g. ARQ (ACKs with timeout + SEQ number) </li></ul></ul><ul><li>Non -functional properties also important </li></ul><ul><ul><li>Sliding window improves performance by pipelining. Achieves several send/ACK exchanges in parallel </li></ul></ul><ul><ul><li>Piggybacking for duplex versions of same protocols </li></ul></ul>
  111. 111. Medium Access Control
  112. 112. Multiple Access Channels
  113. 113. Multiple Access Channels
  114. 114. MAC Overview <ul><li>The MAC (sub-)layer </li></ul><ul><li>ALOHA Protocols </li></ul><ul><li>Carrier-Sense Protocols </li></ul><ul><li>Wireless protocols </li></ul>
  115. 115. The MAC sub-layer Data-Link Layer provides packet send/receive service to Network Layer
  116. 116. The MAC sub-layer Physical Layer provides binary send/receive to Data-Link Layer
  117. 117. The MAC sub-layer But, different media have different constraints about multiple nodes accessing the medium
  118. 118. The MAC sub-layer <ul><li>We could hide this all in the physical layer: </li></ul><ul><ul><li>send(bit b) returns once the medium is reserved and the bit has been sent </li></ul></ul><ul><li>Very inefficient </li></ul><ul><li>We want to reserve the medium for a longer space of time (i.e. at least the length of a single frame) </li></ul>
  119. 119. The MAC sub-layer MAC layer provides medium-access service to the Data-Link layer A separate protocol is needed to implement the service for each different transmission medium
  120. 120. Channel Allocation Problem <ul><li>Channel cannot carry two signals in the same frequency range at the same time </li></ul><ul><li>Two obvious multiplexing-based solutions: </li></ul><ul><ul><li>Frequency multiplexing </li></ul></ul><ul><ul><li>Time multiplexing </li></ul></ul>
  121. 121. Channel Allocation Problem <ul><li>Multiplexing works with constant traffic </li></ul><ul><li>Time-Division fails with heterogeneous traffic </li></ul>
  122. 122. Channel Allocation Problem <ul><li>Multiplexing works with constant traffic </li></ul><ul><li>Time-Division fails with heterogeneous traffic </li></ul>
  123. 123. Channel Allocation Problem <ul><li>Multiplexing works with constant traffic </li></ul><ul><li>Frequency-Division fails with bursty traffic </li></ul>
  124. 124. Channel Allocation Problem <ul><li>Multiplexing works with constant traffic </li></ul><ul><li>Frequency-Division fails with bursty traffic </li></ul>
  125. 125. Channel Allocation Problem <ul><li>With bursty, heterogeneous traffic we must find a dynamic way to allocate a node access to the channel </li></ul><ul><ul><li>When a node has no traffic to send it does not waste bandwidth </li></ul></ul><ul><ul><li>When a node has traffic to send it can obtain all capacity of the channel, not just a slice </li></ul></ul>
  126. 126. ALOHA Protocols <ul><li>Classical shared-medium problem </li></ul><ul><ul><li>Radio towers all in range of central antenna </li></ul></ul><ul><ul><li>Two concurrent senders = collision (both frames are lost entirely) </li></ul></ul>
  127. 127. ALOHA Protocols <ul><li>Two General Problems: </li></ul><ul><ul><li>How to know when a collision has happened? </li></ul></ul><ul><ul><li>How to share the medium in general when collisions cannot be predicted? </li></ul></ul><ul><li>Two General Solutions: </li></ul><ul><ul><li>Resend when a collision happens and hope for the best (Pure ALOHA) </li></ul></ul><ul><ul><li>Synchronise sending to a timer to reduce – but not eradicate - collisions (Slotted ALOHA) </li></ul></ul>
  128. 128. ALOHA – Collision Detection <ul><li>Central station bounces ACK back to sender </li></ul><ul><li>ACKs sent on separate frequency so never collide </li></ul><ul><li>If ACK not received then sender assumes collision </li></ul>
  129. 129. Pure ALOHA <ul><li>On Collision… </li></ul><ul><ul><li>Wait random amount of time and resend </li></ul></ul><ul><ul><li>Randomisation is vital </li></ul></ul>
  130. 130. Pure ALOHA <ul><li>On Collision… </li></ul><ul><ul><li>Wait random amount of time and resend </li></ul></ul><ul><ul><li>Randomisation is vital </li></ul></ul>
  131. 131. Pure ALOHA <ul><li>Weakness: potential for collision is large </li></ul><ul><ul><li>For a frame-period of length F , the frame is vulnerable for a period of 2F </li></ul></ul>
  132. 132. Slotted ALOHA <ul><li>Time divided in to slots of size F </li></ul><ul><ul><li>Frames delayed until beginning of the next slot </li></ul></ul>
  133. 133. Slotted vs. Pure ALOHA <ul><li>Both use randomisation after collision </li></ul><ul><li>Slotted reduces probability of collision </li></ul><ul><ul><li>If frame is ready in middle of period: </li></ul></ul><ul><ul><ul><li>In Pure ALOHA I will begin sending and destroy any currently sending frames </li></ul></ul></ul><ul><ul><ul><li>In Slotted ALOHA I will wait and only destroy other waiting frames </li></ul></ul></ul>
  134. 134. MAC throughput performance <ul><li>Reducing collisions increases throughput </li></ul><ul><ul><li>Throughput S = Number of frames successfully received for a given unit time </li></ul></ul><ul><ul><li>Generally: </li></ul></ul><ul><ul><ul><li>G = offered load (total frames generated) </li></ul></ul></ul><ul><ul><ul><li>P(s) = probability of success for a single frame </li></ul></ul></ul><ul><ul><ul><li>S = G × P(s) </li></ul></ul></ul>
  135. 135. MAC throughput performance <ul><li>We can also increase S by increasing G </li></ul><ul><li>But P(s) is a function of G </li></ul><ul><ul><li>For Pure ALOHA: P(s) = e -2G , S = Ge -2G </li></ul></ul><ul><ul><li>For Slotted ALOHA: P(s) = e -G , S = Ge -G </li></ul></ul>
  136. 136. MAC throughput performance <ul><li>P(s k ) = Probability a frame requires k attempts </li></ul><ul><li>Total frames sent per data frame (average case) </li></ul><ul><li>Same results are significant for error control schemes… </li></ul>
  137. 137. Carrier Sense Protocols (CSMA) <ul><li>Medium can be sensed for traffic </li></ul><ul><ul><li>1-persistent </li></ul></ul><ul><ul><ul><li>channel free: send immediately </li></ul></ul></ul><ul><ul><ul><li>channel busy: send once it is free </li></ul></ul></ul><ul><ul><li>non-persistent </li></ul></ul><ul><ul><ul><li>channel free: send immediately </li></ul></ul></ul><ul><ul><ul><li>channel busy: send after random amount of time </li></ul></ul></ul><ul><ul><li>(slotted) p-persistent CSMA </li></ul></ul><ul><ul><ul><li>channel free: transmit with prob p </li></ul></ul></ul><ul><ul><ul><li>channel busy: repeat algorithm next slot </li></ul></ul></ul>
  138. 138. CSMA Performance
  139. 139. Carrier Sense Protocols (CSMA) <ul><li>CSMA also comes in two flavours </li></ul><ul><ul><li>Collision Detection (/CD) </li></ul></ul><ul><ul><ul><li>Can ascertain if two data frames have collided </li></ul></ul></ul><ul><ul><ul><li>Used in Ethernet 802.3 protocol family </li></ul></ul></ul><ul><ul><li>Collision Avoidance (/CA) </li></ul></ul><ul><ul><ul><li>Channel is reserved using special frames </li></ul></ul></ul><ul><ul><ul><li>Data frames will never collide </li></ul></ul></ul><ul><ul><ul><li>Reservation frames still can </li></ul></ul></ul><ul><ul><ul><li>Used in Wireless LAN 802.11 protocol family </li></ul></ul></ul>
  140. 140. CSMA/CD in Ethernet <ul><li>Copper Wire: Full Broadcast Medium </li></ul><ul><ul><li>Voltage Levels – collision destroys all data </li></ul></ul><ul><ul><li>Key Point: each node can hear all transmissions </li></ul></ul><ul><ul><li>This enables us to: </li></ul></ul><ul><ul><ul><li>Determine whether the medium is free </li></ul></ul></ul><ul><ul><ul><li>Determine whether our transmission collided with someone else’s </li></ul></ul></ul>
  141. 141. CSMA/CD in Ethernet <ul><li>Propagation delay means collision are not detected immediately. </li></ul><ul><li>Can be thought of as a frame ‘bouncing’ off another frame and back to the sender </li></ul>
  142. 142. CSMA/CD in Ethernet <ul><li>Collision Detection can greatly reduce the impact of collisions </li></ul><ul><ul><li>Medium is only jammed for as long as it takes colliding nodes to realise they are colliding… </li></ul></ul>
  143. 143. CSMA/CD in Ethernet <ul><li>Collision Detection can greatly reduce the impact of collisions </li></ul><ul><ul><li>Medium is only jammed for as long as it takes colliding nodes to realise they are colliding… </li></ul></ul>
  144. 144. CSMA/CD in Ethernet <ul><li>Delay makes carrier-sensing imperfect </li></ul><ul><ul><li>If A sends before vulnerable period, B will sense it in time </li></ul></ul><ul><ul><li>If A becomes ready to send after vulnerable period it will sense B’s transmission </li></ul></ul><ul><li>Vulnerable period is twice longest latency </li></ul>
  145. 145. CSMA/CD in Ethernet <ul><li>Also relates to frame-size </li></ul><ul><ul><li>If B cannot hear collision before frame has finished sending it will not be detected </li></ul></ul><ul><li>F size /bps > RTT </li></ul><ul><ul><li>i.e. the sender must still be sending when the collision arrives back </li></ul></ul>
  146. 146. CSMA/CD in Ethernet <ul><li>Physical Limits </li></ul><ul><ul><li>Latency = Distance / Propagation Speed </li></ul></ul><ul><ul><li>Send Time = Frame Size / Data Rate </li></ul></ul><ul><li>Variables </li></ul><ul><ul><li>Each 802.3 flavour has specific Propagation Speed and Data Rate </li></ul></ul><ul><ul><li>Distance and Frame Size are therefore a direct tradeoff </li></ul></ul>
  147. 147. CSMA/CD in Ethernet <ul><li>100baseT (100 Mbps over UTP) </li></ul><ul><ul><li>Max Distance = 200m </li></ul></ul><ul><ul><li>Min Frame Length = 512 bits </li></ul></ul><ul><li>1000baseT (1 Gbps over 4 x UTP) </li></ul><ul><ul><li>Max Distance = 200m </li></ul></ul><ul><ul><li>Min Frame Length = 4096 bits </li></ul></ul><ul><li>etc… </li></ul>
  148. 148. CSMA/CD in Ethernet <ul><li>Broadcast Topologies </li></ul><ul><ul><li>Linear </li></ul></ul><ul><ul><ul><li>single shared coaxial cable </li></ul></ul></ul><ul><ul><ul><li>direct connection (vampire taps or transceivers) </li></ul></ul></ul>
  149. 149. CSMA/CD in Ethernet <ul><li>Broadcast Topologies </li></ul><ul><ul><li>Star </li></ul></ul><ul><ul><ul><li>Multiple Cat5 cables plug in to a hub </li></ul></ul></ul><ul><ul><ul><li>Hub echoes each frame on all ports </li></ul></ul></ul>
  150. 150. CSMA/CA in WiFi <ul><li>Wireless LANs </li></ul><ul><ul><li>2.4Ghz Radio Frequencies </li></ul></ul><ul><ul><li>FDM + QAM encoding </li></ul></ul><ul><li>Hidden station problem </li></ul><ul><ul><li>In Ethernet, all stations receive same signal eventually </li></ul></ul><ul><ul><li>In WLANs each station hears a subset of the broadcasts </li></ul></ul>
  151. 151. CSMA/CA in WiFi <ul><li>Hidden station problem </li></ul><ul><ul><li>Increase power </li></ul></ul><ul><ul><ul><li>Needs more power (!) </li></ul></ul></ul><ul><ul><ul><li>Collision domain grows </li></ul></ul></ul><ul><ul><li>ALOHA approach (Echo complete frame) </li></ul></ul><ul><ul><ul><li>Wasteful – cannot detect collision until 2 x frame send time + RTT </li></ul></ul></ul>
  152. 152. CSMA/CA in WiFi <ul><li>We cannot detect collisions reliably </li></ul><ul><li>Instead we avoid them: </li></ul><ul><ul><li>Dynamic Channel reservation </li></ul></ul><ul><ul><li>RTS = Request to send </li></ul></ul><ul><ul><ul><li>Sent by sender, reserves channel </li></ul></ul></ul><ul><ul><ul><li>id of requesting station (a MAC address) </li></ul></ul></ul><ul><ul><ul><li>length of frame (duration of reservation) </li></ul></ul></ul><ul><ul><li>CTS = Clear to send </li></ul></ul><ul><ul><ul><li>Send by access point – confirms reservation </li></ul></ul></ul>
  153. 153. CSMA/CA in WiFi <ul><li>Sender </li></ul><ul><li>Send RTS(id,len) </li></ul><ul><li>wait for frame… </li></ul><ul><li>if (CTS) </li></ul><ul><li>if CTS.id == id </li></ul><ul><li>send data frame </li></ul><ul><li>else </li></ul><ul><li>wait(CTS.len) </li></ul><ul><li>CSMA algorithm </li></ul><ul><li>if (RTS) </li></ul><ul><li>wait(RTS.len) </li></ul><ul><li>CSMA algorithm </li></ul><ul><li>Receiver </li></ul><ul><li>wait for RTS… </li></ul><ul><li>send CTS(id,len) </li></ul><ul><li>wait(RTS.len) </li></ul>
  154. 154. CSMA/CA in WiFi <ul><li>Only prevents data frames colliding </li></ul><ul><ul><li>RTS can still collide </li></ul></ul><ul><li>Each node creates a virtual jam on the channel </li></ul><ul><ul><li>If a virtual jam is sensed when RTS is ready the carrier-sense algorithm will see this as a broadcast in progress </li></ul></ul><ul><ul><li>Some CSMA algorithm is then applied </li></ul></ul>
  155. 155. CSMA/CA in WiFi <ul><li>Virtual Jamming </li></ul><ul><ul><li>Each node only needs to hear the CTS from the Access Point to do this </li></ul></ul><ul><ul><li>Can use RTS to increase efficiency </li></ul></ul><ul><ul><li>e.g. C will hear RTS from A but D will only hear CTS from B </li></ul></ul>
  156. 156. CSMA/CA in WiFi
  157. 157. CSMA with Adaptive Backoff <ul><li>What is a good value for p ? </li></ul>
  158. 158. CSMA with Adaptive Backoff <ul><li>What is a good value for p ? </li></ul><ul><ul><li>Too high: </li></ul></ul><ul><ul><ul><li>Nodes too eager to send, many collisions </li></ul></ul></ul><ul><ul><li>Too Low: </li></ul></ul><ul><ul><ul><li>Nodes wait too long, poor utilisation </li></ul></ul></ul><ul><ul><li>(note, this is true in /CD and /CA protocols) </li></ul></ul><ul><li>Answer: make p adaptive </li></ul><ul><ul><li>When collisions are high, make p low </li></ul></ul><ul><ul><li>When collisions are low, make p high </li></ul></ul>
  159. 159. CSMA – Adaptive Backoff <ul><li>CSMA with Exponential Backoff </li></ul><ul><ul><li>Random range = [0,2 c -1] (where c = #collisions) </li></ul></ul><ul><ul><li>Slotted time (in Ethernet 1 slot length = RTT) </li></ul></ul><ul><ul><ul><li>t=0s: A and B collide </li></ul></ul></ul><ul><ul><ul><li>A and B choose randomly from 2 1 slots: [0,1] </li></ul></ul></ul><ul><ul><ul><li>A chooses 1, B chooses 1 </li></ul></ul></ul><ul><ul><ul><li>t=2s: A and B collide </li></ul></ul></ul><ul><ul><ul><li>A and B choose randomly from 2 2 slots: [0,3] </li></ul></ul></ul><ul><ul><ul><li>A chooses 2, B chooses 0 </li></ul></ul></ul><ul><ul><ul><li>t=3s: B transmits successfully </li></ul></ul></ul><ul><ul><ul><li>t=5s: A transmits successfully </li></ul></ul></ul>
  160. 160. 802 error rates <ul><li>Error rates are measured in 2 ways </li></ul><ul><ul><li>Packet Error Rate (PER) packets rejected </li></ul></ul><ul><ul><li>Bit Error Rate (BER) bits flipped </li></ul></ul><ul><li>802.3 </li></ul><ul><ul><li>Between 1 in 10 8 and 1 in 10 12 </li></ul></ul><ul><ul><li>Error Detection with 32-bit CRC (PER ∞ BER) </li></ul></ul><ul><li>802.11 </li></ul><ul><ul><li>Between 1 in 10 3 and 1 in 10 6 </li></ul></ul><ul><ul><li>Error Correction (various) </li></ul></ul>
  161. 161. 802 addressing <ul><li>MAC addresses </li></ul><ul><ul><li>48-bits as twelve hexadecimal digits </li></ul></ul><ul><ul><ul><li>(e.g. 00-00-0c-12-34-56) </li></ul></ul></ul><ul><ul><li>First 24-bits are assigned to device vendors </li></ul></ul><ul><ul><li>Second 24-bits are assigned by vendor to an individual device </li></ul></ul>
  162. 162. 802 inter-connections <ul><li>Bridges </li></ul><ul><ul><li>Multiple nodes connect to one port </li></ul></ul><ul><ul><li>Each port is one collision domain </li></ul></ul><ul><ul><li>Frames forwarded if for different domain </li></ul></ul><ul><li>Switches </li></ul><ul><ul><li>One node per port </li></ul></ul><ul><ul><li>Each frame sent to single destination port </li></ul></ul><ul><ul><li>No Medium-Access Control needed! </li></ul></ul>
  163. 163. 802 inter-connections <ul><li>Bridges </li></ul>
  164. 164. 802 inter-connections <ul><li>Switches </li></ul>
  165. 165. MAC Layer Summary <ul><li>Data Link Layer split in to two layers: </li></ul><ul><ul><li>LLC: addressing and flow control (802.2) </li></ul></ul><ul><ul><li>MAC: error and medium-access control (802.3/11/16) </li></ul></ul><ul><li>ALOHA protocols </li></ul><ul><ul><li>Randomisation of re-send time (slotted/pure) </li></ul></ul><ul><li>CSMA protocols (with persistence level) </li></ul><ul><ul><li>Collision Detection (Ethernet) </li></ul></ul><ul><ul><li>Collision Avoidance (WLAN) </li></ul></ul><ul><ul><li>Both use Exponential Back-off </li></ul></ul><ul><li>MAC collision domains </li></ul><ul><ul><li>Can be separated by Bridges </li></ul></ul><ul><ul><li>Can be eradicated by Switches </li></ul></ul>
  166. 166. Data Link Layer Summary <ul><li>Error Control </li></ul><ul><ul><li>Detection/Correction </li></ul></ul><ul><ul><li>Framing </li></ul></ul><ul><li>Flow Control </li></ul><ul><ul><li>Correctness (deadlock, duplication) </li></ul></ul><ul><ul><li>Efficiency (channel utilisation, sliding windows) </li></ul></ul><ul><li>Medium Access </li></ul><ul><ul><li>Carrier Sense/Non-Sensed </li></ul></ul><ul><ul><li>Collision Detection/Avoidance </li></ul></ul>

×