0% found this document useful (0 votes)
29 views30 pages

CNE Lec3 Chapter3-DataLinkLayer (Reading)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views30 pages

CNE Lec3 Chapter3-DataLinkLayer (Reading)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 30

The Data Link Layer

Chapter 3

• Data Link Layer Design Issues


• Error Detection and Correction
• Elementary Data Link Protocols
• Sliding Window Protocols
• Example Data Link Protocols

Revised: August 2011


CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
The Data Link Layer

Application
Responsible for delivering frames of
Transport
information over a single link
Network
• Handles transmission errors and
Link
regulates the flow of data
Physical

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Data Link Layer Design Issues

• Frames »
• Possible services »
• Framing methods »
• Error control »
• Flow control »

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Frames

Link layer accepts packets from the network layer, and


encapsulates them into frames that it sends using the
physical layer; reception is the opposite process

Network

Link
Virtual data path

Physical Actual data path

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Possible Services

Unacknowledged connectionless service


• Frame is sent with no connection / error recovery
• Ethernet is example

Acknowledged connectionless service


• Frame is sent with retransmissions if needed
• Example is 802.11

Acknowledged connection-oriented service


• Connection is set up; rare

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Framing Methods

• Byte count »
• Flag bytes with byte stuffing »
• Flag bits with bit stuffing »
• Physical layer coding violations
− Use non-data symbol to indicate frame

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Framing – Byte count

Frame begins with a count of the number of bytes in it


• Simple, but difficult to resynchronize after an error

Expected
case

Error
case

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Framing – Byte stuffing

Special flag bytes delimit frames; occurrences of flags in


the data must be stuffed (escaped)
• Longer, but easy to resynchronize after error

Frame
format

Need to escape
extra ESCAPE
bytes too!
Stuffing
examples

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Framing – Bit stuffing

Stuffing done at the bit level:


• Frame flag has six consecutive 1s (not shown)
• On transmit, after five 1s in the data, a 0 is added
• On receive, a 0 after five 1s is deleted

Data bits

Transmitted bits
with stuffing

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Control

Error control repairs frames that are received in error


• Requires errors to be detected at the receiver
• Typically retransmit the unacknowledged frames
• Timer protects against lost acknowledgements

Detecting errors and retransmissions are next topics.

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Flow Control

Prevents a fast sender from out-pacing a slow receiver


• Receiver gives feedback on the data it can accept
• Rare in the Link layer as NICs run at “wire speed”
− Receiver can take data as fast as it can be sent

Flow control is a topic in the Link and Transport layers.

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Detection and Correction

Error codes add structured redundancy to data so errors


can be either detected, or corrected.
Error correction codes:
• Hamming codes »
• Binary convolutional codes »
• Reed-Solomon and Low-Density Parity Check codes
− Mathematically complex, widely used in real systems

Error detection codes:


• Parity »
• Checksums »
• Cyclic redundancy codes »
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Bounds – Hamming distance

Code turns data of n bits into codewords of n+k bits


Hamming distance is the minimum bit flips to turn one
valid codeword into any other valid one.
• Example with 4 codewords of 10 bits (n=2, k=8):
− 0000000000, 0000011111, 1111100000, and 1111111111
− Hamming distance is 5

Bounds for a code with distance:


• 2d+1 – can correct d errors (e.g., 2 errors above)
• d+1 – can detect d errors (e.g., 4 errors above)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Correction – Hamming code

Hamming code gives a simple way to add check bits


and correct up to a single bit error:
• Check bits are parity over subsets of the codeword
• Recomputing the parity sums (syndrome) gives the
position of the error to flip, or 0 if there is no error

(11, 7) Hamming code adds 4 check bits and can correct 1 error

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Correction – Convolutional codes

Operates on a stream of bits, keeping internal state


• Output stream is a function of all preceding input bits
• Bits are decoded with the Viterbi algorithm

…111 … 0 1 1
1 0 1

Popular NASA binary convolutional code (rate = ½) used in 802.11

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Detection – Parity (1)

Parity bit is added as the modulo 2 sum of data bits


• Equivalent to XOR; this is even parity
• Ex: 1110000  11100001
• Detection checks if the sum is wrong (an error)

Simple way to detect an odd number of errors


• Ex: 1 error, 11100101; detected, sum is wrong
• Ex: 3 errors, 11011001; detected sum is wrong
• Ex: 2 errors, 11101101; not detected, sum is right!
• Error can also be in the parity bit itself
• Random errors are detected with probability ½
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Detection – Parity (2)

Interleaving of N parity bits detects burst errors up to N


• Each parity sum is made over non-adjacent bits
• An even burst of up to N errors will not cause it to fail

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Detection – Checksums

Checksum treats data as N-bit words and adds N check


bits that are the modulo 2N sum of the words
• Ex: Internet 16-bit 1s complement checksum

Properties:
• Improved error detection over parity bits
• Detects bursts up to N errors
• Detects random errors with probability 1-2N
• Vulnerable to systematic errors, e.g., added zeros

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Detection – CRCs (1)
Adds bits so that transmitted frame viewed as a polynomial
is evenly divisible by a generator polynomial

Start by adding
0s to frame
and try dividing

Offset by any reminder


to make it evenly
divisible

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Detection – CRCs (2)

Based on standard polynomials:


• Ex: Ethernet 32-bit CRC is defined by:

• Computed with simple shift/XOR circuits

Stronger detection than checksums:


• E.g., can detect all double bit errors
• Not vulnerable to systematic errors

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Elementary Data Link Protocols

• Link layer environment »


• Utopian Simplex Protocol »
• Stop-and-Wait Protocol for Error-free channel »
• Stop-and-Wait Protocol for Noisy channel »

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Link layer environment (1)

Commonly implemented as NICs and OS drivers;


network layer (IP) is often OS software

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Link layer environment (2)
Link layer protocol implementations use library functions
• See code (protocol.h) for more details

Group Library Function Description


from_network_layer(&packet) Take a packet from network layer to send
Network to_network_layer(&packet) Deliver a received packet to network layer
layer enable_network_layer() Let network cause “ready” events
disable_network_layer() Prevent network “ready” events
Physical from_physical_layer(&frame) Get an incoming frame from physical layer
layer to_physical_layer(&frame) Pass an outgoing frame to physical layer
wait_for_event(&event) Wait for a packet / frame / timer event
start_timer(seq_nr) Start a countdown timer running
Events &
stop_timer(seq_nr) Stop a countdown timer from running
timers
start_ack_timer() Start the ACK countdown timer
stop_ack_timer() Stop the ACK countdown timer

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Example Data Link Protocols

• Packet over SONET »


• PPP (Point-to-Point Protocol) »
• ADSL (Asymmetric Digital Subscriber Loop) »

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Packet over SONET

Packet over SONET is the method used to carry IP


packets over SONET optical fiber links
• Uses PPP (Point-to-Point Protocol) for framing

Protocol stacks PPP frames may be split


over SONET payloads

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
PPP (1)

PPP (Point-to-Point Protocol) is a general method for


delivering packets across links
• Framing uses a flag (0x7E) and byte stuffing
• “Unnumbered mode” (connectionless unacknow-
ledged service) is used to carry IP packets
• Errors are detected with a checksum

0x21 for IPv4 IP packet

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
PPP (2)

A link control protocol brings the PPP link up/down

State machine for link control


CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
ADSL (1)

Widely used for broadband Internet over local loops


• ADSL runs from modem (customer) to DSLAM (ISP)
• IP packets are sent over PPP and AAL5/ATM (over)

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
ADSL (2)

PPP data is sent in AAL5 frames over ATM cells:


• ATM is a link layer that uses short, fixed-size cells
(53 bytes); each cell has a virtual circuit identifier
• AAL5 is a format to send packets over ATM
• PPP frame is converted to a AAL5 frame (PPPoA)

AAL5 frame is divided into 48 byte pieces, each of


which goes into one ATM cell with 5 header bytes

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
End

Chapter 3

CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011

You might also like