rahul deva data link layer. the data link layer framing error control error correction error...
TRANSCRIPT
RAHUL DEVA
Data Link Layer
The Data Link Layer
Framing Error Control
Error Correction Error Detection
Flow Control Retransmission with Sliding Window Protocols Protocol Specification and Verification Example Data Link Protocols
2
Data Link Layer Services
Unacknowledged connectionless service Voice
Acknowledged connectionless servicewireless
Acknowledged connection-oriented service no out-of-order
3
Framing
To break the bit stream up into discrete frames and compute the checksum for each frame. When a frame arrives at the destination, the checksum is recomputed and validated.
One way to achieve this framing is to insert time gaps between frames. However, networks rarely make any guarantees about timing.
4
Error Control
Three types of frames at a receiver’s endDamaged frame: Negative
acknowledgment / retransmissionLost frame: Time-out mechanismValid frame: Sequence numbering /
discarding for valid but duplicate frames
5
Flow Control
A technique for assuring that a transmitting station
does not overwhelm a receiving station with data
6
Data Framing
Character count Starting and ending characters with character stuffing Starting and ending flags with bit stuffing Physical layer coding violations
7
Character Count
5 1 2 3 4 5 6 7 8 9 8 0 1 2 3 4 5 6 8 7 8 9 0 1 2 3
character count
frame 15 characters
frame 25 characters
frame 38 characters
frame 48 characters
5 1 2 3 4 7 6 7 8 9 8 0 1 2 3 4 5 6 8 7 8 9 0 1 2 3
frame 2(wrong)
frame 15 characters
one-bit error
Now a character count
Even if the checksum is incorrect so the destination knows that the frame is bad, it still has no way of telling where the next frame starts.
8
Starting and Ending Characters with Character Stuffing
DLE STX user data DLE ETX
beginningof frame
end offrame
DLE(0x10): Data Link EscapeSTX(0x02): Start of TeXtETX(0x03): End of TeXt
DLE STX A DLE B DLE ETX
user data 0x10
DLE STX A DLE B DLE ETX
DLE stuffed at the sender
DLE destuffed at the receiver
DLE STX A DLE DLE B DLE ETX
9
Starting and Ending Flags with Bit Stuffing
01111110 user data 01111110
beginningof frame
end offrame
flag
011011111111111111110010
011011111111111111110010
011011111011111011111010010
bits stuffed at the sender
bits destuffed at the receiver
original data
10
Introduction: Error Detection and Correction
It is physically impossible for any data recording or transmission medium to be 100% perfect over its entire expected useful life.
Noise is always present If a communications line experiences too much noise, the
signal will be lost or corrupted Communication systems should check for transmission errors Once an error is detected, a system may perform some action Some systems perform no error control, but simply let the
data in error be discarded
11
Noise
Also known as thermal or Gaussian noiseRelatively constant and can be reducedIf noise gets too strong, it can completely disrupt the
signal
12
Noise (continued)13
Impulse Noise
One of the most disruptive forms of noise Random spikes of power that can destroy one or more bits of
information Difficult to remove from an analog signal because it may be hard to
distinguish from the original signal Impulse noise can damage more bits if the bits are closer together
(transmitted at a faster rate)
14
The effect of impulse noise on a digital signal
Crosstalk
Unwanted coupling between two different signal paths For example, hearing another conversation while talking on
the telephone Relatively constant and can be reduced with proper measures
Three Telephone Circuits experiencing crosstalk
15
Echo
The reflective feedback of a transmitted signal as the signal moves through a medium
Most often occurs on coaxial cable If echo bad enough, it could interfere with original signalRelatively constant, and can be significantly reduced
A signal bouncing back at the end of a cable and causing echo
16
Jitter
The result of small timing irregularities during the transmission of digital signals
Occurs when a digital signal is repeated over and overIf serious enough, jitter forces systems to slow down their
transmissionSteps can be taken to reduce jitter
Original digital signal and digital signal with jitter
17
Delay Distortion
Occurs because the velocity of propagation of a signal through a medium varies with the frequency of the signal Can be reduced
18
Attenuation
The continuous loss of a signal’s strength as it travels through a medium
19
Error Prevention (continued)
Error Detection
Despite the best prevention techniques, errors may still happen
To detect an error, something extra has to be added to the data/signal This extra is an error detection code
Three basic techniques for detecting errors: parity checking, arithmetic checksum, and cyclic redundancy checksum
Parity Checks
Simple parityIf performing even parity, add a parity bit such that
an even number of 1s are maintainedIf performing odd parity, add a parity bit such that
an odd number of 1s are maintainedFor example, send 1001010 using even parityFor example, send 1001011 using even parity
22
Parity Checks (continued)
Simple parity (continued)What happens if the character 10010101 is sent
and the first two 0s accidentally become two 1s?Thus, the following character is received:
11110101Will there be a parity error?
Problem: Simple parity only detects odd numbers of bits in error
23
Parity Checks (continued)
Longitudinal parity Adds a parity bit to each character then adds
a row of parity bits after a block of charactersThe row of parity bits is actually a parity bit
for each “column” of charactersThe row of parity bits plus the column parity
bits add a great amount of redundancy to a block of characters
24
25
Vertical Redundancy Check (VRC)
Append a single bit at the end of data block such that the number of ones is even Even Parity (odd parity is similar)0110011 011001100110001 01100011
VRC is also known as Parity CheckPerformance:
Detects all odd-number errors in a data block
26
Longitudinal Redundancy Check (LRC)
Organize data into a table and create a parity for each column
11100111 11011101 00111001 10101001
11100111110111010011100110101001
10101010
11100111 11011101 00111001 10101001 10101010
Original Data LRC
Longitudinal Redundancy Check and Vertical Redundancy Check
1 0 1 1 0 1 1 11 1 0 1 0 1 1 10 0 1 1 1 0 1 01 1 1 1 0 0 0 01 0 0 0 1 0 1 10 1 0 1 1 1 1 10 1 1 1 1 1 1 0
VRC
LRC
27
Parity Checks (continued)
Both simple parity and longitudinal parity do not catch all errors
Simple parity only catches odd numbers of bit errorsLongitudinal parity is better at catching errors but
requires too many check bits added to a block of dataWe need a better error detection method
What about arithmetic checksum?
28
Modulo 2
Modulo 2 arithmetic works like clock arithmetic. In clock arithmetic, if we add 2 hours to 11:00, we get 1:00. In modulo 2 arithmetic if we add 1 to 1, we get 0. The addition
rules couldn’t be simpler:
0 + 0 = 0 0 + 1 = 1
1 + 0 = 1 1 + 1 = 0
29
Find the quotient and remainder when 1111101 is divided by 1101 in modulo 2 arithmetic.As with traditional
division, we note that the dividend is divisible once by the divisor.
We place the divisor under the dividend and perform modulo 2 subtraction.
30
Error Detection and Correction
Find the quotient and remainder when 1111101 is divided by 1101 in modulo 2 arithmetic…Now we bring down the
next bit of the dividend.We see that 00101 is not
divisible by 1101. So we place a zero in the quotient.
31
Error Detection and Correction
Find the quotient and remainder when 1111101 is divided by 1101 in modulo 2 arithmetic…1010 is divisible by 1101
in modulo 2.We perform the modulo 2
subtraction.
32
Error Detection and Correction
Find the quotient and remainder when 1111101 is divided by 1101 in modulo 2 arithmetic…
We find the quotient is 1011, and the remainder is 0010.
This procedure is very useful to us in calculating CRC syndromes.
Note: The divisor in this example corresponds to a modulo 2 polynomial: X 3 + X 2 + 1.
33
Suppose we want to transmit the information string: 1111101.
The receiver and sender decide to use the (arbitrary) polynomial pattern, 1101.
The information string is shifted left by one position less than the number of positions in the divisor.
The remainder is found through modulo 2 division (at right) and added to the information string: 1111101000 + 111 = 1111101111.
34
Cyclic redundancy checking (CRC)
If no bits are lost or corrupted, dividing the received information string by the agreed upon pattern will give a remainder of zero.
We see this is so in the calculation at the right.
Real applications use longer polynomials to cover larger information strings. Some of the standard poly-
nomials are listed in the text.
35
Cyclic redundancy checking (CRC)
The minimum Hamming distance for a code, D(min), determines its error detecting and error correcting capability.
For any code word, X, to be interpreted as a different valid code word, Y, at least D(min) single-bit errors must occur in X.
Thus, to detect k (or fewer) single-bit errors, the code must have a Hamming distance of D(min) = k + 1.
Hamming codes36
37
Flow Control and Error Control
Flow control A set of procedures that tells the sender how much data
can be sent before waiting for acknowledgment Error control
Includes both error detection and correction Allows receiver to inform sender of lost or duplicate
frames Mostly based on Automatic Repeat Request (ARQ)
38
Data Link Protocols
39
Protocols for Noiseless Channel
Assuming channel is error free Not realistic…
No need for error control
40
"Simplest" Mechanism
Assuming Noiseless channel Unlimited buffer and speed for the receiver
41
"Simplest" : Pseudo Code
Sender
Receiver
42
"Simplest": Flow Diagram
43
Stop-and-Wait Mechanism
Still noiseless channel Receiver has limited buffer
Requires flow control Sender sends one frame at a time and wait for an
acknowledgment
44
Stop-and-Wait: Overview
45
Stop-and-Wait: Pseudo Code
Sender side
46
Stop-and-Wait: Pseudo Code
Receiver side
47
Stop-and-Wait: Flow Diagram
48
Noisy Channel
Realistic Error can and will happen Require error control
Mechanisms: Stop-and-Wait ARQ Go-Back-N ARQ Selective Repeat ARQ
49
Stop-and-Wait ARQ
Sender keeps a copy of sent frame until successful delivery is ensured
Receiver responds with an ack when it successfully receives a frame
Both data and ack frames must be numbered.
(For identification purpose, both data frames and ACK frames are numbered alternately 0 and 1.)
When sender does not receive an ack within certain time, it assumes frame is lost, then retransmits the same frame.
50
Stop-and-Wait ARQ
51
Flow Diagram: Normal Operation
Time
Sender Receiver
Time
Frame 0
ACK 1
Frame 1
ACK 0
S = 0
S = 1
R = 0
R = 1
R = 0
Deliver
Deliver
52
Thinking Corner
Why data frames need to be numbered?
53
Flow Diagram: Lost Frame
Time
Sender Receiver
Time
Frame 0
ACK 1
Frame 1
ACK 0
S = 0 R = 0
R = 1
R = 0
S = 1
Timeout
Frame 1
Deliver
Deliver
54
Flow Diagram: Lost ACK
Time
Sender Receiver
Time
Frame 0
ACK 1
Frame 1
ACK 0
S = 0 R = 0
R = 1
R = 0
Frame 1S = 1
Timeout
ACK 0
S = 1
S = 0
R = 0Frame 0 expected;
discard
Deliver
Deliver
55
Flow Diagram: Delayed ACK
Sender Receiver
Frame 0
ACK 1
ACK 0
S = 0 R = 0
R = 1
R = 0
Frame 0Timeout
S = 1
S = 0
R = 1
Frame 0 expected; discard
Deliver
ACK 1Frame 1
Timeout Frame 1
Deliver
56
Bidirectional Transmission
Data are transferred both ways ACK are "piggybacked" with data frames
57
Improving Link Utilization
Previous example demonstrates major disadvantage of Stop-and-Wait ARQ
Prefer to send more frames before waiting for ACK Example:
Recalculate the link utilization if we allow up to 15 frames to be sent before waiting for an ACK
58
Go-Back-N ARQ
Allows multiple frames to be sent before waiting for ACK These frames must be numbered differently Frame numbers are called Sequence numbers
Frames must be received in the correct order If a frame is lost, the lost frame and all of the
following frames must be retransmitted
59
Sequence Numbers
Frame header contains m bits for sequence number That allows up to 2m different frame numbers How big should m be?
60
Sending Window
Sending more than one frame at once requires sender to buffer multiple frames Known as "sending window" Any of these frames in the window can be lost
61
"Sliding" Window
Once the first frames in the window is ACKed ACKed frames are removed from the buffer More frames are transmitted Result: The window slides to the right
62
Receiving Window
Receiver expects one frame at a time
63
Send vs. Receive Windows
64
Go-Back-N: Window Sizes
For m-bit sequence numbers Send window size: at most 2m-1
Up to 2m-1 frames can be sent without ACK Receive window size: 1
Frames must be received in order
65
Go-Back-N: Normal Operation
66
Go-Back-N: Lost Frame
ACKs are cumulative
67
Lost ACK: Window Size < 2m
68
Lost ACK: Window Size = 2m
69
Selective Repeat ARQ
Go-Back-N always discards out-of-order frames Losing one frame may result in
retransmission of multiple frames Very inefficient in noisy link
Selective Repeat ARQ allows frames to be received out of order Therefore, receive window > 1
70
Send and Receive Windows
Sender and receiver share window space equally
For m-bit sequence numbers Send window: up to 2m-1
Receive window: up to 2m-1
71
Send Window
72
Receive Window
73
Negative ACK
Used by receiver to indicate missing frame
74
Selective Repeat: Window Size