# A Software-Defined Networking Framework to Provide Dynamic QoS Management in IEEE 802.11 Networks
## 2 Contention Window Adaptation Mechanism
### The Proposed Mechanism
#### 2.2.1 Modeling the Gain  
In backoff-based algorithms, the stations that are competing for the medium have a probability of winning the channel that depends on the backoff parameters. We call this probability \(P(win)\). As said before, DEDCA algorithm is based on the modification of the \(CW_{min}\) value of some terminals to increase or decrease their probability of winning the channel. Thus, we define \(Gain\)\(G\) as the multiplicative increase or decrease of this probability when a terminal modifies its \(CW_{min}\) value with respect to a non-modified terminal. This scalar value \(G\) is obtained as the probability of winning the channel when the station modifies its \(CW_{min}\) value, normalized to the case when \(CW_{min}\) has the default value:  
\[G=\frac{P(win)|_{CW_{min}=default\_CW_{min}\pm k}}{P(win)|_{CW_{min}=default \_CW_{min}}}\]  
Firstly, we obtain the probability of winning the channel access of a reference station, that is, a non-modified station. The \(U_{i}\) variable is defined as the backoff counter that station \(i\) obtains for a particular channel access. For convenience, instead of using the interval \([0,CW_{min}]\) we will use the interval \([1,W]\), where \(W=CW_{min}+1\). Therefore, \(U_{i}\in[1,W]\) with \(P(U_{i})=1/W\). After the random backoff procedure, the channel access is obtained by the node of the \(n\) competing nodes with the lowest \(U_{i}\) value. If we consider station 1 as reference, and without loss of generality, its channel access probability \(P(win)\) can be calculated as follows:  
\[P(win)=P((U_{1}<U_{2})\wedge(U_{1}<U_{3})\wedge...\wedge(U_{1}<U_{n}))\]  
The above equation is difficult to calculate because the involved variables are dependent on each others. Nevertheless, if an auxiliary random variable \(d\) is defined as:  
\[d=\min\{U_{2},U_{3},...,U_{n}\}\in[1,W]\]  
then, the probability that station 1 wins the backoff contention is simply:  
\[P(win)=P(U_{1}<d) \tag{1}\]  
Random variable \(d\) models the behavior of the rest of stations. Using it, the probability of winning conditioned to \(d\) can be easily calculated:and applying the total probability theorem:  
\[P(win)=\sum P(win|d)P(d)=\] \[=\frac{1}{W}\sum_{i=2}^{W}{(i-1)P(d=i)}=\frac{E[d]-1}{W} \tag{2}\]  
Now, we obtain the probability of a reference station of winning the channel access when its \(CW_{min}\) value is decremented in \(k\) units, that is, it obtains some advantage with respect to the others (a similar development can be applied in the case that \(CW_{min}\) value is increased in \(k\) units). If station 1 decreases its \(CW_{min}\) in \(k\) units, then:  
\[U_{1}\in[1,W-k]\] \[U_{i}\in[1,W]\ \ \ i\geq 2\] \[d=\min\{U_{2},U_{3},...,U_{n}\}\in[1,W]\]  
with \(P(U_{i})=1/W\ \ \forall i\geq 2\), \(P(U_{1})=1/(W-k)\). As before, the probability of winning conditioned to \(d\) can be calculated:  
\[P(win|d) \ d\] \[P(win)=P((U_{1}<U_{2})\wedge(U_{1}<U_{3})\wedge...\wedge(U_{1}<U_{n}))\]0  
Therefore,  
\[P(win)=P((U_{1}<U_{2})\wedge(U_{1}<U_{3})\wedge...\wedge(U_{1}<U_{n}))\]1 \[P(win)=P((U_{1}<U_{2})\wedge(U_{1}<U_{3})\wedge...\wedge(U_{1}<U_{n}))\]2  
Finally, the gain \(G\) associated with the reference station is obtained:  
\[P(win)=P((U_{1}<U_{2})\wedge(U_{1}<U_{3})\wedge...\wedge(U_{1}<U_{n}))\]3  
Surprisingly, the calculation of \(G\) is relatively straightforward. Both terms have been already calculated when the window size is decremented (Equations (2) and (4) respectively). Therefore,  
\[P(win)=P((U_{1}<U_{2})\wedge(U_{1}<U_{3})\wedge...\wedge(U_{1}<U_{n}))\]4 \[P(win)=P((U_{1}<U_{2})\wedge(U_{1}<U_{3})\wedge...\wedge(U_{1}<U_{n}))\]5  
The term \(\Delta G\) can be expressed as:  
\[P(win)=P((U_{1}<U_{2})\wedge(U_{1}<U_{3})\wedge...\wedge(U_{1}<U_{n}))\]6  
Figure 1 shows the term \(1+\Delta G\) as a function of \(k\) for \(W=\{16,32\}\) (that is, \(default\_CW_{min}=\{15,31\}\)). It can be seen that the value of \(1+\Delta G\) is practically one, even for values of \(k\) close to \(W\).