• Like
  • Save
The Data Link Layer
Upcoming SlideShare
Loading in...5
×
 

The Data Link Layer

on

  • 7,526 views

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

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

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

Statistics

Views

Total Views
7,526
Views on SlideShare
7,378
Embed Views
148

Actions

Likes
5
Downloads
380
Comments
0

3 Embeds 148

http://www.ustudy.in 113
http://www.slideshare.net 27
http://ustudy.in 8

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    The Data Link Layer The Data Link Layer Presentation Transcript

    • 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