0% found this document useful (0 votes)
38 views

Data Link Layer

This document provides an overview of the data link layer. It discusses several topics: 1. Framing, including fixed and variable framing approaches like byte stuffing and bit stuffing to delineate frames. 2. Switching techniques at the data link layer, including circuit switching which establishes a dedicated path and packet switching which divides messages into packets sent over multiple paths. 3. Error detection and correction methods like parity bits, CRC codes, and Hamming codes to detect errors in transmitted frames. 4. Flow control methods like stop-and-wait and sliding window protocols to regulate data transmission rates. 5. MAC protocols including ALOHA, CSMA/CD, CSMA

Uploaded by

mubin.pathan765
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Data Link Layer

This document provides an overview of the data link layer. It discusses several topics: 1. Framing, including fixed and variable framing approaches like byte stuffing and bit stuffing to delineate frames. 2. Switching techniques at the data link layer, including circuit switching which establishes a dedicated path and packet switching which divides messages into packets sent over multiple paths. 3. Error detection and correction methods like parity bits, CRC codes, and Hamming codes to detect errors in transmitted frames. 4. Flow control methods like stop-and-wait and sliding window protocols to regulate data transmission rates. 5. MAC protocols including ALOHA, CSMA/CD, CSMA

Uploaded by

mubin.pathan765
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 121

UNIT 2: DATA LINK LAYER

Reference Book: 1. Computer networks- Andrew S. Tanenbaum


2. Data communication- B.A. Forouzan, 4th Edition Tata Mc Graw hill Publication

By: Ms. Mohua Biswas (M.E)


Assistant Professor
Department of Electronics & Telecommunication Engineering
CONTENTS
 Framing

 Circuit Switching and Packet Switching

 Error Detection and Error Correction


 Block Parity Code

 CRC Code

 Hamming Code

 Flow Control Methods


 Stop and Wait Protocol

 Sliding Window Protocol

 Piggybacking

 MAC
 ALOHA

 CSMA: CSMA/CD, CSMA/CA

 HDLC

 STP Protocol
INTRODUCTION TO DATA LINK LAYER
 The data link layer uses the services of the physical layer to send and receive bits over
communication channels.

 It has a number of functions, including:

1. Providing a well-defined service interface to the network layer.

2. Dealing with transmission errors.

3. Regulating the flow of data so that slow receivers are not swamped (flooded) by fast
senders.

 To accomplish these goals, the data link layer takes the packets it gets from the network layer and
encapsulates them into frames for transmission.

Fig.: Data Link Layer Services


FRAMING
Frame In Data Link Layer:

Fig.: Relationship Between Packets and Frames

 The data link layer divides the stream of bits received from the network layer into
manageable data units called frames.
PAYLOAD
FLAG HEADER TRAILER FLAG
FIELD
Fig.: Parts of a Frame
 A frame contains

 Frame Header: It contains the source and the destination addresses of the frame.

 Payload Field: It contains the message to be delivered.

 Frame Trailer: It contains the error detection and error correction bits.

 Flag: It marks the beginning and end of the frame.


FRAMING (CONTD…)
Types of Framing:

 There are two types of framing:

a) Fixed-Size Framing:

 The frame is of fixed size.

 There is no need to provide boundaries to the frame, length of the frame itself acts as
delimiter.

b) Variable-Size Framing:

 Here, the size of each frame to be transmitted may be different.

 So additional mechanisms are kept to mark the end of one frame and the beginning of
the next frame.

 Historically, two approaches were used for this purpose:

i) Character-Oriented Approach/ Byte Stuffing

ii) Bit-Oriented Approach/ Bit Stuffing


FRAMING (CONTD…)
i) Frame in a Character – Oriented Approach:

 In character – oriented protocols, the message is coded as 8-bit characters.

 A frame has the following parts −

Frame Header − It contains the source and the destination addresses of the frame.

Payload field − It contains the message to be delivered.

Trailer − It contains the error detection and error correction bits.

Flags − 1- byte (8-bits) flag at the beginning and at end of the frame.

Fig.: Parts of a Frame

Byte Stuffing Mechanism:

In this method, start and end of frame are recognized with the help of flag bytes.

Each frames starts with and ends with a flag byte.

Two consecutive flag bytes indicate the end of one frame and start of the next one.
FRAMING (CONTD…)
The flag bytes used in the figure used is named as “ESC” flag byte.

Fig.: Byte Stuffing and Un-stuffing


FRAMING (CONTD…)
If the pattern of the flag byte is present in the message byte, there should be a
strategy so that the receiver does not consider the pattern as the end of the frame.

In character – oriented protocol, the mechanism adopted is byte stuffing.

In byte stuffing, a special byte called the escape character (ESC) is stuffed before
every byte in the message with the same pattern as the flag byte.

If the ESC sequence is found in the message byte, then another ESC byte is stuffed
before it. Data from Network Layer
Flag Header A B ESC C D Trailer Flag

Sending Machine Byte Stuffing


Data Link Frame Sent
Flag Header A B ESC ESC C D Trailer Flag

Data Link Frame Received


Flag Header A B ESC ESC C D Trailer Flag

Receiving Machine Byte Un-stuffing


Data to Network Layer
Flag Header A B ESC C D Trailer Flag

Fig.: Byte Stuffing and Un-stuffing


FRAMING (CONTD…)
ii) Frame in a Bit – Oriented Approach:
 In bit-oriented protocols, the message is coded as a sequence of bits.
 A frame has the following parts −
Frame Header − It contains the source and the destination addresses of the frame.
Payload field − It contains the message to be delivered.
Trailer − It contains the error detection and error correction bits.
Flags − A bit pattern that defines the beginning and end bits in a frame. It is
generally of 8-bits. Most protocols use the 8-bit pattern 01111110 as flag.

Bit Stuffing Mechanism: Fig.: Parts of a Frame

In a data link frame, the delimiting flag sequence generally contains six or more
consecutive 1s.
In order to differentiate the message from the flag in case of the same sequence, a
single bit is stuffed in the message.
FRAMING (CONTD…)
Whenever a 0 bit is followed by five consecutive 1bits in the message, an extra 0 bit
is stuffed at the end of the five 1s.

When the receiver receives the message, it removes the stuffed 0s after each
sequence of five 1s. The un-stuffed message is then sent to the upper layers.
Data from Network Layer
011111 Header 00111111111010100011111001 Trailer 011111
Sending
Machine Bit Stuffing
Data Link Frame Sent
011111 Header 0011111011110101000111110001 Trailer 011111

Data Link Frame Received


011111 Header 0011111011110101000111110001 Trailer 011111
Receiving Bit Un-stuffing
Machine Data to Network Layer
011111 Header 00111111111010100011111001 Trailer 011111
Fig.: Bit Stuffing and Un-stuffing
SWITCHING TECHNIQUES
 In large networks, there can be multiple paths from sender to receiver.

 The switching technique will decide the best route for data transmission.

 Switching technique is used to connect the systems for making one-to-one communication.

 Selecting a path that data must take out of the available options is called switching.

Fig.: Switching

Classification Of Switching Techniques:


Switching Techniques

Circuit Switching Packet Switching

Fig.: Switching Techniques


SWITCHING TECHNIQUES (CONTD…)
i) Circuit Switching:

Fig.: Circuit Switching

 Circuit switching is a switching technique that establishes a dedicated path between


sender and receiver.

 In the Circuit Switching Technique, once the connection is established then the
dedicated path will remain to exist until the connection is terminated.

 Circuit switching in a network operates in a similar way as the telephone works.

 A complete end-to-end path must exist before the communication takes place.
SWITCHING TECHNIQUES (CONTD…)
 In case of circuit switching technique, when any user wants to send the data, voice, video,
a request signal is sent to the receiver then the receiver sends back the acknowledgment to
ensure the availability of the dedicated path.
 After receiving the acknowledgment, dedicated path transfers the data.

 Circuit switching is used in public telephone network. It is used for voice transmission.

 Fixed data can be transferred at a time in circuit switching technology.

 Communication through circuit switching has 3 phases:

a) Connection establishment

b) Data transfer

c) Connection termination
SWITCHING TECHNIQUES (CONTD…)
ii) Packet Switching:

Fig.: Packet Switching


 The packet switching is a switching technique in which the message is sent in one
go, but it is divided into smaller pieces, and they are sent individually.

 The message splits into smaller pieces known as packets and packets are given a
unique number to identify their order at the receiving end.

 Every packet contains some information in its headers such as source address,
destination address and sequence number.

 Packets will travel across the network, taking the shortest path as possible.

 All the packets are reassembled at the receiving end in correct order.
SWITCHING TECHNIQUES (CONTD…)
 If any packet is missing or corrupted, then the message will be sent to resend the
message.

 If the correct order of the packets is reached, then the acknowledgment message
will be sent.

 There are two approaches to Packet Switching:

a) Datagram Packet Switching

b) Virtual Circuit Switching

a) Datagram Packet Switching:

It is a packet switching technology in which packet is known as a datagram,


is considered as an independent entity.

Each packet contains the information about the destination and switch uses
this information to forward the packet to the correct destination.

In Datagram Packet Switching technique, the path is not fixed.

Intermediate nodes take the routing decisions to forward the packets.

Datagram Packet Switching is also known as connectionless switching.


SWITCHING TECHNIQUES (CONTD…)
b) Virtual Circuit Switching:

Virtual Circuit Switching is also known as connection-oriented switching.

In the case of Virtual circuit switching, a preplanned route is established


before the messages are sent.

Call request and call accept packets are used to establish the connection
between sender and receiver.

In this case, the path is fixed for the duration of a logical connection.

 A and B are the sender and receiver respectively.


 1 and 2 are the nodes.
 Call request and call accept packets are used to
establish a connection between the sender and
receiver.
 When a route is established, data will be transferred.
 After transmission of data, an acknowledgment signal
is sent by the receiver that the message has been
received.
 If the user wants to terminate the connection, a clear
Fig.: Virtual Circuit Switching signal is sent for the termination.
ERROR DETECTION AND ERROR CORRECTION
Error Detection:
 Networks must be able to transfer data from one device to another with acceptable
accuracy.
 Any time data are transmitted from one node to the next, they can become corrupted in
passage.
 When data is transmitted from one device to another device, the system does not guarantee
whether the data received by the device is identical to the data transmitted by another
device.
 An Error is a situation when the message received at the receiver end is not identical to
the message transmitted.
Types of Error:
Errors can be classified into two categories:
Types of Error

Single-Bit Error Burst Error

Fig.: Types of Error


ERROR DETECTION AND ERROR CORRECTION
a) Single-Bit Error:
 The term single-bit error means that only one bit of a given data unit is
changed from 1 to 0 or from 0 to 1.

Fig.: Single-Bit Error


 Figure shows the effect of a single-bit error on a data unit.
 The message which is sent is corrupted as single-bit, i.e., 0 bit is changed to 1.
 Single-Bit Error mainly occurs in Parallel Data Transmission.
b) Burst Error:
 The term burst error means that 2 or more bits in the data unit have changed
from 1 to 0 or from 0 to 1.
 A burst error 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.
ERROR DETECTION AND ERROR CORRECTION

Fig.: Burst Error

 Figure shows the effect of a burst error on a data unit.


 Burst Errors are most likely to occur in Serial Data Transmission.
 The number of affected bits depends on the duration of the noise and data rate.

Error Detecting Techniques:


 The most popular Error Detecting Techniques are:
a) Single parity check
b) Two-dimensional parity check
c) Cyclic Redundancy Check (CRC)
ERROR DETECTION AND ERROR CORRECTION
a) Single Parity Check:
 Single Parity checking is the simple mechanism and inexpensive to detect the
errors.

 In this technique, a redundant bit is also known as a parity bit which is


appended at the end of the data unit.

 If the number of 1s bits is odd, then parity bit 1 is appended.

 If the number of 1s bits is even, then parity bit 0 is appended at the end of the
data unit.

 At the receiving end, the parity bit is calculated from the received data bits and
compared with the received parity bit.
ERROR DETECTION AND ERROR CORRECTION

Fig.: Even Parity Checking


 This technique generates the total number of 1s even, so it is known as even-
parity checking.

 Drawbacks Of Single Parity Checking:

It can only detect single-bit errors which are very rare.

If two bits are interchanged, then it cannot detect the errors.


ERROR DETECTION AND ERROR CORRECTION
b) Two-Dimensional Parity Check:

 Two Dimensional Parity can detect as well as correct one or more bit errors.
 If a one or more bit error takes place then the receiver will receive the message with
the changed parity bit.

 It indicates that some error has taken place which means the error is detected.

 Two-Dimensional Parity Check organizes the data in the form of a table.

 In Two-Dimensional Parity check, a block of bits is divided into rows, and the
redundant row of bits is added to the whole block.

 At the receiving end, the parity bits are compared with the parity bits computed
from the received data.

Fig.: Two Dimensional (Even) Parity


ERROR DETECTION AND ERROR CORRECTION
 Two-dimensional parity scheme can correct all 1 bit errors.

Fig.: Two Dimensional (Even) Parity

 In the example, the receiver can take the initiative and correct (change) the
received message
ERROR DETECTION AND ERROR CORRECTION
c) Cyclic Redundancy Check (CRC):

 Cyclic Redundancy Check (CRC) is a block code invented by W. Wesley


Peterson in 1961.
 Cyclic Redundancy Check (CRC) is an error detection method.
 It is based on binary division.
 So, CRC is also called polynomial code checksum.
 CRC uses Generator Polynomial which is available on both sender and receiver
side.
 This generator polynomial helps in finding the CRC generator represented as a
bit pattern.
 The power of each term in CRC generator gives the position of the bit.
 For Example: The CRC generator is 𝒙𝟕 + 𝒙𝟔 + 𝒙𝟒 + 𝒙𝟑 + 𝒙 + 𝟏
ERROR DETECTION AND ERROR CORRECTION
Sender Site:

 Sender has a generator G(x) polynomial.

 Sender appends (n-1) zero bits to the data.

where n= no of bits in generator

 Dividend appends the data with generator G(x) using modulo 2 division
(arithmetic).

 Remainder of (n-1) bits will be CRC.


n-bits
Data 00….0

Division

Divisor n+1 bits Codeword

Remainder Data CRC


CRC
To Receiver
n-bits
Fig.: CRC Generator at Sender Site
ERROR DETECTION AND ERROR CORRECTION
 Example: Assume that – (a) data is 10110 (m(x)= 𝒙𝟒 + 𝒙𝟐 + 𝒙𝟏 )
(b) code generator is 1101 (G(x)= 𝒙𝟑 + 𝒙𝟐 + 𝟏)

Solution:

1. Code generator is 1101 (𝒙𝟑 + 𝒙𝟐 + 𝟏) so append 000 with the data→


10110000 → 𝒙𝟕 + 𝒙𝟓 + 𝒙𝟒

2. Data unit 10110000 is divided by 1101.

3. Therefore, the remainder is 101 (CRC)

4. The encoded data sent is 10110101

Data + CRC

OR
ERROR DETECTION AND ERROR CORRECTION
Receiver Site:

 Receiver has same generator G(x).

 Receiver divides received data (Data + CRC) with generator.

 If remainder is zero, data is correctly received.

 Else, there is error.


From Sender

Data CRC Data CRC

Division n+1 bits

Divisor

Fig.: Checker at Receiver Site


Remainder

Zero Non-Zero

No Error Error
ERROR DETECTION AND ERROR CORRECTION
 Example: Assume the received message is 10110110.

Solution:

1. Data received is 10110110 → 𝒙𝟕 + 𝒙𝟓 + 𝒙𝟒 + 𝒙𝟐 + x

2. This data is again divided by a divisor 1101 → 𝒙𝟑 + 𝒙𝟐 + 𝟏

3. It does not add any padding bits.

4. The remainder obtained is 001; it means there is an error.

OR
ERROR DETECTION AND ERROR CORRECTION
 Example: Assume we have our data as 100100 and the generator Polynomial is
(G(x)=𝒙𝟑 + 𝒙𝟐 + 𝟏).

Solution:

1. In the above code, code generator is 1101 (4 bits) so append 000 with the data.
100100000 → Data plus extra zeros
ERROR DETECTION AND ERROR CORRECTION
Error Correction:
 Error Correction codes are used to detect and correct the errors when data is transmitted from the
sender to the receiver.
 For correcting the errors, one has to know the exact position of the error.
 To determine the position of the bit which is in error, a technique developed by R.W Hamming
is Hamming code.
 The hamming code uses the number of redundant bits depending on the number of information
bits in the message.
 Redundant bits are extra binary bits that are generated and added to the information-carrying bits
of data transfer to ensure that no bits were lost during the data transfer.
 The number of redundant bits can be calculated using the following formula:
𝟐𝑷 ≥ m + P + 1
where, P = redundant bit/parity bit, m = data bit

 Let's understand the concept of Hamming code through an example:


ERROR DETECTION AND ERROR CORRECTION
 Example: Suppose the original data is 1010 which is to be sent.

Solution: 1) Total number of data bits ‘m' = 4

2) Number of redundant bits/ parity bits P : 𝟐𝑷 ≥ m + P + 1

= 2𝑃 ≥ 4 + P + 1

Therefore, the value of r is 3 that satisfies the above relation.

3) Total number of bits = m + P = 4+3 = 7.

Step I: Determining the Parity bits

The number of redundant bits is 3.

The position of the redundant bits is calculated with corresponds to the raised power of
2.

Therefore, their corresponding positions are 𝟐𝟎 , 𝟐𝟏 , 𝟐𝟐 .

The position of 𝑷𝟏 = 1
𝒎𝟕 𝒎𝟔 𝒎𝟓 𝑷𝟒 𝒎𝟑 𝑷𝟐 𝑷𝟏
The position of 𝑷𝟐 = 2
Fig.: Representation of data and
The position of 𝑷𝟒 = 4 parity bits
ERROR DETECTION AND ERROR CORRECTION
Step II: Determining the Parity bits
Bit Location 7 6 5 4 3 2 1
Bit Designation m7 m6 m5 P4 m3 P2 P1
Bit Representation 111 110 101 100 011 010 001
Data Bits 1 0 1 0
Parity Bits P4 P2 P1

Parity bit 𝐏𝟏 ∶

 It covers all data bits in positions whose binary representation has 1 in the least
significant position (001, 011, 101, 111).
 Thus 𝐏𝟏 checks the bit in locations 1, 3, 5, 7.
 Now, we perform the even-parity check at these bit positions.
𝐏𝟏 : 1, 3, 5, 7 = P1 , 0, 1, 1
𝐏𝟏 = 0
 The total number of 1 at these bit positions corresponding to 𝐏𝟏 is even, therefore,
the value of the 𝐏𝟏 bit is 0.
ERROR DETECTION AND ERROR CORRECTION

Bit Location 7 6 5 4 3 2 1
Bit Designation m7 m6 m5 P4 m3 P2 P1
Bit Representation 111 110 101 100 011 010 001
Data Bits 1 0 1 0
Parity Bits P4 P2 P1

Parity bit 𝐏𝟐 :

 It covers all data bits in positions whose binary representation has 1 in the 2nd least
significant position (010, 011, 110, 111).

 Thus 𝐏𝟐 checks the bit in locations 2, 3, 6, 7.

 Now, we perform the even-parity check at these bit positions.

𝐏𝟐 : 2, 3, 6, 7 = P2 , 0, 0, 1

𝐏𝟐 = 1

 The total number of 1 at these bit positions corresponding to 𝐏𝟐 is odd, therefore,


the value of the 𝐏𝟐 bit is 1.
ERROR DETECTION AND ERROR CORRECTION

Bit Location 7 6 5 4 3 2 1
Bit Designation m7 m6 m5 P4 m3 P2 P1
Bit Representation 111 110 101 100 011 010 001
Data Bits 1 0 1 0
Parity Bits P4 P2 P1

Parity bit 𝐏𝟒 :

 It covers all data bits in positions whose binary representation has 1 in the 3rd least
significant position (100, 101, 110, 111).

 Thus 𝐏𝟒 checks the bit in locations 4, 5, 6, 7.

 Now, we perform the even-parity check at these bit positions.

𝐏𝟒 : 4, 5, 6, 7 = P4 , 1, 0, 1

𝐏𝟒 = 0

 The total number of 1 at these bit positions corresponding to 𝐏𝟒 is even, therefore,


the value of the 𝐏𝟒 bit is 0.
ERROR DETECTION AND ERROR CORRECTION
Data transferred is given below:
After receiving the encoded message, each parity bit along with its corresponding group of
bits are checked for proper parity.
While checking, the correct result of individual parity is marked as 0 and the wrong result is
marked as 1.
Suppose the 4th bit is changed from 0 to 1 at the receiving end, then parity bits are
recalculated. Bit Location 7 6 5 4 3 2 1
Bit Designation m7 m6 m5 P4 m3 P2 P1
Bit Representation 111 110 101 100 011 010 001
Received Code 1 0 1 1 0 1 0
𝐏𝟏: 1, 3, 5, 7 = 0, 0, 1, 1 → even= 0
𝐏𝟐: 2, 3, 6, 7 = 1, 0, 0, 1 → even= 0
𝐏𝟒: 4, 5, 6, 7 = 1, 1, 0, 1 → odd= 1

The binary representation of redundant bits, i.e., 𝐏𝟒 𝐏𝟐 𝐏𝟏 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.
FLOW CONTROL METHODS
Flow Control:
 Flow control coordinates the amount of data that can be sent before receiving an
acknowledgement.
 Flow control tells the sender how much data to send.
 It makes the sender wait for some sort of acknowledgement (ACK) before continuing to send
more data.
 Receiver should also be able to inform the transmitter before its limits are reached and the sender
must send fewer frames.
 Hence, Flow control refers to the set of procedures used to restrict the amount of data the
transmitter can send before waiting for acknowledgment.
Protocols for Flow Control:
 Protocols at data link layer for flow control can be categorized into two types:
a) Protocol for noiseless (error-free) channels
b) Protocol for noisy (error-prone) channels

Fig.: Taxonomy of Protocols


FLOW CONTROL METHODS (CONTD…)
Protocols for Noiseless Channels:

 An idealistic channel in which no frames are lost, duplicated, or corrupted.

 There are two protocols for this type of channel:

i) Simplest Protocol: It does not use flow control;

ii) Stop-and-Wait Protocol: the one that use flow control

 Neither has error control because we have assumed that the channel is a perfect noiseless
channel

i) Simplest Protocol:

It is a unidirectional protocol in which data frames are traveling in only one direction-
from the sender to receiver.

In this, the receiver can immediately handle the frame it receives whose processing
time is small enough to be considered as negligible.

Receiver has infinite buffer space and infinite processing speed.

Thus no flow or error control needed.


FLOW CONTROL METHODS (CONTD…)
Design of the Simplest Protocol:

Fig.: Design of the Simplest Protocol


 The data link layer at the sender site gets data from its network layer, makes a frame out of
the data, and sends it.

 The data link layer(receiver site) receives a frame from its physical layer, extracts data
from the frame, and convey the data to its network layer.

 The data link layers of the sender and receiver provide communication/ transmission
services for their network layers.
FLOW CONTROL METHODS (CONTD…)
Flow Diagram for Simplest Protocol

Fig.: Flow Diagram for Simplest Protocol

 This Flow Diagram shows an example of communication using the simplest protocol.

 It is very straightforward.

 The sender sends a series of frames without further consideration about the receiver.

 Let‟s take an example, three frames will send from the sender, and three frames received
by receivers.

 Bear in mind the data frames are shown by tilted boxes; the height of the box defines the
transmission time difference between the first bit and the last bit in the frame.
FLOW CONTROL METHODS (CONTD…)
ii) Stop-and-Wait Protocol:
If data frames arrive at the receiver site faster than they can be processed, the frames
must be stored until their use.
In Stop-and-Wait Protocol the sender sends one frame, stops until it receives
confirmation from the receiver (okay to go ahead), and then sends the next frame.
Design of the Stop-and-Wait Protocol:

Fig.: Design of the Stop-and-Wait Protocol

 Comparing this with simplest protocol, we can see the traffic on the forward channel (from
sender to receiver) and the reverse channel.
 At any time, there is either one data frame on the forward channel or one ACK frame on the
reverse channel.
 We therefore need a half-duplex link.
FLOW CONTROL METHODS (CONTD…)
Flow Diagram for Stop-and-Wait Protocol:

Fig.: Flow Diagram for Stop-and-Wait Protocol

 This figure shows an example of communication using the Stop-and-wait protocol.

 It is still straightforward.

 The sender sends a frame and waits for a response from the receiver.

 When ACK(acknowledged) will arrival from the receiver side then send the next frame
and so on.

 Keep it in mind when two frames will be there sender will involve in four event and the
receivers will involve in two events.
FLOW CONTROL METHODS (CONTD…)
Disadvantages of Stop and Wait protocol:
 The following are the problems associated with a stop and wait protocol:
a) Problems occur due to lost data:
In this case, two problems occur:
Sender waits for an infinite amount of time for an ACK.
Receiver waits for an infinite amount of time for a data.
b) Problems occur due to lost acknowledgment:
In this case, problem occur:
Sender waits for an infinite amount of time for an ACK.
c) Problem due to the delayed data or acknowledgment:
Suppose the sender sends the data and it has also been
received by the receiver.
The receiver then sends the acknowledgment but the ACK
is received after the timeout period on the sender's side.
As the acknowledgment is received late, so ACK can be
wrongly considered as the acknowledgment of some other
data packet.
FLOW CONTROL METHODS (CONTD…)
Protocols for Noisy Channels:

 In a real channel (noisy) frames are lost, duplicated, or corrupted thus error control is
required.

 Receiver has finite buffer space and finite processing speed.

 Thus flow control needed.

 There are two protocols for this type of channel:

i) Stop-and-Wait ARQ Protocol

ii) Sliding Window Protocol Go-Back-N ARQ

Selective Repeat ARQ

i) Stop-and-Wait ARQ Protocol :

Stop and Wait ARQ is an improved and modified version of Stop and Wait protocol.

Stop and Wait ARQ assumes-

 The communication channel is noisy.

 Errors may get introduced in the data during the transmission.


FLOW CONTROL METHODS (CONTD…)
Stop and wait ARQ works similar to stop and wait protocol.

It provides a solution to all the limitations of stop and wait protocol.

Stop and wait ARQ includes the following three extra elements.

Extra Elements in Stop-and-Wait ARQ Time Out Timer

Sequence Numbers for Data Packets

Sequence Numbers for ACK

Thus, we can say-


Stop and Wait ARQ = Stop and Wait Protocol + Time Out Timer + Sequence
Numbers for Data Packets and Acknowledgements
a) Sequence Numbers:

The received frame could be the correct one, or a duplicate, or a frame out of order.

When the frame arrives at the receiver site, it is checked and if it is corrupted, it is
silently discarded.

The detection of errors in this protocol is manifested by the silence of the receiver.

The solution is to number the frames.

A field is added to the data frame to hold the sequence number of that frame.
FLOW CONTROL METHODS (CONTD…)
When the receiver receives a data frame that is out of order, this means that frames
were either lost or duplicated.

The corrupted or lost frames need to be resent in this protocol.

b) Acknowledgement Numbers:

The acknowledgment numbers always announce the sequence number of the next
frame expected by the receiver.

For example, if frame 0 has arrived safe and sound, the receiver sends an ACK
frame with acknowledgment 1 (meaning frame 1 is expected next).

Design:

Fig.: Design of the Stop-and-Wait ARQ


Protocol
FLOW CONTROL METHODS (CONTD…)
Figure shows the design of the Stop-and-Wait ARQ Protocol.

The sending device keeps a copy of the last frame transmitted until it receives
an acknowledgment for that frame.

A data frames uses a seq. No. (sequence number); an ACK frame uses an ack
No. (acknowledgment number).

The sender has a control variable, which we call 𝑺𝒏 (sender, next frame to
send), that holds the sequence number for the next frame to be sent (0 or 1).

The receiver has a control variable, which we call 𝑹𝒏 (receiver, next frame
expected), that holds the number of the next frame expected.

When a frame is sent, the value of 𝑺𝒏 is incremented (modulo-2), which means


if it is 0, it becomes 1 and vice versa.

When a frame is received, the value of 𝑹𝒏 is incremented (modulo-2), which


means if it is 0, it becomes 1 and vice versa.
FLOW CONTROL METHODS (CONTD…)
Flow Diagram:

Fig.: Flow Diagram for Stop-and-Wait ARQ Protocol


FLOW CONTROL METHODS (CONTD…)
Frame 0 is sent and acknowledged.

Frame 1 is lost and resent after the time-out.

The resent frame 1 is acknowledged and the timer stops.

Frame 0 is sent and acknowledged, but the acknowledgment is lost.

The sender has no idea if the frame or the acknowledgment is lost, so after the time-
out, it resends frame 0, which is acknowledged.
FLOW CONTROL METHODS (CONTD…)
ii) Sliding Window Protocol:

The sliding window is a technique for sending multiple frames at a time.

It controls the data packets between the two devices where reliable and gradual
delivery of data frames is needed.

It is also used in TCP (Transmission Control Protocol).

In this technique, each frame has sent from the sequence number.

The sequence numbers are used to find the missing data in the receiver end.

The purpose of the sliding window technique is to avoid duplicate data, so it uses the
sequence number.

Types of Sliding Window Protocol:

Sliding window protocol has two types:

a) Go-Back-N ARQ

b) Selective Repeat ARQ


FLOW CONTROL METHODS (CONTD…)
a) Go-Back-N ARQ:

Go-Back-N ARQ protocol is also known as Go-Back-N Automatic Repeat Request.

It is a data link layer protocol that uses a sliding window method.

In this, if any frame is corrupted or lost, all subsequent frames have to be sent again.

The size of the sender window is N in this protocol.

For example, we say that Go-Back-4, which means that the four frames can be sent
at a time before expecting the acknowledgment from the receiver..

The receiver window size is always 1.

It uses the principle of protocol pipelining in which the multiple frames can be sent
before receiving the acknowledgment of the first frame.

If we have four frames and the concept is Go-Back-4, which means that the four
frames can be sent, i.e., frame no 0, frame no 1, frame no 2, and frame no 3 can be
sent before expecting the acknowledgment of frame no 0.
FLOW CONTROL METHODS (CONTD…)

In Go-Back-N ARQ, the frames are numbered sequentially as Go-Back-N ARQ sends
the multiple frames at a time that requires the numbering approach to distinguish the
frame from another frame, and these numbers are known as the sequential numbers.

The number of frames that can be sent at a time totally depends on the size of the
sender's window.

So, we can say that 'N' is the number of frames that can be sent at a time before
receiving the acknowledgment from the receiver.
FLOW CONTROL METHODS (CONTD…)
Example: Suppose the sender's window size is 2, and we have 11 frames to send, then
the sequence numbers will not be 0,1,2,3,4,5,6,7,8,9,10.

Solution:

N is the sender's window size.

If the size of the sender's window is 4 then the sequence number will be
0,1,2,3,0,1,2,3,0,1,2, and so on.

The number of bits in the sequence number is 2 to generate the binary sequence
00, 01, 10, 11.

Step 1: Firstly, the sender will send the first four frames to the receiver, i.e.,
0,1,2,3, and now the sender is expected to receive the acknowledgment of the 0th
frame.
FLOW CONTROL METHODS (CONTD…)
Step 2: Let's assume that the receiver has sent the acknowledgment for the 0
frame, and the receiver has successfully received it.

Step 3: The sender will then send the next frame, i.e., 4, and the window slides
containing four frames (1,2,3,4).
FLOW CONTROL METHODS (CONTD…)
Step 4: The receiver will then send the acknowledgment for the frame no 1. After
receiving the acknowledgment, the sender will send the next frame, i.e., frame no
5, and the window will slide having four frames (2,3,4,5).

Step 5: Now, let's assume that the receiver is not acknowledging the frame no 2,
either the frame is lost, or the acknowledgment is lost. Instead of sending the frame no 6,
the sender Go-Back to 2, which is the first frame of the current window, retransmits all
the frames in the current window, i.e., 2,3,4,5.
FLOW CONTROL METHODS (CONTD…)
FLOW CONTROL METHODS (CONTD…)
Example: In GB4, if every 6th packet being transmitted is lost and if we have to spend
10 packets then how many transmissions are required?
Solution:
Here, GB4 means that N is equal to 4. The size of the sender's window is 4.
Step 1: As the window size is 4, so four packets are transferred at a time, i.e.,
packet no 1, packet no 2, packet no 3, and packet no 4.

Step 2: Once the transfer of window size is completed, the sender receives the
acknowledgment of the first frame, i.e., packet no1. As the acknowledgment receives, the
sender sends the next packet, i.e., packet no 5. In this case, the window slides having four
packets, i.e., 2,3,4,5 and excluded the packet 1 as the acknowledgment of the packet 1 has
been received successfully.
FLOW CONTROL METHODS (CONTD…)

Step 3: Now, the sender receives the acknowledgment of packet 2. After receiving
the acknowledgment for packet 2, the sender sends the next packet, i.e., packet no 6. As
mentioned in the question that every 6th is being lost, so this 6th packet is lost, but the
sender does not know that the 6th packet has been lost.
FLOW CONTROL METHODS (CONTD…)
Step 4: The sender receives the acknowledgment for the packet no 3. After receiving
the acknowledgment of 3rd packet, the sender sends the next packet, i.e., 7th packet. The
window will slide having four packets, i.e., 4, 5, 6, 7.

Step 5: When the packet 7 has been sent, then the sender receives the
acknowledgment for the packet no 4. When the sender has received the acknowledgment,
then the sender sends the next packet, i.e., the 8th packet. The window will slide having
four packets, i.e., 5, 6, 7, 8.
FLOW CONTROL METHODS (CONTD…)

Step 6: When the packet 8 is sent, then the sender receives the acknowledgment of
packet 5. On receiving the acknowledgment of packet 5, the sender sends the next packet,
i.e., 9th packet. The window will slide having four packets, i.e., 6, 7, 8, 9.
FLOW CONTROL METHODS (CONTD…)
Step 7: The current window is holding four packets, i.e., 6, 7, 8, 9, where the 6th
packet is the first packet in the window. As we know, the 6th packet has been lost, so the
sender receives the negative acknowledgment NAK(6). As we know that every 6th packet
is being lost, so the counter will be restarted from 1. So, the counter values 1, 2, 3 are
given to the 7th packet, 8th packet, 9th packet respectively.
FLOW CONTROL METHODS (CONTD…)
Step 8: As it is Go-BACK, so it retransmits all the packets of the current window. It
will resend 6, 7, 8, 9. The counter values of 6, 7, 8, 9 are 4, 5, 6, 1, respectively. In this
case, the 8th packet is lost as it has a 6-counter value, so the counter variable will again
be restarted from 1.
FLOW CONTROL METHODS (CONTD…)
Step 9: After the retransmission, the sender receives the acknowledgment of packet
6. On receiving the acknowledgment of packet 6, the sender sends the 10th packet. Now,
the current window is holding four packets, i.e., 7, 8, 9, 10.
FLOW CONTROL METHODS (CONTD…)
Step 10: When the 10th packet is sent, the sender receives the acknowledgment of
packet 7. Now the current window is holding three packets, 8, 9 and 10. The counter
values of 8, 9, 10 are 6, 1, 2.
FLOW CONTROL METHODS (CONTD…)
Step 11: As the 8th packet has 6 counter value which means that 8th packet has been
lost, and the sender receives NAK (8).
Step 12: Since the sender has received the negative acknowledgment for the 8th
packet, it resends all the packets of the current window, i.e., 8, 9, 10.

Step 13: The counter values of 8, 9, 10 are 3, 4, 5, respectively, so their


acknowledgments have been received successfully.
FLOW CONTROL METHODS (CONTD…)
b) Selective Repeat ARQ:

Selective-Reject ARQ technique is more efficient than Go-Back-n ARQ.

In this technique, only those frames are retransmitted for which negative
acknowledgement (NAK) has been received.

The receiver storage buffer keeps all the damaged frames on hold until the frame in
error is correctly received.

The receiver must have an appropriate logic for reinserting the frames in a correct
order.

The sender must consist of a searching mechanism that selects only the requested
frame for retransmission.
PIGGYBACKING
 The process of carrying the acknowledgement along with the data on the same channel is
known as piggybacking.

 In data communication, transmitter transmits the data packet and waits for
acknowledgement from the other end before it starts transmitting the next packet.

 This can be achieved in two ways as follows.

Method 1: There will be two separate channels, one channel is used for
transmission of data in forward direction and the other channel is used for transmission of
ACK in the reverse direction.

Method 2 : There will be single channel used for transmission of data/ACK but
one at a time.
PIGGYBACKING (CONTD…)
 The Method 1 reduces bandwidth efficiency by utilizing entire channel for ACK.

 Moreover Method 2 introduces delay between successive packet or frame transmissions.

 The above mentioned drawbacks are avoided by transmitting ACK along with data packet.

Benefits or advantages of Piggybacking

1. It offers efficient use of available channel bandwidth.

It saves bandwidth to greater extent.

2. The transmitter (say A) need not have to wait for ACK

separately as it receives previous packet's ACK along

with next data packet from the other end (say B). This

improves latency of data transfer between A and B.

Drawbacks or disadvantages of Piggybacking

1. It increases additional system complexity.

2. The more delay in waiting for ACK by data link layer often leads to retransmission of
the packet.
MEDIA ACCESS CONTROL (MAC)
Data Link Layer :

 The data link layer is used in a computer network to transmit the data between two devices
or nodes.

 It divides the layer into parts such as Data Link Control and the Multiple Access
Resolution/Protocol.

 The upper layer has the responsibility to flow control and the error control in the data link
layer, and hence it is termed as logical link control (LLC)or data link control.

 Whereas the lower sub-layer is used to handle and reduce the collision or multiple access
on a channel and hence it is termed as media access control (MAC) or the multiple
access resolutions.

Fig.: Sub-layers of Data Link Layer


MEDIA ACCESS CONTROL (MAC) (CONTD…)
Data/Logical Link Control (LLC):
 A data link control is a reliable channel for transmitting data over a dedicated link using
various techniques such as framing, error control and flow control of data packets in the
computer network.

Fig.: Data Link Control


Media Access Control (MAC):
 When a sender and receiver have a dedicated link to transmit data packets, the data link
control is enough to handle the channel.
 Suppose there is no dedicated path to communicate or transfer the data between two
devices in that case, multiple stations access the channel and simultaneously transmits the
data over the channel.
MEDIA ACCESS CONTROL (MAC) (CONTD…)
 It may create collision and cross talk.

 Hence, the multiple access protocol is required to reduce the collision and avoid crosstalk
between the channels.

Example: Suppose that there is a classroom full of students. When a teacher asks a
question, all the students (small channels) in the class start answering the question at the
same time (transferring the data simultaneously). All the students respond at the same time
due to which data is overlap or data lost. Therefore it is the responsibility of a teacher
(multiple access protocol) to manage the students and make them one answer.
MEDIA ACCESS CONTROL (MAC) (CONTD…)
Types of Media Access Control:

 Following are the types of multiple access protocol or media access control that is
subdivided into the different process as:
Media Access Control

Random Access Protocols Controlled Access Protocols Channelization Protocols

ALOHA Reservation FDMA


CSMA Polling TDMA

CSMA/CD Token Passing CDMA

CSMA/CA

Fig.: Types of Media Access Control


MEDIA ACCESS CONTROL (MAC) (CONTD…)
Random Access Protocol:
 In this protocol, all the station has the equal priority to send the data over a channel.
 In random access protocol, one or more stations cannot depend on another station nor any
station control another station.
 Depending on the channel's state (idle or busy), each station transmits the data frame.
 However, if more than one station sends the data over a channel, there may be a collision
or data conflict.
 Due to the collision, the data frame packets may be lost or changed.
 And hence, it does not receive by the receiver end.
 Following are the different methods of random-access protocols for broadcasting frames
on the channel.
i) ALOHA
ii) CSMA
iii) CSMA/CD
iv) CSMA/CA
MEDIA ACCESS CONTROL (MAC) (CONTD…)
Binary Exponential Back-Off Algorithm:

 After the occurrence of collision, station waits for some random back off time and then
retransmits.

 This waiting time for which the station waits before retransmitting the data is called as
back off time.

 Back Off Algorithm is used for calculating the back off time.

 Transmitting station chooses a random number in the range [0, 𝟐𝒏 -1] if the packet is
undergoing collision for the nth time.

 If station chooses a number k, then-

Back off time = k x Time slot

Example-

Consider the following scenario where stations A and D start transmitting their data
simultaneously-
MEDIA ACCESS CONTROL (MAC) (CONTD…)
Scene-01: For 1st Data Packet Of Both Stations-

 Both the stations start transmitting their 1st data packet simultaneously.

 This leads to a collision.

 Clearly, the collision on both the packets is occurring for the 1st time.

 So, collision number for the 1st data packet of both the stations = 1.

At Station A-

After detecting the collision,

- Station A randomly chooses a number in the range [0, 𝟐𝟏 -1] = [0,1].

- If station A chooses the number 𝑲𝑨 , then back off time = 𝑲𝑨 units.


At Station D-

After detecting the collision,

- Station D randomly chooses a number in the range [0, 𝟐𝟏 -1] = [0,1].

- If station D chooses the number 𝑲𝑫 , then back off time = 𝑲𝑫 units.

 Following 4 cases are possible-


MEDIA ACCESS CONTROL (MAC) (CONTD…)

 From here,

𝟏
Probability of station A to successfully retransmit its data after the 1st collision =
𝟒

𝟏
Probability of station D to successfully retransmit its data after the 1st collision =
𝟒

𝟐 𝟏
Probability of occurrence of collision again after the 1st collision = =
𝟒 𝟐
MEDIA ACCESS CONTROL (MAC) (CONTD…)
Scene-02: For 2nd Data Packet Of Station A And 1st Data Packet Of Station D-.

 Consider after some time, Station A starts transmitting its 2nd data packet and station D
starts retransmitting its 1st data packet simultaneously.

 This leads to a collision.

At Station A-

- The 2nd data packet of station A undergoes collision for the 1st time.

- So, collision number for the 2nd data packet of station A = 1.

- Now, station A randomly chooses a number in the range [0, 𝟐𝟏 -1] = [0 , 1].

- If station A chooses the number 𝑲𝑨 , then back off time = 𝑲𝑨 units.


At Station D-

- The 1st data packet of station D undergoes collision for the 2nd time.

- So, collision number for the 1st data packet of station D = 2.

- Now, station D randomly chooses a number in the range [0, 𝟐𝟐 -1] = [0 , 3].

- If station D chooses the number 𝑲𝑫 , then back off time = 𝑲𝑫 units.


MEDIA ACCESS CONTROL (MAC) (CONTD…)
 Following 8 cases are

𝑲𝑨 𝑲𝑫 Remarks
In this case, both the stations start retransmitting their data immediately. This case
0 0
leads to a collision again.
In this case, station A starts retransmitting its data immediately while station D
0 1 waits for 1 unit of time. This case leads to A successfully retransmitting its data
after the 2nd collision.
In this case, station A starts retransmitting its data immediately while station D
0 2 waits for 2 unit of time. This case leads to A successfully retransmitting its data
after the 2nd collision.
In this case, station A starts retransmitting its data immediately while station D
0 3 waits for 3 unit of time. This case leads to A successfully retransmitting its data
after the 2nd collision.
In this case, station A waits for 1 unit of time while station D starts retransmitting
1 0 its data immediately. This case leads to D successfully retransmitting its data after

the
. 2nd collision.
In this case, both the stations wait for 1 unit of time and then starts retransmitting
1 1
their data simultaneously. This case leads to a collision again.
In this case, station A waits for 1 unit of time while station D waits for 2 unit of
1 2 time. This case leads to A successfully retransmitting its data after the 2nd
collision.
In this case, station A waits for 1 unit of time while station D waits for 3 unit of
1 3 time. This case leads to A successfully retransmitting its data after the 2nd
collision.
MEDIA ACCESS CONTROL (MAC) (CONTD…)
 From here,

𝟓
Probability of station A to successfully retransmit its data after the 2nd collision =
𝟖

𝟏
Probability of station D to successfully retransmit its data after the 2nd collision =
𝟖

𝟐 𝟏
Probability of occurrence of collision again after the 2nd collision = =
𝟖 𝟒
MEDIA ACCESS CONTROL (MAC) (CONTD…)
i) ALOHA Random Access Protocol:

 It is designed for wireless LAN (Local Area Network) but can also be used in a shared
medium to transmit data.

 Using this method, any station can transmit data across a network simultaneously when a
data frameset is available for transmission.

 Any station can transmit data to a channel at any time.

 It does not require any carrier sensing.

 Collision and data frames may be lost during the transmission of data through multiple
stations.

Fig.: Collision
 Acknowledgment of the frames exists in Aloha and hence, there is no collision detection.

 It requires retransmission of data after some random amount of time.


MEDIA ACCESS CONTROL (MAC) (CONTD…)
 There are two different versions of ALOHA-

Fig.: Types of ALOHA


a) Pure ALOHA Random Access Protocol:
 Whenever data is available for sending over a channel at stations, we use Pure ALOHA.
 In Pure ALOHA, when each station transmits data to a channel without checking whether
the channel is idle or not, the chances of collision may occur, and the data frame can be
lost.
 When any station transmits the data frame to a channel, the Pure ALOHA waits for the
receiver's acknowledgment.
 If it does not acknowledge the receiver end within the specified time, the station waits for
a random amount of time, called the Back-off time (Tb).
 And the station may assume the frame has been lost or destroyed.
 Therefore, it retransmits the frame until all the data are successfully transmitted to the
receiver.
MEDIA ACCESS CONTROL (MAC) (CONTD…)

Fig.: Frames in Pure ALOHA


MEDIA ACCESS CONTROL (MAC) (CONTD…)
 As we can see in the figure above, there are four stations for accessing a shared channel
and transmitting data frames.

 Some frames collide because most stations send their frames at the same time.

 Only two frames, frame 1.1 and frame 2.2, are successfully transmitted to the receiver end.

 At the same time, other frames are lost or destroyed.

 Whenever two frames fall on a shared channel simultaneously, collisions can occur, and
both will suffer damage.

 If the new frame's first bit enters the channel before finishing the last bit of the second
frame.

 Both frames are completely finished, and both stations must retransmit the data frame.
MEDIA ACCESS CONTROL (MAC) (CONTD…)

Fig.: Flowchart for Pure ALOHA


MEDIA ACCESS CONTROL (MAC) (CONTD…)
b) Slotted ALOHA Random Access Protocol:

 Slotted ALOHA was invented to improve the efficiency of pure ALOHA as chances of
collision in pure ALOHA are very high.

 In slotted ALOHA, the time of the shared channel is divided into discrete intervals called
slots.

 The stations can send a frame only at the beginning of the slot and only one frame is sent
in each slot.

 In slotted ALOHA, if any station is not able to place the frame onto the channel at the
beginning of the slot i.e. it misses the time slot then the station has to wait until the
beginning of the next time slot.

 • In slotted ALOHA, there is still a possibility of collision if two stations try to send at the
beginning of the same time slot as shown in figure.
MEDIA ACCESS CONTROL (MAC) (CONTD…)

Fig.: Frames in Slotted ALOHA


MEDIA ACCESS CONTROL (MAC) (CONTD…)

Fig.: Frames in Slotted ALOHA


MEDIA ACCESS CONTROL (MAC) (CONTD…)
ii) CSMA Protocol:

 CSMA Protocol stands for Carrier Sense Media Access Protocols.

 This method was developed in order to minimize the chance of collision and therefore,
increase the performance.

 Principle of CSMA “sense before transmit” or “ listen before talk”.

 It sense the traffic on a channel (idle or busy) before transmitting the data.

 Carrier Idle Transmission is taking place

 Carrier Busy No transmission currently taking place

 The possibility of collision still exists because of propagation delay; a station may sense
the medium and find it idle, because the first bit sent by another station has not yet been
received.
MEDIA ACCESS CONTROL (MAC) (CONTD…)
Types of CSMA Protocol:
 There are four different types of CSMA Protocols:
CSMA

1-Persistent Non-Persistent P-Persistent


Fig.: Types of CSMA Protocol

i) 1-Persistent CSMA:
 In this method, station that wants to transmit data continuously senses the channel
to check whether the channel is idle or busy.
 If the channel is busy, the station waits until it becomes idle.
 When the station detects an idle-channel, it immediately transmits the frame with
probability 1. Hence it is called 1-persistent CSMA.
 This method has the highest chance of collision because two or more stations may
find channel to be idle at the same time and transmit their frames.
 When the collision occurs, the stations wait a random amount of time and start
allover again.
MEDIA ACCESS CONTROL (MAC) (CONTD…)

Fig.: 1-Persistent CSMA Protocol


 Algorithm of 1-Persistent CSMA Protocol:

• When a frame is ready, the transmitting station checks whether the channel is
idle or busy.

• If the channel is busy, the station waits and continually checks until the channel
becomes idle.

• If the channel is idle then it transmits the frame immediately, with a probability
1.

 Drawback of 1-Persistent CSMA Protocol:

• The propagation delay time greatly affects this protocol.


MEDIA ACCESS CONTROL (MAC) (CONTD…)
ii) Non-Persistent CSMA:

 In this scheme, if a station wants to transmit a frame and it finds that the channel is
busy (some other station is transmitting) then it will wait for fixed interval of time.

 After this time, it again checks the status of the channel and if the channel is.free it
will transmit.

 A station that has a frame to send senses the channel.

 If the channel is idle, it sends immediately.

 If the channel is busy, it waits a random amount of time and then senses the channel
again.

 In non-persistent CSMA the station does not continuously sense the channel for the
purpose of capturing it when it detects the end of previous transmission.

Fig.: Non-Persistent CSMA Protocol


MEDIA ACCESS CONTROL (MAC) (CONTD…)
 Algorithm of Non-Persistent CSMA Protocol:

• When a frame is ready, the transmitting station checks whether the channel is
idle or busy.

• If the channel is idle then it transmits the frame immediately.

• If the channel is busy, the station waits for a random time period during which it
does not check whether the channel is idle or busy.

• At the end of the waiting time period, it again checks the status of the channel
and restarts the algorithm.

 Advantages of Non-Persistent CSMA Protocol:

• It rate of collisions is much reduced than 1-persistent CMSA. This is because


each station waits for a random amount of time before attempting retransmission.
The probability that multiple stations will wait for same amount of time is
extremely low.
MEDIA ACCESS CONTROL (MAC) (CONTD…)
iii) P-Persistent CSMA:

 This method is used when channel has time slots such that the time slot duration is
equal to or greater than the maximum propagation delay time.

 Whenever a station becomes ready to send, it senses the channel.

 If channel is busy, station waits until next slot.

 If channel is idle, it transmits with a probability p.

 With the probability q=l-p, the station then waits for the beginning of the next time
slot.

 If the next slot is also idle, it either transmits or waits again with probabilities p and
q.

 This process is repeated till either frame has been transmitted or another station has
begun transmitting.

 In case of the transmission by another station, the station acts as though a collision
has occurred and it waits a random amount of time and starts again.
MEDIA ACCESS CONTROL (MAC) (CONTD…)

Fig.: P-Persistent CSMA Protocol

 Algorithm of P-Persistent CSMA Protocol:

• When a frame is ready, the transmitting station checks whether the channel is
idle or busy.

• If the channel is idle then it transmits the frame immediately.

• If the channel is busy, the station waits and continually checks until the channel
becomes idle.

• When the channel becomes idle, the station transmits the frame with a
probability p.
MEDIA ACCESS CONTROL (MAC) (CONTD…)
• With a probability ( 1 – p ), the channel waits for next time slot. If the next time
slot is idle, it again transmits with a probability p and waits with a probability
( 1– p ).

• The station repeats this process until either frame has been transmitted or
another station has begun transmitting.

• If another station begins transmitting, the station waits for a random amount of
time and restarts the algorithm.

 Advantages of P-Persistent CSMA Protocol:

• It is the most efficient among 1-persistent CSMA, non-persistent CSMA and p-


persistent CSMA. It reduces the number of collisions considerably as compared
to 1-persistent CSMA. The channel utilization is much better than non-persistent
CSMA.
MEDIA ACCESS CONTROL (MAC) (CONTD…)
iii) CSMA/CD Protocol:

 CSMA / CD stands for Carrier Sense Multiple Access / Collision Detection.

 The meaning of the individual component of CSMA/CD.

o CS – It stands for Carrier Sensing. It implies that before sending data, a station first
senses the carrier. If the carrier is found free, then the station transmits data else it
refrains.

o MA – Stands for Multiple Access i.e. if there‟s a channel, then there are many stations
that are trying to access it.

o CD – Stands for Collision Detection. It also guides to proceed in case of packet data
collision.

 CSMA/CD, a MAC process protocol, first senses for any transmissions from the other
stations in the channel and starts transmitting only when the channel is clear to transmit.

 As soon as a station detects a collision, it stops transmission and sends a jam signal.

 It then waits for some time period before retransmitting.

 Each station can sense the carrier only at its point of contact with the carrier.
MEDIA ACCESS CONTROL (MAC) (CONTD…)
 It is not possible for any station to sense the entire carrier.
 Thus, there is a huge possibility that a station might sense the carrier free even when it is
actually not.

Example:
 At the current instance, if station A senses the carrier at its point of contact, then it will find the
carrier free.
 But the carrier is actually not free because station D is already transmitting its data.
 If station A starts transmitting its data now, then it might lead to a collision with the data
transmitted by station D.
 So, both the stations will receive inaccurate collided data.
 If the colloidal signal comes back during the process of transmission, then it indicates that the
collision has occurred.
 For this, the stations need to keep on transmitting.
 Only then they can be sure that it‟s their own data that got collided/corrupted.
MEDIA ACCESS CONTROL (MAC) (CONTD…)
Algorithm:
MEDIA ACCESS CONTROL (MAC) (CONTD…)
 First, the station that wants to transmit the data senses the carrier as to whether it is
busy or idle.

 If a carrier is found idle, then the transmission is carried out.

 The transmission station detects a collision, if any, using the condition: 𝐓𝐭 >= 2 * 𝐓𝐩
where 𝐓𝐭 is the transmission delay and 𝐓𝐩 is the propagation delay.
The propagation delay is the time it takes for one bit to travel from one end of the link to the
other.
Transmission delay is the time needed to push all the packet bits on the transmission link.
According to this condition, if the size of data packet is smaller, then collision detection would
not be possible
 The station releases the jam signal as soon as it detects a collision.

 After collision has occurred, the transmitting station stops transmitting and waits for
some random amount of time called the „back-off time‟. After this time, the station
retransmits again.
MEDIA ACCESS CONTROL (MAC) (CONTD…)
iv) CSMA/CA Protocol:

 Carrier Sense Multiple Access with Collision Avoidance (CSMA/CA) is a network


protocol for carrier transmission that operates in the Medium Access Control (MAC) layer.

 In contrast to CSMA/CD (Carrier Sense Multiple Access/Collision Detection) that deals


with collisions after their occurrence, CSMA/CA prevents collisions prior to their
occurrence.

 It is a technique using which the chances of collision are decreased.

 The transmission method used in Wi-Fi networks (IEEE 802.11).

 In short, the main aim of this technique is to ensure that the data is transmitted safely and
the collision is avoided.

 There are proper steps taken to ensure that the data does not collide.

 There are three main types of techniques used for collision avoidance.

a) Interframe space

b) Contention window

c) Acknowledgments
MEDIA ACCESS CONTROL (MAC) (CONTD…)
a) Interframe space:

 Whenever the channel is found idle, the station does not transmit immediately.

 It waits for a period of time called inter-frame space (IFS).

 When channel is sensed to be idle, it may be possible that same distant station may
have already started transmitting and the signal of that distant station has not yet
reached other stations.

 Therefore the purpose of IFS time is to allow this transmitted signal to reach other
stations.

 If after this IFS time, the channel is still idle, the station can send, but it still needs
to wait a time

b) Contention window:

 It is the amount of time divided into slots.

 A station which is ready to send frames chooses random number of slots as wait
time.
MEDIA ACCESS CONTROL (MAC) (CONTD…)
c) Acknowledgments:

 Besides all the measures taken for not avoiding collisions, there are still some
chances where the data might collide.

 In such cases, Acknowledgment is used.

 The receiver will send Acknowledgement saying that the data is received.

 Once the data is received, it is confirmed that the data is not destroyed.
MEDIA ACCESS CONTROL (MAC) (CONTD…)
Algorithm:
MEDIA ACCESS CONTROL (MAC) (CONTD…)
 This is the CSMA protocol with collision avoidance.

 The station ready to transmit, senses the line by using one of the persistent
strategies.

 As soon as it find the line to be idle, the station waits for an IFG (Interframe gap)
amount of time.

 If then waits for some random time and sends the frame.

 After sending the frame, it sets a timer and waits for the acknowledgement from the
receiver.

 If the acknowledgement is received before expiry of the timer, then the transmission
is successful.

 But if the transmitting station does not receive the expected acknowledgement
before the timer expiry then it increments the back off parameter, waits for the back
off time and resenses the line.
MEDIA ACCESS CONTROL (MAC) (CONTD…)
Difference between CSMA/CA and CSMA/CD:-
HDLC
 High-level Data Link Control (HDLC) is a bit-oriented protocol for communication over
point-to-point and multipoint links.
 It implements the ARQ mechanisms.
 With the help of the HDLC protocol, full-duplex communication is possible.

Types of Stations
 In order to make the HDLC protocol applicable for various network configurations,
there are three types of stations
a) Primary Station: It is the responsibility of the primary station to connect and
disconnect the data link. The frames issued by the primary station are commonly known
as commands.
b) Secondary Station: The secondary station operates under the control of the
primary station. The frames issued by the secondary stations are commonly known as
responses.
c) Combined Station: The combined station acts as both Primary stations as
well as Secondary stations. The combined station issues both commands as well as
responses.
HDLC (CONTD…)
Configurations and Transfer Modes

 HDLC provides two common transfer modes that can be used in different
configurations:

a) Normal Response Mode (NRM)

b) Asynchronous Balanced Mode (ABM)

a) Normal Response Mode:

In this mode, the configuration of the station is unbalanced.

There are one primary station and multiple secondary stations.

The primary station can send the commands and the secondary station can only
respond.

The NRM is used for both point-to-point and multiple-point links


HDLC (CONTD…)
b) Asynchronous Balance Mode:

In this mode, the configuration of the station is balanced.

In this mode, the link is point-to-point, and each station can function as a primary and
as secondary.
HDLC (CONTD…)
HDLC Frame Types

 In order to provide the flexibility that is necessary to support all the options possible in
the modes.

 There are three types of frames defined in the HDLC:

a) Information Frames (I-frames): These frames are used to transport the


user data and the control information that is related to the user data. If the first bit of the
control field is 0 then it is identified as I-frame.

b) Supervisory Frames (S-frames): These frames are only used to transport


the control information. If the first two bits of the control field are 1 and 0 then the frame
is identified as S-frame.

c) Unnumbered Frames (U-Frames): These frames are mainly reserved for


system management. These frames are used for exchanging control information between
the communicating devices.

 Each type of frame mainly serves as an envelope for the transmission of a different
type of message.
HDLC (CONTD…)
HDLC Frame Format
 There are up to six fields in each HDLC frame.
 There is a beginning flag field, the address field then, a control field, an information
field, a frame check sequence field(FCS), and an ending field.

i) Flag: It is an 8-bit sequence that marks the beginning and the end of the
frame. The bit pattern of the flag is 01111110.
ii) Address: It contains the address of the receiver. If the frame is sent by the
primary station, it contains the address(es) of the secondary station(s). If it is sent by the
secondary station, it contains the address of the primary station. The address field may be
from 1 byte to several bytes.
iii) Control: It is 1 or 2 bytes containing flow and error control information.
iv) Payload: This carries the data from the network layer. Its length may
vary from one network to another.
v) FCS: It is a 2 byte or 4 bytes frame check sequence for error detection.
HDLC (CONTD…)
a) Information Frames (I-frames):
 I-frames carry user‟s data and control information about user‟s data.
 I-frame carries user data in the information field.
 The I-frame format is shown in diagram.

 The 1st bit of control field is always zero, i.e. the presence of zero at this place
indicates that it is I-frame.
 Bit number 2, 3 & 4 in control field is called N(S) that specifies the sequence
number of the frame. Thus it specifies the number of the frame that is currently
being sent. Since it is a 3.bit field, only eight sequence numbers are possible 0, 1, 2,
3, 4, 5, 6, 7 (000 to 111).
HDLC (CONTD…)
 Bit number 5 in control field is P/F i.e. Poll/Final and is used for these two
purposes. It has, meaning only when it is set i.e. when P/F=1. It can represent the
following two cases.

(i) It means poll when frame is sent by a primary station to secondary (when
address field contains the address of receiver).

(ii) It means final when frame is sent by secondary to a primary (when the
address field contains the address of the sender).

 Bit number 6, 7, and 8 in control field specifies N(R) i.e. the sequence number of
the frame expected in return in two-way communication.

 If last frame received was error-free then N(R) number will be that of the next
frame is sequence. If the last frame was not received correctly, the N(R) number
will be the number of the damaged frame, asking for its retransmission.
HDLC (CONTD…)
b) Supervisory Frames (S-frames):

 S-frame carries control information, primarily data link layer flow and error
controls.

 It does not contain information field.

 The format of S-frame is shown in diagram.

 The first two bits in the control field of S-frame are always 10.

 Then there is a bit code field that specifies four types of S-frame with combination
00, 01, 10, 11 as shown in table :-
HDLC (CONTD…)

 1. RR: Receive Ready-used to acknowledge frames when no I-frames are availab1e


to piggyback the acknowledgement.

 2. REJ: Reject-used by the receiver to send a NAK when error has occurred.

 3. RNR: Receive Not Ready-used for flow control.

 4. SREJ: Selective Reject-indicates to the transmitter that it should retransmit the


frame indicated in the N(R) subfield.

 There is no N(S) field in control field of S-frame as S-frames do not transmit data.

 P/F bit is the 5th bit i.e. Poll/Final

 Last three bits in control field indicates N(R) i.e. they correspond to the ACK or
NAK value.
HDLC (CONTD…)
c) Unnumbered Frames (U-frames):

 U-frames are reserved for system management and information carried by them is
used for managing the link

 U-frames are used to exchange session management and control information


between the two connected devices.

 Information field in U-frame does not carry user information rather, it carries
system management information.

 The frame format of U-frame is shown in diagram.

 U-frame is identified by the presence of 11 in the first and second bit position in
control field.

 • These frames do not contain N(S) or N(R) in control field.


HDLC (CONTD…)

 U-frame codes are divided into two sections: a 2-bit prefix and a 3-bit, together,
these two segments (5 bits) can be used to create up to 32 different types of U-
frames.

 Some of the more common types are shown in Table .


HDLC (CONTD…)
STP PROTOCOL
 Spanning Tree Protocol (STP) is a Layer 2 network protocol used to prevent looping
within a network topology.

 STP was created to avoid the problems that arise when computers exchange data on a local
area network (LAN) that contains redundant paths.

 IEEE standardized STP protocols as IEE 802.1D.

 Loop Networking: It is a phenomenon when a packet neither arrives at its destination not
it get dropped along the path. It keep on travelling in the network until it consumes all
network resources and bring the network down.

How Loop Occurs in Switched Networks:

 When switches are connected to each other in a linear way, then there is no concern of
loop formation because a frame has only one path to reach from source to destination in
the switched network.
STP PROTOCOL
Loop Condition:

 But when switches are connected to each other in a ring so that we could have backup/
redundant links, there will exist multiple paths to reach from source to destination.

 It will create loop in the switched network.

 Looping occurs when data travels from a source to a destination along redundant paths
and the data begins to circle around the same paths, becoming amplified and resulting in a
broadcast storm.

 When Spanning-Tree is enabled on a switch (it is by default on all Cisco switches), it


controls the state of every switch port and places each one in either a forwarding or a
blocking state where:

a) Ports in forwarding state send and receive frames and act as normal switch
interface. In our examples, these ports are shown in green.
STP PROTOCOL
b) Ports in blocking state do not process any frames except for Spanning-Tree
messages and do not learn MAC addresses. In the examples, these ports are shown in orange.

 Using this logic, Spanning-Tree breaks the looped physical topology into a loop-free logic
topology.

Example 1:

 Let's visualize this with the example shown in figure.

 We have a triangle of interconnected switches.


STP PROTOCOL
 This creates a looped topology and Spanning-Tree detects that by exchanging messages
over each link.

 In the end, STP places ports highlighted in green in forwarding state and the one in orange
in blocking state.

 This results in the logical topology presented on the right. You can see that logically there
is a loop-free topology.

Example 2:

 The same logic applies to larger topologies with many redundant links.

 If we look at figure, we can that there are multiple looped topologies.

 Hence the STP protocol must block a few ports in order to achieve the loop-free topology
shown on the right.
STP PROTOCOL

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy