Upload
abed-ahmad-al-zaben
View
41
Download
0
Embed Size (px)
DESCRIPTION
Talking about the IEEE802.11b anomaly. Changing the contention window based on the RF conditions .
Citation preview
1
Yarmouk University
Hijjawi Faculty for Engineering Technology
Department of Telecommunication Engineering
Secondary Project
First Semester 2011/2012
IEEE 802.11b unfairness solution
Name Abdulhafeez Al-Zaben
Tareq Zeida
Student Number 2007973036
2007873006
Supervisor Name Dr. Haythem Bani Salameh
2
Abstract
IEEE 802.11 standards were breakthrough
technologies in the jargon of broadband wireless access.
It was and still the most common used method for
internet access. Hotspots are everywhere, and everybody
has a “fair” probability for accessing it. IEEE 802.11b
has an algorithm to achieve this fairness. It provides fair
access for the medium. However, it does not provide fair
bandwidth utilization. That’s why we conducted this
project; to find an advanced algorithm to eliminate this
unfairness.
Downloadable version
3
Table of Contents
Chapter1.............................................................................................................................. 4 Introduction ............................................................................................................................. 4
1.1. General description about IEEE 802.11b ......................................................... 4
1.2. Distributed Coordination Function .................................................................. 4
1.3. IEEE 802.11b Anomaly .................................................................................. 5
1.4. Related works ................................................................................................. 5
Chapter2.............................................................................................................................. 7 Theoretical background ........................................................................................................... 7
2.1 IEEE 802.11b DCF Anomaly........................................................................... 7
2.2 DCF-MB and DCF-MBA .............................................................................. 10
Chapter3............................................................................................................................ 14 Design in Details .................................................................................................................... 14
3.1 The design ..................................................................................................... 14
3.2 Advantages of DCF-MBA ............................................................................. 16
Chapter4............................................................................................................................ 18 Testing and Validation ........................................................................................................... 18
4.1 Design simulation .......................................................................................... 18
4.1.1 Network Configurations .......................................................................... 18
4.2 Simulation results and comments ................................................................... 19
Appendices............................................................................................................................. 24
Appendix A ......................................................................................................... 24
Appendix B ......................................................................................................... 25
Figure 4.1 ........................................................................................................ 25
Figure 4.2 ........................................................................................................ 30
3 nodes running at different times DCF-MB .................................................... 34
3 nodes running at different times DCF-MBA.................................................. 38
Appendix C ......................................................................................................... 42
4
Chapter
1
Introduction
1.1. General description about IEEE 802.11b
IEEE 802.11b is an upgraded version of IEEE 802.11 specification that has an
extended throughput up to 11 Mbps using the same 2.4 GHz spectrum, and it’s
specified under the name of Wi-Fi.
The IEEE 802.11b is a set of IEEE standards that provide wireless networking
transmission methods in the home, office and some commercial establishments.
As we mentioned before the 802.11b has a maximum data rate up to 11 Mbps
and it is divided into several data rates; 11, 5.5, 2 and 1 Mbps assigned to the users
depending on their distance from the Access point (i.e. RF conditions), giving
11Mbps for the nodes whose RF condition is considered to be strong (i.e. high
SNR) and 1 Mbps for the stations with weak RF conditions.
1.2. Distributed Coordination Function
The use of Distributed Coordination Function ( DCF ) presents two main
drawbacks that can be summarized as the DCF algorithm is unsuitable for Quality
of service aware applications, and its throughput unfairness issues, which known
as the 802.11b anomaly which will be the goal of our study. Although these two
drawbacks, the function (DCF) algorithm, which is based on Carrier Sense
Multiple Access with Collision Avoidance (CSMA/CA) technique, the non-
centralized algorithm (DCF), strongly participates in the success of IEEE 802.11b
due to its simplicity.
5
1.3. IEEE 802.11b Anomaly
Due to this anomaly the throughput of each access node dramatically reduced
once a station’s transmission bit rate decreases due to physical radio properties
(As mentioned before the IEEE 802.11b works under the band of 2.4 GHz, having
the same operating band of microwave ovens, Bluetooth devices and cordless
telephones). Specifically, a node that is relatively far from the access point is
subject to important signal fading and interference leading to repeated
unsuccessful frame transmission. As a result, the standard IEEE 802.11b reacts by
degrading the station bit rate from 11Mbps rate to 5.5, 2, 1Mbps; which will cause
a reduction in the throughput of all nodes. In other words, it means that all the
nodes are penalized due to the position of one node.
The basic CSMA/CA scheme allows a fair access to the shared channel. In this
regard, a node with a relatively low bit rate captures the channel a longer period
with respect to the remaining nodes transmitting at high bit rate. This leads to a
degradation of all access nodes’ throughput.
To solve this problem, we found a new strategy based on multiplication of
backoff window with an optimal value. We refer to this technique as the DCF-
MBA (DCF Multiple Backoff Advanced). In our scheme, access nodes are
classified into different sets according to their transmission bit rate (11, 5.5, 1
Mbps) and then each set will be characterized by each own backoff window.
1.4. Related works
In the recent years, several studies have been appeared to deal with the
analysis of the unfairness behavior of DCF protocol due to the basic CSMA/CA
algorithm, without providing a particular solution for this anomaly.
6
One of these solutions based on the SNR (Signal to Noise Ratio) classes’
differentiation, by providing each SNR node class with a distinct and fixed
backoff value. This solution fixes the contention window interval size for each
SNR, and defining two SNR classes: the good and low SNR classes, with
respectively, 31 and 1023 as backoff values. In doing so, the good SNR nodes
transmit more frequently than the low SNR nodes, and the throughput of the good
SNR nodes will be not affected by the low speed transmitting nodes belonging to
the low SNR class. However, this solution is only limited to two classes of SNR,
whereas in reality much more SNR classes are found.
Another solution founded for the anomaly is to specify the maximum packet
size that can be transmitted by each node according to its associated SNR class.
This solution is shown to be effective, but it counters two main limitations.
Applying this approach involves several modifications to the existing IEEE
802.11 protocol and a new layer is required at each access station to fragment the
packets according to the maximum packet size associated to each SNR class.
The last solution (DCF-MB) which almost will be like our new approach
(DCF-MBA), where the access nodes are classified into different sets according to
their transmission bit rate (11, 5.5, 1 Mbps) and then each set will be characterized
by each own backoff window. The difference between (DCF-MBA) and (DCF-
MB) is the formula being used to assign the backoff window size. Simulation in
chapter 4 shows that the collision and the throughput are better when using DCF-
MBA. So finally, we can say that each node has more stable behavior and not
being severely affected by other nodes.
7
Chapter
2
Theoretical background
In this chapter we will discuss the IEEE 802.11b DCF anomaly in details,
and we will also discuss the theoretical basis of DCF-MBA depending on the
theoretical background of DCF-MB.
2.1 IEEE 802.11b DCF Anomaly
The IEEE 802.11b standard defines two access methods: the DCF
technique, which is based on the CSMA/CA protocol, and the centralized
point coordination function (PCF), which provides free collision access.
In the DCF access method which is based on the CSMA/CA principle,
when a node wishes to transmit a frame, it senses the channel’s activity until
an idle period is detected. Then, the node waits for a random backoff interval
before transmitting. The backoff time counter is decremented in term of slot
time as long as the channel is sensed free. The counter freezes once a
transmission among the channel is detected, and it resumes with the old
remaining backoff interval when the channel is sensed idle again, and it will
transmit its frame when the counter reaches zero.
If the frame is correctly received, the receiving host sends an
acknowledgement (ACK) after a short period of time called Short Inter Frame
Space (SIFS). If the sending node does not receive this ACK frame, then a
collision is assumed to be happened. In this case, the sending node attempts to
send the packet again when the channel is free, but this time with a different
backoff time interval.
8
For each new transmission attempt, the backoff interval takes a random
value chosen from the range [0, CW]. During the first attempt to send, the CW
is equal to CWmin which equals to 31 time slots and the value will be chosen
randomly from the range of [0, 31]. In case of collision, the node will resend
the same packet again but now with different contention window size doubled
from the minimum size until a maximum backoff window size reached
CWmax which equals to 1023.
DCF ensure an equal access to the shared medium among all transmitting
nodes, which does not guarantee a fair medium utilization among all the
nodes. Specifically, a node located away from the access point which results
degradation in the bit rate from 11Mbps to 1Mbps. In this case, this node will
capture the channel for a period 11 times longer than a node located in front of
the access point to transmit the same packet. This situation will affect the total
throughput of the network.
To illustrate this situation, we consider three nodes situated at different
distances from the access point, which accordingly the first node will have a
bit rate of 11Mbps, the second node will have a bit rate of 5.5Mbps and the
third node will have a bit rate of 1Mbps. Moreover, the second node will be
activated after 10s and the third node after 20s, the overall network will be
tested for 30s to check the network throughput evolution. Table 1 will show
the DCF parameters used and these parameters will be mutual for DCF-MB
and DCF-MBA.
9
Parameters of IEEE 802.11 b
Class bit rate 1 ; 5.5 ; 11 Mbps
DIFS 50 µs
SIFS 10 µs
Backoff-Slot Time 20 µs
CWmin 31
CWmax 1023
ACK 14 bytes
Table 1.1: Parameters of IEEE 802.11b
Figure 1.2: Throughput of each node in DCF standard case
As shown in figure 1.2, during the first 10s, only the first node is activated, its
throughput is maximal and approaches 5.92Mbps, which represents 53.82% of its
transmission bit rate (11Mbps). This difference is due to the backoff delay, SIFS and
DIFs periods left on the medium for each packet transmission.
Once the station 2 is activated, as noticed the first node throughput reduces. But,
this reduction is dramatic since the new throughput does not exceeds 2.753Mbps
which is less than the expected throughput for the second node 5.5Mbps, and the
throughput for both first and second node have the same 2.753Mbps throughput
although their different bit rates. Indeed, the throughput of first node is decelerated
11
due the relatively low bit rate of the second node. In this case, node 2 occupies the
channel twice more times than the first node. As a result, node 1 is unfairly penalized
as well as the total network throughput equals to 5.506Mbps.
The anomaly of DCF will be clear when node number three activated. In this case,
the useful throughput of each station is limited to 1.691Mbps and the total throughput
becomes lower and equals to 5.073Mbps.
2.2 DCF-MB and DCF-MBA
The idea of this method is to provide each class bit rate Ci with its associated
contention window size CWmin which is equal to 31 as in standard, and then the
contention window of 5.5Mbps and 1Mbps is derived as follows
( ) ( )
(1)
According to formula (1), we get CWmin (1) = 31, CWmin (2) = 60 and CWmin
(3) = 330, which are the window sizes of classes C1 (11Mbps), C2 (5.5Mbps) and C3
(1Mbps), respectively.
Unlike the standard DCF the throughput of this method can be described as
follow. When node one activated, the throughput of this node is divided by 2 when
station activated and is divided by 3 when the third one is activated, which means that
performance of the first node only depends on the number of sharing access nodes and
no more with their relative positions with respect to the AP, which means that each
node is completely separated from other nodes.
Regarding to our approach DCF-MBA, we referred to the following equation in
order to calculate the throughput of each node; node number is activated first 10s then
node two activated after 10s and the third node activated after 20s.
To calculate the Signal to Noise Ratio (SNR) of each node,
11
(2)
Where,
D = distance between the AP and the node.
n = the two ray reflection coefficient and is equal to 4.
No =White noise (5 * 10-2).
Pt. = transmitted power from the AP and set to be 1w.
To calculate the data rate of each node (R), using formula (2)
( ) (3)
Where;
B= 2.5 * 106 Hz.
Setting the packet length to 2 Kb, figure 2.2 shows the throughput of each node
using the DCF-MB concept and our new concept DCF-MBA.
Figure 2.2: Throughput of DCF-MB comparing with DCF-MBA
As shown in figure 2.2, during the first 10s, only the first node is activated, its
throughput is maximal and approaches 6.281Mbps for DCF-MBA and 6.12Mbps for
DCF-MB, which represents 57.1% of its transmission bit rate (11Mbps). This
12
difference is due to the backoff delay, SIFS and DIFS periods left on the medium for
each packet transmission.
Once the station 2 is activated, as noticed the first node throughput reduces. But,
this reduction is slight since the new throughput is 5.934Mbps which confirms that
node one does not affected by the activation of node two, and the throughput for the
second node has the value of 4.98Mbps throughput. Indeed, the throughput of first
node is not affected by the relatively low bit rate of the second node.
The performance of DCF-MBA will be clear when node number three activated.
In this case, the useful throughput of each node is slightly affected. The throughput of
the first node will be 5.77Mbps, for the second node 4.83Mbps and for the third node
2.141Mbps.
To have the previous results, we have modified the formula used to calculate the
backoff size of each node, setting the value of optimal X to 5. When choosing this
value of X, we took in concern that we need to achieve high useful throughput for the
network, and to reduce the number of collided packets.
( ) (
( ) )
(4)
Depending on X which equals to 5, the interval of the backoff size of the first
node CW (1) will be a random value from the interval of [0, 31], the backoff size of
the second node CW (2) will be chosen randomly from the interval [0, 36] and the
third node will also took a random value from [0, 81].
Choosing a value of X=1, the backoff size for the three nodes will be reduced to
[0, 31] for the first node, [0, 32] for the second one and [0, 41] for the last one. Using
these values for the contention window size, although the total number of the
transmitted packets which indicates total useful throughput will be higher, but also the
collided number of packets will also be higher, which is not desirable.
13
Choosing a value of X=10, the interval of the backoff size for the three nodes will
be expanded to [0, 31] for the first node, [0, 41] for the second one and [0, 131] for
the last one. Using these values for the contention window size, although the total
number of the collided packets will be lower, and the total transmitted number of
packets which indicates total useful throughput will also be lower, this value is not
desirable. Then the value of X=5 will be the optimal value for the DCF-MBA.
Figure 2.3: optimal X value.
14
Chapter
3
Design in Details
3.1 The design
In this chapter we go through the details of our design, however, we didn’t make
any hardware. However, we will show some figures and block diagrams of the design.
In general, the IEEE 802.11b anomaly is due to the simplicity of the design, this
simplicity is achieved by making the system decentralized, which means, that each
node doesn’t take a straight-forward command from the AP to send a burst. On the
contrary, each node “senses” the medium periodically to see if it is possible to send its
queued packets.
Figure 3.1: Medium Access [3]
By using this mechanism, the probability of collision between the competing
nodes increases, and it may cause the at-the-same-time-transmitted-packets to be
discarded by the AP, which degrades the performance of the network. Our work
suggested a way to overcome the anomaly by using the MB techniques. By assigning
each node its own backoff window depending on the SNR (i.e.: data-rate class). Far
away nodes will cause the system to degrade, since they will need more channel
acquisition by re-transmitting redundant packets. Hence, by giving the low SNR
stations more backoff windows, this anomaly can be reduced.
15
The design should be simple, since DCF is based on simplicity, any further
amendment in the system should take this criterion in consideration. As being said
before, the multiple backoff windows mechanism is very effective and it could reduce
the redundant packets and hence improve our system’s performance.
Figure 3.2 depicts a hypothetical system, which consists of three competing nodes.
Table 3.1 summarizes the parameters of each node. In the standard case, each node
has a random backoff window chosen from the range [0, 31], regardless of the RF
conditions of the node.
Station Backoff window
range
RF condition Data Rate
Station 1 [0,31] Excellent 11 Mbps
Station 2 [0,31] Medium 5.5 Mbps
Station 3 [0,31] Weak 1 Mbps
Table 3.1: System’s parameters
In DCF-MBA we will assign each node a backoff window depending on its RF
condition, thus, we assure that each node will get fair access to the medium.
DCF’s main concern was to provide “fair” medium access, and it really did
achieve that, but the “fair” access was not “fair” bandwidth-utilization. That’s why the
DCF algorithm needs to be adjusted to meet this limitation.
AP
Station 1 Station 2 Station 3
Figure 3.2: Hypothetical System
16
As being said before, the idea of multiple backoffs is an efficient way to revoke
the limitation, the job is done and the simplicity is still there.
The AP will not being be modified, and all the IEEE 802.11b algorithm will work
just like the standardized version. However, the nodes’ MAC layer will be modified,
so that it can assign a random backoff window size to the node depending on its feed-
backed RF condition. The RF condition can be inferred by the number of re-
transmitted packets. When the number of re-transmitted packets is higher, then the
SNR has lower values.
Equation (4) is the equation that should be implemented in the nodes’ algorithms.
3.2 Advantages of DCF-MBA
Why to use multiple backoffs? This is the question that needs to be answered to
show the advantageous behavior of DCF-MBA or even DCF-MB. The anomaly exists
because, far away nodes, trying to access the medium, are given access to medium
with the same probability as near or almost-near nodes. Doing so, DCF ensures that
all the competing nodes have the chance to transmit their packets fairly, but this
fairness, is actually unfair. When far away nodes transmit packets, their SNRs are
very low; the number of corrupted bits is high. So eventually, most of the packets
arrived from the far away station (in our example station 3) at the AP will be dropped
and discarded, so, the medium was inefficiently occupied.
The time needed to transmit station 3’s packets was wasted and the other good
conditioned nodes’ too. This time could have been well utilized if the channel access
was given to station 1 or even 2. In DCF-MB/A, this is what really happens. The good
stations are given less backoff window size, so that they can transmit their packets
more frequent than other low-SNR stations. Doing so, not only enhance the
17
performance of the stations, it also improves the performance of the whole system
(i.e. total network throughput).
But what is the difference between the DCF-MB and DCF-MBA’s performances.
Both of them use the multiple backoff window sizes, in the case of MB, the backoff
window is given by equation (1), where it really, improves the good-SNR stations’
performance by unfair medium access of far-away nodes (low SNRs),then the idea
behind DCF ( fair access) is abused.
The DCF-MBA, improves the performance of the good-SNR stations, and slightly
delays the far-away nodes from accessing the medium. But this delay is negligible
compared to the MB.
The delay doesn’t affect the close-to-the-AP nodes. However, the performance of
the far-away nodes is much way better in MBA than MB. This is due to changing the
formula and using an optimum value of X.
18
Chapter
4
Testing and Validation
4.1 Design simulation
In this chapter, we will talk about our simulation and the results that we gained by
running our different network configurations.
4.1.1 Network Configurations
Different network configurations mean that, by using different system parameters
and fixing them, we obtained results for a specific variant parameter.
The next section will show the simulation results and comments on those results,
but here we will talk about the network configurations in general that gave us the
desired results.
First of all, we created a system, consisting of 3 nodes, their parameters are the
same as Table 3.1 (in the case of the standard DCF), the node with the strongest RF
condition is working for the first 10 seconds, after that, node 2 (i.e. Station 2) joins the
network. Finally, at the 30th
second, Station 3 joins. The parameters being monitored
are the number of packets collided, the total throughput of the network and the
throughput per node. This system was simulated by the DCF-MB and DCF-MBA
techniques, to compare which one is more efficient.
We also simulated the standard case of the IEEE 802.11b, along with the DCF-
MB and DCF-MBA techniques.
In the DCF-MBA technique, there is parameter X that should be chosen carefully,
so in order to find the optimum X, we ran the system with different values of X ( we
talk about it in the next section), but for now, X equals 5 is our choice.
19
And finally, we will simulate a system, with 36 nodes, distributed across three
different ranges of coverage (150, 300 and 450 m width x height).
4.2 Simulation results and comments
At this section, we show the results of the network configurations. At first, we will
show the standard case we talked about in 4.1.1.
Figure 4.1: Standard IEEE 802.11b
Figure 4.1 depicts the case of the three-nodes-system while using the standardized
version of IEEE 802.11b. We can see that, the node with the strong RF condition (11
Mbps data rate) is affected by the entrance of the second node and severely affected
by the entrance of the third node.
Next, we consider the optimum range of a network, with 36 competing nodes, and
three ranges of coverage. By range of coverage we mean that all the nodes are
distributed randomly across that coverage area. Figure 4.2 depicts that the range 350
m is the optimal.
21
Figure 4.2: Optimum Range
This is due to the fact that, at small coverage areas, all the nodes, takes values of
backoff windows in the range of [0, 31] so the probability of collision increases.
Hence, the total throughput of the network degrades. However, if the coverage area is
too large, then most of the nodes will get medium and low conditions, hence, low
data-rates (i.e. poor performance of the network).
After that, we are concerned about the X value in the DCF-MBA technique, in
order to find the optimum value of X; we need to run the system multiple times, with
variant number of X.
We ran the system, with 10 different values of X, ranging from 1 to 10. And we
plotted the throughout in terms of packets and the collided packets.
Figure 4.3 below depicts the simulated system. We can see that at X equals to 1,
the total throughput of the network is maximized. However, the total number of
collided packets is also maximized as well. And at X equals to 10, we see that the
throughput here is minimum as well as the number of collided packets is minimized.
21
So, in order to set the value of X, we have two choices, either by finding optimum
value, or by trade-offs.
Figure 4.3: Optimum X
By trade-offs, we mean that, you either choose the X equals to 1, where the total
throughput is higher, but also with higher values of collided packets. Or when X is
equal to 10 or greater, then throughput is minimized, by with less number of collided
packets.
In this project, we took the first approach. We wanted to find the optimum value
of X which was 5. At X equals to 5, we can see that, the number of packets being
transmitted is “good” and the number of collided packets is “good” too.
By now, we have found our parameters for an optimum DCF-MBA algorithm; we
need to compare this algorithm with DCF-MB and the standard DCF algorithm to
show our advantageous design.
Figure 4.4 depicts that our algorithm is better than the DCF-MB in general, and
specifically for the weak RF conditioned nodes. It’s like a hybrid between the
standard case and the MB. It’s design to make a “fair” access and utilization of the
broadband spectrum in IEEE 802.11b.
22
Figure 4.4: DCF-Mb vs. DCF-MBA (Throughput per node)
As you can see, in station 1’s case, the performance enhancement is negligible,
however, it’s significant in the case of station 2 and 3 (medium and low RF conditions
respectively).
The previous figure shows us the enhancement in terms of throughput per node,
also, enhancement per node, means enhancement over the total throughput of the
network. This is shown in figure 4.5, where the total throughput of the network is
shown for both DCF-MB and DCF-MBA. In terms of bandwidth efficiency and
throughput enhancement, the DCF-MBA is way better than the DCF-MB and the
DCF standard. Nevertheless, we need to see the number of collided packets, for each
technique; just to make it clearer that DCF-MBA is better.
23
Figure 4.5: DCF-MB vs. DCF-MBA (Total throughput)
Figure 4.6 depicts that, when node 2 and 3 joins the network, collisions occurs,
and it shows also that, the collision in the DCF-MB is way better than the case of
standard DCF algorithm, however, the collided packet in the case of DCF-MB is
logically less than DCF-MBA, where the backoff intervals ranges are much larger
than DCF-MB, hence, collision will be less. No need to simulate DCF-MB’s collided
packets. However, in telecommunications, tradeoffs occur, and we must seek for
what’s best for our applications. Here the enhanced throughput is needed more than
the slightly increased collided packets.
Finally, it can be seen that DCF-MBA can be seen as a hybrid of DCF-MB and
standard DCF, and it’s the mean to achieve the real meaning of fairness, which was
the main purpose while developing the IEEE 802.11b.
24
Appendices
Appendix A
References
1 http://en.wikipedia.org/wiki/IEEE_802.11b-1999
2 http://paper.ijcsns.org/07_book/200701/200701B14.pdf
3 Yassine Chetoui, Nizar Bouabdallah, “Adjustment mechanism for the IEEE 802.11 contention window: An efficient bandwidth sharing scheme”,p. 3
25
Appendix B
Matlab codes
Figure 4.1
clc clear all clf close all transmitting_nodes = [];% this array will be used to indicate if
there's a transmitting node & it will be used to caclulate # packets transmitting_nodes1=0; lop= 2*1024; % Length of Packet % SIM=input('Enter the simulation time: '); timeslot=20e-6; % timeslot duration DIFS = 50e-6 / timeslot; SIFS = 10e-6 / timeslot; ACK = 14 * 8 ; % # bits in an ACK collided = zeros(1,30); Noise=0.05; n=4; tx=1; B=2.5*(10e6); % transmitting_nodes = zeros(1,3); % this array will be used to
indicate if there's a transmitting node & it will be used to
caclulate # packets datarate=[]; packet=[]; % CW=[31 62 341]; tx1 = 0; tx2 = 0; tx3 = 0; collided2=0; % packet=zeros(1,3); ; packet1=zeros(1,30); packet2=zeros(1,30); packet3=zeros(1,30); datarate=[11e6 5.5e6 1e6]; x=0; for k=1:3 time(k)=lop/datarate(k); CW(k)=31+(((11e6)/datarate(k))-1).*x; end counter=0; counter2=0; for time2=1:30 for ts=1:(1/timeslot) if time2<10 transmitting_nodes=false; for z=1:1 if CW(z)== 0 transmitting_nodes(z) = 1; % assign '1' to a transmitting
node new_cw1 = randi(30)+1; if new_cw1 == 0 new_cw1 = 31;
26
end CW(1) = new_cw1;
current_ts = fix(time(z) / timeslot); % stop 'current_ts'
timeslots before decreasing the non-transmitting nodes i = i + current_ts + DIFS + SIFS + fix((ACK/datarate(z))
/ timeslot); else transmitting_nodes(z) = 0;
end
if sum(transmitting_nodes) == 1 % if there's no colliding
nodes then add a packet to the transmitting node. packet1(time2) = packet1(time2) + 1; elseif sum(transmitting_nodes) > 1 collided(time2) = collided(time2) + 1; end end CW = CW - [1 0 0]; end if time2>=10 && time2<20 transmitting_nodes=zeros(1,2);
% packet=zeros(1,2); for z=1:2
if CW(z)== 0
transmitting_nodes(z) = true; % assign '1' to a
transmitting node if z == 1 tx1 = 1; % new_cw1 =31; % if new_cw1 == 0 % new_cw1 = 31; % end
end if z ==2 tx2 = 1; % new_cw2 = 31; % if new_cw2 ==0 % new_cw2 = 31; % end % CW(2) = new_cw2; end
current_ts = fix(time(1) / timeslot); % stop 'current_ts'
timeslots before decreasing the non-transmitting nodes i = i + current_ts + DIFS + SIFS + fix((ACK/datarate(1)) /
timeslot); else % tx1 = 0; % tx2 = 0; transmitting_nodes(z)= false;
27
end end
if sum(transmitting_nodes) == 1 % if there's no colliding
nodes then add a packet to the transmitting node. if tx1 == 1 && tx2 ==0 packet1(time2) = packet1(time2) + 1; CW(1) = randi(30)+1; elseif tx1==0 && tx2==1 packet2(time2) = packet2(time2) + 1; CW(2) = randi(30)+1; end
elseif sum(transmitting_nodes) > 1 counter=counter+1; if counter==1 CW(1)=randi(61)+1; CW(2)=randi(61)+1; elseif counter>1 && counter<=8 CW(1)= randi(counter*61)+1; CW(2)= randi(counter*61)+1; elseif counter>=9 CW(1)= randi(1023)+1; CW(2)= randi(1023)+1; end
% if CW(1)>1023 % CW(1)= randi(30)+1; % % CW(2)=randi(30)+1; % end
collided(time2) = collided(time2) + 1;
end tx1 = 0; tx2 = 0; CW = CW - [1 1 0]; end
if time2>=20
transmitting_nodes=zeros(1,3); % packet=zeros(1,3); for z=1:3
if CW(z)== 0 transmitting_nodes(z) = true; % assign '1' to a
transmitting node if z==1 tx1 = 1; % new_cw1 = 31; % if new_cw1 == 0 % new_cw1 = 31; % end % CW(1) = new_cw1;
28
end if z==2 tx2 = 1; % new_cw2 =31; % if new_cw2 ==0 % new_cw2 = 31; % end % CW(2) = new_cw2; end if z==3 tx3 = 1; % new_cw3 =31; % if new_cw3 == 0 % new_cw3 = 31; % end % CW(3) = new_cw3; end
current_ts = fix(time(1) / timeslot); % stop 'current_ts'
timeslots before decreasing the non-transmitting nodes i = i + current_ts + DIFS + SIFS + fix((ACK/datarate(1))
/ timeslot); else transmitting_nodes(z) = false;
end end
if sum(transmitting_nodes) == 1 % if there's no colliding
nodes then add a packet to the transmitting node. if tx1 ==1 && tx2 ==0 && tx3==0 CW(1) = randi(30)+1; packet1(time2) = packet1(time2) + 1; elseif tx1 ==0 && tx2 ==1 && tx3==0 CW(2) = randi(30)+1; packet2(time2) = packet2(time2) + 1; elseif tx1 ==0 && tx2 ==0 && tx3==1 CW(3) = randi(30)+1; packet3(time2) = packet3(time2) + 1; end elseif sum(transmitting_nodes) > 1 counter2=counter2+1; if counter2==1 CW(1)=randi(61)+1; CW(2)=randi(61)+1; CW(3)=randi(61)+1; elseif counter2>1 && counter2<=8 CW(1)= randi(counter*61)+1; CW(2)= randi(counter*61)+1; CW(3)= randi(counter*61)+1; elseif counter2>=9 CW(1)= randi(1023)+1; CW(2)= randi(1023)+1; CW(3)= randi(1023)+1; end collided(time2) = collided(time2) + 1; end
29
tx1 = 0; tx2 = 0; tx3 = 0; CW = CW - 1; transmitting_nodes = zeros(1,3); end % CW = CW -1 ; % ts=ts+i;
end end
% packet_total=[0,packet1,packet2,packet3]
th1=(packet1.*lop)./1024.^2; th2=(packet2.*lop)./1024.^2; th3=(packet3.*lop)./1024.^2; total = packet1 + packet2+packet3; % hold on plot(1:30,smooth(total),'-k'); % plot(1:30,smooth(th2(:,1:30)),'--k'); % plot(1:30,smooth(th3(:,1:30)),':k'); % legend ('11Mbps node','5.5Mbps node','1Mbps node') % xlabel('Time') % ylabel('Throughput') % grid on
31
Figure 4.2
clc clear all clf close all transmitting_nodes = []; % this array will be used to indicate if
there's a transmitting node & it will be used to caclulate # packets lop= 576; % Length of Packet SIM=input('Enter the simulation time: '); timeslot=20e-6; % timeslot duration DIFS = 50e-6 / timeslot; SIFS = 10e-6 / timeslot; ACK = 14 * 8 ; % # bits in an ACK collided = 0; z_new = []; f_thr=[]; time_axis = 1:SIM; f_thr_axis = zeros(size(time_axis)); Noise=0.05; n=4; tx=1; B=2.5*(10e6); for L=150:150:450
l_new(L/150) = L; transmitting_nodes = []; % this array will be used to indicate if
there's a transmitting node & it will be used to caclulate # packets
datarate=[]; packet=[]; CW=[]; time_axis = []; f_thr_axis = []; % l_new=[]; z=36; packet=zeros(1,z); datarate=zeros(1,z); distance=[]; if(L/150)==1 nn=1; for i=1:6
netXloc = [25 50 75 100 125 150]; for j=1:6 netYloc = [25 50 75 100 125 150] ; distance(nn)= sqrt((netXloc(i) - (L/2))^2 + (netYloc(j) - (L/2))^2); nn=nn+1; end
end elseif (L/150)==2 nn=1; for i=1:6
netXloc = [37 75 112 186 223 260]; for j=1:6
31
netYloc = [37 75 112 186 223 260] ; distance(nn)= sqrt((netXloc(i) - (L/2))^2 + (netYloc(j) - (L/2))^2); nn=nn+1; end
end elseif (L/150)==3 nn=1; for i=1:6
netXloc = 40:75:450; for j=1:6 netYloc = 40:75:450 ; distance(nn)= sqrt((netXloc(i) - (L/2))^2 + (netYloc(j) - (L/2))^2); nn=nn+1; end
end end for i=1:z
SNR=(1/((distance(i)^n).*Noise)).*tx; datarate(i)=B*log2(1+SNR); if datarate(i)<=1 datarate(i)=1; elseif 1<datarate(i) && datarate(i)<=2 datarate(i)=2; elseif 2<datarate(i) && datarate(i)<=5.5 datarate(i)=5.5; elseif 5.5<datarate(i) datarate(i)=11; end datarate(i)=datarate(i)*(10^6); % calculation of the datarate
to assign a CW according to it and to calculate transmission time time(i)=lop/datarate(i); % transmission time per packet at a
given datarate CW(i)=(11000000/datarate(i))*31; % we assign a general CW per
packet then we randomize the value
if CW(i)==31 CW(i)=randint(1,1,31); elseif CW(i)==62 CW(i)=randint(1,1,62); % CW ~ [0 , 62] elseif CW(i)==170.5 CW(i)=randint(1,1,171); % CW ~ [0 , 170.5] elseif CW(i)==341 CW(i)=randint(1,1,341); % CW ~ [0 , 341] end % CW= fix(CW); % rounding the CW value end nn=1;
for sim=1:SIM
packet=zeros(1,36);
for i=1:(1/timeslot) for j=1:z % per node check whether the CW equals to zero if CW(j)== 0
32
transmitting_nodes(j) = true; % assign '1' to a
transmitting node CW(j)=(11e6/datarate(j))*31; % assign new CW current_ts = fix(time(j) / timeslot); % stop 'current_ts'
timeslots before decreasing the non-transmitting nodes i = i + current_ts + DIFS + SIFS + fix((ACK/datarate(j)) /
timeslot); if CW(j)==31 CW(j)=randint(1,1,31); if CW(j) == 0 if sum(transmitting_nodes) == 1 CW(j) = 1; else CW(j) = 15; end end elseif CW(j)==62 CW(j)=randint(1,1,62); elseif CW(j)==170.5 CW(j)=randint(1,1,171); elseif CW(j)==341 CW(j)=randint(1,1,341); end % CW(j)= fix(CW(j)); else transmitting_nodes(j) = false; end end if sum(transmitting_nodes) == 1 % if there's no colliding
nodes then add a packet to the transmitting node. packet = packet + transmitting_nodes; elseif sum(transmitting_nodes) > 1 collided = collided + 1; end CW = CW -1 ; transmitting_nodes = zeros(1,z);
end
f_thr= sum(packet) * lop / 1024^2; time_axis(round( sim)) = sim; f_thr_axis(round( sim)) = f_thr; sim end
f_thr1(L)=f_thr xxx=[f_thr1(150) f_thr1(300) f_thr1(450)]; plot(150:150:450,smooth(xxx)); axis([0 500 5 9])
figure(1) hold on xlabel('Time (s)'); ylabel('Throughput (Mbps)') title('Throupht with different ranges') t_ref = f_thr_axis(1); time_axis = [0 0.2 0.4 0.6 0.8 time_axis]; f_thr_axis = [0 0.2*t_ref 0.4*t_ref 0.6*t_ref 0.8*t_ref f_thr_axis]; if (L/150)==1
33
plot(smooth(time_axis),smooth(f_thr_axis),'--
r','LineWidth',1,'MarkerEdgeColor','k','MarkerFaceColor','g','MarkerS
ize',7) elseif (L/150)==2 plot(smooth(time_axis),smooth(f_thr_axis),'--
g','LineWidth',1,'MarkerEdgeColor','k','MarkerFaceColor','g','MarkerS
ize',7) elseif (L/150)==3 plot(smooth(time_axis),smooth(f_thr_axis),'--
k','LineWidth',1,'MarkerEdgeColor','k','MarkerFaceColor','g','MarkerS
ize',7) end axis([0 SIM 0 11]) legend('Range = 150m','Range = 300m','Range = 450m',4) grid on end
34
3 nodes running at different times DCF-MB
clc clear all clf close all transmitting_nodes = [];% this array will be used to indicate if
there's a transmitting node & it will be used to caclulate # packets transmitting_nodes1=0; lop= 2048; % Length of Packet % SIM=input('Enter the simulation time: '); timeslot=20e-6; % timeslot duration DIFS = 50e-6 / timeslot; SIFS = 10e-6 / timeslot; ACK = 14 * 8 ; % # bits in an ACK collided = 0; Noise=0.05; n=4; tx=1; B=2.5*(10e6); % transmitting_nodes = zeros(1,3); % this array will be used to
indicate if there's a transmitting node & it will be used to
caclulate # packets datarate=[]; packet=[]; CW=[31 62 341]; tx1 = 0; tx2 = 0; tx3 = 0; % packet=zeros(1,3); ; packet1=zeros(1,30); packet2=zeros(1,30); packet3=zeros(1,30); datarate=[11e6 5.5e6 1e6]; for k=1:3 time(k)=lop/datarate(k); end for time2=1:30 for ts=1:(1/timeslot) if time2<10 transmitting_nodes=false; for z=1:1 if CW(z)== 0 transmitting_nodes(z) = 1; % assign '1' to a transmitting
node new_cw1 = randi(31,1,1); if new_cw1 == 0 new_cw1 = 15; end CW(1) = new_cw1;
current_ts = fix(time(z) / timeslot); % stop 'current_ts'
timeslots before decreasing the non-transmitting nodes i = i + current_ts + DIFS + SIFS + fix((ACK/datarate(z))
/ timeslot); else transmitting_nodes(z) = 0;
end
35
if sum(transmitting_nodes) == 1 % if there's no colliding
nodes then add a packet to the transmitting node. packet1(time2) = packet1(time2) + 1; elseif sum(transmitting_nodes) > 1 collided1 = collided1 + 1; % packet1(time2) = packet1(time2) - 1; end end CW = CW - [1 0 0]; end if time2>=10 && time2<20 transmitting_nodes=zeros(1,2);
% packet=zeros(1,2); for z=1:2
if CW(z)== 0
transmitting_nodes(z) = true; % assign '1' to a
transmitting node if z == 1 tx1 = 1; new_cw1 = randi(31,1,1); if new_cw1 == 0 new_cw1 = 15; end CW(1) = new_cw1; end if z ==2 tx2 = 1; new_cw2 =randi(62,1,1); if new_cw2 ==0 new_cw2 = 45; end CW(2) = new_cw2; end
current_ts = fix(time(1) / timeslot); % stop 'current_ts'
timeslots before decreasing the non-transmitting nodes i = i + current_ts + DIFS + SIFS + fix((ACK/datarate(1)) /
timeslot); else % tx1 = 0; % tx2 = 0; transmitting_nodes(z)= false;
end end
if sum(transmitting_nodes) == 1 % if there's no colliding
nodes then add a packet to the transmitting node. if tx1 == 1 && tx2 ==0 packet1(time2) = packet1(time2) + 1; elseif tx1==0 && tx2==1 packet2(time2) = packet2(time2) + 1; end
36
elseif sum(transmitting_nodes) > 1 collided = collided + 1; if tx1 == 1 && tx2 ==0 % packet1(time2) = packet1(time2) - 1; elseif tx1==0 && tx2==1 % packet2(time2) = packet2(time2) - 1; end end tx1 = 0; tx2 = 0; CW = CW - [1 1 0]; end
if time2>=20
transmitting_nodes=zeros(1,3); % packet=zeros(1,3); for z=1:3
if CW(z)== 0 transmitting_nodes(z) = true; % assign '1' to a
transmitting node if z==1 tx1 = 1; new_cw1 = randi(31,1,1); if new_cw1 == 0 new_cw1 = 15; end CW(1) = new_cw1; end if z==2 tx2 = 1; new_cw2 = randi(62,1,1); if new_cw2 ==0 new_cw2 = 45; end CW(2) = new_cw2; end if z==3 tx3 = 1; new_cw3 = randi(341,1,1); if new_cw3 == 0 new_cw3 = 250; end CW(3) = new_cw3; end
current_ts = fix(time(1) / timeslot); % stop 'current_ts'
timeslots before decreasing the non-transmitting nodes i = i + current_ts + DIFS + SIFS + fix((ACK/datarate(1))
/ timeslot); else transmitting_nodes(z) = false;
end
37
end
if sum(transmitting_nodes) == 1 % if there's no colliding
nodes then add a packet to the transmitting node. if tx1 ==1 && tx2 ==0 && tx3==0 packet1(time2) = packet1(time2) + 1; elseif tx1 ==0 && tx2 ==1 && tx3==0 packet2(time2) = packet2(time2) + 1; elseif tx1 ==0 && tx2 ==0 && tx3==1 packet3(time2) = packet3(time2) + 1; end elseif sum(transmitting_nodes) > 1 if tx1 ==1 && tx2 ==0 && tx3==0 % packet1(time2) = packet1(time2) - 1; elseif tx1 ==0 && tx2 ==1 && tx3==0 % packet2(time2) = packet2(time2) - 1; elseif tx1 ==0 && tx2 ==0 && tx3==1 % packet3(time2) = packet3(time2) - 1; end collided = collided + 1; end
tx1 = 0; tx2 = 0; tx3 = 0; CW = CW - 1; transmitting_nodes = zeros(1,3); end % CW = CW -1 ; ts=ts+i;
end end
% packet_total=[0,packet1,packet2,packet3]
th1=(packet1.*lop)./1024.^2; th2=(packet2.*lop)./1024.^2; th3=(packet3.*lop)./1024.^2; total_thr = packet1 + packet2 + packet3; save ('tun_approach.mat','total_thr') % hold on % plot(1:30,smooth(th1,'-k')); % plot(10:30,smooth(th2(:,10:30)),'--k'); % plot(20:30,smooth(th3(:,20:30)),':k'); % legend ('11Mbps node','5.5Mbps node','1Mbps node') % xlabel('Time') % ylabel('Throughput') % grid on
38
3 nodes running at different times DCF-MBA
clc clear all clf close all transmitting_nodes = [];% this array will be used to indicate if
there's a transmitting node & it will be used to caclulate # packets transmitting_nodes1=0; lop= 2*1024; % Length of Packet % SIM=input('Enter the simulation time: '); timeslot=20e-6; % timeslot duration DIFS = 50e-6 / timeslot; SIFS = 10e-6 / timeslot; ACK = 14 * 8 ; % # bits in an ACK collided = zeros(1,30); Noise=0.05; n=4; tx=1; B=2.5*(10e6); % transmitting_nodes = zeros(1,3); % this array will be used to
indicate if there's a transmitting node & it will be used to
caclulate # packets datarate=[]; packet=[]; % CW=[31 62 341]; tx1 = 0; tx2 = 0; tx3 = 0; % packet=zeros(1,3); ; packet1=zeros(1,30); packet2=zeros(1,30); packet3=zeros(1,30); datarate=[11e6 5.5e6 1e6]; x=5; for k=1:3 time(k)=lop/datarate(k); CW(k)=31+(((11e6)/datarate(k))-1).*x; end
for time2=1:30 for ts=1:(1/timeslot) if time2<10 transmitting_nodes=false; for z=1:1 if CW(z)== 0 transmitting_nodes(z) = 1; % assign '1' to a transmitting
node new_cw1 = randint(1,1,31); if new_cw1 == 0 new_cw1 = 15; end CW(1) = new_cw1;
current_ts = fix(time(z) / timeslot); % stop 'current_ts'
timeslots before decreasing the non-transmitting nodes i = i + current_ts + DIFS + SIFS + fix((ACK/datarate(z))
/ timeslot); else transmitting_nodes(z) = 0;
39
end
if sum(transmitting_nodes) == 1 % if there's no colliding
nodes then add a packet to the transmitting node. packet1(time2) = packet1(time2) + 1; elseif sum(transmitting_nodes) > 1 collided(time2) = collided(time2) + 1; end end CW = CW - [1 0 0]; end if time2>=10 && time2<20 transmitting_nodes=zeros(1,2);
% packet=zeros(1,2); for z=1:2
if CW(z)== 0
transmitting_nodes(z) = true; % assign '1' to a
transmitting node if z == 1 tx1 = 1; new_cw1 = randint(1,1,31); if new_cw1 == 0 new_cw1 = 15; end CW(1) = new_cw1; end if z ==2 tx2 = 1; new_cw2 = randint(1,1,36); if new_cw2 ==0 new_cw2 = 34; end CW(2) = new_cw2; end
current_ts = fix(time(1) / timeslot); % stop 'current_ts'
timeslots before decreasing the non-transmitting nodes i = i + current_ts + DIFS + SIFS + fix((ACK/datarate(1)) /
timeslot); else % tx1 = 0; % tx2 = 0; transmitting_nodes(z)= false;
end end
if sum(transmitting_nodes) == 1 % if there's no colliding
nodes then add a packet to the transmitting node. if tx1 == 1 && tx2 ==0 packet1(time2) = packet1(time2) + 1; elseif tx1==0 && tx2==1
41
packet2(time2) = packet2(time2) + 1; end elseif sum(transmitting_nodes) > 1 collided(time2) = collided(time2) + 1; end tx1 = 0; tx2 = 0; CW = CW - [1 1 0]; end
if time2>=20
transmitting_nodes=zeros(1,3); % packet=zeros(1,3); for z=1:3
if CW(z)== 0 transmitting_nodes(z) = true; % assign '1' to a
transmitting node if z==1 tx1 = 1; new_cw1 = randint(1,1,31); if new_cw1 == 0 new_cw1 = 15; end CW(1) = new_cw1; end if z==2 tx2 = 1; new_cw2 = randint(1,1,36); if new_cw2 ==0 new_cw2 = 34; end CW(2) = new_cw2; end if z==3 tx3 = 1; new_cw3 =randint(1,1,81); if new_cw3 == 0 new_cw3 = 40; end CW(3) = new_cw3; end
current_ts = fix(time(1) / timeslot); % stop 'current_ts'
timeslots before decreasing the non-transmitting nodes i = i + current_ts + DIFS + SIFS + fix((ACK/datarate(1))
/ timeslot); else transmitting_nodes(z) = false;
end end
41
if sum(transmitting_nodes) == 1 % if there's no colliding
nodes then add a packet to the transmitting node. if tx1 ==1 && tx2 ==0 && tx3==0 packet1(time2) = packet1(time2) + 1; elseif tx1 ==0 && tx2 ==1 && tx3==0 packet2(time2) = packet2(time2) + 1; elseif tx1 ==0 && tx2 ==0 && tx3==1 packet3(time2) = packet3(time2) + 1; end elseif sum(transmitting_nodes) > 1 collided(time2) = collided(time2) + 1; end
tx1 = 0; tx2 = 0; tx3 = 0; CW = CW - 1; transmitting_nodes = zeros(1,3); end % CW = CW -1 ; ts=ts+i;
end end
% packet_total=[0,packet1,packet2,packet3]
th1=(packet1.*lop)./1024.^2; th2=(packet2.*lop)./1024.^2; th3=(packet3.*lop)./1024.^2; our_thr = packet1 + packet2 + packet3; save('our_approach.mat','our_thr') % hold on % plot(1:30,smooth(th1),'-k'); % plot(10:30,smooth(th2(:,10:30)),'--k'); % plot(20:30,smooth(th3(:,20:30)),':k'); % legend ('11Mbps node','5.5Mbps node','1Mbps node') % xlabel('Time') % ylabel('Throughput') % grid on %
42
Appendix C
Abbreviations
AP Access Point
DCF-MB Distribuated Coordinated Function - Multiple Backoff
DCF-MBA Distribuated Coordinated Function - Multiple Backoff Advanced
IEEE Institute of Electrical and Electronics Engineers
QoS Quality of Service