Lecture 6
Lecture 6
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
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:
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).
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
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