Skip to main content
. 2019 Oct 6;19(19):4321. doi: 10.3390/s19194321
Algorithm 2 Optimal Contention Window Selction
Initialization: 𝚥 = 0, 𝚤 = 0, Tx = 0.
procedure
2:     count 𝚤▹𝚤 is a flow sensed at the physical layer by a node, which is out of transmission range but within the sensing range
4:     count 𝚥 ▹ 𝚥 is a flow within the transmission range
6:     for each TS duration do ▹ MAC layer is divided into Time Slots (TS) of fixed intervals
8:     𝚥’s duration = 10% × 𝚥’s time + 90% × Tx duration ▹ time taken by 𝚥 flow
10:        Tx = 0
12:        for each packet p do
14:           if p is CTS then
16:             Tx = Trtc + Tcts
18:           elseif p is ACK then
20:             Tx = Tdata + Tack
22:            end if
24:         end for
26:     end for
28:     R=𝚥TSduration R is real allocation of bandwidth
30:     F = 𝚥𝚤+𝚥 F is the fair allocation of bandwidth to a node
32:     CWadjusted = CW ×RF
34:     CWoptimal = κ×CWadjusted ▹ if packet is marked using Equation (6) and κ > 1 is a delay factor.
36:     CWoptimal = CWadjusted ▹ if packet is not marked using Equation (6)
38: end procedure