Skip to content

GeorgeFawkes/CSMA-CA-Backoff-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSMA/CA Backoff Algorithm Simulator

A group project simulating and comparing three backoff mechanisms used in CSMA/CA wireless networks: Binary Exponential Backoff (BEB), Exponential Increase Exponential Decrease (EIED), and Logarithmic Increment Backoff (LIB). Each algorithm is implemented as a threaded, RTS/CTS-driven node simulation with per-node contention window tracking and energy consumption modeling.

Built collaboratively by George Mensah, Tilak Marupilla, Robert Quainoo, and Soniya Kadam.

Background

CSMA/CA (Carrier Sense Multiple Access with Collision Avoidance) is the medium access control approach behind most 802.11-based WLANs. When a node has data to send, it waits for a random backoff period before attempting an RTS (Request to Send); if the channel is busy or a collision occurs, the backoff mechanism determines how long it waits before trying again. The choice of backoff algorithm directly affects contention window growth, transmission delay, and energy consumption — this project simulates that choice under identical conditions to see how the three approaches actually differ in practice.

The three algorithms

Algorithm Contention window rule
Binary Exponential Backoff (BEB) Doubles on every collision (CW = min(2·CW, CW_max)), resets to CW_min on success
Exponential Increase Exponential Decrease (EIED) Grows by a factor α=1.25 on collision, shrinks by a factor β=0.8 on success — a softer landing than BEB's hard reset
Logarithmic Increment Backoff (LIB) Backoff range calculated directly as 2^retries, so window growth tracks the number of retries logarithmically rather than the window size itself

Simulation setup

All three scripts default to the same 3-node topology used to produce the results below: Node 1 at (1,1) and Node 3 at (20,20) both transmitting, Node 2 at (10,10) receiving.

Node Locations

Shared constants across all three: DIFS = 0.05s, SIFS = 0.01s, slot time = 0.02s, CW_min = 15, CW_max = 1023, max retries = 7.

Results

Binary Exponential Backoff

Node 1 Node 3
BEB Node 1 BEB Node 3

Node 1's contention window climbs exponentially, peaks near 1000, then drops sharply — a clear signature of a successful transmission resetting the window — before climbing again. Node 3 shows a steadier climb to the same ceiling without ever resetting during the simulation window, meaning no successful transmission was captured in that run.

BEB Energy

Node 1 (the node whose window reset, implying more total activity) consumed the most energy at ~532 units; Node 3 consumed about half that (~271 units); Node 2, the receiver, consumed only ~2 units.

Exponential Increase Exponential Decrease

Node 1 Node 3
EIED Node 1 EIED Node 3

Node 1 shows a clean sawtooth pattern: window grows on repeated collisions, then drops sharply on success, repeating in cycles — the EIED mechanism visibly at work. Node 3's growth is smoother with no sharp drop, indicating fewer successful transmissions in that run relative to Node 1.

EIED Energy

Total energy consumption is far lower across the board than BEB (~103 units for Node 1 vs. ~532 for BEB's Node 1), since EIED's window rarely grows anywhere near BEB's exponential ceiling.

Logarithmic Increment Backoff

Node 1 Node 3
LIB Node 1 LIB Node 3

Node 1's window grows steadily to just over 120 with no drop, suggesting repeated retries without a captured success in this run. Node 3 shows a single sharp spike to ~128 before dropping back down — one significant backoff event followed by a successful transmission.

LIB Energy

Energy consumption here sits between the other two algorithms: Node 3 (~79 units) consumed more than Node 1 (~37 units) in this run, the reverse of the pattern seen in BEB and EIED, consistent with Node 3 experiencing the larger single backoff spike.

Takeaways

BEB adapts quickly to contention but its aggressive doubling drives up both delay and energy use. EIED's gentler exponential decrease keeps the contention window — and energy consumption — consistently lower, at the cost of slower adaptation after a burst of collisions. LIB sits in between: its logarithmic growth avoids BEB's runaway window sizes while still scaling with retry count. Which one is "best" depends on the deployment: EIED suits energy-constrained networks, BEB suits scenarios needing fast adaptation to bursty contention, and LIB offers a middle ground.

Running it

Each script is self-contained and only depends on matplotlib (standard library otherwise):

pip install matplotlib
python beb.py     # or eied.py, or lib.py

Running with no arguments reproduces the 3-node topology and results shown above. Pass --interactive to be prompted for a custom node count and layout instead:

python beb.py --interactive

Tools

Python 3, matplotlib, threading (for concurrent node simulation), Google Colab (original development environment).

About

Simulates and compares three CSMA/CA backoff algorithms (BEB, EIED, Logarithmic Increment) using a threaded RTS/CTS node simulation with contention window and energy tracking

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages