CSMA 802.11 Scripting In Python
You are to study the performance of multiple access protocols in a wireless setting. Consider the network shown in Figure 1.
The circles denote the communication range R of each station. We are interested in the following two scenarios:
A. Concurrent Communications: Stations A, B, C, and D of Figure 1(a) are within the same collision domain (any transmission is received by all). Communication takes place between pairs A → B and C → D. Traffic is generated at A and C according to a Poisson arrival process with parameters λA and λC, respectively. B. Hidden Terminals: Stations A, B, and C of Figure 1(b), belong to two collision domains. Communication takes place between pairs A → B and C → B. Traffic is generated at A and C according to a Poisson arrival process with parameters λA and λC, respectively. For each scenario, compute relevant performance metrics for the following multiple access protocols. A time-slotted system is assumed. 1. CSMA with Collision Avoidance (CSMA/CA) according to the 802.11 DCF function. (a) A station T x ready to transmit (when a frame has arrived for transmission from the upper layers of the network stack) selects a random backoff value in [0, CW0 − 1]. It first senses the channel for an initial period of DIFS time.
(b) If the channel is busy, T x (and every other station with a frame for transmission) monitors the channel until it becomes idle. When the channel becomes idle, T x decrements his counter by one with every idle slot. If the channel becomes busy, T x freezes its backoff counter. When the counter reaches zero, T x transmits its frame. (c) If the frame is successfully received (no collision) by Rx, the station Rx replies with an ACK frame after SIFS time. This completes the transmission round and the protocol repeats for the next transmission. For successive transmissions, the station has to sense for DIFS time before starting the countdown. (d) If a collision occurs, the stations that collided double their contention window CW and repeat the backoff process. After k collisions, the backoff value is selected from [0, 2 kCW0 − 1]. The CW value cannot exceed threshold CWmax
so basically the concept in there is that a global time is ongoing, and each stations randomly transmit data in any slot.
(so I have to create simulation where packets are sent at random times by station A and B).
Then each packet sense media by first sending DIFS to see if media is free and then send RTS to control media and then sends data.
Meanwhile station B should sees media is busy and should wait.
I am like lost on what could be best approach to implement it, I looked at producer consumer concept in python, but it does not synchronize well in my logic flow.
Any ideas/directions with examples will be highly appreciated.
Here is the algorithm overview:
https://i.stack.imgur.com/Qhmwl.png