Chapter3 DataLinkLayer
Chapter3 DataLinkLayer
Parity Bit Error Detection
Problem with multiple bit errors in burst errors.
Considerer the data stream as a matrix of n bits by k bits.
Each (k) row is computed a parity.
Interleaving is used to compute parity in different order from
that that is being transmitted.
Compute parity for each n columns
Transmit the data as k rows.
The last row we will send the n parity bits.
Example in the next slide gives the case for n=7 and k=7.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Parity Error-Detecting Codes (2)
Interleaving of parity bits to detect a burst error.
Parity Error-Detecting Codes
A burst of length n+1 will pass undetected.
The probability of that any of the n columns
will have the correct parity by accident is
0.5; the probability of a bad block being
accepted as a good one is 2
-n
.
Checksum Error-Detecting Codes
A group of parity bits is one example of a
checksum.
Stronger checksums are based on a running sum of
the data bits of the message.
The checksum is usually placed at the end of the
message complementary sum.
Errors can be detected by summing the entire
received codeword, both data bits and checksum
bits.
If result is zero no error has been detected.
Checksum Error-Detecting Codes
Example if checksum is the 16-bit Internet error
detection used as part of the IP protocol.
It is applied to 16-bit words.
It will detect an error for cases where parity
detection fails.
Checksum error would fail for:
Deletion or addition of zero data,
Swapping part of the message,
Messages splices in which parts of two packets are
put together.
Those are typical errors caused by faulty hardware.
Checksum Error-Detecting Codes
Fletchers checksum
Includes positional component- adding the product
of the data and its position to the running sum.
The stronger kind of error-detecting code is Cyclic
Redundancy Check (CRC) know as polynomial
code.
A k-bit frame is regarded as the coefficient list for a
polynomial with k terms ranging from x
k-1
to x
0
CRC Error-Detecting Codes
Example:
110001: 1x
5
+ 1x
4
+ 0x
3
+ 0x
2
+ 0x
1
+ 1x
0
Module 2 arithmetic
Addition and Subtraction are equivalent to exclusive
OR.
Long division is carried the same way except that
subtraction operation is again done module 2.
CRC Error-Detecting Codes
Protocol requires that sender to agree in advance
with the receiver on the generator polynomial,
G(x).
Both high- and low-order bits must be 1.
CRC is computed for a frame of length m- bits
corresponding that is longer than the G(x).
When the receiver gets a checksummed frame it
divides it by G(x). If there the result is not equal to
zero it means that there has been transmission error.
CRC Error-Detecting Codes
Algorithm:
1. Let r be the degree of G(x). Append r zero bits to
the low-order end of the frame so it now contains
m+r bits and corresponds to the polynomial x
r
M(x)
2. Divide the bit string corresponding to G(x) into the
bit string corresponding to x
r
M(x) using modulo 2
division.
3. Subtract the remanider (which is always r or fewer
bits) from the bit string corresponding to x
r
M(x)
using module 2 subtraction. The result is the
checksummed frame, T(x), to be transmitted.
CRC Error-Detecting Codes
Example:
Frame: 1101011111
Generator: x
4
+x+1
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Error-Detecting Codes (3)
Example calculation of the CRC
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
CRC Error-Detecting Codes
Certain polynomials have become international
standards: IEEE 802
x
32
+ x
26
+ x
23
+ x
22
+ x
16
+ x
12
+ x
11
+ x
10
+ x
8
+ x
7
+ x
4
+ x
2
+ x
1
+ 1
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Elementary Data Link Protocols (1)
Utopian Simplex Protocol
Simplex Stop-and-Wait Protocol
Error-Free Channel
Simplex Stop-and-Wait Protocol
Noisy Channel
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Elementary Data Link Protocols (2)
Implementation of the physical, data link, and network layers.
Elementary Data Link Protocols
Assumptions:
1. A wants to send a long stream of data to machine B.
2. It uses reliable connection-oriented service.
3. It assumes to have infinite supply of data ready to
send,
4. It does not have to wait for data to be produced.
5. Machines A and B do not crash
6. Data link layer treads the data as packets of pure
data whose every bit is to be delivered to the
destination's network layer.
Elementary Data Link Protocols
Data Link layer job is to:
FRAMEING: encapsulate the data packets in a frame
by adding the header and trailer.
Elementary Data Link Protocols
Error Correction and Detection:
Control information is added to header, and
Checksum is added to trailer.
Frame is then transmitted to the other machine.
Elementary Data Link Protocols
Library procedures:
to_physical_layer
from_physical_layer
wait_for_event(&event)
event object will contain the information what has
happened.
In the receiving end:
Data is being received and the checksum is being computed.
If the error has occurred the data link layer is being
informed: event = chksum_err
If the data has arrived undamaged: event = frame_arrival.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Elementary Data Link Protocols (3)
Some definitions needed in the protocols to follow. These
definitions are located in the file protocol.h.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Elementary Data Link Protocols (4)
Some definitions needed in the protocols to follow. These
definitions are located in the file protocol.h.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Elementary Data Link Protocols (5)
Some definitions needed in the protocols to follow. These
definitions are located in the file protocol.h.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Utopian Simplex Protocol (1)
A utopian simplex protocol.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Utopian Simplex Protocol (2)
A utopian simplex protocol.
Utopian Simplex Protocol
Unrealistic
It does not handle flow control
It does not handle error correction
Resembles connectionless service that relies
on higher layer to solve those problems.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Simplex Stop-and-Wait Protocol
for a Noisy Channel (1)
A simplex stop-and-wait protocol.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Simplex Stop-and-Wait Protocol
for a Noisy Channel (2)
A simplex stop-and-wait protocol.
Simplex Protocol
Solves the problem of flow control.
Blocking acknowledgment of the reception of
the frame partially achieves this.
If acknowledgment frame gets lost the
protocol will fail.
Error correction is not implemented.
One direction only.
Sliding Window Protocols
Full duplex data transmission
Running two instances of one of the previous
protocols,
Each uses separate data link for simplex data traffic in
different directions (forward channel and reverse
channel).
Better idea is to use the same channel in both
directions.
A and B frames are intermixed with acknowledgment
frames from A and B.
Kind field in the header of the incoming frame will be
used to tell the difference.
Sliding Window Protocols
In addition to being able to use duplex
communication, the further protocol improvement
would be to send the acknowledgment frame
together with the new data frame. This provides for
a free ride.
The technique of delaying the acknowledgment for
a bit to be added to the next packet is know as
piggybacking.
This technique add another complication.
If the data frame is available within a short time
period (less than msec) it will use piggybacking.
Otherwise, it will send separate acknowledgment.
Sliding Window
At any instant of time the sender maintains a set of
sequences numbers that correspond to frames that
are permitted to be send.
Those frames are said to fall within a sending
window.
Receiver also maintains a receiving window that
corresponds to the set of frames that it is permitted
to accept.
Sliding Window
The sequence numbers within the senders window
represent the frames that have been sent or can be
sent but are not yet been acknowledged.
Whenever the a new packet arrives from the
network layer, it is given the next highest sequence
number, and
The upper edge of the window is advanced by one.
When acknowledgement arrives the lower edge is
advance by one.
This is how the protocol maintains the list of
unacknowledged frames.
Sliding Window Protocols
A sliding window of size 1, with a 3-bit sequence number.
(a) Initially. (b) After the first frame has been sent.
Sliding Window Protocols
A sliding window of size 1, with a 3-bit sequence number
(c) After the first frame has been received. (d) After the first acknowledgement
has been received.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Sliding Window Protocols (1)
A positive acknowledgement with retransmission protocol.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Sliding Window Protocols (2)
A positive acknowledgement with retransmission protocol.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Sliding Window Protocols (3)
A positive acknowledgement with retransmission protocol.
One-Bit Sliding Window Protocol
Window size = 1
Stop-and-wait
Sender transmits a frame and waits for its
acknowledgment before it sends the next one.
Figure of next slide depicts such a protocol.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
One-Bit Sliding Window Protocol (1)
A 1-bit sliding window protocol.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
One-Bit Sliding Window Protocol (2)
A 1-bit sliding window protocol.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
One-Bit Sliding Window Protocol (3)
A 1-bit sliding window protocol.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
One-Bit Sliding Window Protocol (4)
Two scenarios for protocol 4. (a) Normal case. (b) Abnormal
case. The notation is (seq, ack, packet number). An asterisk
indicates where a network layer accepts a packet
Protocol Using Go-Back-N
Up-to-know the protocols depicted so far are based
on the assumption that the time required for
transmission and reception of the acknowledgment
packets is negligible.
If this assumptions is not true then round-trip time
can have important implications in the efficiency of
the communication and the bandwidth utilization.
Protocol Using Go-Back-N
Example:
50 kbps satellite channel
500 msec round-trip propagation delay.
Lets use Protocol 4 (previous slides) to send a 1000 bit frames
via the satellite.
t = 0: the sender starts the first frame
t = 20 msec: the frame has been completely sent.
t = 270 msec: the frame has fully arrived at the satellite.
t = 520 msec: the acknowledgment has arrived at the sender.
Sender was blocked 500/520 or 96% of the time. In order to
send the packed the sender utilized 4% of the available
bandwidth.
Protocol Using Go-Back-N
The problem?
Consequence of the rule that requires a sender to
wait for an acknowledgment before sending another
frame.
Relaxing this condition will enable achieving
significantly better throughput.
Solution!
Allowing sender the transmit w frames before
blocking.
Acknowledgment will arrive for previous frames
before the window becomes full.
Protocol Using Go-Back-N
Must correctly establish what is the actual size of
w.
Number of frames to fit inside the channel.
Capacity of the channel is determined by
Bandwidth in bits/sec
One-way transit time, or
The bandwidth-delay product of the link: BD
The actual size should be set to:
w = 2BD+1
Protocol Using Go-Back-N
Example:
Link with the bandwidth of 50 kbps
One way transit time of 250 msec
Bandwidth delay product is
BD = 50 kbps x 250 msec = 12.5 kbits or 12.5 frames
of 1000 bits.
2BD+1 = 26 frames.
t = 0: sends a first frame and subsequent frames after
20 msec.
t = 520 msec: acknowledgment for the first frame is
received, while 26 frames were transmitted.
Thereafter, acknowledgments will arrive every 20
msec.
Protocol Using Go-Back-N
Just in time for the sender to continue transmitting.
25 or 26 unacknowledged frames will always be
outstanding.
Hence, the senders maximum window size is 26
frames.
For smaller window size, the utilization of the link
will be less than 100%.
1 + 2
Upper bound of the link utilization:
It does not allow for any frame processing time
Treats acknowledgment frame as having zero length.
Protocol Using Go-Back-N
From the equation:
Large bandwidth-delay product requires a large
window.
With stop-and-wait for which w = 1, of there is even
one frames worth of propagation delay, the
efficiency will be less than 50%.
Pipelining technique where the number of frames
(much greater than 1) are send immediately.
What will happen then when a certain frame is
received in error?!
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (1)
Pipelining and error recovery. Effect of an error when
(a) receivers window size is 1
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (2)
Pipelining and error recovery. Effect of an error when
(b) receivers window size is large.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (3)
A sliding window protocol using go-back-n.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (4)
A sliding window protocol using go-back-n.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (5)
A sliding window protocol using go-back-n.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (6)
A sliding window protocol using go-back-n.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (7)
A sliding window protocol using go-back-n.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (8)
A sliding window protocol using go-back-n.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (9)
A sliding window protocol using go-back-n.
Cumulative Acknowledgment
When an acknowledgment comes in for frame n,
frames n-1, n-2, are also automatically
acknowledged.
Because protocol 5 has multiple outstanding
frames, it logically needs multiple timers, one per
outstanding frame.
Each frame times out independently of all the other
ones.
The pending timeouts from a linked list, with each
node of the list containing the
Number of clock ticks until the timer expires,
Frame being timed,
A pointer to the next node
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (10)
Simulation of multiple timers in software. (a) The queued
timeouts (b) The situation after the first timeout has expired.
Selective Repeat
The go-back-n protocol works well if errors are rare.
If the line is poor it wastes a lot of bandwidth on
retransmitting frames.
A Selective Repeat protocol allows the receiver to
accept and buffer the frames following a damaged
or lost one.
Selective Repeat
Sender and Receiver maintain a window of
outstanding and acceptable sequence numbers,
respectively.
Sender:
Window size starts a 0,
Grows to some predefined maximum,
Receiver:
Is always fixed in size
Equal to the predetermined maximum.
Selective Repeat
Sender and Receiver maintain a window of
outstanding and acceptable sequence numbers,
respectively.
Sender:
Window size starts a 0,
Grows to some predefined maximum,
Receiver:
Is always fixed in size
Equal to the predetermined maximum.
Has a buffer reserved for each sequence number
within its fixed window.
Associated with it is a bit (arrived) telling whether
the buffer is full or empty.
Selective Repeat
Whenever the frame arrives, the receiver does the
following:
Check the frame sequence number if it does fall
within its fixed window,
If this is the case and the sequence has not been
received in previous transmissions it will be stored.
It does so without regard if the frame contains the
next packet expected by the network layer.
This frame is going to be kept until all the lower-
numbered frames have already been delivered to the
network layer in the correct order.
Selective Repeat
Consequential receive introduces further constrains
on frame sequence numbers vs. the protocols that
accepted frames in order.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (4)
A sliding window protocol using selective repeat.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (1)
A sliding window protocol using selective repeat.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (2)
A sliding window protocol using selective repeat.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (3)
A sliding window protocol using selective repeat.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (5)
A sliding window protocol using selective repeat.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (6)
A sliding window protocol using selective repeat.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (7)
A sliding window protocol using selective repeat.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (8)
A sliding window protocol using selective repeat.
. . .
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (9)
A sliding window protocol using selective repeat.
Selective Repeat
Example:
3-bit sequence number,
7 frames are permitted to be send by transmitter,
before it is required to wait (for acknowledgment).
Window size restriction:
Must be at most half the range of the sequence
numbers.
Window size for protocol 6 is (MAX_SEQ+1)/2.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (10)
a) Initial situation with a window of size7
b) After 7 frames sent and received but not acknowledged.
c) Initial situation with a window size of 4.
d) After 4 frames sent and received but not acknowledged.
Selective Repeat
If there is a lot of traffic in one direction and no
traffic in the other direction, the protocol will block
when the sender window reaches its maximum.
Axillary timer is started by start_ack_timer after an
in-sequence data frame arrives.
If no reverse traffic has presented itself for
piggybacking before the timer expires, a separate
acknowledgement will be send.
Interrupt due to this timer is called ack_timeout
event.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Example Data Link Protocols
1. Packet over SONET
2. ADSL (Asymmetric Digital Subscriber Loop)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Packet over SONET (1)
Packet over SONET. (a) A protocol stack. (b) Frame relationships
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Packet over SONET (2)
Point-to-Point Protocol (PPP) Features
1. Separate packets, error detection
2. Link Control Protocol
3. Network Control Protocol
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Packet over SONET (3)
The PPP full frame format for unnumbered mode operation
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
Packet over SONET (4)
State diagram for bringing a PPP link up and down
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
ADSL (Asymmetric Digital
Subscriber Loop) (1)
ADSL protocol stacks.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
ADSL (Asymmetric Digital
Subscriber Loop) (1)
AAL5 frame carrying PPP data
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, Pearson Education-Prentice Hall, 2011
End
Chapter 3