Professional Documents
Culture Documents
R19 CNSA - Unit 2
R19 CNSA - Unit 2
R19 CNSA - Unit 2
UNIT – II
LINK LAYER
Contents
• Transmission at data link layer starts with breaking up the bit stream
- Into discrete frames
- Computation of a checksum for each frame and
- Include the checksum into the frame before it is transmitted
• Burst error - Two or more bits in the data unit have changed.
Error Detection and Correction - Redundancy
• To detect or correct errors, extra (redundant) bits are added along
with the data.
• Two basic strategies to deal with errors:
- Include only enough redundancy to allow the receiver to
deduce that an error has occurred (but not which error).
Error detecting codes.
• Ratio of redundant bits to data bits and robustness of the process are
important in coding schemes.
• The receiver receives 011. It is a valid codeword. The receiver extracts the
dataword 01 from it.
• The codeword is corrupted during transmission and 111 is received. This is not a
valid codeword and is discarded.
• We add 3 redundant bits to the 2-bit dataword to make 5-bit codeword. Table
shows the datawords and codewords.
• Assume the dataword is 01. The sender creates the codeword 01011.
• The codeword is corrupted during transmission, and 01001 is received. First,
the receiver finds that the received codeword is not in the table. This means an
error has occurred.
• The receiver, assuming that there is only 1 bit corrupted, uses the following
strategy to guess the correct dataword.
Example (Contd.)
• Comparing the received codeword with the first codeword in the table (01001
versus 00000), the receiver decides that the first codeword is not the one that
was sent because there are two different bits.
• By the same reasoning, the original codeword cannot be the third or fourth
one in the table.
• The original codeword must be the second one in the table because this is the
only one that differs from the received codeword by 1 bit. The receiver
replaces 01001 with 01011 and consults the table to find the dataword 01.
Hamming Distance
• One of the key concepts in coding for error control is Hamming distance.
• The Hamming distance between two words is the number of differences
between the corresponding bits.
• The minimum Hamming distance, dmin is the smallest Hamming distance
between all possible pairs in a set of words which is used for designing a
code.
Ex: Let us find the Hamming distance between two pairs of words.
Solution:
•Error Correction:
• To guarantee the correction of up to ‘t’ errors in all cases, the minimum
Hamming distance in a block code must be dmin = 2t + 1.
2. One single-bit error changes a1 . The received codeword is 10011. The syndrome is 1. No
dataword is created.
3. One single-bit error changes r0 . The received codeword is 10110. The syndrome is 1. No
dataword is created.
4. An error changes r0 and a second error changes a3 .The received codeword is 00110. The
syndrome is 0. The dataword 0011 is created at the receiver. Note that here the dataword
is wrongly created due to the syndrome value.
5. Three bits a3, a2, and a1 are changed by errors. The received codeword is 01011. The
syndrome is 1. The dataword is not created. This shows that the simple parity check,
guaranteed to detect one single error, can also find any odd number of errors.
Two-dimensional parity-check code
• Performance can be improved by using two-dimensional parity check.
• The whole table is sent to the receiver, which finds the syndrome for
each row and each column.
Two-dimensional parity-check code
Two-dimensional parity-check code
Hamming Codes
• Single parity bit can only detect error, not correct it.
• Hamming code is an important error correcting code that requires more than a
single parity bit.
r0 = a2 + a1 + a0 s 0 = b2 + b 1 + b 0 + q 0
r1 = a3 + a2 + a1 s1 = b3 + b2 + b1 + q1
r2 = a1 + a0 + a3 s2 = b1 + b0 + b3 + q2
Logical decision made by the correction logic analyzer:
• The words are then sent column by column. When a burst error occurs,
it will affect 1 bit in several words as the transmission is read back into
the block format and each word is checked individually.
Burst error correction using Hamming code
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 along with the checksum to get the sum.
• The sum is complemented. If the result is zero, the received data is
accepted; otherwise it is discarded.
• The checksum detects all errors involving an odd number of bits. It also
detects most errors involving even number of bits.
Example
Cyclic Codes
• Cyclic codes are special linear block codes with one extra property.
• It is done to make flow control and error control efficient. Frames can be
of fixed or variable size.
Byte stuffing -
Process of adding
1 extra byte
whenever there is
a flag or escape
character in the
text.
Bit Oriented Protocols
• Data section of a frame is a sequence of bits to be interpreted as text,
graphic, audio, video and so on..
• In addition to header and possible trailers, a delimiter is used to
separate one frame from the other.
• Most protocols use a special 8-bit pattern flag 01111110 as delimiter.
• If the flag pattern appears in the data, we stuff 1 bit to prevent the
pattern from looking like a flag – BIT STUFFING.
• If a 0 is followed by 5 consecutive 1’s, an extra 0 bit is added regardless
of the next bit.
• This guarantees that the flag sequence does not appear in the frame.
A Frame In a Bit-Oriented Protocol
• Flow control refers to a set of procedures that tells the sender how much
data it can send before waiting for an acknowledgment from the receiver.
• The flow of data must not be allowed to overwhelm the receiver. Most of
the receivers are provided with buffers for storing incoming data until
they are processed. If buffer is full, receiver asks to halt the transmission.
• Unidirectional protocol.
• Sender cannot send a frame until network layer has packet to send.
• Receiver cannot deliver packet to network layer until a frame arrives.
• When the frames arrive at receiver, they are checked and if it is corrupted, it is
silently discarded. Detection is manifested by the silence of the receiver.
• Receiver has buffer ‘W’ long and we can send up to ‘W’ frames without
ACK.
• Sliding window defines the range of sequence numbers that is the concern
of sender and receiver.
• The send window is an imaginary box with three variables: S f, Sn, Ssize.
• Receiver has only one variable, Rn, that holds the sequence number of the
frame it expects to receive.
Sender Sliding Window
• If the frames are damaged/out of order, receiver is silent and discard all
subsequent frames until it receives the one it is expecting.
• The silence of the receiver causes the timer of the unacknowledged frame to
expire. Then the sender resends all frames, beginning with the one with the
expired timer.
• For example, suppose the sender has sent frame 6, but the timer for frame 3
expires (i.e. frame 3 has not been acknowledged), then the sender goes back and
sends frames 3, 4, 5, 6 again. Thus it is called Go-Back-N-ARQ.
• The receiver does not have to acknowledge each frame received, it can send one
cumulative ACK for several frames.
Go-Back-N ARQ, Normal Operation
• The sender keeps track of the outstanding frames and updates the
variables and windows as the ACKs arrive.
Go-Back-N ARQ, lost Frame
• Frame 2 is lost.
• When the receiver receives frame 3, it discards frame 3 as it is expecting
frame 2 (according to window).
• After the timer for frame 2 expires at the sender site, the sender sends
frame 2 and 3 (go back to 2).
Go-Back-N ARQ, Sender Window Size
• Size of the sender window must be less than 2m .
• Size of the receiver is always 1.
• If m = 2, window size = 2m – 1 = 3.
• Fig. compares a window size of 3 and 4.
Accepts as
the 1st
frame in
the next
cycle-an
error
Design of Go-Back-N ARQ
Selective Repeat ARQ
• Go-Back-N ARQ is inefficient for a noisy link.
• In a noisy link, frames have higher probability of damage, which means
the resending of multiple frames is necessary.
• This resending consumes the bandwidth and slows down the
transmission.
Solution:
• Selective Repeat attempts to retransmit only those frames that are
actually lost (due to errors).
– Receiver must be able to accept frames out of order.
• It defines a Negative Acknowledgement (NAK) that report the sequence
number of a damaged frame before the timer expires.
• It is more efficient for noisy link, but the processing at the receiver is
more complex. Size of the window is (2m-1).
Selective Repeat ARQ, sender and receiver windows
• The window size is reduced to one half of 2m
• Sender window size = receiver window size = 2m/2
• Window size = 2m-1
• If m = 2, Window size = 4/2=2
• Sequence number = 0, 1, 2, 3
Selective Reject (NAK)
• Also called selective retransmission
• Only rejected frames are retransmitted
• Subsequent frames are accepted by the receiver and buffered
• Minimizes retransmission
• Receiver must maintain large buffer
Send and Receive window for Selective Repeat ARQ
Selective Repeat ARQ, lost frame
• Frames 0 and 1 are
accepted when received
because they are in the
range specified by the
receiver window. Same
for frame 3.
• The receiver waits until its network layer passes in the next data
packet. The delayed acknowledgement is then attached to this
outgoing data frame.
• Every node has two windows: Send and Receive both using the same algorithms.
• Although HDLC is a general protocol that can be used for both point-to-
point and multipoint configurations, one of the most common protocols
for point-to-point access is the Point-to-Point Protocol (PPP).
• PPP is a byte-oriented protocol using byte stuffing with the escape byte
to be 01111101.
High-level Data Link Control
HDLC Station Types:
Flag: 8-bit and the sequence 01111110 identifies the beginning and end of
the frame. Serves as synchronization pattern for receiver.
FCS: Frame Check Sequence is error detection field. Contains 2/4-byte CRC.
Address: Contains the address of the secondary station.
If ‘primary’ created the frame, it contains to address else a from address. It
can be one byte (last bit is 1) or more . If the address is more than one byte,
all bytes end with zero except the last byte ends with 1. Ending each
intermediate byte with 0 indicates to the receiver that more address bytes
are to come.
Control Field: Determine the type of frame and defines its functionality
(used for flow and error control). It is 1 or 2 byte long.
Control field format for different frame types
I-Frame
• Control field:
- The first bit (0) defines the frame type (I-Frame).
- N(S): Defines the sequence number of the frame.
- N(R): Acknowledgment number when piggybacking is used.
- P/F: Valid only if set to 1 and has dual purpose:
- Poll: Frame sent by the primary station (the address field contains the address of the
receiver) to secondary.
- Final: Frame sent by secondary station (the address field contain the address of the sender)
to primary.
S-Frame Control Field in HDLC
1. Receiver Ready (RR): 00 - receiver acknowledges the receipt of a safe frame and
ready to accept more frames.
2. Receiver Not Ready (RNR): 10 - receiver not ready to accept more frames because
it is busy.
3. Reject (REJ): 01 - This is NAK Frame that can be used in ‘Go-Back-N’ to improve
the efficiency by informing the sender that the last frame is lost or damaged.