Download as pdf or txt
Download as pdf or txt
You are on page 1of 94

BITS 1313

DATA COMMUNICATION
& NETWORKING
Lecture 07/08

Data Link (Flow) and Error Control


Flow and Error Control

Flow Control (Kawalan Aliran)

Error Control (Kawalan Ralat)


Flow and Error Control
Flow Control (Kawalan Aliran)
refers to a set of procedures used to restrict the
amount of data that the sender can send before
waiting for acknowledgment.

Error Control (Kawalan Ralat)


in the data link layer is based on automatic repeat
request, which is the retransmission of data.
Acknowledgement
• In data networking and telecommunications, an
acknowledgement (ACK) is a signal that is passed
between communicating processes, computers, or
devices to signify acknowledgement, or receipt of
message, as part of communications protocol.

5
Lecture 07

Data Link (Flow) Control


Type of Flow Control

Stop & Wait Selective Repeat


ARQ
Go-Back-N ARQ
Stop-and-Wait ARQ
Stop-and-Wait ARQ

Normal operation

Lost Frame
Lost ACK frame
Delayed ACK frame
Normal operation Stop- And- Wait ARQ

eH
lost frame Stop- And- Wait ARQ

eH
lost ACK frame Stop- And- Wait ARQ

eH
delayed ACK Stop- And- Wait ARQ

eH
Note:

In Stop-and-Wait ARQ, numbering


frames prevents the retaining of
duplicate frames.

Numbered acknowledgments are


needed if an acknowledgment is
delayed and the next frame is lost.
Piggybacking Stop- And- Wait ARQ
Go-Back-N ARQ
Go-Back-N ARQ

Sequence Number

Sender and Receiver Sliding Window


Control Variables and Timers
Acknowledgment

Resending Frames

Operation
Sender sliding window Go- Back- N ARQ
Receiver sliding window Go- Back- N ARQ
Control variables Go- Back- N ARQ
normal operation Go- Back- N ARQ
lost frame Go- Back- N ARQ
sender window size Go- Back- N ARQ
Selective-Repeat ARQ
Selective-Repeat ARQ

Sender and Receiver Windows

Operation

Sender Window Size

Bidirectional Transmission

Pipelining
sender and receiver windows Selective Repeat ARQ
lost frame Selective Repeat ARQ
Note:

In Selective Repeat ARQ, the size of


the sender and receiver window must
be at most one-half of 2m.
sender window size Selective Repeat ARQ
Lecture 08

Error Control
What’s an “error”?

• Human errors:
– Incorrect IP address assignment, or subnet mask, etc., etc.

• Network errors:
– Lost data
– Corrupted data (received, but garbled)
Basic concepts

• Networks must be able to transfer data from


one device to another with complete
accuracy.
• Data can be corrupted during
transmission.
• For reliable communication, errors must be
detected and corrected.
• Error detection and correction are
implemented either at the data link layer or
the transport layer of the OSI model.
32
Line Noise and Distortion Errors

Source Likely cause


Line outage Storm, accident

White noise Movement of electrons

Impulse noise Random spikes of power

Cross-talk Guardbands, wires too close

Echo Reflective feedback

Jitter Timing irregularities

Delay distortion Propagation speed

Attenuation Wires too long


Error Prevention

• To prevent errors from happening, several techniques


may be applied:
– Proper shielding of cables to reduce interference
– Telephone line conditioning or equalization
– Replacing older media and equipment with new, possibly digital
components
– Proper use of digital repeaters and analog amplifiers
– Observe the stated capacities of the media
Types of Errors
Types of Errors
Single-bit error

eH
Single bit errors are the least likely
type of errors in serial data
transmission because the noise must
have a very short duration which is
very rare. However this kind of errors
can happen in parallel transmission.
Example:
If data is sent at 1Mbps then each bit
lasts only 1/1,000,000 sec. or 1 μs.
For a single-bit error to occur, the noise
must have a duration of only 1 μs,
which is very rare.
eH
Multiple bit error

eH
Burst error

eH
The term burst error means that two
or more bits in the data unit have
changed from 1 to 0 or from 0 to 1.

Burst errors does not necessarily


mean that the errors occur in
consecutive bits, the length of the
burst is measured from the first
corrupted bit to the last corrupted bit.
Some bits in between may not have
been corrupted.
eH
Burst error is most likely to happen in
serial transmission since the duration of
noise is normally longer than the duration of
a bit.
The number of bits affected depends on the
data rate and duration of noise.
Example:
If data is sent at rate = 1Kbps then a noise of
1/100 sec can affect 10 bits.(1/100*1000)

If same data is sent at rate = 1Mbps then a noise


of 1/100 sec can affect 10,000 bits.(1/100*106)
eH
Question

Why a burst error is more likely to occur than


a single bit erroe?

Because of the the duration of noise. It is


normally longer than the duration of 1 bit,
which means that when noise affects data, it
affects a set of bits.

eH
Error Detection and
Correction
Error detection

Error detection means to decide whether the


received data is correct or not without
having a copy of the original message.

Error detection uses the concept of


redundancy, which means adding extra
bits for detecting errors at the destination.
Error Detection Methods

• The only way to do error detection and correction is to


send extra data with each message
• Two common error detection methods:
– Parity checking
• Simple parity
• Longitudinal parity
– Cyclic redundancy checksum (CRC)
Simple Parity

• Add an additional bit to each byte in the message:


– Even parity causes the sum of all bits (including the parity bit) to
be even
– Odd parity causes the sum of all bits to be odd

1 Even parity
0 1 0 1 0 1 0
0 Odd parity
Example

Letter 7-bit ASCII Parity bit

D 1 0 1
0 1
0 1 0 0 1

A 1 0 0 0 0 0 1 1

T 1 0 1 0 1 0 0 0

A 1 0 0 0 0 0 1 1
Longitudinal Parity

• Add block check character (BCC) to the end of the


message:
– Perform odd parity checking on the block of bits for each
character in the message

0 1 0 1 0 1 0 0
1 0 0 1 1 1 0 1
BCC 0 0 1 1 0 1 1 1
Example

Letter 7-bit ASCII Parity bit


D 1 0 1 1 0
0 0 1 0 1
A 1 0 1
0 0 0 1
0 1 1
T 1 0 1 0 1 0 0 0
A 1 0 0 0 0 0 1 1
BCC 1 1 0 1 1 1 1 1
Parity Checks

• Both simple parity and longitudinal parity do not catch all


errors
• Simple parity only catches odd numbers of bit errors
• Longitudinal parity is better at catching errors
– But requires too many check bits added to a block of data
• We need a better error detection method
– What about cyclic redundancy checksum?
Arithmetic Checksum

• Used in TCP and IP on the Internet


• Characters to be transmitted are converted to numeric
form and summed
• Sum is placed in some form at the end of the
transmission
• Receiver performs same conversion and summing and
compares new sum with sent sum
• TCP and IP processes a little more complex but idea is
the same
Polynomial Checking
• Adds a character (or series of characters) to the end of the
message based on a mathematical algorithm:
– Checksum
• Sum the message values and divide by 255. The remainder is the
checksum

D 68
A 65 282
= 1 remainder 27
T 84 255
A 65
Checksum 0 0 1 1 0 1 1 1
Cyclical redundancy check

• CRC error detection method treats packet of data to be transmitted


as a large polynomial
• Transmitter
– Using polynomial arithmetic, divides polynomial by a given generating
polynomial
• Quotient is discarded
– Remainder is “attached” to the end of message
• Message (with the remainder) is transmitted to the receiver
• Receiver divides the message polynomial plus the remainder
(checksum) by same generating polynomial
• If a remainder of zero results  no error during transmission
• If a remainder not equal to zero results  error during transmission
Example: CRC

7 6 5 4 3 2 1 0
0 0 1 1 0 1 1 1

Message polynomial
x5+x4+x2+x1+x0  x5+x4+x2+x+1

Generating polynomial
ATM CRC x8 + x2 + x + 1
CRC-16 x16 + x15 + x2 + 1
56
Error Control

• Once an error is detected, the receiver can:

1. Toss the frame/packet


❖ Some newer systems such as frame relay perform this type of
error control
2. Return an error message to the transmitter
❖ Stop-and-wait error control
❖ Sliding window error control
3. Fix the error with no further help from the transmitter
Toss frame/packet

• Seems like a strange way to control errors but some


lower-layer protocols such as frame relay perform this
type of error control
• For example, if frame relay detects an error, it simply
tosses the frame
• No message is returned
• Frame relay assumes a higher protocol (such as TCP/IP)
will detect the tossed frame and ask for retransmission
Return A Message

• Once an error is detected, an error


message is returned to the transmitter
• Two basic forms:
– Stop-and-wait error control
– Sliding window error control
Stop-and-wait Error Control
• A transmitter sends a
frame then stops and
waits for an
acknowledgment
• If a positive
acknowledgment (ACK)
is received, the next
frame is sent
• If a negative
acknowledgment (NAK)
is received, the same
frame is transmitted
again
Sliding Window Error Control

• These techniques assume that multiple frames are in


transmission at one time
• A sliding window protocol allows the transmitter to send
a number of data packets at one time before receiving
any acknowledgments
– Depends on window size
• When a receiver does acknowledge receipt, the returned
ACK contains the number of the frame expected next
• Older sliding window protocols numbered each frame or
packet that was transmitted
• More modern sliding window protocols number each
byte within a frame
• Notice that an ACK is not always sent after each frame is
received
– It is more efficient to wait for a few received frames before returning
an ACK
• How long should you wait until you return an ACK?
62
TCP/IP
• Rule 1: If a receiver just received data
and wants to send its own data,
piggyback an ACK along with that data
• Rule 2: If a receiver has no data to
return and has just ACKed the last
packet, receiver waits 500 ms for
another packet
– If while waiting, another packet arrives,
send the ACK immediately
• Rule 3: If a receiver has no data to
return and has just ACKed the last
packet, receiver waits 500 ms
– No packet, send ACK
Packet Lost
• If a frame is lost, the
following frame will be
“out of sequence”
– The receiver will hold the
out of sequence bytes in a
buffer and request the
sender to retransmit the
missing frame
ACK
Lost
• If an ACK is lost, the
sender will wait for the
ACK to arrive and
eventually time out
– When the time-out occurs,
the sender will resend the
last frame
Correct the Error

• For a receiver to correct the error with no further help


from the transmitter requires a large amount of
redundant information to accompany the original data
– This redundant information allows the receiver to determine the
error and make corrections
• This type of error control is often called forward error
correction and involves codes called Hamming codes
– Hamming codes add additional check bits to a character
• These check bits perform parity checks on various bits
• For example, what if bit b9 flips?
– The c8 check bit checks bits b12, b11, b10, b9 and c8 (01000)
• This would cause a parity error
– The c4 check bit checks bits b12, b7, b6, b5 and c4 (00101)
• This would not cause a parity error (even number of 1s)
– The c2 check bit checks bits b11, b10, b7, b6, b3 and c2 (100111)
• This would not cause a parity error
– The c1 check bit checks b11, b9, b7, b5, b3 and c1 (100011)
• This would cause a parity error
– Writing the parity errors in sequence gives us 1001, which is binary for
the value 9
• Thus, the bit error occurred in the 9th position

67
Redundancy
Four types of redundancy checks are used
in data communications
Vertical Redundancy Check
VRC
Performance

It can detect single bit error


It can detect burst errors only if the total
number of errors is odd.
Longitudinal Redundancy Check
LRC
Performance

LCR increases the likelihood of detecting


burst errors.
If two bits in one data units are damaged
and two bits in exactly the same positions in
another data unit are also damaged, the LRC
checker will not detect an error.
VRC and LRC
Cyclic Redundancy Check
CRC
Cyclic Redundancy Check
• Given a k-bit frame or message, the
transmitter generates an n-bit
sequence, known as a frame check
sequence (FCS), so that the resulting
frame, consisting of (k+n) bits, is
exactly divisible by some
predetermined number.
• The receiver then divides the incoming
frame by the same number and, if there
is no remainder, assumes that there
was no error.
Binary Division
We can use a polynomial to represent a
divisor binary word.

Each bit from right to left is mapped onto


a power term.
Using
Polynomials The rightmost bit represents the “0”
power term. The bit next to it the “1”
power term, etc.
If the bit is of value zero, the power term
is deleted from the expression.

78
Figure 10.21 A polynomial to represent a divisor binary word

79
CRC division using polynomials • The dataword 1001 is represented as
x3 + 1. The divisor 1011 is represented
as x3 + x + 1.
• To find the augmented dataword, we
have left-shifted the dataword 3 bits
(multiplying by x3). The result is x6 + x3.
• Division is straightforward. We divide
the first term of the dividend, x6, by the
first term of the divisor, x3. The first
term of the quotient is then x6/x3, or x3.
• Then we multiply x3 by the divisor and
subtract (according to our previous
definition of subtraction) the result from
the dividend. The result is x4, with a
degree greater than the divisor’s
degree; we continue to divide until the
degree of the remainder is less than
the degree of the divisor.

80
Checksum
At the sender
The unit is divided into k sections, each of
n bits.
All sections are added together using
one’s complement to get the sum.
The sum is complemented and becomes
the checksum.
The checksum is sent with the data
At the receiver
The unit is divided into k sections, each of
n bits.
All sections are added together using
one’s complement to get the sum.
The sum is complemented.
If the result is zero, the data are accepted:
otherwise, they are rejected.
Performance
The checksum detects all errors involving
an odd number of bits.
It detects most errors involving an even
number of bits.
If one or more bits of a segment are
damaged and the corresponding bit or bits
of opposite value in a second segment are
also damaged, the sums of those columns
will not change and the receiver will not
detect a problem.
Error Correction
It can be handled in two ways:
1) receiver can have the sender retransmit
the entire data unit.
2) The receiver can use an error-correcting
code, which automatically corrects
certain errors.
Single-bit error correction
To correct an error, the receiver reverses the
value of the altered bit. To do so, it must know
which bit is in error.
Number of redundancy bits needed
• Let data bits = m
• Redundancy bits = r
Total message sent = m+r
The value of r must satisfy the following
relation:
2r ≥ m+r+1
Error Correction
Hamming Code
Hamming Code
Hamming Code
Example of Hamming Code
Single-bit error
Error
Detection
Any
Questions?

You might also like