Data Link Layer
Data Link Layer
CRC Code
Hamming Code
Piggybacking
MAC
ALOHA
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.
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.
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.
Frame Trailer: It contains the error detection and error correction bits.
a) Fixed-Size Framing:
There is no need to provide boundaries to the frame, length of the frame itself acts as
delimiter.
b) Variable-Size Framing:
So additional mechanisms are kept to mark the end of one frame and the beginning of
the next frame.
Frame Header − It contains the source and the destination addresses of the frame.
Flags − 1- byte (8-bits) flag at the beginning and at end of the frame.
In this method, start and end of frame are recognized with the help of flag bytes.
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.
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
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
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
In the Circuit Switching Technique, once the connection is established then the
dedicated path will remain to exist until the connection is terminated.
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.
a) Connection establishment
b) Data transfer
c) Connection termination
SWITCHING TECHNIQUES (CONTD…)
ii) Packet Switching:
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.
Each packet contains the information about the destination and switch uses
this information to forward the packet to the correct destination.
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.
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
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.
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.
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):
Dividend appends the data with generator G(x) using modulo 2 division
(arithmetic).
Division
Solution:
Data + CRC
OR
ERROR DETECTION AND ERROR CORRECTION
Receiver Site:
Divisor
Zero Non-Zero
No Error Error
ERROR DETECTION AND ERROR CORRECTION
Example: Assume the received message is 10110110.
Solution:
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
= 2𝑃 ≥ 4 + P + 1
The position of the redundant bits is calculated with corresponds to the raised power of
2.
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).
𝐏𝟐 : 2, 3, 6, 7 = P2 , 0, 0, 1
𝐏𝟐 = 1
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).
𝐏𝟒 : 4, 5, 6, 7 = P4 , 1, 0, 1
𝐏𝟒 = 0
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.
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
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:
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:
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.
Stop and Wait ARQ is an improved and modified version of Stop and Wait protocol.
Stop and wait ARQ includes the following three extra elements.
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.
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.
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:
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.
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:
It controls the data packets between the two devices where reliable and gradual
delivery of data frames is needed.
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.
a) Go-Back-N ARQ
In this, if any frame is corrupted or lost, all subsequent frames have to be sent again.
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..
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:
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.
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.
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.
The above mentioned drawbacks are avoided by transmitting ACK along with data packet.
with next data packet from the other end (say B). This
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.
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
CSMA/CA
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.
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.
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-
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.
At Station A-
- The 2nd data packet of station A undergoes collision for the 1st time.
- Now, station A randomly chooses a number in the range [0, 𝟐𝟏 -1] = [0 , 1].
- The 1st data packet of station D undergoes collision for the 2nd time.
- Now, station D randomly chooses a number in the range [0, 𝟐𝟐 -1] = [0 , 3].
𝑲𝑨 𝑲𝑫 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.
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.
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.
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…)
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…)
This method was developed in order to minimize the chance of collision and therefore,
increase the performance.
It sense the traffic on a channel (idle or busy) before transmitting the data.
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
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…)
• 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.
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.
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.
• When a frame is ready, the transmitting station checks whether the channel is
idle or busy.
• 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.
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.
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…)
• 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.
• 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.
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.
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.
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:
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.
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:
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.
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:
The primary station can send the commands and the secondary station can only
respond.
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.
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.
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…)
2. REJ: Reject-used by the receiver to send a NAK when error has occurred.
There is no N(S) field in control field of S-frame as S-frames do not transmit data.
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
Information field in U-frame does not carry user information rather, it carries
system management information.
U-frame is identified by the presence of 11 in the first and second bit position in
control field.
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.
STP was created to avoid the problems that arise when computers exchange data on a local
area network (LAN) that contains redundant paths.
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.
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.
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.
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:
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.
Hence the STP protocol must block a few ports in order to achieve the loop-free topology
shown on the right.
STP PROTOCOL