Docsity

Data Link Layer: Services and Error Control in Computer Networks - Prof. Errin Fulp, Study notes of Computer Science

Toggle sidebar
bg1
Data Link Layer, Part 1
CSC 343·643
WAKE FO R E S T
UNIVERSITY
Department of Computer Science
Fall 2008
Internet Protocols CSC 343·643 Data Link Layer, Part 1 1
Data Link Layer
Provide reliable and efficient communications between to adjacent
machines (physically connected via a channel)
•Providing well-defined service interface to the network layer
•Design issues
–Determining how bits are grouped into frames
–Error detection (possibly correction)
–Line discipline
–Flow control (between adjacent machines)
Were any of these items provided by the physical layer?
E. W. Fulp Fall 2008
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Data Link Layer: Services and Error Control in Computer Networks - Prof. Errin Fulp and more Study notes Computer Science in PDF only on Docsity!

Data Link Layer, Part 1

CSC 343· 643 WAKE FORESTU N I V E R S I T Y Department of Computer Science Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 1

Data Link Layer

Provide reliable and efficient communications between to adjacent machines (physically connected via a channel)

  • Providing well-defined service interface to the network layer
  • Design issues
    • Determining how bits are grouped into frames
    • Error detection (possibly correction)
    • Line discipline
    • Flow control (between adjacent machines) Were any of these items provided by the physical layer?

Services Provided to the Network Layer

Three possible services provided

  1. Unacknowledged connectionless service
    • Source sends independent frames to destination
    • Destination machine does not acknowledge receipt
    • No connection is established or released
    • If frame lost, then no attempt to recover/retransmit What types of traffic can benefit from this service?
  2. Acknowledged connectionless service
    • No connection is used
    • Each frame is acknowledged by destination Is there a need for acknowledgements at this layer?

E. W. Fulp Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 3

  • Acknowledgements (ACKs) are not a requirement...
    • ACKs can be handled in higher layers (network and/or transport) Any disadvantage to higher layer ACKs
  1. Acknowledged connection-oriented service
  • Source and destination establish a connection
  • Each frame is numbered
  • Service guarantees each frame received
  • Each frame is received only once and in the right order
  • Reliable bit stream

Start/End Character Framing

Use special characters to delineate frame

  • Each frame starts with the ASCII sequence DLE (Data Link Escape) STX (Start of TeXt)
  • Each frame ends with the sequence DLE ETX (End of TeXt)

DLE STX P L U F L I V E S DLE ETX

  • If the destination losses track of boundary, it just needs to look for the next boundary What is a possible problem with the starting/ending sequences?

E. W. Fulp Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 7

  • It is possible that the start/stop sequence may appear in the actual data stream (consider binary data)
  • One solution is character stuffing
    • Insert an extra DLE before any accidental DLE
    • Receiver must remove the additional DLE

Original data A DLE B Stuffed framed data DLE STX A DLE DLE B DLE ETX

  • Disadvantage - Closely tied to 8 bit characters

Start/End Flag Framing

Use flag byte to delineate frame

  • Each frame begins/ends with 01111110
  • Bit stuffing is required
    • When the sender sees five consecutive 1’s, it inserts (stuffs) a 0
    • Receiver must remove stuffed bit
    • Similar to character stuffing

Original 011011111111111111110010 Stuffed framed 0111111001101111101111101111101001001111110

What does 0111110 look like stuffed?

E. W. Fulp Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 9

Physical Layer and Redundant Framing

Digital encoding that provide synchronization can be used for framing What are examples of such encoding methods?

  • If a 0 is represented by a low-to-high state and 1 by a high-to-low
    • Then high-to-high and low-to-low is not used
    • Use these non-transitions as boundaries
    • Part of the 802 LAN standards Most data link protocols employ redundant framing
  • Use character counts and frame flags
  • Then receiver knows the correct location of the end flag

Vertical Redundancy Check (VRC)

Also called a parity check

  • An extra bit (parity-bit) added to the end of a message
  • The extra bit is added to cause the number of 1 bits to be even (or odd) Data Even Parity Odd Parity 10110101 101101011 101101010
  • Performance
    • Can detect single-bit errors
    • Can detect burst-errors, with odd lengths Data Even Parity Error Frame 10110101 101101011 100111011

E. W. Fulp Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 13

Hamming Distance

  • Assume a message has m bits and r redundant (check) bits
    • The total length is n = m + r
    • The n bit sequence of bits is the codeword
    • On the previous slide m = 7, r = 1, and n = 8 bits
  • Given any two valid codewords, determine how bits differ
    • XOR the codewords and count the number of 1 ’s
    • The minimum number is called the Hamming distance
    • If two codewords have a distance of d, then it will require d errors to convert one into the other ⇒ undetected error What is the Hamming distance of VRC?

Longitudinal Redundancy Check (LRC)

  • Message is arranged as a table (instead of a single row)
  • Assume we are sending a 32 bit message 11100111 11011101 00111001 10101001
  • Organize as a table with 4 rows and 8 columns 11100111 11011101 00111001 10101001 LRC → 10101010
  • LRC (column parity bits) is calculated based on the columns, then added to the end of the message 11100111 11011101 00111001 10101001 10101010

E. W. Fulp Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 15

LRC Performance

  • Suppose the following message is sent 10101001 00111001 11011101 11100111 10101010
  • Suppose it is received in error as follows 10100011 10001001 11011101 11100111 10101010
  • LRC detects the error 10100011 10001001 11011101 11100111 10101010
  • Can handle burst-errors What error pattern can cause a problem?

/* Compute Internet checksum for count bytes, beginning at

  • location addr */ unsigned short checksum(unsigned short *addr, int count) { register long sum = 0; while(count > 1) { sum += addr++; count -= 2; } / Add any left-over byte */ if(count > 0) sum += addr; / Fold 32 bit sum into 16 bits */ while(sum >> 16) sum = (sum & 0xffff) + (sum >> 16); return -sum; }

E. W. Fulp Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 19

Cyclic Redundancy Check (CRC)

  • Represent the message as a n degree polynomial
    • Where the highest-order term is xn
    • Value of each bit is the coefficient of each term

[ 10011010 ] ⇒ 1 · x^7 + 0 · x^6 + 0 · x^5 + 1 · x^4 + 1 · x^3 + 0 · x^2 + 1 · x^1 + 0 · x^0 = x^7 + x^4 + x^3 + x

  • Sender and receiver must agree on a divisor, c(x)
    • Another polynomial of degree k, for example x^3 + x^2 + 1
  • Sender sends message m(x) ⇒ n + 1 data and k redundant bits
    • Create m(x) so it is completely divisible by c(x)

CRC Rules for Polynomial Math

Assume b(x) and c(x) are polynomials

  • b(x) can be divided by c(x) if b(x) has a higher degree than c(x)
  • b(x) can be divided once by c(x) if b(x) and c(x) have the same degree
  • Remainder of b c((xx)) is obtained from subtracting c(x) from b(x)
  • To subtract c(x) from b(x), XOR matching coefficients Examples
  • x^3 + 1 can be divided by x^3 + x^2 + 1
  • The remainder would be 0 · x^3 + 1 · x^2 + 0 · x^1 + 0 · x^0
  • Easier to see using bit patterns, [ 1001 ] divided by [ 1101 ] ⇒ [ 0100 ]

E. W. Fulp Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 21

Rules for Generating CRC Message

  • Want to create a message that consists of original data m(x) and redundant bits, that is exactly divisible by c(x)
  • Rules for message generation
    1. Multiply m(x) by xk^ (add k zeroes to end) call this t(x)
    2. Divide t(x) by c(x) and find the remainder
      • Remainder is called the CRC
    3. Subtract remainder from t(x) and transmit
  • Rules for error detection
    1. Divide received message by c(x)
    2. If remainder is zero, then no errors, otherwise error occured

CRC Performance

  • Standard polynomials include

CRC-12 x^12 + x^11 + x^3 + x + 1 CRC-16 x^16 + x^15 + x^2 + 1 CRC-ITU-T x^16 + x^12 + x^5 + 1

What is the divisor polynomial on the previous slide?

  • CRC performance
    • Can detect all burst errors that affect an odd number of bits
    • Can detect all burst errors of length less than or equal to the degree of the polynomial
    • Can detect with a high probability burst errors of length greater than the degree of the polynomial

E. W. Fulp Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 25

Single-Bit Error Correction

We are interested in detecting and correcting a single-bit error

  • Using a parity bit
    • We have shown that two-states (parity) is enough to recognize an error
    • We also need to know the error location
  • For example, to correct a single-bit error in an ASCII character
    • Must identify which of the seven bits are in error (eight different states)
    • This can be encoded as three extra bits
    • What if the error occurs in the redundancy bits?
    • There are 10 bits total, but can only identify 8 error locations

Redundancy Bits

To calculate the number of redundancy bits r required to correct a given number of data bits m, must find a relationship between m and r

data bits m r

total m + r

  • m + r bits ⇒ r must indicate at least m + r + 1 different states
    • Each state identifies a specific bit
    • One of the states must indicate no error
  • Therefore, if m + r + 1 states are needed and r can identify 2 r states 2 r^ ≥ m + r + 1

E. W. Fulp Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 27

  • The value of r can be determined by using the value of m
  • If m = 7 then the smallest r is 4 24 ≥ 7 + 4 + 1

Data bits (m) Redundancy bits (r) Total bits (m + r) 1 2 3 2 3 5 3 3 6 4 3 7 5 4 9 6 4 10 7 4 11

  • For the VRC - Data bits are included at lease twice, while redundancy bits are included once
  • What is the pattern? Look at the binary value of each bit position
    • r 1 is calculated using all bit positions whose binary representation includes a 1 in the right-most position 1011 1001 0111 0101 0011 0001 d 11 d 10 d 9 r 8 d 7 d 6 d 5 r 4 d 3 r 2 r 1
  • r 2 is calculated using all bit positions whose binary representation includes a 1 in the second right-most position 1011 1010 0111 0110 0011 0010 d 11 d 10 d 9 r 8 d 7 d 6 d 5 r 4 d 3 r 2 r 1
  • This repeats for the remaining r bits

E. W. Fulp Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 31

  • Once the the message is at the receiver
    • Calculate new VRC’s based on the message (use same method)
    • Assemble new parity bits as binary number [r 8 , r 4 , r 2 , r 1 ]
    • Number identifies the location of the error
  • Example, assume the data is [ 1001101 ] d 11 d 10 d 9 r 8 d 7 d 6 d 5 r 4 d 3 r 2 r 1 1 0 0? 1 1 0? 1?? d 11 d 10 d 9 r 8 d 7 d 6 d 5 r 4 d 3 r 2 r 1 1 0 0? 1 1 0? 1? 1 d 11 d 10 d 9 r 8 d 7 d 6 d 5 r 4 d 3 r 2 r 1 1 0 0? 1 1 0? 1 0 1 d 11 d 10 d 9 r 8 d 7 d 6 d 5 r 4 d 3 r 2 r 1 1 0 0? 1 1 0 0 1 0 1 d 11 d 10 d 9 r 8 d 7 d 6 d 5 r 4 d 3 r 2 r 1 1 0 0 1 1 1 0 0 1 0 1
  • The resulting message [ 10011100101 ] is sent
  • Assume the received message is [ 10010100101 ], determine which bit is in error d 11 d 10 d 9 d 8 d 7 d 6 d 5 d 4 d 3 d 2 d 1 1 0 0 1 0 1 0 0 1 0 1 r 8 r 4 r 2 r 1 ????

d 11 d 10 d 9 d 8 d 7 d 6 d 5 d 4 d 3 d 2 d 1 1 0 0 1 0 1 0 0 1 0 1 r 8 r 4 r 2 r 1 ??? 1

d 11 d 10 d 9 d 8 d 7 d 6 d 5 d 4 d 3 d 2 d 1 1 0 0 1 0 1 0 0 1 0 1 r 8 r 4 r 2 r 1 ?? 1 1

E. W. Fulp Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 33

d 11 d 10 d 9 d 8 d 7 d 6 d 5 d 4 d 3 d 2 d 1 1 0 0 1 0 1 0 0 1 0 1 r 8 r 4 r 2 r 1 ? 1 1 1

d 11 d 10 d 9 d 8 d 7 d 6 d 5 d 4 d 3 d 2 d 1 1 0 0 1 0 1 0 0 1 0 1 r 8 r 4 r 2 r 1 0 1 1 1

  • The resulting code is [ 0111 ] = 7
  • Invert the 7th bit and the message is correct Is there a pattern for the position of r bits?

Can you make Hamming codes handle multiple errors?

ENQ/ACK

  • Typically used for point-to-point links
  • ENQ/ACK coordinates
    • Which device may start a transmission
    • Determine if the recipient is ready
  • How ENQ/ACK works
    1. Initiator transmits an ENQ
    2. Receiver replies with an ACK (OK) or NACK (not OK)
    3. If ACK received transmit data, end with EOT (End of Text)
    4. If no response...

E. W. Fulp Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 37

Data Transmission

Sending messages from machine to machine

  • Propagation delay - Time to propagate across a channel
    • Dependent on the channel medium

tprop = d v

where d is the distance and v velocity of propagation

  • Data transmission - The amount of time required to send the data
    • Dependent on the bit rate

ttrans = m b

where m is the message size and b is the bit rate

  • Processing delay - Data processing and queueing

This can be shown using a time diagram

t t

t t

t t

data

data

time

Station A Station B

  • Propagation delay ⇒ tprop = t 1 − t 0
  • Transmission delay ⇒ ttrans = t 2 − t 1
  • Processing delay ⇒ tproc = t 3 − t 2

E. W. Fulp Fall 2008

Internet Protocols CSC 343· 643 Data Link Layer, Part 1 39

Time diagrams for ENQ/ACK, connection reject and successful data transmission

time

Station A Station B

NACK

ENQ

time

Station A Station B

ACK

DATA EOT

ENQ

N.B. data transmission will depend on flow control mechanism