Download
cps 365 n.
Skip this Video
Loading SlideShow in 5 Seconds..
CPS 365 PowerPoint Presentation

CPS 365

386 Vues Download Presentation
Télécharger la présentation

CPS 365

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. CPS 365 Theophilus Benson

  2. Today’s Lecture • Recap last class • Error detection code • Parity • Check-Sum • Error-Correcting-Codes • Error correcting code • Sophisticated code that can correct errors • Multiple Access Link • Ethernet • Token ring • Note: understand the concepts

  3. Last Class • Approaches to Framing • Latency Breakdown • Reliable Delivery • Stop and Wait V. At-Most-Once • Ensuring high throughput • Sliding Window • Seq # V SWS

  4. At Most Once Goal: send two packets from SW1 to SW3 Assumptions: No Packet Loss Algorithm: At-Most-Once SW1 SW2 SW3

  5. At Most Once SW1 SW3 SW2

  6. Sliding Window Goal: send two packets from SW1 to SW3 Assumptions: No Packet Loss Algorithm: Sliding Window Bandwidth-Delay Product: 4 packet SWS=4 RWS=4 LAR LFS SWS 1 3 2 5 6 4 SW1 SW2 SW3

  7. Sliding Window SW1 SW3 SW2

  8. At Most Once Sliding Window

  9. Today’s Lecture • Recap last class • Error detection code • Parity • Check-Sum • Error-Correcting-Codes • Error correcting code • Sophisticated code that can correct errors • Multiple Access Link • Ethernet • Token ring • 802.11 (WiFi) • Note: understand the concepts

  10. Why Should You Care About Errors? • Still happens in: • Wireless networks • Cellular networks • Error detection + Correction is fundamental • Used to in Storage/Operating Systems • Crucial in data centers • Facebook uses advanced forms to protect data

  11. Error Detection • Must add bits to catch errors in packet • Sometimes can also correct errors • If enough redundancy • Might have to retransmit • Used in multiple layers • Three examples today: • Parity • Internet Checksum • CRC

  12. Errors Abound 1 0 SW1 SW2

  13. Errors Abound • Can we detect the error? 1 1 SW1 SW2

  14. Simplest Schemes: Repeat Frame N times (FEC) 1 1 0 0 1 0 SW1 SW2

  15. Simplest Schemes:Repeat Frame N times (FEC) • Can we detect the error? • Can we correct errors? • What is the problem? 1 1 0 1 1 0 SW1 SW2

  16. Simplest Schemes: Parity Bit • Add a parity bit to the end of a word 1 1 0 SW1 SW2

  17. Simplest Schemes: Parity Bit1 Error • Add a parity bit to the end of a word • Can we detect the error? • Can we correct the error? 0 1 0 SW1 SW2

  18. Simplest Schemes: Parity Bit2 Errors • Add a parity bit to the end of a word • Can we detect error when there are two errors? 0 1 1 SW1 SW2

  19. Simplest Schemes: Parity Bit2 Errors • Add a parity bit to the end of a word • Can we detect error when there are two errors? If using this parity, you can only detect an ‘odd’ number of errors!!!! 0 1 1 SW1 SW2

  20. XoR encoding 1 1 0 1 1 0 SW1 SW2

  21. XoR encoding 0 1 1 1 1 1 1 0 0 XOR 0 1 1 1 0 1 1 1 0 SW1 SW2

  22. XoR encoding • What happens when there’s an error… • In the Correcting Code Error in correcting code no one cares 0 1 1 1 0 1 1 0 0 SW1 SW2

  23. XoR encoding • What happens when there’s an error… • In the Correcting Code • How about in the data? Error in Data!!! Code RED!!! 0 1 1 1 0 0 0 1 0 SW1 SW2

  24. XoR encoding • What happens when there’s an error… • In the Correcting Code • How about in the data? • How do we correct this? 1 1 1 0 1 1 1 0 0 XOR 0 1 1 1 0 0 0 1 0 SW1 SW2

  25. 2-D Parity • Add 1 parity bit for each 7 bits • Add 1 parity bit for each bit position across the frame) • Can correct single-bit errors • Can detect 2- and 3-bit errors, most 4-bit errors • Find a 4-bit error that can’t be corrected

  26. Internet checksum algorithm:IP Checksum • Fixed-length code • n-bit code should capture all but 2-n fraction of errors • Why? • Trick is to make sure that includes all common errors • IP Checksum is an example: 16-bits • 1’s complement of 1’s complement sum of every 2 bytes uint16 cksum(uint16 *buf, int count) { uint32 sum = 0; while (count--) if ((sum += *buf++) & 0xffff0000) // carry sum = (sum & 0xffff) + 1; return ~(sum & 0xffff); }

  27. 1’s complement • -x is each bit of x inverted • If there is a carry bit, add 1 to the sum • Example: 4-bit integer • -3: 1100 (invert of 0011) • -4: 1011 (invert of 0100) • -3 + -4 = 0111 + 1 = 1000 (invert of 0111 (-7))

  28. How good is it? • 16 bits not very long: misses how many errors? • 1 in 216, or 1 in 64K errors • Checksum detects all 1-bit errors • But not all 2-bit errors • E.g., increment word ending in 0, decrement one ending in 1 • Checksum also optional in UDP • All 0s means no checksums calculated • If checksum word gets wiped to 0 as part of error, bad news

  29. From rfc791 (IP) “This is a simple to compute checksum and experimental evidence indicates it is adequate, but it is provisional and may be replaced by a CRC procedure, depending on further experience.”

  30. Cyclic Redundancy Check A branch of finite fields Goal: maximize protection, minimize bits High-level idea: Represent an n+1-bit message with an n degree polynomial M(x) • Each bit is one coefficient • E.g., message 10101001 -> m(x) = x7 + x5+ x3 + 1 • E.g., 11111111-> m(x) = x8+x7 +x6+ x5+x4 +x3+x2+x1 + 1

  31. CRC • Checking CRC is easy • Reduce message by C(x), make sure remainder is 0

  32. An example 8-bit msg: 10011010 Divisor (3bit CRC):101 Calculating Checksum Select a divisor polynomial C(x), degree k Let n(x) = m(x)xk (add k 0’s to m) Compute r(x) = n(x) mod C(x) New P(x) = n(x) – r(x) Checking the Checksum P(x) mod C(x) = 0 Original Msg M(x) Add k 0’s C(x) N(x) n(x) K-bit CRC

  33. Why is this good? • Suppose you send m(x), recipient gets m’(x) • E(x) = m’(x) – m(x) (all the incorrect bits) • If CRC passes, C(x) divides m’(x) • Therefore, C(x) must divide E(x) • Choose C(x) that doesn’t divide any common errors! • All single-bit errors caught if xk, x0 coefficients in C(x) are 1 • All 2-bit errors caught if at least 3 terms in C(x) • Any odd number of errors if last two terms (x + 1) • Any error burst less than length k caught

  34. Common CRC Polynomials • Polynomials not trivial to find • Some studies used (almost) exhaustive search • CRC-8: x8 + x2 + x1 + 1 • CRC-16: x16 + x15 + x2+ 1 • CRC-32: x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x1 + 1 • CRC easily computable in hardware

  35. Why is this good? Easy to Implement in Hardware All routers must implement this Calculating Checksum Select a divisor polynomial C(x), degree k Let n(x) = m(x)xk (add k 0’s to m) K-bit shift registers Compute r(x) = n(x) mod C(x) Mod is XOR New m(x) = n(x) – r(x) Subtraction is also XOR

  36. An alternative for reliability • Erasure coding • Assume you can detect errors • Code is designed to tolerate entire missing frames • Collisions, noise, drops because of bit errors • Forward error correction • Examples: Reed-Solomon codes, LT Codes, Raptor Codes • Property: • From K source frames, produce B > K encoded frames • Receiver can reconstruct source with any K’ frames, with K’ slightly larger than K • Some codes can make B as large as needed, on the fly

  37. Trade-Off: Efficiency Versus Reliability No Codes IP-Checkum Parity 2d-Parity XOR FEC

  38. Today’s Lecture • Recap last class • Error detection code • Parity • Check-Sum • Error-Correcting-Codes • Error correcting code • Sophisticated code that can correct errors • Multiple Access Link • Ethernet • Token ring • 802.11 (WiFi) • Note: understand the concepts

  39. Media Access Control • Control access to shared physical medium • E.g., who can talk when? • If everyone talks at once, no one hears anything • Job of the Link Layer • Two conflicting goals • Maximize utilization when one node sending • Approach 1/N allocation when N nodes sending

  40. Different Approaches • Partitioned Access • Time Division Multiple Access (TDMA) • Frequency Division Multiple Access (FDMA) • Code Division Multiple Access (CDMA) • Random Access • ALOHA/ Slotted ALOHA • Carrier Sense Multiple Access / Collision Detection (CSMA/CD) • Carrier Sense Multiple Access / Collision Avoidance (CSMA/CA) • RTS/CTS (Request to Send/Clear to Send) • Token-based

  41. Case Study: Ethernet (802.3) • Dominant wired LAN technology • 10BASE2,10BASE5 (Vampire Taps) • 10BASET, 100BASE-TX, 1000BASE-T, 10GBASE-T,… • Both Physical and Link Layer specification • CSMA/CD • Carrier Sense / Multiple Access / Collision Detection • Frame Format (Manchester Encoding):

  42. Ethernet Addressing • Globally unique, 48-bit unicast address per adapter • Example: 00:1c:43:00:3d:09 (Samsung adapter) • 24 msb: organization • http://standards.ieee.org/develop/regauth/oui/oui.txt • Broadcast address: all 1s • Multicast address: first bit 1 • Adapter can work in promiscuous mode

  43. Ethernet MAC: CSMA/CD • Problem: shared medium • 10Mbps: 2500m, with 4 repeaters at 500m • Transmit algorithm • If line is idle, transmit immediately • Upper bound message size of 1500 bytes • Must wait 9.6μs (96-bit time) between back to back frames • (Old limit) To give time to switch from tx to rx mode • If line is busy: wait until idle and transmit immediately

  44. Handling Collisions • Collision detection (10Base2 Ethernet) • Uses Manchester encoding. Why does that help? • Constant average voltage unless multiple transmitters • If collision • Jam for 32 bits, then stop transmitting frame • Collision detection constrains protocol • Imposes min. packet size (64 bytes or 512 bits) • Imposes maximum network diameter (2500m) • Must ensure transmission time ≥ 2x propagation delay (why?)

  45. Collision Detection Me you Check to see If any one is tx Check to see If any one is tx Detects collision Doesn’t detect collisions

  46. Collision Detection Me you Check to see If any one is tx Check to see If any one is tx Detects collision detect collisions

  47. When to transmit again? • Delay and try again: exponential backoff • nth time: k × 51.2μs, for k = U{0..2min(n,10)-1} • 1st time: 0 or 51.2μs • 2nd time: 0, 51.2, 102.4, or 153.6μs • Give up after several times (usually 16)

  48. Capture Effect • Exponential backoff leads to self-adaptive use of channel • A and B are trying to transmit, and collide • Both will back off either 0 or 51.2μs • Say A wins. • Next time, collide again. • A will wait between 0 or 1 slots • B will wait between 0, 1, 2, or 3 slots • …

  49. Ethernet experience 30% utilization is heavy Most Ethernets are not light loaded Very successful Easy to maintain Price: does not require a switch which used to be expensive

  50. Wireless links Most common Asymmetric: base station and client node Point-to-multipoint Radio waves can be received simultaneously by many devices