Professional Documents
Culture Documents
Updated Unit IV
Updated Unit IV
(18CSS202J)
Unit IV
Agenda
Framing, Flow Control Mechanisms
Stop Wait Protocol
Goback N ARQ, Selective Reject ARQ
CRC, Checksum
Types of Errors
Forward Error Correction
CSMA, CSMA/CD
Hamming Distance
Error Correction and Detection
HDLC
PPP
Framing, Flow Control Mechanism
Flow & Error Control
Data Link Control
Enquiry/Acknowledgment (ENQ/ACK)
Poll/Select
Flow Control
Frames can be sent one after another i.e. link can carry
several frames at once and its capacity can be used
efficiently
At receiver we got not n-1 data frames but n-1 spaces for frames
As new frames come in the size of the receiver window shrinks
Receiver window does not represent number of frames received but
number of frames that may still be received before an ACK can be
sent.
If a receiver got a window size of w, if three frames are received
without being acknowledged , number of spaces in window is w-3.
As soon as ACK is received , the window expands to include more
spaces for number of frames equal to number of frames
acknowledged
Let us take the receiving window of size 7 i.e 0 through 6
With the arrival of data frame 0, receiving window shrinks moving
from 0 to 1 and receiver window has now shrunk to six frames before
sending an ACK
Once say frames 0 through 3 are received without sending an ACK,
receiving window now shrinks to 3 frame spaces.
Sliding Window
Sender side Stop and Wait Protocol,
Receiver side Stop and Wait Protocol
Stop and Wait
pace.
Too much data arriving before a device can handle it causes data overflow,
Stop and wait for means, whatever the data that the sender wants to send, he
The idea behind the usage of this frame is that when the sender sends the
frame then he waits for the acknowledgment before sending the next frame.
Stop and Wait
Primitives of Stop and Wait Protocol
Sender side
Rule 2: Sender sends the next packet only when it receives the acknowledgment of
the previous packet.
stop and wait protocol on the sender's side is very simple, i.e., send one packet at a
time, and do not send another packet before receiving the acknowledgment.
Stop and Wait
Receiver side
Rule 2: When the data packet is consumed, the receiver sends the
acknowledgment to the sender.
Therefore, the idea of stop and wait for a protocol on the receiver's side is
also very simple, i.e., consume the packet, and once the packet is consumed,
the acknowledgment is sent. This is known as a flow control mechanism.
Stop and Wait ARQ
Stop and Wait
If there is a sender and receiver, then the sender sends the
packet and that packet is known as a data packet.
The sender will not send the second packet without receiving the
acknowledgment of the first packet.
The receiver sends the acknowledgment for the data packet that
it has received.
Once the acknowledgment is received, the sender sends the
next packet.
Stop and Wait
This process continues until all the packets are not sent.
For example, if there are 1000 data packets to be sent, then all
the 1000 packets cannot be sent at a time as in Stop and Wait
for protocol, one packet is sent at a time.
Stop and Wait
Problems occur due to lost data
• Suppose the sender sends the data and the data is lost.
• Suppose the sender sends the data and it has also been
received by the receiver.
• There is also no chance for the sender to send the next packet
as in stop and wait for protocol, the next packet cannot be sent
until the acknowledgment of the previous packet is received
• Suppose the sender sends the data and it has also been
received by the receiver.
Stop and Wait
Problem due to the delayed data or acknowledgment
44
Single Bit Error & Burst Error
45
Single Bit Error & Burst Error
46
Redundancy
47
Redundancy
48
Redundancy Checks in Data
Communication
49
Vertical Redundancy Check
50
Vertical Redundancy Check
51
Vertical Redundancy Check
Example :
If the source wants to transmit data unit 1100111 using even parity
to the destination.
52
Vertical Redundancy Check
Advantages :
• VRC can detect all single bit error.
• It can also detect burst errors but only in those cases where number of
bits changed is odd, i.e. 1, 3, 5, 7, …….etc.
Disadvantages :
• It is not able to detect burst error if the number of bits changed is even,
i.e. 2, 4, 6, 8, …….etc.
53
Longitudinal Redundancy Check
54
Longitudinal Redundancy Check
55
Longitudinal Redundancy Check
Suppose 32 bit data plus LRC that was being transmitted is hit by a burst error of
length 5 and some bits are corrupted as shown
56
Longitudinal Redundancy Check
Advantage :
LRC is used to detect burst errors.
Disadvantage :
It is not able to detect error if two bits in a data unit are damaged and two bits
in exactly the same position in other data unit are also damaged.
57
Cyclic Redundancy Check (CRC)
First a string of 0’s appended to data unit. The number n is less than the number of bits in the
divisor which is n+1
Secondly new elongated data is divided by the divisor using a process of modulo 2 binary
division
Remainder resulting from division is CRC
CRC of n bits derived which is the remainder is appended to the data unit by replacing the
appended 0’s
This data unit arrives at the receiver followed by CRC
Now the receiver divides the data unit by the same divisor to find the remainder
If remainder is 0 it means data is error free and is accepted
If remainder is non zero, data got error and is rejected.
CRC Generator
Remainder is 0111 through modulo 2 division which is added to the data unit by
replacing the appended 0’s to get 1111101000+ 0111= 1111101111
Receiver divides the appended data unit by the divisor to see if remainder is zero.
If zero it is error free
68
Checksum
69
Checksum
70
At the sender
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
• When the information received at the receiver end does not match
the sent data.
• At the time of transmission, errors are introduced into the binary
data sent from the sender to the receiver due to noise during
transmission.
• This means that a bit having a 0 value can change to 1 and a bit
having a 1 value can change to 0.
• Types of Errors
• Single-bit Error
• Multiple-bit Error
• Burst Error
Single-bit Error
• Typically, only one bit of the
frame received is corrupt, and
he corrupted bit can be located
anywhere in the frame.
• Single-Bit Error does not appear more
likely in Serial Data Transmission.
• Single-Bit Error mainly occurs in Parallel
Data Transmission. For example, if eight
wires are used to send the eight bits of a
byte, if one of the wire is noisy, then
single-bit is corrupted per byte.
Multiple-bit Error
• More than one bit received in the frame
is found to be corrupted.
Burst Error
• More than one consecutive bit is
corrupted in the received frame.
• The Burst Error is determined from the
first corrupted bit to the last corrupted
bit.
• The duration of noise in Burst Error is
more than the duration of noise in
Single-Bit.
• Burst Errors are most likely to occurr in
Serial Data Transmission.
• The number of affected bits depends on
the duration of the noise and data rate.
Forward Error correction
Forward Error Correction
1=1, 2=2, 3= 1+2, 4=4, 5= 1+4, 6= 2+4, 7= 1+2+4, 8=8, 9= 1+8, 10=
2+8, 11= 1+2+8
so now r1= 1,3, 5, 7, 9, 11; r2= 2,3,6,7,10,11; r4= 4,5, 6,7; r8= 8,9,10,11
Example
Hamming Code
• Now we write the parity bit for each of the r value . For
example parity bit of r1 is calculated to provide even
parity of combination 3,5,7,9,11 which sees odd number
of 1’s and we add 1 to r1. Similarly we perform for r2, r4
and r8 ending in the final code as 10011100101
• Now the code is sent to the receiver say 10010100101and
receiver calculates the four new VRC’s using the same set
of bits used by sender plus relevant parity bits (r1,r2,r4,
r8) for each set
• Then receiver reassembles new parity values into a
binary number in order of r position (r8, r4, r2, r1) which
results in 0111.
• That is bit 7 is the error and is corrected to give
10010100101
Single-bit error
Error
Detection
CSMA
Error Detection Techniques
• Data Link Layer uses various error detection techniques to attain
certain level of accuracy.
• Errors are classified into
• Single Bit Error
At each instance, a station that has data to send uses a procedure defined by
the protocol to make a decision on whether or not to send.
This procedure depends on the state of the medium whether it is idle or busy.
Reason for Random Access or Contention
Random access methods we would be studying have evolved from a very interesting
protocol known as ALOHA which uses a very simple procedure called Multiple Access
(MA)
Method was later improved with the addition of procedure that forces the station to
sense the medium before transmitting. This was called Carrier Sense Multiple Access
CSMA can reduce the possibility of collision but cannot eliminate it.
When a station sends a frame and any other station sends a frame during this time,
a collision will result.
But if the first bit of frame reaches the end of medium, every station will have
heard the bit and will refrain from sending.
Figure in next slide shows the worst case where a frame sent by station A at time t 1
If the medium is busy it waits until it becomes idle and sends its
frame with a probability of 1.
In this method, a station monitors the medium after it sends a frame to see
if the transmission was successful
Before sending the last bit of frame, sending station must detect collision , if any
must abort the transmission
Reason for this is a station once sent the entire frame does not monitor the line for
collision detection
If two stations involved in collision are maximum distance apart, signals from first
takes time Tp to reach the second and effect of collision takes another time T p to
reach the first.
Solution
The frame transmission time is Tfr = 2 × Tp = 51.2 μs. This means, in the worst
case, a station needs to transmit for a period of 51.2 μs to detect the collision.
The minimum size of the frame is 10 Mbps × 51.2 μs = 512 bits or 64 bytes.
This is actually the minimum size of the frame for Standard Ethernet.
Error Detection and Correction using
Hamming Code
Hamming Code
• Basic Idea:
• Codeword = Data bits + Redundancy/Check bits
• Redundant bits are added to check whether the data is correct or some errors have
been taken place
• Valid vs. Invalid Codewords: Set of codewords of same size (number of
bits) used to interpret all data symbols is called valid codewords, while
the set of codewords which does not belong to this set is called invalid
codewords
• Both valid and invalid codewords are known to both sender and receiver in
transmission
• A single bit error can transfer a valid codeword to an invalid codeword
• Distance between codewords: The distance between two codewords Ci
and Cj, denoted as Dist (Ci , Cj), is the number of bit positions, the
codewords differ
Hamming Code
• Error Detection:
• For a single bit error detection, the distance between any
pair of valid codewords must be at least 2
• Suppose C1 and C2 are two valid codewords and the distance
between C1 and C2 is 1: C1 = 101101 and C2 = 101100 (the
last bit differs)
• Due to single bit error in C2 in the last bit position, C2
becomes C1, also a valid codeword
• Error detection fails
• If the distance is 2, a single bit error still make their difference
at least 1
• Error detection successful
• For detecting k errors, the distance must be at least (k+1)
Hamming Code
• Error Correction:
• Received codeword with bit errors can only be corrected if we can
determine the bit positions where the bit errors have been taken place
• After correction, the received codeword will be converted to one and only one
valid codeword
• For single bit error correction, the distance must be at least 3
Distance = 2 Distance = 3
Sent: 100100 100111 000100 100111
C1 C2 C1 C2
Received: 100101 = 100101 000101 ≠ 100101
100101
100101
000101
110101
Invalid 001101 Invalid
101101 codewords codewords
000111
100001
100100 000100
Valid
Valid 100111 codewords
100111
codewords
Hamming Code
• Illustration of k bit Error Correction:
• For k bit error correction, the distance must be at least (2k+1)
Distance = 2k
Common Part K bit K bit Unchanged Part K bit changed
C1
C2
C1
C2
1 K bit changed
Common Part
bit
K bit K bit Distance = 2k+1
Hamming Code
f8 f4 f2 f1
Step 4: Now we perform even parity check for each column of the
above table. Set a parity bit to 1 to ‘f1’ if the total number of ones
in the corresponding positions of its column is
odd. Set a parity bit to 0 if the total number of ones in the positions
it checks is even. Then, we repeat this process for ‘f2’, ‘f4’, ‘f8’ and
so on.
Hamming Code
Example: Suppose we have to transmit a data block 7 bits: 1001101. We
need to generate a hamming code of this data block.
Step 1: We need to determine minimum value of ‘r’ first, where 2r >= 7+r+1.
We find r = 4.
Step 2: The codeword will be looked like as follows:
11 10 9 8 7 6 5 4 3 2 1
1 0 0 f8 1 1 0 f4 1 f2 f1
Step 3 & 4: Determination of redundancy bits:
f1 depends upon the bits in the positions of 3, 5, 7, 9, 11. Number of ones
is 3, which is odd. To make it even, the redundancy bit f1 will be 1
f2 depends upon the bits in the positions of 3, 6, 7, 10 and 11. Number of
ones is 4, which is even. So, the redundancy bit f2 will be 0
Following the similar procedure, the value of f4 and f8 will be 0 and 1
respectively
Hence the final codeword will be as follows:
11 10 9 8 7 6 5 4 3 2 1
1 0 0 1 1 1 0 0 1 0 1
Hamming Code
Illustration:
f1
f2
f4
f8
Hamming Code
• Error Detection and Correction:
Suppose in the above example the 5th bit is changed from 0 to 1
during data transmission, then it gives new parity values for the
codeword:
11 10 9 f8 7 6 5 f4 3 f2 f1 11 10 9 f8 7 6 5 f4 3 f2 f1
1 0 0 1 1 1 0 0 1 0 1 1 0 0 1 1 1 1 0 1 0 1
Determine x and y.
b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1
Answer: Codeword is: d8 d7 d6 d5 c8 d4 d3 d2 c4 d1 c2 c1
▪ b1 ⊕ b3 ⊕ b5 ⊕ b7 ⊕ b9 ⊕ b11 = 0 🡺 c1 ⊕ d1 ⊕ d2 ⊕ d4 ⊕ d5 ⊕ d7 = 0
🡺0⊕1⊕0⊕0⊕x⊕1=0🡺x=0
▪ b2 ⊕ b3 ⊕ b6 ⊕ b7 ⊕ b10 ⊕ b11 = 0 🡺 c2 ⊕ d1 ⊕ d3 ⊕ d4 ⊕ d6 ⊕ d7 =
0 🡺 1 ⊕ 1 ⊕ 1 ⊕ 0 ⊕ 0 ⊕ 1 = 0 (No x or y)
▪ b4 ⊕ b5 ⊕ b6 ⊕ b7 ⊕ b12 = 0 🡺 c4 ⊕ d2 ⊕ d3 ⊕ d4 ⊕ d8 = 0 🡺 0 ⊕ 0 ⊕
1 ⊕ 0 ⊕ 1 = 0 (No x or y)
▪ b8 ⊕ b9 ⊕ b10 ⊕ b11 ⊕ b12 = 0 🡺 c8 ⊕ d5 ⊕ d6 ⊕ d7 ⊕ d8 = 0 🡺 y ⊕ x
⊕ 0 ⊕ 1 ⊕ 1 = 0 🡺 y =0
Correction
Vs
Detection
Error Detection Techniques
• Data Link Layer uses various error detection techniques to attain
certain level of accuracy.
• Errors are classified into
• Single Bit Error
• Multiple Bit Error
• Burst Error Error
• Error control mechanism involves two ways
• Error Detection
• Error Correction
Error Control Techniques
• Error control mechanism involves two ways
• Error Detection
• Error Correction
• Error Detection
• Error detection involves checking whether any error has occurred or not. The
number of error bits and the type of error does not matter
• Error Detecting Codes (Implemented either at Data link layer or Transport
Layer of OSI Model)
• Some popular techniques for error detection are:
• Simple Parity check
• Two-dimensional Parity check
• Checksum
• Cyclic redundancy check
Error Detection Techniques
• Simple Parity check
• Blocks of data from the source are subjected to a check bit or parity bit
generator form, where a parity of :
• 1 is added to the block if it contains odd number of 1’s, and
• 0 is added if it contains even number of 1’s
Error Detection Techniques
• Two-dimensional Parity check
• Parity check bits are calculated for
each row, which is equivalent to a
simple parity check bit.
• Parity check bits are also calculated
for all columns, then both are sent
along with the data.
• At the receiving end these are
compared with the parity bits
calculated on the received data.
Error Detection Techniques
• Checksum
• In checksum error detection scheme, the
data is divided into k segments each of m
bits.
• In the sender’s end the segments are
added using 1’s complement arithmetic to
get the sum. The sum is complemented to
get the checksum.
• The checksum segment is sent along with
the data segments.
• At the receiver’s end, all received
segments are added using 1’s complement
arithmetic to get the sum. The sum is
complemented.
• If the result is zero, the received data is
accepted; otherwise discarded.
Error Detection Techniques
Detection of errors and reconstruction of the original Detection of errors caused by Noise or other
error free data or signal impairments during transmission from the
transmitter to the receiver
Error-correcting codes are usually distinguished Error detection is most commonly realized using a
between convolutional codes and block codes. suitable hash function(or specifically, a check sum,
cyclic redundancy check or other algorithm).
Unbalanced Mode
Commands
Primary
Responses
Secondary Secondary
Balanced
mode
Combined Combined
commands/Responses
HDLC
Both the above modes mean that the secondary node is logically
disconnected from the primary node
• Initialization Mode
• A node negotiates transmission parameters with the other node E.g., flow
control information
• Parameters negotiated in this mode are used during any of the data
transfer modes
Data Link Control HDLC frame structure
(a) Frame
Format
(b) Control
field
format
Data Link Control
HDLC frame structure
• Flag: 01111110- start and ending delimiter. Bits are stuffed for flags in data frames
• FCS: 16-bit CRC using generating polynomial
G(x) = x16 + x12 + x5 + 1
• Address field:
• mainly used in multidrop link configuration, and not used in point-to-point
• In unbalanced configuration, every secondary is assigned a unique address. Contains
address of secondary station in both command and response frames
• In balanced mode, command frame has destination address and response frame has sending
node’s address
• Group addresses are also possible. E.g., One command sent to all the secondaries
• In I-frames, N(s) is the sequence number of the frame being sent, and R(s) is the
sequence number of the frame being expected.
• The P/F bit, known as the poll/final bit, is used with different meaning in different
contexts.
• It is used to indicate polling, to indicate the final I-frame, etc
HDLC
• Services
• Framing
• Error control
• Reliability
• Connection management
• Medium access control
• Switching
• Protocols, Standards
• Ethernet
• Token Ring
• FDDI
• Wireless
• PPP
• HDLC
PPP
The Data Link Layer in the Internet
A home personal computer acting as an internet host.
158
PPP Design Requirements (cont.)
159
PPP non-requirements
• No error correction/recovery
(modems do one layer FEC, one layer packetization +
retransmission “under the covers” anyway; other
technologies are pretty reliable)
• No flow control
• Out of order delivery OK
160
PPP Data Frame
161
PPP Data Frame
162
Byte Stuffing
flag byte
pattern
in data
to send
164
Where does PPP get used?
165