Download presentation
Presentation is loading. Please wait.
Published byRolf West Modified over 9 years ago
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 SW1 SW2 SW3 Goal: send two packets from SW1 to SW3 Assumptions: No Packet Loss Algorithm: At-Most-Once
5
At Most Once SW1 SW2 SW3
6
Sliding Window SW1 SW2 SW3 Goal: send two packets from SW1 to SW3 Assumptions: No Packet Loss Algorithm: Sliding Window Bandwidth-Delay Product: 4 packet SWS=4 RWS=4 1 2 3 4 5 6 SWS LFS LAR
7
Sliding Window SW1 SW2 SW3 Goal: send two packets from SW1 to SW3 Assumptions: No Packet Loss Algorithm: Sliding Window Bandwidth-Delay Product: 4 packet SWS=4 RWS=4 1 2 3 4 5 6 7 8 SWS LFS LAR
8
Sliding Window SW1 SW2 SW3
9
At Most OnceSliding Window
10
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
11
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
12
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
13
Errors Abound 1 0 SW1 SW2
14
Errors Abound Can we detect the error? 1 1 SW1 SW2
15
Simplest Schemes: Repeat Frame N times (FEC) 1 0 1 0 1 0 SW1 SW2
16
Can we detect the error? Can we correct errors? What is the problem? Simplest Schemes: Repeat Frame N times (FEC) 1 1 1 0 1 0 SW1 SW2
17
Add a parity bit to the end of a word Simplest Schemes: Parity Bit 1 0 1 SW1 SW2
18
Add a parity bit to the end of a word Can we detect the error? Can we correct the error? Simplest Schemes: Parity Bit 1 Error 0 0 1 SW1 SW2 Parity 110 101 011 000
19
Add a parity bit to the end of a word Can we detect error when there are two errors? Simplest Schemes: Parity Bit 2 Errors 0 1 1 SW1 SW2 Parity 110 101 011 000
20
Add a parity bit to the end of a word Can we detect error when there are two errors? Simplest Schemes: Parity Bit 2 Errors 0 1 1 SW1 SW2 Parity 110 101 011 000 If using this parity, you can only detect an ‘odd’ number of errors!!!!
21
XoR encoding 1 1 1 0 1 0 SW1 SW2
22
XoR encoding 1 1 1 0 1 0 SW1 SW2 1 0 1 1 1 1 0 1 0 1 0 1 XOR
23
XoR encoding 1 1 1 0 1 0 SW1 SW2 0 0 1 Error in correcting code no one cares What happens when there’s an error… – In the Correcting Code
24
XoR encoding What happens when there’s an error… – In the Correcting Code – How about in the data? 1 0 0 0 1 0 SW1 SW2 1 0 1 Error in Data!!! Code RED!!!
25
What happens when there’s an error… – In the Correcting Code – How about in the data? How do we correct this? XoR encoding 1 0 0 0 1 0 SW1 SW2 1 0 1 1 1 1 0 1 0 1 0 1 XOR
26
In general Hamming distance: number of bits that are different – E.g.: HD (00001010, 01000110) = 3 If min HD between valid codewords is d: – Can detect d-1 bit error – Can correct ⌊ (d-1)/2 ⌋ bit errors What is d for parity and 3-voting?
27
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
28
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); }
29
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))
30
How good is it? 16 bits not very long: misses how many errors? – 1 in 2 16, 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
31
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.”
32
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) = x 7 + x 5 + x 3 + 1 – E.g., 11111111-> m(x) = x 8 +x 7 +x 6 + x 5 +x 4 +x 3 +x 2 +x 1 + 1
33
CRC Checking CRC is easy – Reduce message by C(x), make sure remainder is 0
34
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)x k (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 C(x)N(x) K-bit CRC Add k 0’s Original Msg M(x) n(x)
35
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 x k, x 0 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
36
Common CRC Polynomials Polynomials not trivial to find – Some studies used (almost) exhaustive search CRC-8: x 8 + x 2 + x 1 + 1 CRC-16: x 16 + x 15 + x 2 + 1 CRC-32: x 32 + x 26 + x 23 + x 22 + x 16 + x 12 + x 11 + x 10 + x 8 + x 7 + x 5 + x 4 + x 2 + x 1 + 1 CRC easily computable in hardware
37
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)x k (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
38
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
39
Trade-Off: Efficiency Versus Reliability No Codes FEC Parity 2d-Parity XOR IP-Checkum
40
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
41
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
42
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
43
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):
44
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/ou i.txt http://standards.ieee.org/develop/regauth/oui/ou i.txt Broadcast address: all 1s Multicast address: first bit 1 Adapter can work in promiscuous mode
45
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
46
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?)
47
Collision Detection Without minimum frame length, might not detect collision
48
Collision Detection Meyou Check to see If any one is tx Check to see If any one is tx Detects collision Doesn’t detect collisions
49
Collision Detection Meyou Check to see If any one is tx Check to see If any one is tx Detects collision detect collisions
50
When to transmit again? Delay and try again: exponential backoff nth time: k × 51.2μs, for k = U{0..2 min(n,10) -1} – 1 st time: 0 or 51.2μs – 2 nd time: 0, 51.2, 102.4, or 153.6μs Give up after several times (usually 16)
51
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 …
52
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
53
Token rings A token circulates the ring If a node has something to send, take the token off the ring, and send the frame – Node 1 Each node along the way simply forwards the frame Receiver copies the frame – Node 4 Frame comes back to sender – Sender removes the packet and puts the token back
54
Token ring standard IBM Token Ring A nearly identical IEEE standard – 802.5: not widely used Fiber Distributed Data Interface (FDDI) – Derived from the IEEE 802.4 Resilient Packet Ring (RPR) – 802.17
55
Challenges must be addressed Fault tolerance – Robust to node failure Media access control – How long each node can hold the token? Reliability – How does the sender know the frame is received Resource utilization
56
Adding fault tolerance Problem: single node powers off disconnects the ring Solution: relay that closes when host’s powered off an electromechanical relay
57
Token ring media access control An adaptor has a receiver and a transmitter Problem: how long can a node holds a token? – Token holding time (THT), default 10ms in 802.5 – Short: waste bandwidth – Long: starve others – What if you have an important short message?
58
802.5 Token Access Protocol A token has a 3-bit priority field A frame has three reservation bits – A device seizes the token if its packet’s priority is at least as great as the token’s – Reservation A sender X sets priority n in the three reservation bits in a data frame going past if – The bits are not set to a higher value The station that holds the token set priority to n when it releases it – Sender X lowers the token priority after releasing it so other senders can send – Drawback: may starve lower priority traffic
59
Token ring reliability No sliding window! Two trailing bits (A, C) after each frame – A recipient sets A bit when it sees the frame – Sets C bit after it copies the frame back to its adaptor – If a sender does not see both bits set, retransmits A=0, C=0: the intended recipient is not functioning or absent A=1, C=0: for some reason (e.g., lack of buffer space), the destination could not accept the frame A=1, C=1: frame received
60
When to release a token Which one is better? – 802.5 originally used (b), and adds (a) later Early release: Sender inserts the token back onto the ring immediately following its frame Late release: Sender inserts the token after the frame it transmits has gone all the way around the ring and been removed Better bandwidth utilization
61
802.5 Token ring maintenance A monitor makes sure the token is not lost – Periodically announces itself If the monitor fails – A station elects itself by sending a claim token – If the token comes back, it’s the monitor – If competition, highest address wins
62
Monitor’s job If it does not see a token for a long time, it creates a new one – the maximum possible token rotation time: # of stations * token holding time + ringLatency Detect and remove orphaned frames (whose “parent” died) – Monitor sets a head bit to 1 after seeing a frame – If it sees the bit already set, remove the packet
63
802.5 Frame format Similar to the Ethernet, 802.5 addresses are 48 bits long. The frame also includes a 32-bit CRC. Frame status byte includes the A and C bits for reliable delivery
64
Wireless links Most common Asymmetric: base station and client node Point-to-multipoint Radio waves can be received simultaneously by many devices
65
Wireless access control Can’t use Ethernet protocol – A node on an Ethernet receives every other node’s transmissions – A node on an 802.11 network may be too far from certain other nodes to receive their transmissions (and vice versa) – Problems: hiddlen terminal & exposed terminal
66
Wireless access control – Hidden terminal A and C can’t hear each other’s collision at B – Exposed terminal B can send to A; C can send to D C’s transmission to D will not interfere with A’s ability to receive from B
67
802.11 (WiFi) Multiple access with collision avoidance Sender and receiver exchange control frames – Sender receiver: Request to send (RTS) Specifies the length of frame – Receiver sender: Clear to send (CTS) Echoes length of frame – Sender receiver: frame – Receiver sender: ack – Other nodes can send after hearing ACK Node sees CTS – Too close to receiver, can’t transmit – Addressing hidden terminals Node only sees RTS – Okay to transmit – Addressing exposed terminals
68
MACA – Multiple Access Collision Avoidance Use of additional control frames – Sender asks receiver whether it is able to receive a transmission - Request to Send (RTS) – Receiver agrees, sends out a Clear to Send (CTS) – Sender sends, receiver Acknowledgements (ACKs) A B C RTS CTSACK DATA time B C A 1 2 3 4 Detect Collision Find Transmission Complete
69
Exposed Terminal MACA – continued When a node hears an RTS from a neighboring node, but not the corresponding CTS, that node can deduce that it is an exposed terminal and is permitted to transmit to other neighboring nodes. AD B C RTS CTS DATA C A time B D RTS CTS t1t1 t2t2 t3t3 t4t4 t5t5 t6t6 DATA 1 2 3 4 5 6
70
How to resolve collision Two or more nodes detect an idle link and try to transmit an RTS frame at the same time.. Sender can’t do collision detection – Single antenna can’t send and receive at the same time If no CTS after a period of time, then RTS collide Exponential backoff to retransmit
71
Distribution system Hosts associate with APs – Each AP serves the nodes in some region APs connect via the distribution system – A layer-2 system Ethernet, token ring, etc. – Host IP addresses do not need to change
72
AP association Selecting an AP: Active scanning – Node: a Probe frame – APs: Probe response – Node selects one of APs, send Association request – AP replies Association Response Passive scanning – AP sends Beacon to announce itself – Node sends Association Request
73
802.11 Frame format Same AP – Addr1: dst – Addr2: src Different APs – ToDS and FromDS in control field set – Add1: dst, Addr2: AP_dst – Addr3: AP_src, Add4: src
74
Summary Error Detection and Correction – FEC – Simple-XOR-FEC (Parity Bit) – XOR-error-correcting codes – IP-Checksum Multiple access links – Ethernet – 802.11 (WiFi) – Note: understand the concepts
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.