You are on page 1of 29

Lecture 6

Random access protocols


in MAC
(CSMA – CSMA/CD-
CSMA/CA)
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
6.1
Media Access Control in Wired Networks
• If two devices transmit at the same time on a
network’s shared medium, whether wired or
wireless, the two signals will interfere and the
result will be unusable to both devices.
• Access to the shared medium therefore needs
to be actively managed to ensure that the
available bandwidth is not wasted through
repeated collisions of this type. This is the
main task of the MAC layer
2
1. CSMA (Carrier Sense Multiple Access)
• CSMA gives improved throughput
compared to Aloha protocols.
• Listens to the channel before
transmitting a packet (avoid avoidable
collisions).

3
Collision Mechanism in CSMA
Node 1 Node 5 sense
Packet Node 2
Packet Node 3 Delay
Packet
1 2 3 4 5
Time
Delay Collision
Node 4 sense

4
Kinds of CSMA
Non-persistent CSMA
CSMA

Persistent CSMA

CSMA/CD, wired network IEEE 802.3

CSMA

CSMA/CA, wireless IEEE 802.11


network
Nonpersistent/x-persistent CSMA Protocols
• Non-persistent CSMA Protocol:
Step 1: If the medium is idle, transmit immediately
Step 2: If the medium is busy, wait a random amount of time
and repeat Step 1
– Random backo reduces probability of collisions
– Waste idle time if the backo time is too long
• 1-persistent CSMA Protocol:
Step 1: If the medium is idle, transmit immediately
Step 2: If the medium is busy, continue to listen until medium
becomes idle, and then transmit immediately
– There will always be a collision if two nodes want to
retransmit (usually you stop transmission attempts after
few tries)

6
Carrier Sense Multiple Access/Collision
Detection (CSMA/CD), IEEE 802.3
• The most commonly used MAC method.
• When a device has a data frame to transmit
onto a network that uses this method, it rst
checks the physical medium (carrier sensing)
to see if any other device is already
transmitting.
7
CSMA/CD (Cont’d)
• If the device senses another transmitting
device it waits until the transmission has
nished. As soon as the carrier is free it
begins to transmit data, while at the same
time continuing to listen for other
transmissions.
• If it detects another device transmitting at
the same time (collision detection), it stops
transmitting and sends a short jam signal to
tell other devices that a collision has occurred.
8
CSMA/CD (Cont’d)
• Back-o algorithm is a collision resolution
mechanism which is commonly used to
schedule retransmissions after collisions in
Ethernet. The waiting time that a station
waits before attempting retransmission of
the frame is called as back o time.

9
How much time the station should
wait to re-transmit?
• Waiting time = back–o time
• Let n = collision number or re-transmission
serial number.
• Then, Waiting time = K * Tslot
• where K = [0, 2n – 1 ]
10
Case 1:
• Suppose 2 stations A and B start
transmitting data (Packet 1) at the same
time then, collision occurs. So, the collision
number n for both their data (Packet 1) = 1.
Now, both the station randomly pick an
integer from the set K i.e. {0, 1}.

11
Case 1:
 When both A and B choose K = 0
Waiting time for A = 0 * Tslot = 0
Waiting time for B = 0 * Tslot = 0
Therefore, both stations will transmit at the
same time and hence collision occurs.
When A chooses K = 0 and B chooses K = 1
Waiting time for A = 0 * Tslot = 0
Waiting time for B = 1 * Tslot = Tslot
Therefore, A transmits the packet and B waits
for time Tslot for transmitting and hence A wins
12
Case 1:
 When A chooses K = 1 and B chooses K = 0
Waiting time for A = 1 * Tslot = Tslot
Waiting time for B = 0 * Tslot = 0
Therefore, B transmits the packet and A waits
for time Tslot for transmitting and hence B wins.
When both A and B choose K = 1
Waiting time for A = 1 * Tslot = Tslot
Waiting time for B = 1 * Tslot = Tslot
Therefore, both will wait for the same time Tslot
and then transmit. Hence, collision occurs.
13
Conclusion:
 Probability that A wins = 1/4
 Probability that B wins = 1/4
 Probability of collision = 2/4

14
Case 2:
• Assume that A wins in Case 1 and
transmitted its data(Packet 1). Now, as soon
as B transmits its packet 1, A transmits its
packet 2. Hence, collision occurs.
occurs Now
collision no. n becomes 1 for packet 2 of A
and becomes 2 for packet 1 of B.
• For packet 2 of A, K = {0, 1}
• For packet 1 of B, K = {0, 1, 2, 3}
15
Case 2:

Probability that A wins = 5/8


Probability that B wins = 1/8
Probability of collision = 2/8
So, the probability of collision decreases as compared to Case 1.

16
disadvantages, CSMA/CD
CSMA / CD is a fast way to access but as the
network grows, it becomes ine ective
because larger networks are more prone to
data collisions due to the following:
• Because more users are trying to reach the
transmission medium.
• because more data is generated and
exchanged on the network.
• The CSMA / CD is therefore only suitable for
small networks.
17
CSMA/CA (CSMA with collision Avoidance)
• CSMA/CA protocol is used in wireless networks
because they cannot detect the collision so the
only solution is collision avoidance.
• CSMA/CA avoids the collisions using three basic
techniques:
 Interframe space
 Contention window
 Acknowledgements

18
1. Interframe Space (IFS)
• Whenever the channel is found idle, the station
does not transmit immediately. It waits for a
period of time called interframe space (IFS).

• If after this IFS time, the channel is still idle, the


station can send, but it still needs to wait a time
equal to contention time.
time
19
2. Contention Window
• Contention window is an amount of time divided
into slots.
• A station that is ready to send chooses a random
number of slots as its wait time.
• The number of slots in the window changes
according to the binary exponential back-o
strategy. It means that it is set of one slot the rst
time and then doubles each time the station
cannot detect an idle channel after the IFS time.
20
Contention Window cont.
• In contention window the station needs to sense
the channel after each time slot.
• If the station nds the channel busy, it does not
restart the process. It just stops the timer &
restarts it when the channel is sensed as idle.

21
CSMA/CA (Cont’d)
Node A’s Node B’s frame Node C’s
frame frame
Delay: B Time
Delay: C
Nodes B & C sense
the medium
Nodes B resenses the Nodes C starts
medium and transmits its transmitting.
frame.
Node C freezes its counter.
Nodes C resenses the
medium and starts
decrementing its
counter.
22
CSMA/CA Explained
DIFSContention
window DIFS Contention
window
Medium Busy Next Frame
Time
Defer access Slo
t
Backo after defer

DIFS – Distributed Inter Frame Spacing

23
CSMA/CA with ACK
• Immediate Acknowledgements from
receiver upon reception of data frame
without any need for sensing the medium.
• ACK frame transmitted after time interval
SIFS (Short Inter-Frame Space) (SIFS < DIFS)
• Receiver transmits ACK without sensing
the medium.
• If ACK is lost, retransmission done.
24
CSMA/CA/ACK
DIFS Data Time
Source
SIFS
ACK
Destinati
on DIFS Contention
window
Next Frame
Othe
r Defer access Backo after defer
SIFS – Short Inter Frame Spacing
25
CSMA/CA with RTS/CTS
• Transmitter sends an RTS (request to send)
after medium has been idle for time
interval more than DIFS.
• Receiver responds with CTS (clear to send)
after medium has been idle for SIFS.
• Then Data is exchanged.
• RTS/CTS is used for reserving channel for
data transmission so that the collision can
only occur in control message.

26
CSMA/CA with RTS/CTS (Cont’d)
DIFS SIFS
Sourc RTS Data Time
e SIFS SIFS
Destinati CTS ACK
on DIFS
Contention
window
Next Frame
Othe
r Backo after defer
Defer access

27
We can comparison between CSMA/CD and
CSMA/CA is given below:
CSMA/CD CSMA/CA
1. CSMA CD takes e ect after a collision 1. CSMA CA takes e ect before a
collision
2. CSMA/CD is part of the IEEE 802.3 2. CSMA/CA is part of the IEEE 802.11
standard standard
3. CSMA/CD reduces the recovery time 3. CSMA/ CA minimizes the possibility
of collision
4. CSMA/CD is more e cient than 4. CSMA/CA is less e ciency than
CSMA/CA CSMA/CD
5. CSMA CD is typically used in wired 5. CSMA/CA is used in wireless
networks. networks.
28
Table 3-2 IEEE 802 standards

You might also like