Sei sulla pagina 1di 7

> REPLACE THIS LINE WITH YOUR PAPER IDENTIFICATION NUMBER (DOUBLE-CLICK HERE TO EDIT) < 1

Simulation of 802.11 Networks using NS-2


Raviteja Gadde (raviteja969@ufl.edu)

Abstract—802.11 networks are a set of evolving 802.11 and draw inferences regarding the inner
standards for wireless local area networks developed workings of these networks.
by IEEE. These networks have become extremely The paper follows the following order. Sections 2 and
popular and are found almost everywhere. These 3 look in to details of 802.11. Followed by section 4
networks overcame many problems associated with explaining NS-2 in details. Then we look in to
extreme noise present in air interface and also simulations done using NS-2 in sections 5 and 6.
security issues. In this paper, we will discuss the
fundamental properties of these networks. Then we
will study these networks using NS-2, a network II.802.11
simulator.
The idea of wireless networks is quite compelling. But
it has some fundamental challenges. Radio transmission
is highly susceptible to noise and also signal strength
Index Terms— IEEE 802.11, Network Simulator-2, plays an important role in these systems. Having
CSMA/CA, Contention Window. concrete walls can seriously degrade the quality of signal
making the system inaccessible with short distances. The
medium of communication here is air and it’s
everywhere. This makes it both strongest and weakest
I. INTRODUCTION
point of 802.11. This quality gives us the advantages of
Communication is an important part of livelihood on mobility and at the same time making it insecure. There
this planet. From the evolution of language, is no way we can secure air from eavesdropping. Finally
communicating has played a key role in human lives. In radio communications use spectrum, which is scarce and
recent years, there has been an explosion in regulated. Spectrum issue was addressed by using
communication systems. From analog systems to high- unlicensed bands of 2.5Ghz and 5Ghz. The protocol was
speed digital systems these networks are pervasive. developed to incorporate strong error control and
Initially these were wired and fixed at a particular place. security measures to overcome these problems.
Mobility has become key in present era ability to access Wireless LANs can be divided in to two types: Ad-
information the go provides an advantage to businesses. Hoc and infrastructure LANs. Ad-Hoc networks are
802 standards were first developed for wired LANs temporary in nature. It usually has a group of stations
and then extended to wireless in terms of 802.11. 802.11 communicating with each other and can be formed
are basically a MAC layer specification as were previous spontaneously.
To understand Infrastructure networks we need to look
specification since 802.3. These standards started with
in to concept of Basic Service Set (BSS). BSS is a set of
speeds of 2Mbps and now reached theoretical speeds of
stations coordinating access over a medium.
500Mbps (802.11n). WiFi devices, which use these
Infrastructure networks combine BSSs with a Access
standards for wireless LANs, have made this standard Point and a distribution system combining with a Portal
greatly reachable and popular. Now, we can find 802.11 to internet. These also have options of authenticating
compatible devices in almost all portable computers, stations and privacy options. When Multiple BSSs are
smart phones and gaming consoles. interconnected it’s called an Extended Service Set.
The standard uses features form Ethernet along with To provide compatibility with 802 LANs all MAC
CSMA/CA (Carrier Sense Multiple Access with layers should present same format to LLC so MAC layer
Collision Avoidance). This is basically CSMA version handle the mobility of the stations.
from Ethernet adapted to wireless LANs. In this paper
we study these components of 802.11. We use NS-2 to The 802.11 MAC layer uses coordination functions to
study these networks. NS-2 is basically present determine when stations are allowed to transmit. 802.11
generation network simulator developed using C++ and mainly use Distributed Coordination Function (DCF)
OTCL. We use this to conduct some simulations of under which all stations are in contention for channel.
Another Coordination function, Point Coordination
> REPLACE THIS LINE WITH YOUR PAPER IDENTIFICATION NUMBER (DOUBLE-CLICK HERE TO EDIT) < 2

Function (PCF), is optionally included in the frame. If another station obtains this channel before
specification. In this the access point can describe back-off slot expires then the timer restarts again when
contention and contention free periods. Contention free the contention period starts. This means that stations
period gives AP the control on who gets the channel waiting for longer time can obtain the channel earlier
eliminating any contention. than newer stations waiting. This introduces some
amount of fairness in sharing of the wireless channel.
When a station fails on transmission, didn’t receive
A. Distributed Coordination Function:
ACK frame with in time out, then for re-transmission the
DCF supports asynchronous data transmission on best back-off slot number is not selected from [0,CWmin] but
effort basis. Ad-Hoc networks use only DCF while is doubled until CWmax is reached. If the number of re-
infrastructure networks can use both DCF and PCF. This transmissions exceeds a certain value the frame is
function sits over physical layer. DCF is mainly based dropped and CW value is reset to its minimum. This
on CSMA/CA (Carrier Sense Multiple Access/Collision time frame is vendor dependant.
Avoidance) protocol. One thing we can understand from this is that if
CSMA was first used in 802.3 LANs where it used CWmin value is high station may needed to wait longer
collision detection. In CSMA, nodes check if channel is than necessary to transmit reducing throughput. In
idle to start a transmission. In 802.3 LANs when a 802.11 standard CW value is defaulted to 31. When
channel detects collision it backs off for a certain slot stations in the system are low, smaller CW sizes can
time and wais for channel to get idle. This method works provide better throughput. In following sections we will
fine in a wired medium where it is possible to detect explore this using simulations of a five-node network.
collision using electrical energy of signal. But in 802.11 networks suffer from a problem called hidden
wireless medium detecting collision is nearly node problem. For example take 3 nodes A, B, C where
impossible. There are many interfaces in the medium, B can see A and C while A and C are unaware of each
which can’t be controlled, and also the factor of mobility other existence. So A can think that B is idle and start
of stations makes detection not feasible on a noisy transmission but in reality C is already transmitting to B.
channel. To avoid collisions a mechanism called RTS/CTS is
To overcome this problem the protocol with Collision employed. For example if A wants to transmit to B, it
Avoidance was developed. Since collisions can’t be sends a RTS packet B and if B is idle it sends a CTS
detected we avoid them. Here each station tries to obtain packet to all the stations in its range. So C knows that Bb
the channel at times generated randomly. CSMA/CA is already in transmission and wait till that transmission
works by making the channel idle for certain period after ends.
a transmission. This time is called inter-frame Space This method is disabled by default in 802.11
(IFS). networks. This is because usually WLANs are simple
The IFS depends on priority of frames. If it’s a high enough and don’t require this and also using RTS/CTS
priority frame like a ACK frame waits smaller time can degrade the throughput of the system.
called SIFS (short IFS). Then there is normal waiting Since we are going to deal with Ad-Hoc networks ony
time called DIFS (DCF IFS), which applies to normal in this paper, we aren’t discussing PCF which is not
data. There is an intermediate IFS called PIFS used by possible in Ad-Hoc Networks.
PCF when contention free period is set. Along with deciding channel access to stations, 802.11
Every station has to wait for a random Back-Off time MAC layer has to take care of protocol data unit
when it fails to obtain the channel. This random number addressing, frame formatting, error checking,
is chose using Contention Window. A value CWmin is fragmentation and reassembly. It also manages the
set and each channel chooses a random number between security and power management of the stations.
[0,CWmin] which specifies the Back-Off slots. Time of
each Back-Off slot is determined by PHY layer
parameter slot time. This time differs for standards like
802.11b uses 20 microseconds while 802.11g- only uses
9 microseconds. One thing to remember here is that to
provide backward compatibility 802.11g+802.11b can III. NETWORK SIMULATOR-2
use 20 microseconds if any legacy devices are also Network Simulator is a discrete event simulator
present in network. developed at UC Berkley in C++ and OTcl. It schedules
So when a station transmits a frame and on successful events like packet transmission and timer expiration.
receipt of ACK frame, it waits for specifies DIFS and Since it is a discrete event scheduler it can’t simulate
random contention slot it selected to transmit the next events in parallel but that’s not a problem for most
> REPLACE THIS LINE WITH YOUR PAPER IDENTIFICATION NUMBER (DOUBLE-CLICK HERE TO EDIT) < 3

simulations. The simulator includes protocol sink. It is a simple and best way to analyze the system
implementations for most network components. It can involving multiple connections. We will use these tools
simulate UDP, TCP agents, it can generate application to analyze the network and deduce our observations.
traffic like FTP, CBR (Constant Bit Rate), VBR To create a wireless network we need to specify
(Variable Bit Rate). It also simulates various queuing various properties like method of prorogation, Antenna
systems like DropTail. The wireless extensions were type, Interface queue length and routing type. Figure2
derived from CMU Monarch Project.
NS-2 has two components C++ implementations of
various network components and Tcl scripts to access
those classes. NS is a OTcl interpreter with network
simulation object libraries. OTcl scripts uses objects
from these libraries to create overlay of a network.
Nodes, TCP and UDP agents, scheduling these agents,
bandwidth of links, RTS thresholds, etc all can be
changed using simple objects. We can also access the
C++ libraries in order make any custom objects are
changes.
Ns-2 produces a trace file after completion of Figure2 Properties of Wireless Channel in NS-2 Code
simulation. Studying this trace file gives us the
information we need to understand the workings of the shows a snippet from the code written for simulations
simulation. Each line in trace file starts with an
corresponding to wireless properties.
abbreviation for a event like receive, send, drop, enqueue
and dequeue. Followed by information about nodes that
We create a grid where we place the nodes at specific
it originated or reached, Network Trace level destination
and source address. Parsing these files we obtain packets positions and we can also specify their movement speed
received and dropped and calculate throughput, delay with respect to each other. One thing to remember in
and other parameters of the system. practical implementation RTS/CTS is off by default, but
NAM is another tool with ns-2. It gives us a graphical in NS-2 it’s on by default. To disable this we need to set
representation of the network and packets traversing RTS threshold to 3000, which is, enable RTS only when
through the network. It helps to have cursory glance and packet size is 3000, which will be never.
deduce some events happening in the simulation. Now in next sections we do simulations with above
Figure1 shows a example of graphical representation of settings. First we will see how RTS/CTS affects the
a wired network. system and how effective is it. And next we will see how
contention window affects the throughput of a five-node
network.

IV. SIMULATIONS
In this section, we will see some few simulation
scenarios to understand these networks in detail. First we
will see a simple scenario of four nodes where adjacent
nodes are in range to one another. Then we will simulate

Figure1 Example of a NAM trace

Final tool that can be helpful in analyzing data from


NS-2 is X-Graph. Using some special agents like Loss 5 nodes scenario. These simulations used bit rate of
Monitor we can generate trace files of specific sinks Figure 3: four node Simulation setup
with information on packets received and drops at that 54mbps. RTS is on by default in NS-2, in order to
> REPLACE THIS LINE WITH YOUR PAPER IDENTIFICATION NUMBER (DOUBLE-CLICK HERE TO EDIT) < 4

disable it I set the RTS threshold as 3000. This means and yellow show packets received and lost at node 2.
that RTS is switched on only when packet size is more here we can see node 2 had pretty much perfect
than 3000, which will be never. transmission. While node 3 did not have perfect
In first simulation as been told previously 4 nodes are transmission in fact it lost quite an amount of packets.
present. Topology size is 600x600 and nodes are placed This is because node 2 is a busy receiving packet from 3
with 250 units of distance separating them. In figure 3, and queue at 1 gets full and packets start dropping. Now
We can see the arrangement. we may expect RTS/CTS may improve this situation. In
All nodes are connected to a TCP agent with a next simulation RTS/CTS was on.
constant bit rate. In this simulation we are going to look In figure 5 we see the statistics with RTS/CTS on .H
it to how ongoing transmissions affect each other even if ere we see even more degradation of service here.
RTS/CTS is present. To see how this affects the packets RTS/CTS is not failing in prevention of collisions but in
we simply look how many packets are lost and reached the aim of stopping the collisions its keeping the nodes
at respective nodes. in waiting. The reason here is nodes need to wait extra
To do this we add an agent called loss monitor to the time to start their transmission. This gives node to not
destination nodes. Loss monitor simply counts the transmit when node is busy. But it doesn't make a
packets, which were received or lost due to insufficient difference since they are interfering with each other and
queue in the system. We capture this data in to a trace packets are being lost because queues are getting filled.
file. We load these files using x-graph and we see the As you can see even node 2 saw loss of packets, which
statistics of the system. was, not see previously. Here because of the entire
The first configuration is one where we connect node waiting involved queue get full and packets start to drop.
1 to node 3 and node 3 to node 2. The simulation is done
for 10 secs. In figure 4 we can see the results with
RTS/CTS off.

Figure 5: X-graph with RTS/CTS off

So in previous simulations we saw that RTS/CTS on


doesn't guarantee a perfect transmission and in fact it
reduced the throughput of the system. In practical
conditions RTS/CTS is not kept on. 802.11 networks are
Figure 4: X-graph with RTS/CTS off
usually installed in homes and small business. These
networks usually are small and nodes are with in the
Here in figure 4 we have 4 lines. Red one and light
range. And most of the time these nodes interact with a
green denote packet received and lost at node 3 and blue
> REPLACE THIS LINE WITH YOUR PAPER IDENTIFICATION NUMBER (DOUBLE-CLICK HERE TO EDIT) < 5

centralized access point, which has the information of all


nodes, which are in range. Table 1: Contention Window and Throughput
In this next simulation we want to see how contention Contention Window Size Throughput (bytes/sec)
window size affects the wireless networks. For this
2 225120
simulation we used a new network topology. Here
system was designed in such a way that nodes may have 7 516651
to wait for transmissions. Here node 1 was at the center
15 523562
of the topology. It had no sinks or agents attached to it.
Remaining nodes were placed as shown in figure 6. 31 489327
64 444559
128 321562
1024 75723

In table1, we will see effective throughput of the


system varying with contention window size. Effective
throughput of the system here is calculated by obtaining
total number of packets received by all receivers at
AGENT level and divided by total simulation. The
reason we count packets that reached AGENT level is
these are the effectively useful packets where as packets
Figure 6 Simulation setup -5nodes reaching MAC level contain ACKs an some times RTS
The reason for this placement was any transmission and CTS if it on. Calculation of these packets in case of
had to go through node 1. All the reaming nodes were TCP becomes tricky since they too involve some ACK
not in range of each other while node 1 was in range to reaching that level. Since we have all UDP here we do
all nodes. This meant nodes needed to fight for their not have to worry about them now.
channel with competing transmissions. We can add As we can see in the table contention window sizes
multiple connections between these nodes to increase used are 2, 7, 15, 31, and 64. We can clearly see that
contention. But large number of parallel connections can contention window size of 15 gives us the best
make them interfere with each other too often as we throughput. Contention window size of 31 is not far way
have seen previously leading to very congested and is within acceptable range. This falls in line with
environment. I setup this simulation with 3-connection expectations from previous sections. The topology used
happening. In the beginning all of them were UDP. The here is small with only 5 nodes. Smaller contention
connection details are: window size means nodes get relatively smaller time to
• Node 0 to Node 2 wait and which is perfect for this setup. With more
• Node 0 to Node 3 number of nodes contention window size of 15 means
• Node 4 to Node 2 that when slot time ends many of them may collide
• Packet Size 1000 and Packet Interval: 0.001 again. As we can see, the throughput of the system falls
down miserably as window size increases to 1024.
In previous sections we have seen how contention In table 2 we will see throughput values along with
window mechanism works. Here for this experiment I contention window values with RTS/CTS on. Now as
have set CWmin = CWmax = CW. Now we know that we can see throughput values have decreased but still
contention window size have their affect on throughput. CW value of 15 has higher throughput with 31 following
Now stations have to choose from a random window close behind. This tells us that RTS/CTS doesn’t affect
size to wait out till they can again contend for contention window size throughput. This expected since
transmission. Larger wait times reduce the chance a node RTS/CTS values are sent through SIFS and have no
gets to transmit. affect on random selection of contention window.
> REPLACE THIS LINE WITH YOUR PAPER IDENTIFICATION NUMBER (DOUBLE-CLICK HERE TO EDIT) < 6

Table 2 Contention Window size and throughput With From the table we can see that window size of 15
RTS CTS gives us the best throughput followed by window size of
31. Here the effective throughput of the network is lower
Contention Window Size Throughput (bytes/sec) than UDP. This is because TCP has an
2 110520 acknowledgement system. This makes it more efficient
but also provides lesser throughput.
7 295679 Finally I conducted simulations with different values
15 299081 for CWmin and CWmax. Since these can be a huge set
31 288801 of combinations here I just simulated for some
combinations. Table 6 shows us those values. These
64 271999
values are again for a system with complete UDP
128 210920 network.
Table 6
1024 66922
CW min CW max Throughput

But the reduction in throughput reinforces the 2 31 268281


previous simulation data. Previously we just looked in to 7 31 528240
data that had MAC layer packets. Now as we see there is
a substantial knock on the collective throughput of the 15 128 520799
system. The switching off of RTS/CTS in smaller 15 31 522200
networks is a good idea for this reason. Physical carrier
sense can handle this system in these smaller networks.
In the next simulation I changed the agents from UDP These values are not much different from the values
to TCP. Here while analyzing the trace file we need to we obtained in previous UDP simulation. But one reason
see that since TCP ensure successful transmission we may be for this presence of fewer nodes. In cases with
start to see ACK packets in AGENT layer of nodes. large number of nodes this strategy can improve
Initially when I did my simulations I was unaware of this bandwidth. But from these simulations one thing stands
and was wondering the reason for noticing packets at out, optimum throughput for a given contention window
source of the traffic after fixing this problem in AWK size is at 15 to 31. Our simulations showed very less
files finally I was able to undertake the simulation. difference between these values and were closer than
Connection characteristics of this simulation are: any other values we have seen.
• Node 0 to Node 2 802.11 uses 31 as default value this may be because
• Node 0 to Node 3 standard was developed so that it can scale for more
• Node 4 to Node 2 nodes rather than a size like a five node system.
• Packet Size 1000 and Packet Interval: 0.001
The only difference from previous simulation is that the
traffic source is a TCP agent. Table 3 shows the
throughput values with changing contention window
sizes with RTS/CTS off.
Table 3 V. FUTURE WORK
Contention Window Throughput Optimum Contention window size decision is an
2 238004 ongoing research in wireless field. This has also
implications in fields of power line also. One path that
15 305682 can be taken is to develop a dynamic methodology of
31 313800 selecting contention window size and implement in the
wireless stack of NS-2. These simulations can be
64 291360 approximated to application of the plan to practical
128 186081 802.11 networks.

1024 41096
> REPLACE THIS LINE WITH YOUR PAPER IDENTIFICATION NUMBER (DOUBLE-CLICK HERE TO EDIT) < 7

VI. CONCLUSION
In this paper, we have looked in to the inner workings of
802.11 networks. These networks have become
widespread in present day world. These networks make
communication possible through a highly noisy
environment. These concepts have been applied and
extended to advanced technologies like power line. We
studied the use of DCF and PCF in resolving contention
for channels. Ns-2 was used to simulate the wireless
networks. The results showed that for a 5-node network
a contention window size of 15 was optimum with 31
also being very close to the optimal value.

REFERENCES
[1] http://www.isi.edu/nsnam/ns/tutorial/ Marc Greis
Ns-2 Tutorial
[2] http://www.cse.msu.edu/~wangbo1/ns2/ Network
Simulator-2
[3] http://old.nabble.com/Network-Simulator-ns-2-
f15582.html Ns-2 Forum
[4] http://www.ieee802.org/11/ 802.11 Forum
[5] http://standards.ieee.org/getieee802/802.11.html
802.11 standards
[6] Wireless Communications Rappaport
[7] http://evanjones.ca/ns2/ Ns-2 Tutorial
[8] Effects of contention window and packet size on the
energy efficiency of wireless local area network
[9] On the Effect of Contention-Window Sizes in IEEE
802.11b Networks by Sachin garg, Martin Kappes,
A.S Krishna Kumar
[10] Effect of the contention window size on
performance and fairness of the IEEE 802.11
standard Azade Khalaj, Nasse Yazdani, Maseud
Rahgozar
[11] http://www.winlab.rutgers.edu/~zhibinwu/html/net
work_simulator_2.html Rutgers Lab on Wireless
NS-2
[12] http://www.joshuarobinson.net/docs/ns-
802_11b.html Ns-2 Guide

Potrebbero piacerti anche