MAC Layer: Carrier Sense Multiple Access with Collision Avoidance Simulator
This project will cover the simulation of Carrier Sense Multiple Access with Collision Avoidance (CSMA/CA) focusing on Distributed Coordination Function (DCF) with contention window and basic Inter-Frame Space (IFS). You can find this project on my Github profile MAC Layer - CSMA/CA Technique.
1. Understanding CSMA/CA with DCF
CSMA/CA is a MAC layer protocol used primarily in wireless networks (WiFi - IEEE 802.11) to manage how multiple stations share a common communication medium. CSMA/CA focuses on avoiding collisions before they occur.
The Distributed Coordination Function (DCF) is the fundamental access method in IEEE 802.11. It relies on following principles:
- Carrier Sensing
- A station listens to the wireless medium before attempting to transmit information bits. If the medium is sensed as busy, the station defers its transmission.
- Inter-Frame Space (IFS)
- After the medium becomes idle, a station does not transmit immediately. It waits for a specific period called the IFS.
- Most relevant: Distributed IFS (DIFS): This waiting period ensures that higher-priority traffic (like acknowledgements using Short IFS - SIFS) gets access first.
- Collision Avoidance (CA) with random backoff
- If the medium is sensed idle after the DIFS, the station does not transmit right away. Instead, it enters a contention window and chooses a random backoff time.
- Backoff Time = Random(0,Contention Window) X Slot Time
- Slot Time = Defined by the standard (e.g., 9 µs in 802.11g)
- The backoff timer starts decrementing only when the channel starts being in idle state.
- If the channel becomes busy (e.g., another station starts transmitting), the backoff timer is paused.
- Once the channel becomes idle again and stays idle for a DIFS, the countdown resumes.
- Acknowledgement (ACK)
- After a successful data frame transmission, the receiving station sends an ACK frame after a short SIFS.
- The absence of an ACK within a certain timeout period indicates a potential collision, and the transmitting station will attempt retransmission.
- Binary Exponential Backoff (BEB)
- If a transmission fails (no ACK received), the transmitting station increases its contention window size (CW) for the next retransmission attempt.
- The CW typically doubles with each failed attempt, up to a maximum size.
- This exponential increase in the backoff range further reduces the chances if repeated transmissions.
2. CSMA/CA algorithm steps
2.1 Brief Overview
- Step-1: Start
- Step-2: Packet is ready for Transmission
- Step-3: Channel Sensing
- Step-4: Channel Idle
- Step-4.1: If No, obtain Back-off
- Step-4.2.2: After backoff timer ends, send packet
- Step-4.2: If Yes, send packet
- Step-5: Collision
- Step-5.1: If No, Successful transmission.
- Step-5.2: If Yes, Go back to Step-3
2.2 In-Depth Analysis
2.3 CSMA/CA Mathematical Flowchart
3. Request for Feedback
Are there additional topics you'd like me to cover? Here are some potential topics:3.1 Carrier Sensing Mechanisms: How stations determine if the transmission medium is busy?
Wireless stations employ two complementary methods to assess channel availability:
- Physical Carrier Sensing (PHY Layer)
- Performed by radio hardware through Energy Detection
- Measures RF signal strength on the channel
- Channel declared busy if detected power exceeds threshold (e.g., -82 dBm)
- Key advantage: Works without packet decoding - detects any RF activity
- Example: Network interface defers transmission when detecting nearby WiFi signals
- Virtual Carrier Sensing (MAC Layer via NAV)
- Analyzes packet headers (RTS/CTS/data frames) for Duration fields
- Maintains a Network Allocation Vector (NAV) timer
- Medium considered busy while NAV > 0, regardless of RF detection
- Critical benefit: Solves hidden terminal problems
RTS/CTS Protocol Deep Dive
Collision avoidance in hidden terminal scenarios
Control Frame Functions:
- RTS (Request to Send): Reserves channel for transmission
- CTS (Clear to Send): Confirms channel reservation
Hidden Terminal Scenario:
Scenario:
Step-by-Step implementation:
- A sends RTS (Request to Send) to the AP:
- Includes how long it wants the channel (duration field).
- AP replies with CTS (Clear to Send):
- Broadcasts to all stations that A can now transmit.
- This CTS also contains the same duration info.
- Other stations (like C) hear the CTS:
- Even if they didn’t hear A’s RTS, they now know someone else is using the channel.
- They update their NAV (Network Allocation Vector) and defer transmission.
- A sends the data.
- AP sends an ACK (acknowledgment) if received successfully.
3.2 Inter-Frame Spacing Hierarchy ?
The timing architecture that governs transmission priority
After channel clearance, stations observe prioritized waiting periods:
Type | Name | Purpose | Duration Formula | Priority |
SIFS | Short IFS | High-priority responses | Fixed (~10µs) | Highest |
PIFS | Point IFS | AP-controlled access | SIFS + 1 slot | High |
DIFS | Distributed IFS | Standard data frames | SIFS + 2 slots | Medium |
EIFS | Extended IFS | Error recovery | Longest | Lowest |
Key Applications:
- SIFS: ACK/CTS responses (ensures uncontested replies)
- DIFS: Regular data transmission attempts
- EIFS: Recovery after corrupted frame detection
3.3 Slot Times ?
802.11 Standard | Slot Time (μs) | Notes |
802.11a/g/n/ac/ax (5 GHz) | 9 μs | OFDM-based standards |
802.11b | 20 μs | DSSS/CCK (2.4 GHz legacy) |
802.11n (2.4 GHz) | 9 μs or 20 μs | Depends on legacy compatibility |
802.11ax (HE) | 9 μs | High Efficiency (HE) |
You can find this project on my Github profile MAC Layer - CSMA/CA Technique.
Comments
Post a Comment