Chapter 3 2022
Chapter 3 2022
Chapter 3 2022
Objectives:
1) An introduction to the key design issues present in the data link
layer;
2) A study of protocols by looking at the nature of errors, their
causes, and how they can be detected and corrected;
3) A study of increasingly complex protocols, each one solving more
and more of the problems present in this layer;
4) An examination of protocol modeling and correctness.
Data Link Layer Design Issues (1/4)
The data link layer takes the packets it gets from the network
layer and encapsulates them into the frames for transmission.
Frame management forms the heart of what the data link layer
does.
Data Link Layer Design Issues (3/4)
Subtopics:
The job of the data link layer is to transmit the bits to the
destination machine so they can be handed over to the
network layer.
Services Provided to Network Layer (2/8)
To provide service to the network layer, the data link layer must
use the service provided to it by the physical layer.
What the physical layer does is accept a row bit stream and
attempt to deliver it to the destination.
The number of bits received may be less than, equal to, or more
than the number of bits transmitted, an they may have different
values.
It is up to the data link layer to detect and, if necessary, correct
errors.
Framing (2/12)
The usual approach is for the data link layer 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.
If the newly – computed checksum is different from the one
contained in the frame, the data link layer knows that an error
has occurred and takes steps to deal with it.
Framing (3/12)
1) Character count:
The trouble with this algorithm is that the count can be garbled
by a transmission error.
Framing (5/12)
Bit stuffing
a) The original data.
b) The data as they appear on the line.
c) The data as they are stored in receiver’s memory after
destuffing.
Problem
Solution:
1. The following character encoding is used in a data link protocol:
A: 01000111; B: 11100011; FLAG: 01111110; ESC: 11100000
a) Character count.
Problem
Solution:
1. The following character encoding is used in a data link protocol:
A: 01000111; B: 11100011; FLAG: 01111110; ESC: 11100000
a) Character count.
5 A B ESC FLAG
Problem
Solution:
1. The following character encoding is used in a data link protocol:
A: 01000111; B: 11100011; FLAG: 01111110; ESC: 11100000
a) Character count.
5 A B ESC FLAG
Solution:
1. b) flag bytes with byte stuffing.
A B ESC FLAG
Problem
Solution:
1. b) flag bytes with byte stuffing.
Solution:
1. b) flag bytes with byte stuffing.
Solution:
1. c) flag bytes with bit stuffing.
A B ESC FLAG
Problem
Solution:
1. c) flag bytes with bit stuffing.
A B ESC FLAG
Q 2.
The following data fragment occurs in the middle of a data stream for which the
byte-stuffing algorithm described in the text is used:
A B ESC C ESC FLAG FLAG D. What is the output after stuffing?
Problem
Q 2.
The following data fragment occurs in the middle of a data stream for which the
byte-stuffing algorithm described in the text is used:
A B ESC C ESC FLAG FLAG D. What is the output after stuffing?
Solution:
flag bytes with byte stuffing.
A B ESC C ESC FLAG FLAG D
Problem
Q 2.
The following data fragment occurs in the middle of a data stream for which the
byte-stuffing algorithm described in the text is used:
A B ESC C ESC FLAG FLAG D. What is the output after stuffing?
Solution:
flag bytes with byte stuffing.
A B ESC C ESC FLAG FLAG D
Q.3.
What is the maximum overhead in byte-stuffing algorithm?
Problem
Q.3.
What is the maximum overhead in byte-stuffing algorithm?
Solution:
The maximum overhead in byte stuffing algorithm is 100%(i.e. when the
payload contains only ESC and Flag bytes).
Problem
Q 4.
A bit string, 0111101111101111110, needs to be transmitted at the data link
layer. What is the string actually transmitted after bit stuffing?
Problem
Q 4.
A bit string, 0111101111101111110, needs to be transmitted at the data link
layer. What is the string actually transmitted after bit stuffing?
Solution:
32
Flow Control (1/2)
Another important design issue that occurs in the data link layer (and
higher layers as well) is what to do with a sender that systematically
wants to transmit frames faster than the receiver can accept them.
While errors are rare on the digital part, they are still common on the
local loops.
Furthermore, wireless communication is becoming more common,
and the error rates here are orders of magnitude worse than on the
interoffice fiber trunks.
The advantage of bursts errors is that the computer data are always
sent in blocks of bits.
The disadvantage is that they are much harder to correct than are
isolated errors.
Error Detection and Correction (4/5)
Error-Correcting Codes
To include enough redundant information along with each block of
data sent, to enable the receiver to deduce what the transmitted data
must have been.
Error-Detecting Codes
To include only enough redundancy to allow the receiver to deduce
that an error occurred, but not which error, and have it request a
retransmission.
Error Detection and Correction (5/5)
On channels that are highly reliable, such as fiber, it is cheaper to
use an error detecting code and just retransmit the occasional
block found to be faulty.
What is an error?
example:
10001001
10110001
------------
00111000
Error-Correcting Codes (3/11)
The number of bit positions in which two code words differ is called
the Hamming distance.
The parity bit is chosen so that the number of 1 bits in the codeword is
even (or odd).
Error-Correcting Codes (7/11)
For example, when 1011010 is sent in even parity, a bit is added to the
end to make it 10110100.
A code with a single parity bit has a distance 2, since any single-bit error
produces a codeword with the wrong parity.
Since the total number of bit patterns is 2n, we must have (n+1)2m≤2n.
Given m, this puts a lower limit on the number of check bits needed to
correct single errors.
Error-Correcting Codes (11/11)
Example:
Consider a channel on which errors are isolated and the error rate is
10-6 per bit.
Let the block size be 1000 bits.
To provide error correction for 1000-bit block, 10 check bits are
needed: a megabit of data would require 10,000 check bits.
To merely detect a block with a single 1-bit error, one parity bit per
block will suffice.
Error-Detecting Codes (3/12)
Example (cont.):
Once every 1000 blocks, an extra block (1001 bits) will have to be
transmitted.
The total overhead for the error detection + retransmission method is
only 2001 bits per megabit of data, versus 10,000 bits for a
Hamming code.
Error-Detecting Codes (4/12)
Calculation of the
polynomial code
checksum.
Error-Detecting Codes (11/12)
What kinds of errors will be detected?
Imaging that a transmission error occurs, so that instead of the bit
string for T(x) arriving, T(x)+E(x) arrives.
Each 1 bit in E(x) corresponds to a bit that has been inverted.
If there are k 1 bits in E(x), k single-bit errors have occurred.
A single burst error is characterized by an initial 1, a mixture of 0s
and 1s, and a final 1, with all other bits being 0.
Error-Detecting Codes (12/12)
Upon receiving the checksummed frame, the receiver divides it by
G(x); that is, it computes [T(x)+E(x)]/G(x).
• T(x)/G(x) is 0, so the result of the computation is simply E(x)/G(x).
• Those errors that happen to correspond to polynomials containing
G(x) as a factor will slip by; all other errors will be caught.
Problem
Ex-5:
Let us assume that m = 3 and n = 4. Find the list of valid datawords and codewords assuming
the check bit is used to indicate even parity in the code word.
Problem
Ex-5:
Let us assume that m = 3 and n = 4. Find the list of valid datawords and codewords assuming
the check bit is used to indicate even parity in the code word.
Solution:
Valid codewords : 0000, 0011, 0101, 0110, 1001, 1010, 1100, 1111
Problem
Ex-6:
a. (10000, 00000)
b. (10101, 10000)
c. (11111,11111)
d.(000, 000)
Problem
Ex-6:
a. (10000, 00000)
b. (10101, 10000)
c. (11111,11111)
d.(000, 000)
Solution:
a. 1
b. 2
c. 0
d. 0
Problem
Ex-7:
Given the codeword of size 4 bit. If the size of dataword is 3 bit. What is the value of
hamming distance for the codeword?
Solution :
Hamming distance = 2
Problem
Ex-8:
To provide more reliability than a single parity bit can give, an error-detecting coding scheme
uses one parity bit for checking all the odd-numbered bits and a second parity bit for all the
even-numbered bits. What is the Hamming distance of this code?
Solution:
Making one change to any valid character cannot generate another valid character due to the nature
of parity bits. Making two changes to even bits or two changes to odd bits will give another valid
character, so the distance is 2.
Problem
Ex-9:
Find the minimum Hamming distance to be implemented in codeword for the following cases:
Solution:
Dataword Codeword
00 00000
01 01011
10 10101
11 11110
What is the dataword transmitted for the following codewords received assuming there is 1 bit
error?
01010
11010
Problem
Ex-10:
Solution:
a. 01
b. 11
Problem
Ex-11:
Sixteen-bit messages are transmitted using a Hamming code. How many check bits are
needed to ensure that the receiver can detect and correct single bit errors? Show the bit
pattern transmitted for the message 1101001100110101. Assume that even parity is used in
the Hamming code.
Problem
Ex-11:
Sixteen-bit messages are transmitted using a Hamming code. How many check bits are
needed to ensure that the receiver can detect and correct single bit errors? Show the bit
pattern transmitted for the message 1101001100110101. Assume that even parity is used in
the Hamming code.
Solution:
Codeword:011110110011001110101
Problem
Ex-12:
An 8 bit message using even-parity Hamming code is received as 101001001111. Find the 8
bit message after getting decoded assuming no error during transmission?
Problem
Ex-12:
An 8 bit message using even-parity Hamming code is received as 101001001111. Find the 8
bit message after getting decoded assuming no error during transmission?
Solution:
Solution:
If we number the bits from left to right starting at bit 1, in this example bit 2 (a parity bit)
is incorrect. The 12-bit value transmitted (after Hamming encoding) was 0xA4F. The
original 8-bit data value was 0xAF.
Ex-14: Problem
Suppose that data are transmitted in blocks of sizes 1000 bits. What is the maximum
error rate under which error detection and retransmission mechanism (1 parity bit per
block) is better than using Hamming code? Assume that bit errors are independent of
one another and no bit error occurs during retransmission.
Solution:
From Eq. (m+r+1)≤2r, we know that 10 check bits are needed for each block in case of
using Hamming code. Total bits transmitted per block are 1010 bits. In case of error
detection mechanism, one parity bit is transmitted per block (i.e.1001). Suppose error
rate is x per bit. Thus, a block may encounter a bit error 1000x times. Every time an
error is encountered, 1001 bits have to be retransmitted. So, total bits transmitted per
block are 1001+1000x × 1001 bits. For error detection and retransmission to be better,
1001 + 1000x × 1001 <1010. So, the error rate must be less than 9 ×10-6.
Problem
Ex-15:
Solution:
The remainder is x2+x +1.
Problem
Ex-16:
Given the dataword 101001111 and the divisor 10111. Show the generation of the CRC
codeword at the sender site (using binary division).
Solution:
Ex-17
A bit stream 10101010 is transmitted using the standard CRC method. The generator
polynomial is x3+x2+1. Show the actual bit string transmitted. Suppose the second bit from the
left is inverted during transmission. Show that this error is detected at the receiver’s end.
Solution:
The frame is 10101010. The generator is 1101. We must append 3 zeros to the message (i.e.
10101010000).The remainder after dividing 10101010000 by 1101 is 110. So actual bit string
transmitted is 10101010110.Since the second bit from left is inverted during transmission, the bits
received are 11101010110. Dividing this by 1101 doesn’t give remainder 0. So the received bits
contain error.
Problem
Ex-18:
A bit stream 10011101 is transmitted using the standard CRC method described in the text.
The generator polynomial is x3 + 1. Show the actual bit string transmitted. Suppose the third
bit from the left is inverted during transmission. Show that this error is detected at the
receiver's end.
Solution:
The frame is 10011101. The generator is 1001. The message after appending three zeros is
10011101000. The remainder on dividing 10011101000 by 1001 is 100. So, the actual bit string
transmitted is 10011101100. The received bit stream with an error in the third bit from the left is
10111101100. Dividing this by 1001 produces a remainder 100, not 0. So the received bits contain
error and needs retransmission.
Problem
Ex-19:
A channel has a bit rate of 4 kbps and a propagation delay of 20 msec. For what range of
frame sizes does stop-and-wait give an efficiency of at least 50%?
Solution:
Efficiency will be 50% when the time required to transmit the frame equals the round-trip
propagation delay. At a transmission rate of 4 bits/msec, 160 bits takes 40 msec. For frame
sizes above 160 bits, stop-and-wait is reasonably efficient.
Problem
Ex-20:
Solution:
To operate efficiently, the sequence space (actually, the send window size) must be large
enough to allow the transmitter to keep transmitting until the first acknowledgement has been
received. The propagation time is 18 ms. At T1 speed, which is 1.536 Mbps (excluding the 1
header bit), a 64-byte frame takes 0.300 msec. Therefore, the first frame fully arrives 18.3
msec after its transmission was started. The acknowledgement takes another 18 msec to get
back, plus a small (negligible) time for the acknowledgement to arrive fully. In all, this time is
36.3 msec. The transmitter must have enough window space to keep going for 36.3 msec. A
frame takes 0.3 ms, so it takes 121 frames to fill the pipe. Seven-bit sequence numbers are
needed.
Elementary Data Link Protocols (1/14)
ASSUMPTION 1:
In the physical layer (PhL), data link layer (DLL), and network layer
(NL) are independent processes that comunicate by passing messages
back and forth.
In many cases, PhL and DLL processes will be running on a
processor inside a special network I/O chip and NL code will be
running on the main CPU.
Elementary Data Link Protocols (2/14)
ASSUMPTION 2:
Machine A wants to send a long stream of data to machine B, using
reliable, connection-oriented service.
Later, we will consider the case where B also wants to send data to A
simultaneously.
A is assumed to have an infinite supply of data ready to send and never
has to wait for data to be produced.
Instead, when A’s DLL asks for data, NL is always able to comply
immediately. This restriction will be dropped later.
Elementary Data Link Protocols (4/14)
ASSUMPTION 3:
Machines do not crash. That is these protocols deal with
communication errors, but not the problems caused by computers
crashing and rebooting.
The packet passed across the interface to DLL from NL is pure data,
whose every bit is to be delivered to the destination’s NL.
The fact that the destination’s NL may interpret part of the packet as
a header is of no concern to DLL.
Elementary Data Link Protocols (5/14)
Library procedures:
• to_physical_layer is for sending a frame
Initially, the receiver just sits around waiting for something to happen
(e.g., a frame has arrived).
• wait_for_event(&event) is for receiver to act
• Variable event tells what happened.
• For example, event=cksum_err means that the checksum is incorrect,
there was a transmission error.
• event=frame_arrival means the inbound frame arrived undamaged.
• The set of possible events differs for the various protocols.
Elementary Data Link Protocols (8/14)
. 9
Elementary Data Link Protocols (9/14)
d) frame_kind is wether there are any data in frame, because some of
protocols distinguish frames containing only control information
from those containing data as well.
c) frame is composed of four fields: kind, seq, ack, and info. The first
three contain control information. These control fields are
collectively called the frame header. A last one may contain actual
data to be transferred.
- kind – whether there are any data in the frame.
- seq – for sequence numbers
- ack – for acknowledgements
- info – in data frame it contains a single packet A number of
procedures are also listed in figure.
Elementary Data Link Protocols (10/14)
Continued €
Some
definitions
needed in the
protocols to
follow.
Protocol Definitions
(ctd.) (11/14)
Some definitions
needed in the
protocols to follow.
These are located in
the file protocol.h.
826501 CN&DC 12
Dr. Refik Samet
Elementary Data Link Protocols (12/14)
We still have unidirectional communication for data frames, but auxiliary ACK
frames (simple tokens of acknowledgment) travel from the other direction.
Design of Stop-and-Wait Protocol
Example
Figure shows an example of communication using this protocol. It is still very
simple.
The sender sends one frame and waits for feedback from the receiver. When the ACK
arrives, the sender sends the next frame.
Note that sending two frames in the protocol involves the sender in four events and
the
receiver in two events.
Flow diagram for Example
Simplex Stop-and-
Wait Protocol