Algorithm 2 Optimal Contention Window Selction |
Initialization: 𝚥 = 0, 𝚤 = 0, T = 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% × T duration |
▹ time taken by 𝚥 flow |
10:
|
= 0 |
12:
|
for each packet p
do
|
14:
|
if
p is CTS
then
|
16:
|
T = T + T
|
18:
|
elseif
p is ACK
then
|
20:
|
T = T + T
|
22:
|
end if
|
24:
|
end for
|
26:
|
end for
|
28:
|
|
▹ is real allocation of bandwidth |
30:
|
=
|
▹ is the fair allocation of bandwidth to a node |
32:
|
CW = CW
|
34:
|
CW =
|
▹ if packet is marked using Equation (6) and > 1 is a delay factor. |
36:
|
CW = CW
|
▹ if packet is not marked using Equation (6) |
38:
|
end procedure
|