You are on page 1of 109

Data Communictions and Networking

Data Link Layer

Dr. Pradeep K V
Assistant Professor (Sr)
VIT Chennai

Dr. Pradeep K V Data Communictions and Networking 1/ 109


Contents

Introduction to Data Link Layer


Flow Control
Stop-and-Wait Protocol
Sliding Window Protocol
Error Control
Stop-and-Wait ARQ (Automatic Repeat Request)
Go-Back-N ARQ
Select-and-Reject ARQ
Error Detection and Error Correction
Data Link Control Services
Data Link Layer Protocol
Medium Access Control

Dr. Pradeep K V Data Communictions and Networking 2/ 109


Data Communictions and Networking
Data Link Layer
Services

Dr. Pradeep K V
Assistant Professor (Sr)
VIT Chennai

Dr. Pradeep K V Data Communictions and Networking 3/ 109


Introduction to Datalink Layer and its Services

In the OSI model,DLL is a 6th layer from the top and 2nd layer from
the bottom.
The communication channel that connects the adjacent nodes is
known as links, and in order to move the datagram from source to
the destination, the datagram must be moved across an individual
link.
The main responsibility of the DLL is to transfer the datagram
across an individual link.
The DLL protocol defines the format of the packet exchanged across
the nodes as well as the actions such as Error Correction and
Detection, Retransmission, Flow control, and Random access.
The DLL protocols are Ethernet, Token ring, FDDI and PPP.
An important characteristic of a DLL is that datagram can be
handled by different link layer protocols on different links in a path.
For example, the datagram is handled by Ethernet on the first link,
PPP on the second link.

Dr. Pradeep K V Data Communictions and Networking 4/ 109


DLL Services

Dr. Pradeep K V Data Communictions and Networking 5/ 109


Data Communictions and Networking
Data Link Layer
Flow Control

Dr. Pradeep K V
Assistant Professor (Sr)
VIT Chennai

Dr. Pradeep K V Data Communictions and Networking 6/ 109


Flow Control

It is a technique that allows two stations working at different speeds


to communicate with each other.
It is a set of measures taken to regulate the amount of data that a
sender sends so that a fast sender does not overwhelm a slow
receiver.
In DLL, It restricts the number of frames the sender can send before
it waits for an acknowledgment from the receiver.

Dr. Pradeep K V Data Communictions and Networking 7/ 109


Approaches of Flow Control

Feedback-Based Flow Control : The sender sends frames after it has


received acknowledgments from the user.

Rate-Based Flow Control : They have built in mechanisms to


restrict the rate of transmission of data without requiring
acknowledgment from the receiver.

Dr. Pradeep K V Data Communictions and Networking 8/ 109


Flow Control Techniques
Flow Control : Coordinates the amount of data that can be sent before
receiving acknowledgement.

1 Stop and Wait : The sender sends a frame and waits for
acknowledgment. Once received the next frame is sent.
(i.e One frame at a time).

2 Sliding Window : Both Sender and Receiver agrees upon the number
of frames to be sent based upon the buffer size (Window).
(i.e Several frames at a time)

Dr. Pradeep K V Data Communictions and Networking 9/ 109


Stop-and-Wait Flow Control

It is the simplest form of flow control.


In this method the message is broken into multiple frames, and the
receiver indicates its readiness to receive a frame of data.
The sender waits for a receipt acknowledgement (ACK) after every
frame for a specified time (called a time out).
The receiver sends the ACK to let the sender know that the frame of
data was received correctly.
The sender will then send the next frame only after the ACK.

Operations :
1 Sender: Transmits a single frame at a time.
2 Sender waits to receive ACK within time out.
3 Receiver: Transmits acknowledgement (ACK) as it receives a frame.
4 Go to step 1 when ACK is received, or time out is hit.

Dr. Pradeep K V Data Communictions and Networking 10/ 109


Stop-and-Wait Flow Control

Pros : The only advantage of


this method of flow control is its
simplicity

Cons : The sender needs to wait


for the ACK after every frame it
transmits. This is a source of
inefficiency, and is particularly
bad when the propagation delay
is much longer than the
transmission delay.
Stop and wait can also create
inefficiencies when sending
longer transmissions

Dr. Pradeep K V Data Communictions and Networking 11/ 109


Sliding-Window Flow Control- I

In this, a sender can transmit the several frames before getting an


acknowledgement.

Since, multiple frames are sent one after the another due to which
capacity of the communication channel can be utilized efficiently.

A single ACK acknowledge multiple frames.

The window can hold the frames at either end, and it provides the
upper limit on the number of frames that can be transmitted before
the acknowledgement.

Frames can be acknowledged even when the window is not


completely filled.

The window has a specific size in which they are numbered as


modulo-n means that they are numbered from 0 to n-1.
For example, if n = 8, the frames are numbered from
0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1........
Dr. Pradeep K V Data Communictions and Networking 12/ 109
Sliding-Window Flow Control- II

The size of the window is represented as n-1. Therefore, maximum


n-1 frames can be sent before acknowledgement.

When the receiver sends the ACK, it includes the number of the
next frame that it wants to receive. For example, to acknowledge
the string of frames ending with frame number 4, the receiver will
send the ACK containing the number 5. When the sender sees the
ACK with the number 5, it got to know that the frames from 0
through 4 have been received.

Dr. Pradeep K V Data Communictions and Networking 13/ 109


Sender Window

At the beginning of a transmission, the sender window contains n-1


frames, and when they are sent out, the left boundary moves inward
shrinking the size of the window.
For example, if the size of the window is w=7 if three frames are
sent out, then the number of frames left out in the sender window is
w-3. Once the ACK has arrived, then the sender window expands to
the number which will be equal to the number of frames
acknowledged by ACK.

Dr. Pradeep K V Data Communictions and Networking 14/ 109


Receiver Window
At the beginning of transmission, the receiver window does not contain n
frames, but it contains n-1 spaces for frames.
When the new frame arrives, the size of the window shrinks.
The receiver window does not represent the number of frames received,
but it represents the number of frames that can be received before an
ACK is sent. For example, the size of the window is w, if three frames are
received then the number of spaces available in the window is (w-3).
Once the acknowledgement is sent, the receiver window expands by the
number equal to the number of frames acknowledged.

Dr. Pradeep K V Data Communictions and Networking 15/ 109


Example : Sliding Window Protocol

Dr. Pradeep K V Data Communictions and Networking 16/ 109


Data Communictions and Networking
Data Link Layer
Error Control

Dr. Pradeep K V
Assistant Professor (Sr)
VIT Chennai

Dr. Pradeep K V Data Communictions and Networking 17/ 109


Error Control in DLL

Error Control is a technique of error detection and retransmission and


broadly classified as below

Note : ARQ → Automatic Repeat Request

Dr. Pradeep K V Data Communictions and Networking 18/ 109


Stop-and-Wait ARQ

It is used to retransmit the data in case of damaged or lost frames.

It is used when Stop-and-Wait Flow Control Protocol is used.


Two possibilities of the retransmission:
Damaged Frame : When the receiver receives a damaged frame, i.e.,
the frame contains an error, then it returns the NACK frame.
Lost Frame : Sender is equipped with the timer and starts when the
frame is transmitted. Sometimes the frame has not arrived at the
receiving end so that it can be acknowledged neither positively nor
negatively. The sender waits for acknowledgement until the timer
goes off. If the timer goes off, it retransmits the last transmitted
frame.

Dr. Pradeep K V Data Communictions and Networking 19/ 109


Stop-and-Wait ARQ

Four Features required for Retransmission :


The sending device keeps a copy of the last transmitted frame until
the acknowledgement is received. Keeping the copy allows the
sender to retransmit the data if the frame is not received correctly.

Both the data frames and the ACK frames are numbered alternately
0 and 1 so that they can be identified individually. Suppose data 1
frame acknowledges the data 0 frame means that the data 0 frame
has been arrived correctly and expects to receive data 1 frame.

If an error occurs in the last transmitted frame, then the receiver


sends the NAK frame which is not numbered. On receiving the NAK
frame, sender retransmits the data.

It works with the timer. If the acknowledgement is not received


within the allotted time, then the sender assumes that the frame is
lost during the transmission, so it will retransmit the frame.

Dr. Pradeep K V Data Communictions and Networking 20/ 109


Examples...1

Figure: Negative Acknowledgement

Dr. Pradeep K V Data Communictions and Networking 21/ 109


Sliding-Window ARQ

It is a technique used for continuous transmission error control.


Three Features used for retransmission:
In this case, the sender keeps the copies of all the transmitted frames
until they have been acknowledged. Suppose the frames from 0
through 4 have been transmitted, and the last acknowledgement was
for frame 2, the sender has to keep the copies of frames 3 and 4 until
they receive correctly.
The receiver can send either NAK or ACK depending on the
conditions. The NAK frame tells the sender that the data have been
received damaged. Since the sliding window is a continuous
transmission mechanism, both ACK and NAK must be numbered for
the identification of a frame.
The ACK frame consists of a number that represents the next frame
which the receiver expects to receive. The NAK frame consists of a
number that represents the damaged frame.

Dr. Pradeep K V Data Communictions and Networking 22/ 109


Types of ARQ in Sliding Window Protocol
Go-Back-n ARQ : if one frame is lost or damaged, then it retransmits all
the frames after which it does not receive the positive ACK.
Selective-Reject ARQ : It retransmits only the frame lost or damaged.

Figure: Go-Back Figure: Select-Recject

Dr. Pradeep K V Data Communictions and Networking 23/ 109


Frame/Acknowledge Lost

Figure: Go-Back N Figure: Go-Back N

Dr. Pradeep K V Data Communictions and Networking 24/ 109


Data Communictions and Networking
Data Link Layer
Error Detection and Error Correction

Dr. Pradeep K V
Assistant Professor (Sr)
VIT Chennai

Dr. Pradeep K V Data Communictions and Networking 25/ 109


Error in Data Transmission
Networks must be able to transfer data from one device to another
with acceptable accuracy.
For most applications, a system must guarantee that the data
received are identical to the data transmitted.
Any time data are transmitted from one node to the next, they can
become corrupted in passage (Data transmit).
Many factors can alter one or more bits of a message.
Applications require a mechanism for detecting and correcting errors.

At DLL, if a frame is corrupted between the two nodes, it needs to


be corrected before it continues its journey to other nodes. of the
frame.

Dr. Pradeep K V Data Communictions and Networking 26/ 109


Types of Errors
Whenever bits flow from one point to another, they are subject to
unpredictable changes because of interference, which will change the
shape of the signal.
Two Types of Error:
Single-Bit : only 1 bit of a given data unit is changed.
Burst : Two or more(Group of) bits in the data unit have changed.
(i.e., 1 → 0 or 0 → 1).

Dr. Pradeep K V Data Communictions and Networking 27/ 109


Detection Verses Correction
Error Detection : In this, we focus on Occurance of an Error and not
interested in number(Single/Burst).
Error Correction : Here, we focus on both Number of bits as well as
its location in the corrupted frame.
Both Number of bits, their location and Size of the Message are the
important factors.

Vertical Redundancy Check


Logitudinal Redundancy Check
Cyclice Redundancy Check
Check Sum
Dr. Pradeep K V Data Communictions and Networking 28/ 109
Redundancy and Coding

Redundancy :
The central concept in detecting or correcting errors is redundancy.
To detect or correct errors, we need to send some extra bits (called as
Redundant bits) with our data.
These redundant bits are added by the sender and removed by the
receiver.
Their presence allows the receiver to detect or correct corrupted bits.
Coding :
It is the process of adding redundant bit.
The sender adds redundant bits through a process that creates a
relationship between the redundant bits and the actual data bits.
The receiver checks the relationships between the two sets of bits to
detect errors.
The ratio of redundant bits to data bits and the robustness of the process
are important factors in any coding scheme.

Dr. Pradeep K V Data Communictions and Networking 29/ 109


Block Coding

Block Coding :
Entire Message is divided into blocks, each of ’k’ bits, called datawords.
We add ’r’ redundant bits to each block to make the length ’n = k + r’.
The resulting ’n’-bit blocks are called codewords.
With ’k’ bits, can create a combination of 2k datawords;
With ’n’ bits, can create a combination of 2n codewords. (∀ n > k)
It is one-to-one; the same data-word is always encoded as the same
codeword. Therefore, we have 2n - 2k codewords (Invalid/Illegal) that are
not used.

Dr. Pradeep K V Data Communictions and Networking 30/ 109


Error Detection

Figure: Process of Error Detection in Block coding

Dr. Pradeep K V Data Communictions and Networking 31/ 109


Block Coding

Sender creates Codewords out of Datawords by using a Generator that


applies the rules and procedures of encoding.
Each codeword sent to the receiver may change during transmission.
If the received Codeword is the same as one of the valid Codewords, then
the word is Accepted. Otherwise; it is Discarded.
However, if the Codeword is corrupted during transmission but the
received word still matches a valid codeword, then the error remains
undetected.

Error Detection
An error-detecting code can detect only the types of errors for which it is
designed; other types of errors may remain undetected.

Dr. Pradeep K V Data Communictions and Networking 32/ 109


Parity Check Code

It is the familiar Error-detecting code, which is a linear block code.


In this, a ’k’-bit dataword is changed to an ’n’-bit codeword, where
’n = k + 1’. The extra bit, called the parity bit.
This parity bit is selected to make the total number of 1s in the
codeword as even/odd depends upon implementation.

The minimum Hamming distance for this cat- egory is dmin = 2 .

Dr. Pradeep K V Data Communictions and Networking 33/ 109


Parity Check Code (cont...)

Figure: Encoder and Decoder for parity-check code

Even Parity Bit Generator / Checker


Odd Parity Bit Generator / Chekcer
Dr. Pradeep K V Data Communictions and Networking 34/ 109
Parity Check Code (cont...)

Even Parity Generator / Checker


Generator (Sender)
It generates a parity bit r0 , from Dataword(k-bits)
The bit r0 is computed as : r0 = a3 + a2 + a1 + a0 (modulo-2).
i.e., if the number of 1’s is Even, the result is 0; if the number of 1’s is
Odd, the result is 1.
Now, the Codeword(n=k+1) is sent to receiver.

Checker (Receiver) :
It does the same thing as the generator, but with one exception.
i.e it adds all 5 bits (b3 ,b2 ,b1 ,b0 ,q0 ).
The result s0 = b3 + b2 + b1 + b0 + q0 (modulo-2) is called syndrome.
if s0 = 0, then No Error. Otherwise Error and Message is discarded.

Dr. Pradeep K V Data Communictions and Networking 35/ 109


Parity Check Code (cont...)

Odd Parity Generator / Checker


Generator (Sender)
It generates a parity bit r0 , from Dataword(k-bits)
The bit r0 is computed as : r0 = a3 + a2 + a1 + a0 (modulo-2).
i.e., if the number of 1’s is Odd, the result is 1 ; if the number of 1’s is
Even, the result is 1.
Now, the Codeword(n=k+1) is sent to receiver.

Checker (Receiver) :
It does the same thing as the generator, but with one exception.
i.e it adds all 5 bits (b3 ,b2 ,b1 ,b0 ,q0 ).
The result s0 = b3 + b2 + b1 + b0 + q0 (modulo-2) is called syndrome.
if s0 = 0, then No Error. Otherwise Error and is discarded.

Dr. Pradeep K V Data Communictions and Networking 36/ 109


Example-2 : Simple Parity Check

Dr. Pradeep K V Data Communictions and Networking 37/ 109


Example- : 2-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.

Dr. Pradeep K V Data Communictions and Networking 38/ 109


VRC - Vertical Redundancy Check

Source want to transmit the binary data unit 1100001, adding the
number of 1’s gives us 3, an odd number. Before transmitting, a parity
generator counts the 1’s and appends the parity bit (a 1 in this case) to
the end. The total number of 1 becomes 4 now (even number). The
system now transmits the entire appended unit across the network link.

Dr. Pradeep K V Data Communictions and Networking 39/ 109


Example - Vertical Redundancy Check

Dr. Pradeep K V Data Communictions and Networking 40/ 109


LRC - Longitudinal Redundancy Check

In this error detection method, a block of bits is organized in a table


with rows and columns.
Then the parity bit for each column is calculated and a new row of
eight bits, which are the parity bits for the whole block, is created.
After that the new calculated parity bits are attached to the original
data and sends to the receiver.

Dr. Pradeep K V Data Communictions and Networking 41/ 109


Cyclic Codes

They are special linear block codes with one extra property.
In a Cyclic Code, if a codeword is cyclically shifted (rotated), the result is
another codeword.
For example, if 1011000 is a codeword and we cyclically left-shift, then
0110001 is also a codeword.
In this case, if we call the bits in the first word a0 to a6 , and the bits in
the second word b0 to b6 , we can shift the bits by using the following: b0
= a1 , b1 = a2 , b2 = a3 , b3 = a4 , b4 = a5 , b5 = a6 and b6 = a0 .
The last bit of the first word is wrapped around and becomes the first bit
of the second word.

Dr. Pradeep K V Data Communictions and Networking 42/ 109


Cyclic Redundancy Check

Figure: CRC encoder and decoder

Dr. Pradeep K V Data Communictions and Networking 43/ 109


Cyclic Redundancy Check (Error Correction)

Figure: A CRC code with C(7, 4)

Dr. Pradeep K V Data Communictions and Networking 44/ 109


CRC Encoder
Dataword (Message) = 1001 and Generator (Divisor) = 1011

Figure: Division in CRC encoder

Dr. Pradeep K V Data Communictions and Networking 45/ 109


CRC Decoder

Figure: Division in the CRC decoder for two cases

Dr. Pradeep K V Data Communictions and Networking 46/ 109


Polynomials

A better way to understand cyclic codes and how they can be analyzed is to
represent them as polynomials

A pattern of 0s and 1s can be represented as a polynomial with


coefficients of 0 and 1.
The power of each term shows the position of the bit; the coefficient
shows the value of the bit.

Figure: A polynomial to represent a binary word

Dr. Pradeep K V Data Communictions and Networking 47/ 109


Cyclic Code - Encoder using Polynomials Bits
Let us consider the below :

Figure: CRC division using polynomials

Dr. Pradeep K V Data Communictions and Networking 48/ 109


Cyclic Code Encoder using Polynomials

Figure: CRC division using polynomials

Dr. Pradeep K V Data Communictions and Networking 49/ 109


Cyclic Code - Encoder using Polynomials Bits

The dataword 1001 is represented as x3 + 1.


The divisor 1011 is represented as x3 + x + 1.
To find the augmented dataword, left-shifted the dataword 3 bits
(multiplying by x3 ). The result is x6 + x 3 .
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 the result from the
dividend.
The result is x4 , with a degree greater than the divisor’s degree;
Then, Continue to divide until the degree of the remainder is less than the
degree of the divisor.

Dr. Pradeep K V Data Communictions and Networking 50/ 109


Example : Cyclic Redundancy Check
Data-word (Message) = 100100 and Generator (Divisor) = 1101

Figure: Sender Figure: Receiver

Dr. Pradeep K V Data Communictions and Networking 51/ 109


Example-2 :CRC

Dr. Pradeep K V Data Communictions and Networking 52/ 109


Check Sum - Method-1

Suppose, Data is a list of five 4-bit numbers need to send to


destination. In addition to these numbers, Source send the sum of
the numbers.
Example: if the set of numbers is (7, 11, 12, 0, 6), then we send
(7, 11, 12, 0, 6, 36), where 36 is the sum of the original numbers.
The receiver adds the five numbers and compares the result with the
sum. If both are the same, the receiver assumes no error, accepts
the five numbers, and discards the sum. Otherwise, there is an error
somewhere and the data are not accepted.
(or)
Source can send the negative (complement) of the sum, called the
checksum. In this case, Source sends (7, 11, 12, 0, 6 -36).
The receiver can add all the numbers received (including the
checksum).
If the result is 0, it assumes no error; Otherwise, there is an error.

Dr. Pradeep K V Data Communictions and Networking 53/ 109


Check Sum - Method-2

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.

Dr. Pradeep K V Data Communictions and Networking 54/ 109


Example-1 :Check Sum

Dr. Pradeep K V Data Communictions and Networking 55/ 109


Example-2 :Check Sum

Dr. Pradeep K V Data Communictions and Networking 56/ 109


Example-3 :Check Sum

Dr. Pradeep K V Data Communictions and Networking 57/ 109


Error Correction Codes

The codes which are used for both error detecting and error
correction are called as “Error Correction Codes”.
The error correction techniques are of two types.
Single bit error correction : correcting single bit errors
Burst error correction : correcting burst errors

Hamming code or Hamming Distance Code is the best error


correcting code used in most of the communication network and
digital systems.

Error Correction can be handled in two ways:


Backward error correction: Once the error is discovered, the receiver
requests the sender to retransmit the entire data unit.
Forward error correction: In this case, the receiver uses the
error-correcting code which automatically corrects the errors.

Dr. Pradeep K V Data Communictions and Networking 58/ 109


Hamming Code

Hamming code is a block code that is capable of detecting up to


two simultaneous bit errors and correcting single-bit errors.
It was developed by R.W. Hamming for error correction.
Encoding a message by Hamming Code
Calculation of the number of redundant bits.
Positioning the redundant bits.
Calculating the values of each redundant bit.

Decoding a message in Hamming Code


Calculation of the number of redundant bits.
Positioning the redundant bits.
Parity checking.
Error detection and correction

Dr. Pradeep K V Data Communictions and Networking 59/ 109


Encoding a Message- I

1 Step-1 : Calculation of the number of redundant bits.


If the message contains ’m’ number of data bits, then ’r’ number of
redundant bits are added to it so that ’m’ is able to indicate at least
(m + r + 1) different states.
Here, (m + r) indicates location of an error in each of (m + r) bit
positions and one additional state indicates no error.
Since, ’r’ bits can indicate 2r states, 2r must be at least equal to
(m + r + 1). Thus the following equation should hold 2r ≥ m+r+1

2 Step-2 : Positioning the redundant bits.


The ’r’ redundant bits placed at bit positions of powers of 2, i.e. 1,
2, 4, 8, 16 etc.
They are referred in the rest of this text as r1 (at position 1), r2 (at
position 2), r3 (at position 4), r4 (at position 8) and so on.

Dr. Pradeep K V Data Communictions and Networking 60/ 109


Encoding a Message- II

3 Step-3 : Calculating the values of each redundant bit.


The redundant bits are parity bits, which is an extra bit that makes
the number of 1’s either even or odd (using - Even/Odd) and
computed as :
r1 is the parity bit for all data bits in positions whose binary
representation includes a 1 in the least significant position excluding
1 (3, 5, 7, 9, 11 and so on)
r2 is the parity bit for all data bits in positions whose binary
representation includes a 1 in the position 2 from right except 2 (3,
6, 7, 10, 11 and so on)
r3 is the parity bit for all data bits in positions whose binary
representation includes a 1 in the position 3 from right except 4 (5-7,
12-15, 20-23 and so on)

Dr. Pradeep K V Data Communictions and Networking 61/ 109


Decoding a Message

1 Step-1 : Calculation of the number of redundant bits


(Same as in Encoding)
2 Step-2 : Positioning the redundant bits
(Same as in Encoding)
3 Step-3 : Parity checking
Parity bits are calculated based upon the data bits and the
redundant bits using the same rule as during generation of
c1 ,c2 ,c3 , c4 etc. Thus
c1 = parity(1, 3, 5, 7, 9, 11 and so on)
c2 = parity(2, 3, 6, 7, 10, 11 and so on)
c3 = parity(4-7, 12-15, 20-23 and so on)

4 Step-4 : Error detection and correction


The decimal equivalent of the parity bits binary values is calculated.
If it is 0, there is no error. Otherwise, the decimal value gives the bit
position which has error.

Dr. Pradeep K V Data Communictions and Networking 62/ 109


Redundant Bits Positions

Dr. Pradeep K V Data Communictions and Networking 63/ 109


Example of Hamming Code (Encoding) I

Suppose the original data is 1010 which is to be sent.


Step-1 : Computing the Number of Redundant Bits (r) :
Total number of data(Message) bits ’m’ = 4
Number of redundant bits (r) : 2r ≥ m + r + 1 ( 2r ≥ 4 + r + 1)
Therefore, for r = 3 that satisfies the above relation.
Total number of bits = (m + r) = 4+3 = 7;

Step-2 : Determining the position of the redundant bits


The number of redundant bits is 3. The three bits are represented by
r1 , r2 , r4 .
The position of the redundant bits is calculated with corresponds to
the raised power of 2. Therefore, their corresponding positions are
20 , 21 , 22 (i.e., 1(Position of r1 ), 2 (Position of r2 ), and 4 (Position
of r4 )).

Dr. Pradeep K V Data Communictions and Networking 64/ 109


Example of Hamming Code (Encoding) II
Step-3 : Determining the Parity bits

Finally, The value of r1 = 0, r2 = 1 and r4 = 0. And Data


Transferred is

Dr. Pradeep K V Data Communictions and Networking 65/ 109


Example of Hamming Code (Decoding) I

Suppose the 4th bit is changed from 0 to 1 at the receiving end,


then parity bits are recalculated.

−→
Step - 1 : Find Number of Parity(Redundant) Bits (i.e r = 3)
Step - 2 : Redundant Bits Positions ( r1 , r2 , and r4 )
Step - 3 : Find r1 , r2 , and r4 Values

Dr. Pradeep K V Data Communictions and Networking 66/ 109


Example of Hamming Code (Decoding) II

One can observe from the above figure that the binary
representation of r4 is 1011. Now, we perform the even-parity check,
the total number of 1’s appearing in the r4 bit is an odd number.
Therefore, the value of r4 is 1.

Step - 4 : Error Detection and Correction


The binary representation of redundant bits, i.e., r4 r2 r1 is 100, and
its corresponding decimal value is 4.
Therefore, the error occurs in a 4th bit position.
The bit value must be changed from 1 to 0 to correct the error.

Dr. Pradeep K V Data Communictions and Networking 67/ 109


Solve it, if U Can...!

Generate the Hamming Code for the Following :


ABC
DF
GBC
10101
11001

Detect the Error for the message(Data) received 1 0 0 1 0 1 0 0 1 0 1


instead of 1 0 0 1 1 1 0 0 1 0 1 using Hamming Code Error Correction

Dr. Pradeep K V Data Communictions and Networking 68/ 109


Data Communictions and Networking
Data Link Layer
Medium Access

Dr. Pradeep K V
Assistant Professor (Sr)
VIT Chennai

Dr. Pradeep K V Data Communictions and Networking 69/ 109


Introduction to Medium Access Layer

The medium access control (MAC) is a sublayer of the DLL of the


OSI reference model for data transmission.
It is responsible for flow control and multiplexing for transmission
medium.
It controls the transmission of data packets via remotely shared
channels.
It sends data over the network interface card.

Dr. Pradeep K V Data Communictions and Networking 70/ 109


MAC Layer Functionalities...!

It provides an abstraction of the physical layer to the LLC and upper


layers of the OSI network.

It is responsible for encapsulating frames so that they are suitable for


transmission via the physical medium.

It resolves the addressing of source station as well as the destination


station, or groups of destination stations.

It performs multiple access resolutions when more than one data


frame is to be transmitted. It determines the channel access
methods for transmission.

It also performs collision resolution and initiating retransmission in


case of collisions.

It generates the frame check sequences and thus contributes to


protection against transmission errors.

Dr. Pradeep K V Data Communictions and Networking 71/ 109


Media Access Control Protocol
When Multiple nodes are connected in a network and uses a
common link to communicate, then a protocol is required to
coordinate and access the link.
The problem of controlling the medium access is similar to the rules
of speaking in an assembly.
The procedures guarantee that the right to speak is upheld and
ensure that two people do not speak at the same time, do not
interrupt each other, do not monopolize the discussion, and so on.
Many protocols have been devised to handle access a shared link.

Dr. Pradeep K V Data Communictions and Networking 72/ 109


Random Access

In random-access, no station is superior to other and none is


assigned control over another.
At any point, a station that has data to send uses a protocol to
make a decision on whether to send or not, which depends on the
medium state (idle/busy).
Two features give this method name as Random
Transmission is random among the stations
No rules specify which station should send next.

If more than one station tries to send, there is an access conflict


(collision) and the frames will be either destroyed / modified.
Each station follows a procedure that answers the following
When can the station access the medium?
What can the station do if the medium is busy?
How can the station determine the success / failure of the
transmission?
What can the station do if there is an access conflict?

Dr. Pradeep K V Data Communictions and Networking 73/ 109


1. ALOHA - Random Access

ALOHA, the earliest random access method, was developed at the


University of Hawaii in early 1970.

It was designed for a radio (wireless) LAN, but it can be used on any
shared medium.

ALOHA shares the medium between the stations.

When a station sends data, another station may attempt to do so at


the same time. Then the two stations data collide and become
damaged.
Two Types of ALOHA
Pure ALOHA
Slotted ALOHA

Dr. Pradeep K V Data Communictions and Networking 74/ 109


1.1 Pure ALOHA

The original ALOHA protocol is called pure ALOHA.


This is a simple but elegant protocol.
The idea is that each station sends a frame whenever it has a frame
to send (multiple access). However, since there is only one channel
to share, there is the possibility of collision between frames from
different stations.

Dr. Pradeep K V Data Communictions and Networking 75/ 109


1.1 Pure ALOHA

It relies on acknowledgments from the receiver.


When a station sends a frame, it expects the receiver to send an
acknowledgment. (ACK/NACK)

Dr. Pradeep K V Data Communictions and Networking 76/ 109


Vulnerable time for pure ALOHA protocol

Vulnerable Time : is the length of time in which there is a possibility


of collision

Time
Pure ALOHA Vulnerable time 2 * Tfr

Dr. Pradeep K V Data Communictions and Networking 77/ 109


1.2 Slotted ALOHA - ALOHA Protocol

Pure ALOHA has a vulnerable time of 2 * Tfr , because there is no


rule that defines when the station can send.
Slotted ALOHA was invented to improve the efficiency of pure
ALOHA.
Each station must be synchronized to send frames on a frame
duration interval.

Dr. Pradeep K V Data Communictions and Networking 78/ 109


1.2 Slotted ALOHA - ALOHA Protocol

A station is allowed to send only at the beginning of synchronized


time slot, if a station miss it, then must wait until the beginning of
next time slot.
The vulnerability time is half of the pure ALOHA

Dr. Pradeep K V Data Communictions and Networking 79/ 109


ALOHA Throughput

Pure ALOHA
The throughput for pure ALOHA is S = G * e −2G
The maximum throughput Smax = 1/(2e) = 0.184 when G = (1/2).

Slotted ALOHA
The throughput for Slotted ALOHA is S = G * e −G
The maximum throughput Smax = 0.368 when G = 1.

Dr. Pradeep K V Data Communictions and Networking 80/ 109


2. CSMA - Random Access
CSMA method was developed to reduce collisions.
The chance of collision can be reduced if a station senses the
medium before trying to use.
Carrier sense multiple access (CSMA) requires that each station first
listen to the medium (or check the state of the medium) before
sending. i.e No more than one station can “talk” at a time .

Dr. Pradeep K V Data Communictions and Networking 81/ 109


Vulnerable Time in CSMA

The vulnerable time for CSMA is the propagation time Tp .


The time needed for a signal to propagate from one end of the
medium to the other. When a station sends a frame and any other
station tries to send a frame during this time, a collision will result.
But if the first bit of the frame reaches the end of the medium, every
station will already have heard the bit and will refrain from sending.

Dr. Pradeep K V Data Communictions and Networking 82/ 109


Persistence Methods in CSMA

What should a station do if the channel is busy?


What should a station do if the channel is idle?
Three methods have been devised to answer these questions
1-persistent method,
non-persistent method, and
p-persistent method.
Persistence methods are used to reduce the possibility of a collision.

Dr. Pradeep K V Data Communictions and Networking 83/ 109


Behavior of three persistent methods

Dr. Pradeep K V Data Communictions and Networking 84/ 109


Flow Diagrams of three persistent methods

Dr. Pradeep K V Data Communictions and Networking 85/ 109


2.1 CSMA/CD

The CSMA method does not specify the procedure following a


collision.
Carrier sense multiple access with collision detection (CSMA/CD)
augments the algorithm to handle the collision.
In this method, a station monitors the medium after it sends a frame
to see if the transmission was successful. If so, the station is
finished. If, however, there is a collision, the frame is sent again.

Dr. Pradeep K V Data Communictions and Networking 86/ 109


Collision and abortion in CSMA/CD

Dr. Pradeep K V Data Communictions and Networking 87/ 109


Flow Diagram CSMA/CD

Dr. Pradeep K V Data Communictions and Networking 88/ 109


2.2 CSMA/CA

Carrier sense multiple access with collision avoidance (CSMA/CA)


was invented for wireless networks.
Collisions are avoided through the use of CSMA/CA’s three
strategies:
The interframe space (DIFS & SIFS),
The contention window, and
Control frames (RTS, CTS, ACK).

Dr. Pradeep K V Data Communictions and Networking 89/ 109


Flow Diagram of CSMA/CA

Dr. Pradeep K V Data Communictions and Networking 90/ 109


CSMA/CA and NAV

Dr. Pradeep K V Data Communictions and Networking 91/ 109


Controlled Access

In controlled access, the stations consult one another to find which


station has the right to send.

A station cannot send unless it has been authorized to send.


Controlled Access Types :
Reservation.
Polling.
Token Passing.

Dr. Pradeep K V Data Communictions and Networking 92/ 109


1. Reservation

Here, a station needs to make a reservation before sending data.


Time is divided into intervals. In each interval, a reservation frame
precedes the data frames sent in that interval.
If there are N stations in the system, there are exactly N reservation
minislots in the reservation frame. Each minislot belongs to a
station. When a station needs to send a data frame, it makes a
reservation in its own minislot. The stations that have made res-
ervations can send their data frames after the reservation frame.

Dr. Pradeep K V Data Communictions and Networking 93/ 109


2. Polling

Polling works with topologies in which one device is designated as a


primary station and the other devices are secondary stations.
All data exchanges must be made through the primary device even
when the ultimate destination is a secondary device.
The primary device controls the link; the secondary devices follow its
instructions.
It is up to the primary device to determine which device is allowed to
use the channel at a given time.
Primary Station :
SEL = select, used by the primary device when it wishes to send
POL = used to solicit transmission from secondary devices
ACK = acknowledge receipt from a secondary device
Secondary Station:
ACK = acknowledge receipt from primary device
NACK = non-ACK is used when there is nothing to send.

Dr. Pradeep K V Data Communictions and Networking 94/ 109


Select and Poll functions

Dr. Pradeep K V Data Communictions and Networking 95/ 109


3. Token Passing
Stations in this network are organized in a logical ring: there is a
predecessor and a successor to each node.
The predecessor is the station which is logically before the station in
the ring; the successor is the station which is after the station in the
ring.
A special packet called a token moves from station to station. A
station can only send messages while it holds the token.
The token can be held for a limited amount of time before it is sent
to the successor. Priorities can be configured by setting a different
holding time for each station.
The dual ring, common with the FDDI implementation, allows for
some redundancy if there is a failure on one of the rings.
Each node on the ring must be able to re-generate the token if the
token is lost or damaged.
The ring is vulnerable to loss of a station unless the star ring is used.
The central hub of a star ring is called an MAU (multi-access unit)
Dr. Pradeep K V Data Communictions and Networking 96/ 109
Logical Ring and Physical Topology

Dr. Pradeep K V Data Communictions and Networking 97/ 109


Channelization

Channelization is a multiple-access method where the available


bandwidth of a link is shared among stations by
Time
Frequency
Code

Three common channelization protocols are


TDMA = Time Division Multiple Access
FDMA = Frequency Division Multiple Access
CDMA = Code Division Multiple Access

Dr. Pradeep K V Data Communictions and Networking 98/ 109


FDMA - FDM Access

FDMA divides the available bandwidth into frequency bands.


Each station is allocated a band of frequencies for data transmission.
FDM FDMA
FDMA is at the data-link layer.
FDM is at the physical layer, Each station always uses the
combining low bandwidth same band.
channels into a high
Each stations transmits over the
bandwidth channel. shared link media without a
Used for the first generation multiplexer.
analog mobile phone system. Bandpass filters are used at the
stations to separate the signals.

Dr. Pradeep K V Data Communictions and Networking 99/ 109


FDMA -

Dr. Pradeep K V Data Communictions and Networking 100/ 109


TDMA - TDM Access

Time-Division Multiple Access (TDMA) is where stations share


bandwidth in time.
Each station is allocated a time slot during which it can send data.
Each station transmits its data in its assigned time slot.
This requires all the stations be synchronize
TDM operates at the physical layer.
Low bandwidth channels are combined into a high bandwidth
channel using a multiplexer.
TDMA operates at the data-link layer.
Stations transmit through one shared channel
Each station transmits when its assigned time slot is available

Dr. Pradeep K V Data Communictions and Networking 101/ 109


TDMA - TDM Access

Dr. Pradeep K V Data Communictions and Networking 102/ 109


CSMA - CSM Access
It was conceived several decades ago.
Advances in electronic technology have made its implementation
possible.
CDMA differs from FDMA and TDMA in that all stations transmit
simultaneously each using all the available frequency bandwidth.

Dr. Pradeep K V Data Communictions and Networking 103/ 109


Chip Sequence

Figure: Channel Sequence

Length of the chip is the number of stations sharing the link.


The dot product of any two different chips is zero.
The dot product of a chip with itself is n, where n = number of
communicating stations.

Dr. Pradeep K V Data Communictions and Networking 104/ 109


Data representation & Sharing channel

Figure: Data Representation in CDMA

Figure: Sharing Channel in CDMA

Dr. Pradeep K V Data Communictions and Networking 105/ 109


Digital signal created in CDMA

Figure: Digital signal created by four stations in CDMA

Dr. Pradeep K V Data Communictions and Networking 106/ 109


Decoding of the Composite signal in CDMA

Figure: Decoding of the composite signal in CDMA

Dr. Pradeep K V Data Communictions and Networking 107/ 109


General rules and Creating Walsh tables

Figure: Walsh tables

Each chip is read from a row in the Walsh table.

Dr. Pradeep K V Data Communictions and Networking 108/ 109


Thanks

Dr. Pradeep K V Data Communictions and Networking 109/ 109

You might also like