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

More Related Content

PPT
Chapter 4 data link layer
Naiyan Noor
 
PDF
2.6 ethernet ieee 802.3
JAIGANESH SEKAR
 
PPTX
Error Detection & Error Correction Codes
ShahDhruv21
 
PPTX
Chapter 10
bheemsain
 
PPT
Error detection and correction
Maria Akther
 
PPTX
Data link layer
Mukesh Chinta
 
PPTX
Application Layer
Dr Shashikant Athawale
 
PPTX
Point to-point protocol (ppp)
Kongu Engineering College, Perundurai, Erode
 
Chapter 4 data link layer
Naiyan Noor
 
2.6 ethernet ieee 802.3
JAIGANESH SEKAR
 
Error Detection & Error Correction Codes
ShahDhruv21
 
Chapter 10
bheemsain
 
Error detection and correction
Maria Akther
 
Data link layer
Mukesh Chinta
 
Application Layer
Dr Shashikant Athawale
 
Point to-point protocol (ppp)
Kongu Engineering College, Perundurai, Erode
 

What's hot (20)

PPT
Framming data link layer
PREMAL GAJJAR
 
PPTX
HDLC(High level Data Link Control)
sonangrai
 
PPTX
Wired LANs
Meenakshi Paul
 
PPTX
Transmission Control Protocol (TCP)
k33a
 
PPSX
Error control
selvakumar_b1985
 
PPTX
Computer Network - Network Layer
Manoj Kumar
 
PPTX
Quality of Service
Abhishek Wadhwa
 
PPTX
HDLC and Point to point protocol
Kinza Razzaq
 
PPT
Data Link Layer| Error Detection
Taimoor Muzaffar Gondal
 
PPTX
Network Layer
Dr Shashikant Athawale
 
PPTX
Transport layer
reshmadayma
 
PPT
Icmp
swarna sudha
 
PPTX
Carrier-sense multiple access with collision avoidance CSMA/CA
Soumen Santra
 
PPTX
The medium access sublayer
Lal Bahadur Gehlot
 
PPT
Error detection correction (CRC)
Karam Munir Butt
 
PPTX
Token Ring : 802.5
Pnkj_Sharma
 
PDF
Spanning tree protocol (stp)
RaghulR21
 
PPT
Network layer tanenbaum
Mahesh Kumar Chelimilla
 
PPTX
Frame relay
Ayesha Maqsood
 
PPTX
Multiple access protocol
Merlin Florrence
 
Framming data link layer
PREMAL GAJJAR
 
HDLC(High level Data Link Control)
sonangrai
 
Wired LANs
Meenakshi Paul
 
Transmission Control Protocol (TCP)
k33a
 
Error control
selvakumar_b1985
 
Computer Network - Network Layer
Manoj Kumar
 
Quality of Service
Abhishek Wadhwa
 
HDLC and Point to point protocol
Kinza Razzaq
 
Data Link Layer| Error Detection
Taimoor Muzaffar Gondal
 
Network Layer
Dr Shashikant Athawale
 
Transport layer
reshmadayma
 
Carrier-sense multiple access with collision avoidance CSMA/CA
Soumen Santra
 
The medium access sublayer
Lal Bahadur Gehlot
 
Error detection correction (CRC)
Karam Munir Butt
 
Token Ring : 802.5
Pnkj_Sharma
 
Spanning tree protocol (stp)
RaghulR21
 
Network layer tanenbaum
Mahesh Kumar Chelimilla
 
Frame relay
Ayesha Maqsood
 
Multiple access protocol
Merlin Florrence
 
Ad

Similar to The Data Link Layer (20)

PPTX
Lecture7.pptxhfjgjgjghcgzgzfzfzvzgxhchchc
rani marri
 
DOCX
Calculating the hamming code
Umesh Gupta
 
DOCX
Calculating the hamming code (tutorial)
kiriinyaKev
 
PPT
Ch10 2 v1
Nitesh Singh
 
PPTX
5.Error correction-Hamming Code.pptx
AswathiThotz
 
PPT
this is computer network power presentation
adarshpandey9910
 
PPT
Introduction Data communication and Networking Forouzan
RambabuReddy
 
PPT
3288940.ppt
KhalilThePianist
 
PPTX
docker docker docker docker docker docker docker docker docker docker docker ...
Goran546834
 
PPT
Ch10 2 v1
Vivek Kumar
 
PPT
Ch10 2 v1
bhagavanprasad
 
PPT
Cn lec-06
M Mudassar Khan
 
PPTX
Error Detection and Correction presentation
Badrul Alam
 
PPT
ch10_2_v1.ppt
dlakmlkfma
 
PPT
Ch10 2 v1
Dr. Kavita Sharma
 
PPT
ch10_2_v1.ppt
dlakmlkfma
 
PPT
5(1)crc-chechsum-hamming.ppt
prashant513130
 
PPT
ch10_2_v1.ppt
dlakmlkfma
 
PPT
hamming code detailed
IKhait
 
PPT
ch10_2_v1.ppt
DrDeepakBhatia
 
Lecture7.pptxhfjgjgjghcgzgzfzfzvzgxhchchc
rani marri
 
Calculating the hamming code
Umesh Gupta
 
Calculating the hamming code (tutorial)
kiriinyaKev
 
Ch10 2 v1
Nitesh Singh
 
5.Error correction-Hamming Code.pptx
AswathiThotz
 
this is computer network power presentation
adarshpandey9910
 
Introduction Data communication and Networking Forouzan
RambabuReddy
 
3288940.ppt
KhalilThePianist
 
docker docker docker docker docker docker docker docker docker docker docker ...
Goran546834
 
Ch10 2 v1
Vivek Kumar
 
Ch10 2 v1
bhagavanprasad
 
Cn lec-06
M Mudassar Khan
 
Error Detection and Correction presentation
Badrul Alam
 
ch10_2_v1.ppt
dlakmlkfma
 
ch10_2_v1.ppt
dlakmlkfma
 
5(1)crc-chechsum-hamming.ppt
prashant513130
 
ch10_2_v1.ppt
dlakmlkfma
 
hamming code detailed
IKhait
 
ch10_2_v1.ppt
DrDeepakBhatia
 
Ad

Recently uploaded (20)

PDF
Landforms and landscapes data surprise preview
jpinnuck
 
PPTX
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
PPTX
How to Manage Global Discount in Odoo 18 POS
Celine George
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
Marta Fijak
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
Understanding operators in c language.pptx
auteharshil95
 
PDF
5.Universal-Franchise-and-Indias-Electoral-System.pdfppt/pdf/8th class social...
Sandeep Swamy
 
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
mansk2
 
PPTX
Introduction and Scope of Bichemistry.pptx
shantiyogi
 
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
TumwineRobert
 
PPTX
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
PPTX
Presentation on Janskhiya sthirata kosh.
Ms Usha Vadhel
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
Landforms and landscapes data surprise preview
jpinnuck
 
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
How to Manage Global Discount in Odoo 18 POS
Celine George
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
The Final Stretch: How to Release a Game and Not Die in the Process.
Marta Fijak
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Understanding operators in c language.pptx
auteharshil95
 
5.Universal-Franchise-and-Indias-Electoral-System.pdfppt/pdf/8th class social...
Sandeep Swamy
 
Week 4 Term 3 Study Techniques revisited.pptx
mansk2
 
Introduction and Scope of Bichemistry.pptx
shantiyogi
 
Cardiovascular Pharmacology for pharmacy students.pptx
TumwineRobert
 
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
Presentation on Janskhiya sthirata kosh.
Ms Usha Vadhel
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 

The Data Link Layer

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