1. 1
1
1
1 tohttps://github.com/syaifulahdan/
DATA COMMUNICATION
Error Control and Data Link Control
Data Communications and Networking
Data Link Layer
Framing
Error Detection : Types of Error
Parity Check
Cyclic Redudancy Check
Error Correction Prosess Diagram
LIne Configuration
Traditional Configuration
Flow Control
Model of Frame Transmission
Reading:
Book Chapter 7
Data and Computer Communications, 8th edition
By William Stallings
Stop and Wait Flow Control
Performance of Stop and Wait
Stopand Wait Link Utilization
Sliding WIndow Flow Control
Sliding WIndow Diagram
Example Sliding WIndow
Performance of Sliding Window
Error Control
Automatic Repeat Request (ARQ)
Stop and Wait (ARQ)
Stop and Wait Diagram
Go Back N (ARQ)
Go Back N Damaged F
Go Back N Lost Frame
Go Back N Damage RR
Go Back N Damage REJ
Go Back N Diagram
Selective Reject ARQ
Selective Reject Diagram
High Level Datalink Control
Frame Structure
2. Data Communications and
Networking
Chapter 7
Error Control and Data Link Control
References:
Book Chapter 6 and 7
Data and Computer Communications, 8th edition,
by William Stallings
3. 3
3
3
3 tohttps://github.com/syaifulahdan/ 3
Data Link Layer
• Objective:
— Achieving reliable communication between two adjacent machines
• Design Issues:
— Framing: data are sent in blocks called frames, the beginning and
end of each frame must be recognized by the receiver.
— Error control: bit errors introduced by the transmission system
should be detected and/or corrected.
— Flow control: the sending station must not send frames at a rate
faster than the receiving station can absorb them.
— Addressing: on a multipoint line, such as a LAN, the identity of the
two stations involved in a transmission must be specified.
— Transmit control information and data on the same line
4. 4
4
4
4 tohttps://github.com/syaifulahdan/ 4
Framing
• Large block of data may be broken up into
small frames at the source because:
—limited buffer size at the receiver
—A larger block of data has higher probability of
error
• With smaller frames, errors are detected sooner, and only
a smaller amount of data needs to be retransmitted
—On a shared medium, such as Ethernet and
Wireless LAN, small frame size can prevent one
station from occupying medium for long periods
5. 5
5
5
5 tohttps://github.com/syaifulahdan/ 5
Framing
• Need to indicate the start and end of a block of data
• Use preamble (e.g., flag byte) and postamble
• If the receiver ever loses synchronization, it can just search for
the flag byte.
• Frame: preamble + control info + data + postamble
• Problem: it is possible that the flag byte’s bit pattern occur in the
data
• Two popular solutions:
— Byte stuffing
• The sender inserts a special byte (e.g., ESC) just before each “accidental”
flag byte in the data (like in C language, “ is replaced with ”).
• The receiver’s link layer removes this special byte before the data are
given to the network layer.
— Bit stuffing: each frame starts with a flag byte “01111110”.
• Whenever the sender encounters five consecutive 1s in the data, it
automatically stuffs a 0 bit into the outgoing bit stream.
• When the receiver sees five consecutive incoming 1 bits, followed by a 0
bit, it automatically deletes the 0 bit.
7. 7
7
7
7 tohttps://github.com/syaifulahdan/ 7
Bit Stuffing
Bit stuffing:
(a) The original data.
(b) The data as they appear on the line.
(c) The data as they are stored in the receiver’s memory after destuffing.
8. 8
8
8
8 tohttps://github.com/syaifulahdan/ 8
Error Detection: Types of Error
• An error occurs when a bit is altered between transmission and
reception
• Single bit errors
— One bit is altered
— Adjacent bits are not affected
— Can occur in the presence of white noise (thermal noise)
• Burst errors
— A cluster of bits with Length B
— the first and the last and a number of intermediate bits in error
(not necessarily all the bits in the cluster suffer an error)
— More common and more difficult to deal with
— Can be caused by impulse noise
9. 9
9
9
9 tohttps://github.com/syaifulahdan/ 9
Error Detection Process
• Additional bits are added by transmitter
for error detection (called error-detecting
codes, or check bits, or checksum)
• Can be used in different network
layers
10. 10
10
10
10 tohttps://github.com/syaifulahdan/ 10
Parity Check
• Append a parity bit to the end of a block of
data
• Value of parity bit is such that the new data
has even (even parity) or odd (odd parity)
number of ones
—E.g., original data 1110001 -> 11100011 (odd
parity)
• Even number of bit errors goes undetected
—E.g., 11100011 -> 11010011 (undetected!)
11. 11
11
11
11 tohttps://github.com/syaifulahdan/ 11
Cyclic Redundancy Check
• For a block of k bits, transmitter generates an
(n-k)-bit sequence called Frame Check
Sequence (FCS)
• The resulting frame consisting of n bits is
exactly divisible by some predetermined
number.
• Receiver divides the incoming frame by the
predetermined number:
—If no remainder, assume no error
12. 12
12
12
12 tohttps://github.com/syaifulahdan/ 12
Cyclic Redundancy Check
• Modulo 2 arithmetic
—Binary addition with no carries
—Binary subtraction with no carries
—The same as XOR operation
1111 + 1010 = 0101
1111 − 0101 =
1010
1010 + 1010 = 0000
13. 13
13
13
13 tohttps://github.com/syaifulahdan/ 13
Cyclic Redundancy Check
• Define:
— T = n-bit frame to be transmitted
— D = k-bit block of data: the first k bits of T
— F = (n-k)-bit FCS: the last (n-k) bits of T
— P = pattern of (n-k+1) bits: the predetermined
divisor
• T = 2n-kD + F
• We want T/P to have no remainder.
• Problem: Given D and P, how to calculate F ?
14. 14
14
14
14 tohttps://github.com/syaifulahdan/ 14
Cyclic Redundancy Check
P
R
Q
P
Dkn
2
quotient
remainder
Step 1:
Step 2: F = R
Verification:
Q
P
R
P
R
Q
P
R
P
D
P
RD
P
T
RDT
knkn
kn
22
2
Problem: Given D and P, how to calculate F ?
15. 15
15
15
15 tohttps://github.com/syaifulahdan/ 15
Cyclic Redundancy Check
• Example:
—Given D = 1010001101 (10 bits)
— P = 110101 (6 bits)
—Then n = 15, k = 10, (n-k) = 5
—Multiple D by 25, yielding 101000110100000
—Divide it by P: remainder R = 01110
—Transmit D+R to the receiver: 101000110101110
—The receiver divide it by P, if no remainder, there
is no error.
16. 16
16
16
16 tohttps://github.com/syaifulahdan/ 16
Cyclic Redundancy Check
• By choosing different P, CRC can detect
different types of errors:
—All single-bit errors if P has more than one
nonzero item
—All double-bit errors if P is a primitive polynomial
—Any odd number of errors if P contain factor 11
—……
17. 17
17
17
17 tohttps://github.com/syaifulahdan/ 17
Error Correction
• Retransmission: correction of detected errors usually
requires data block to be retransmitted
—Retransmission may not be appropriate for some wireless
applications
• Bit error rate in wireless network is high
• Result in lots of retransmissions
—Propagation delay can be long (satellite) compared with
frame transmission time
• Result in retransmission of frame in error plus many subsequent
frames (back to this issue in next chapter)
• It would be desirable to enable the receiver to
correct errors in an incoming transmission on the
basis of the bits in that transmission.
• FEC: forward error correction
19. 19
19
19
19 tohttps://github.com/syaifulahdan/ 19
Line Configuration
• Link Topology
—Physical arrangement of stations on the medium (link)
—Link has two stations: a point-to-point link
—More than two stations: a multipoint link
• local area network, satellite
• Half duplex
—Of two stations, only one station may transmit at a time
—Requires one data path
• Full duplex
—Simultaneous transmission and reception between two
stations
—Digital signaling: requires two data paths (e.g., two twisted
pairs)
—Analog signaling: can use different frequencies
21. 21
21
21
21 tohttps://github.com/syaifulahdan/ 21
Flow Control
• Ensuring the sending entity does not overwhelm the
receiving entity
—Preventing buffer overflow
• Transmission time
—Time taken to emit all bits into medium at the sender’s side
—Determined by the data rate
• Propagation time
—Time for a bit to traverse the link and reach the destination
—Determined by the transmission distance
• We first assume error-free transmission.
23. 23
23
23
23 tohttps://github.com/syaifulahdan/ 23
Stop-and-Wait Flow Control
• Source transmits a frame.
• Destination receives the frame, and replies
with a small frame called acknowledgement
(ACK).
• Source waits for the ACK before sending the
next frame.
—This is the core of the protocol !
• Destination can stop the flow by not sending
ACK (e.g., if the destination is busy …).
24. 24
24
24
24 tohttps://github.com/syaifulahdan/ 24
Performance of Stop-and-Wait
• Assumptions
—Transmission time of the data frame is 1
—Transmission time of the ACK frame is 0
—Propagation time is a
• a is the ratio of propagation time over transmission time
—Error-free transmission
• The channel utilization ratio is 1/(1+2a)
—In a time period of 1+2a, the transmitter is only busy with 1
unit of time.
• It is not efficient for long haul transmission and high
speed transmission.
—Another type of protocol called “sliding-window” is
designed for this situation.
26. 26
26
26
26 tohttps://github.com/syaifulahdan/ 26
Sliding-Window Flow Control
• Idea: allow multiple frames to transmit
—Receiver has a buffer of W frames
—Transmitter can send up to W frames without
receiving ACK
• Each frame needs to be numbered: sequence
number is included in the frame header
—Sequence number is bounded by the length of
“sequence number field” in the header, e.g., k
bits
• Frames are numbered modulo 2k
• ACK includes the sequence number of the
next expected frame by the receiver
28. 28
28
28
28 tohttps://github.com/syaifulahdan/ 28
Example Sliding-Window
Have been
delivered to upper
layer
More spaces for
future frames
RR3 means the receiver has
received all frames up to frame 2
and is ready to receive frame 3.
29. 29
29
29
29 tohttps://github.com/syaifulahdan/ 29
Performance of Sliding-Window
• Assumptions
—Window size is W
—Frame transmission time is 1
—ACK transmission time is 0
—Propagation time is a
—Error-free transmission
• The channel utilization ratio is
1 2 1
2 1
2 1
W a
U W
W a
a
32. 32
32
32
32 tohttps://github.com/syaifulahdan/ 32
Error Control
• Error control: detection and correction of errors
• We consider two types of errors:
— Lost frames
• The receiver cannot recognize that this is a frame.
— Damaged frames
• The receiver can recognize the frame, but some bits are in error.
• Two approaches for error control
— ARQ: automatic repeat request, based on some or all of the
following ingredients:
• Error detection
• Positive acknowledgment
• Retransmission after timeout
• Negative acknowledgement and retransmission
— FEC: forward error correction
33. 33
33
33
33 tohttps://github.com/syaifulahdan/ 33
Automatic Repeat Request
(ARQ)
• The effect of ARQ is to turn an unreliable
data link into a reliable one.
• Three versions of ARQ:
—Stop-and-wait
—Go-back-N
—Selective-reject (or, selective repeat)
34. 34
34
34
34 tohttps://github.com/syaifulahdan/ 34
Stop-and-Wait ARQ
• Based on stop-and-wait flow control
• The source station is equipped with a timer.
• Source transmits a single frame, and waits for an ACK
• If the frame is lost…
— The timer eventually fires, and the source retransmits the frame.
• If receiver receives a damaged frame, discard it
— The timer eventually fires, and the source retransmits the frame.
• If everything goes right, but the ACK is damaged or lost, the
source will not recognize it
— The timer eventually fires, the source will retransmit the frame
— Receiver gets two copies of the same frame!
— Solution: use sequence numbers, 1 bit is enough, i.e., frame0 and
frame1, ACK0 and ACK1
36. 36
36
36
36 tohttps://github.com/syaifulahdan/ 36
Go-Back-N ARQ
• Based on sliding-window flow control
• Use window size to control the number of unacknowledged
frames outstanding
• If no error, the destination will send ACK as usual with next
frame expected (positive ACK, RR: receive ready)
• If error, the destination will reply with rejection (negative ACK,
REJ: reject)
— Receiver discards that frame and all future frames, until the
erroneous frame is received correctly.
— Source must go back and retransmit that frame and all succeeding
frames that were transmitted in the interim.
— This makes the receiver simple, but decreases the efficiency
37. 37
37
37
37 tohttps://github.com/syaifulahdan/ 37
Go-Back-N: Damaged Frame
• Suppose A is sending frames to B. After each
transmission, A sets a timer for the frame.
• In Go-Back-N ARQ, if the receiver detects
error in frame i
—Receiver discards the frame, and sends REJ-i
—Source gets REJ-i
—Source retransmits frame i and all subsequent
frames
38. 38
38
38
38 tohttps://github.com/syaifulahdan/ 38
Go-Back-N: Lost Frame (1)
• Assume receiver has received frame i-1. If
frame i is lost
—Source subsequently sends i+1
• Receiver gets frame i+1 out of order
—At data link layer, this means the lost of a frame!
• Receiver sends REJ-i
• Source gets REJ-i, and so goes back to frame
i and retransmits frame i, i+1, …
39. 39
39
39
39 tohttps://github.com/syaifulahdan/ 39
Go-Back-N: Lost Frame (2)
• Assume receiver has received frame i-1
• Frame i is lost and no additional frame is sent
• Receiver gets nothing and returns neither
acknowledgement nor rejection
• Source times out and sends a request to
receiver asking for instructions
• Receiver responses with RR frame, including
the number of the next frame it expects, i.e.,
frame i
• Source then retransmits frame i
40. 40
40
40
40 tohttps://github.com/syaifulahdan/ 40
Go-Back-N: Damaged RR
• Receiver gets frame i and sends RR-(i+1)
which is lost or damaged
• Acknowledgements are cumulative, so the
next acknowledgement, i.e., RR-(i+n) may
arrive before the source times out on frame i
• If source times out, it sends a request to
receiver asking for instructions, just like the
previous example
41. 41
41
41
41 tohttps://github.com/syaifulahdan/ 41
Go-Back-N: Damaged REJ
• It is equivalent to the case of lost frame (2).
• Source times out and sends a request to
receiver asking for instructions
• Receiver responses with RR frame, including
the number of the next frame it expects
• Source then retransmits
42. 42
42
42
42 tohttps://github.com/syaifulahdan/ 42
Go-Back-N
Diagram
Remark:
RR(P bit = 1) is a special RR which
is used by the source to ask for
instructions.
For a k-bit sequence number, the
window size can be at most 2k-1,
otherwise RR 0 is ambiguous (e.g.,
first sends frame 0 and gets back an
RR1, and then sends frames
1,…,7,0, and gets another RR1).
43. 43
43
43
43 tohttps://github.com/syaifulahdan/ 43
Selective-Reject ARQ
• Also called selective repeat
• Pros:
—Only rejected frames are retransmitted
—Subsequent frames are accepted by the receiver
and buffered
—Minimizes the amount of retransmissions
• Cons:
—Receiver must maintain large enough buffer, and
must contain logic for reinserting the retransmitted
frame in the proper sequence
—Also more complex logic in the source
44. 44
44
44
44 tohttps://github.com/syaifulahdan/ 44
Selective Reject -
Diagram
Remark:
For a k-bit sequence number, the window size
can be at most 2k-1, because the sending and
receiving windows overlap.
Assume k=3, and window size is 5.
1. A sends frames 0, 1, …, 4 to B.
2. B receives all 5 frames, and cumulatively
acknowledges with RR5.
3. RR5 is lost.
4. A times out, and retransmits frame 0.
5. B is expecting a new set of frames 5, 6, 7,
0, 1. So it will accept the retransmitted frame
0 and regard it as a new frame, which is
wrong.
47. 47
47
47
47 tohttps://github.com/syaifulahdan/ 47
Frame Structure
•Flag: delimit frame at both ends
•Address: identify the frame receiver
•Control: specify different frame types
•FCS: frame check sequence (error detecting code)
48. 48
48
48
48 tohttps://github.com/syaifulahdan/ 48
KEY POINTS
• Framing is performed by breaking the
information into small frames. Each frame
uses preamble and postamble to indicate the
start and end.
• Error detection is performed by calculating an
error-detecting code that is a function of the
bits being transmitted.
• Error correction operates in a fashion similar
to error detection but is capable of correcting
certain errors.
49. 49
49
49
49 tohttps://github.com/syaifulahdan/ 49
KEY POINTS
• Data link control protocol provides functions such as
flow control, error detection, and error control.
• Flow control enables a receiver to regulate the flow
of data from a sender so that the receiver’s buffers
do not overflow.
• In a data link control protocol, error control can
achieved by retransmission of damaged frames that
have not been acknowledged or for which the other
side requests a retransmission.