Académique Documents
Professionnel Documents
Culture Documents
Chapter 3
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
Network
Link
Virtual data path
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Possible Services
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
Expected
case
Error
case
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Framing Byte stuffing
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
Data bits
Transmitted bits
with stuffing
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Control
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Flow Control
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Detection and Correction
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Bounds Hamming distance
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Bounds Hamming distance
To detect d errors
Required Hamming distance d+1. Why?
This way, d single bit errors will not produce a
valid codeword
To correct d errors,
Required Hamming distance 2d+1. Why?
This way, with d single bit errors the resulting
codeword is still closer to one of the valid
codewords
Example
Valid codewords:
000000, 000111, 111000, 111111
Hamming distance = 3
Can detect up to 2 errors
000011, 000110, 100100, 100001
001111, 000110, 110111, 101111
110011, 011110, 101101, 111100
Example
Valid codewords:
0000000000, 0000011111, 1111100000 1111111111
Hamming distance = 5
Can correct up to 2 errors
Frame consists of
m (message) bits
r (redundant/check) bits
m + r = n-bit codeword (message+check)
There are 2m legal messages
Each message has n illegal codewords at distance 1.
Why?
Each one is obtained by inverting 1 bit
Each legal message requires n+1 dedicated patterns
(+1 is for original)
Error Bounds Hamming distance
(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
Calculating the Hamming Code
1. Mark all bit positions that are powers of two as parity bits. (positions 1, 2, 4, 8, 16, 32, 64, etc.)
2. All other bit positions are for the data to be encoded. (positions 3, 5, 6, 7, 9, 10, 11, 12, 13, 14,
15, 17, etc.)
3. Each parity bit calculates the parity for some of the bits in the code word. The position of the
parity bit determines the sequence of bits that it alternately checks and skips.
Position 1: check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, etc. (1,3,5,7,9,11,13,15,...)
Position 2: check 2 bits, skip 2 bits, check 2 bits, skip 2 bits, etc. (2,3,6,7,10,11,14,15,...)
Position 4: check 4 bits, skip 4 bits, check 4 bits, skip 4 bits, etc.
(4,5,6,7,12,13,14,15,20,21,22,23,...)
Position 8: check 8 bits, skip 8 bits, check 8 bits, skip 8 bits, etc. (8-15,24-31,40-47,...)
Position 16: check 16 bits, skip 16 bits, check 16 bits, skip 16 bits, etc. (16-31,48-63,80-95,...)
Position 32: check 32 bits, skip 32 bits, check 32 bits, skip 32 bits, etc. (32-63,96-127,160-
191,...)
etc.
4. Set a parity bit to 1 if the total number of ones in the positions it checks is odd. Set a parity bit
to 0 if the total number of ones in the positions it checks is even.
Source: http://users.cis.fiu.edu/~downeyt/cop3402/hamming.html
Calculating the Hamming Code
Example
Source: http://users.cis.fiu.edu/~downeyt/cop3402/hamming.html
Calculating the Hamming Code
Example
Then the receiver could calculate which bit was wrong and correct it.
The method is to verify each check bit. Write down all the incorrect
parity bits.
Doing so, you will discover that parity bits 2 and 8 are incorrect. It is
not an accident that 2 + 8 = 10, and that bit position 10 is the location
of the bad bit.
In general, check each parity bit, and add the positions that are
wrong, this will give you the location of the bad bit.
Source: http://users.cis.fiu.edu/~downeyt/cop3402/hamming.html
Error Detection Parity (1)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Detection Parity (2)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Detection Checksums
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
Internet Checksum
Sum is defined in 1s complement
arithmetic (must add back carries)
And its the negative sum
The checksum field is the 16 bit one's
complement of the one's complement
sum of all 16 bit words RFC 791
Computer Networks 28
Internet Checksum (2)
Sending:
0001
1. Arrange data in 16-bit words f203
f4f5
2. Put zero in checksum position, f6f7
+(0000)
add ------
2ddf0
ddf0
3. Add any carryover back to get 16 + 2
------
bits ddf2
220d
Computer Networks 30
Internet Checksum (4)
Receiving:
1.Arrange data in 16-bit words 0001
f203
2.Checksum will be non-zero, add f4f5
f6f7
+ 220d
------
3.Add any carryover back to get 16 bits 2fffd
fffd
+ 2
------
4.Negate the result and check it is 0 ffff
0000
Computer Networks 31
Internet Checksum (5)
Receiving:
1.Arrange data in 16-bit words 0001
f203
2.Checksum will be non-zero, add f4f5
f6f7
+ 220d
------
3.Add any carryover back to get 16 bits 2fffd
fffd
+ 2
------
4.Negate the result and check it is 0 ffff
0000
Computer Networks 32
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
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Error Detection CRCs (2)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Cyclic Redundancy Check (CRC)
Even stronger protection
Given n data bits, generate k check
bits such that the n+k bits are evenly
divisible by a generator C
Example with numbers:
n = 302, k = one digit, C = 3
Computer Networks 35
CRCs (2)
The catch:
Its based on mathematics of
finite fields, in which numbers
represent polynomials
e.g, 10011010 is x7 + x4 + x3 + x1
Receive Procedure:
1. Divide and check for zero
remainder
Computer Networks 37
CRCs (4)
Computer Networks 38
Error Detection in Practice
CRCs are widely used on links
Ethernet, 802.11, ADSL, Cable
Checksum used in Internet
IP, TCP, UDP but it is weak
Parity
Is little used
Computer Networks 39
Elementary Data Link Protocols
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Link layer environment (1)
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
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Utopian Simplex Protocol
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Stop-and-Wait Error-free channel
Protocol (p2) ensures sender cant outpace receiver:
Receiver returns a dummy frame (ack) when ready
Only one frame out at a time called stop-and-wait
We added flow control!
Sender waits to for ack after Receiver sends ack after passing
passing frame to physical layer frame to network layer
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Stop-and-Wait Noisy channel (1)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Stop-and-Wait Noisy channel (2)
{
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Stop-and-Wait Noisy channel (3)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Sliding Window Protocols
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Sliding Window concept (1)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Sliding Window concept (2)
Sender
Receiver
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Sliding Window concept (3)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
One-Bit Sliding Window (1)
Transfers data in both directions with stop-and-wait
Piggybacks acks on reverse data frames for efficiency
Handles transmission errors, flow control, early timers
{
...
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
One-Bit Sliding Window (2)
...
Wait for frame or timeout
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
One-Bit Sliding Window (3)
Two scenarios show subtle interactions exist in p4:
Simultaneous start [right] causes correct but slow operation
compared to normal [left] due to duplicate transmissions.
Time
Notation is (seq, ack, frame number). Asterisk indicates frame accepted by network layer .
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Go-Back-N (1)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Go-Back-N (2)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Go-Back-N (3)
For go-back-n, MAX_SEQ frames may be outstanding at any instant, even
though there are MAX_SEQ + 1 distinct sequence numbers (0, 1, ,
MAX_SEQ). To see why this restriction is required, consider the following
scenario with MAX_SEQ = 7:
1. The sender sends frames 0 through 7.
2. A piggybacked acknowledgement for 7 comes back to the sender.
3. The sender sends another eight frames, again with sequence
numbers 0 through 7.
4. Now another piggybacked acknowledgement for frame 7 comes in.
The question is this: did all eight frames belonging to the second batch arrive
successfully, or did all eight get lost (counting discards following an error as
lost)?
In both cases the receiver would be sending frame 7 as the
acknowledgement.
The sender has no way of telling. For this reason the maximum number of
outstanding frames must be restricted to MAX_SEQ.
Selective Repeat (1)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Selective Repeat (2)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Selective Repeat (3)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Example Data Link Protocols
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
Packet over SONET
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
PPP (1)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
PPP (2)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011
ADSL (2)
CN5E by Tanenbaum & Wetherall, Pearson Education-Prentice Hall and D. Wetherall, 2011