wifi broadcast question 1: range for busy state

453 views
Skip to first unread message

Michael

unread,
Aug 31, 2009, 8:23:56 PM8/31/09
to ns-3-users
I have a question about what a "realistic" range is for an adhoc
station to register a busy state. I am using the default values in an
adhoc network simulation, and I'm getting a busy state from a
broadcast node over 4500 meters away. I have not experimented with
hardware before to know what a realistic range is, but this seems a
greater distance than I expected. Nodes greater than 200 meters away
do not successfully receive broadcast packets.

I have a (simple) broadcast adhoc network (adapted from examples/
third.cc), composed of nWifi nodes arranged along an x-axis, each node
latDistance from the previous node. The node at (0,0) is always set
to broadcast, while the node at (latDistance * nWifi) only broadcasts
if twoBroadcast=true. The results below show that the nodes are
contending for the medium even when the nodes are 4500 meters apart,
but when they are 9000 meters apart, they no longer contend for the
medium. I didn't run the simulation at every interval in between to
find out where the exact distance was, I was trying to determine that
they were contending for the medium at (what I think is) a great
distance, and then at an even greater distance they were not.

My reasoning for thinking that contention is occurring is that when
one node broadcasts, 2667 packets are broadcast, but when two nodes
are broadcasting, fewer than 2667 packets are broadcast, which I
believe must be due to contention for the medium.

The code and the results are listed below.

/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* This program is free software; you can redistribute it and/or
modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
*/

#include <fstream>
#include <string>
#include "ns3/core-module.h"
#include "ns3/simulator-module.h"
#include "ns3/node-module.h"
#include "ns3/helper-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
#include "ns3/adhoc-wifi-mac.h"

// Default Network Topology
//
// Wifi 10.1.3.0
//
// * * * * ... *
// | | | | |
// n0 n1 n2 n3 nWifi-1
//

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("ThirdScriptExampleWifiOnly");

static Vector
GetPosition (Ptr<Node> node)
{
Ptr<MobilityModel> mobility = node->GetObject<MobilityModel> ();
return mobility->GetPosition();
}

int
main (int argc, char *argv[])
{
bool verbose = true;
bool twoBroadcast = true;
uint32_t nWifi = 4;
double latDistance = 50;
double rndStart = 0.000016;
UniformVariable rndStartValue(0.0, rndStart);

Config::SetDefault ("ns3::OnOffApplication::PacketSize", StringValue
("500"));
Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue
("6000kb/s"));

CommandLine cmd;
// use --<argument>=0 for false when <argument> is boolean
cmd.AddValue ("nWifi", "Number of wifi adhoc devices", nWifi);
cmd.AddValue ("verbose", "Tell echo applications to log if true",
verbose);
cmd.AddValue ("latDistance", "Distance between nodes, in meters",
latDistance);
cmd.AddValue ("twoBroadcast", "Sets a second node to broadcast if
true", twoBroadcast);

cmd.Parse (argc,argv);

if (verbose)
{
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
}

NodeContainer wifiStaNodes;
wifiStaNodes.Create (nWifi);

YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
phy.SetChannel (channel.Create ());

WifiHelper wifi = WifiHelper::Default ();
wifi.SetStandard(WIFI_PHY_STANDARD_80211a);
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue
("wifia-6mbs"));

NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
mac.SetType ("ns3::AdhocWifiMac",
"Slot", StringValue ("16us"));

NetDeviceContainer staDevices;
staDevices = wifi.Install (phy, mac, wifiStaNodes);

MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc =
CreateObject<ListPositionAllocator> ();
for (uint32_t x = 0; x < nWifi; x++)
{
positionAlloc->Add (Vector ((x*latDistance), 0.0, 0.0));
}
mobility.SetPositionAllocator (positionAlloc);

// Nodes are stationary
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (wifiStaNodes);

// print current location of the nodes
for (uint32_t i = 0; i < nWifi; ++i)
{
Vector pos = GetPosition(wifiStaNodes.Get(i));
std::cout << "Node " << i << " " << pos.x << " " << pos.y <<
std::endl;
}

InternetStackHelper stack;
stack.Install (wifiStaNodes);

Ipv4AddressHelper address;

address.SetBase ("10.1.3.0", "255.255.255.0");
address.Assign (staDevices);

NS_LOG_INFO ("Create Applications.");
uint16_t port = 9; // Discard port is 9 (RFC 863)

Ipv4Address remoteAddr = "255.255.255.255"; // send to the broadcast
address

OnOffHelper onoff ("ns3::UdpSocketFactory",
Address (InetSocketAddress (remoteAddr, port)));
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable
(10)));
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable
(0)));

// set Node 0 to broadcast
ApplicationContainer apps;
Ptr<Node> appSource = NodeList::GetNode (0);
apps = onoff.Install (appSource);
apps.Start (Seconds (rndStartValue.GetValue()));
apps.Stop (Seconds (2.0));

// set furthest node to broadcast also
if (twoBroadcast == true)
{
Ptr<Node> appSource = NodeList::GetNode (nWifi-1);
apps = onoff.Install (appSource);
apps.Start (Seconds (rndStartValue.GetValue()));
apps.Stop (Seconds (2.0));
}


// Create a packet sink to receive these packets on each of the middle
Nodes
// Node (0) and Node (nWifi-1) do not have a sink installed
// Output does not change if the sink is not installed
PacketSinkHelper sink ("ns3::UdpSocketFactory",
InetSocketAddress (Ipv4Address::GetAny (),
port));
for (uint32_t nNodes = 1; nNodes < (nWifi-1); nNodes++)
{
std::cout << "Node " << nNodes << " is a sink." << std::endl;
Ptr<Node> appSink = NodeList::GetNode (nNodes);
apps = sink.Install (appSink);
apps.Start (Seconds (0.0));
}

Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

// Tracing configuration
NS_LOG_INFO ("Configure Tracing.");
std::ofstream ascii;
ascii.open ("third_adhoc.txt");
YansWifiPhyHelper::EnableAsciiAll (ascii);
InternetStackHelper::EnableAsciiAll (ascii);
phy.EnablePcapAll ("third_adhoc");

Simulator::Stop (Seconds (10.0));

Simulator::Run ();
Simulator::Destroy ();
return 0;
}
=================================
=============Results================
=================================
With latDistance = 50, these are the node locations:
X Y
Node 0 0 0
Node 1 50 0
Node 2 100 0
Node 3 150 0
Node 4 200 0
Node 5 250 0
Node 6 300 0
Node 7 350 0
Node 8 400 0
Node 9 450 0

**twoBroadcast = false
nWifi = 10
latDistance = 50 (450 meters between node 0 and node 9)
Number Tx Node 0 = 2667 // node 0 broadcasts 2667 packets during the
sim run
Number Tx Node 9 = 0 // node 9 does not broadcast since
twoBroadcast = false
Number Rx Node 0 = 0
Number Rx Node 1 = 2667 // node 1 receives 2667 packets during the sim
run (from node 0)
Number Rx Node 2 = 2667 // node 2 receives 2667 packets during the sim
run (from node 0)
Number Rx Node 3 = 1677 // node 3 receives 1667 packets during the sim
run (from node 0)
Number Rx Node 4 = 0 // remaining nodes are out of range, receive 0
packets (node 4 is 200 meters from node 0)
Number Rx Node 5 = 0
Number Rx Node 6 = 0
Number Rx Node 7 = 0
Number Rx Node 8 = 0
Number Rx Node 9 = 0

**twoBroadcast = true
nWifi = 10
latDistance = 50 (450 meters between node 0 and node 9)
Number Tx Node 0 = 1642 // node 0 broadcasts 1642 packets during the
sim run
Number Tx Node 9 = 1614 // node 0 broadcasts 1614 packets during the
sim run
Number Rx Node 0 = 0
Number Rx Node 1 = 1642 // received packets during sim run (from node
0)
Number Rx Node 2 = 1642 // received packets during sim run (from node
0)
Number Rx Node 3 = 913 // received packets during sim run (from node
0)
Number Rx Node 4 = 0 // outside range
Number Rx Node 5 = 0 // outside range
Number Rx Node 6 = 859 // received packets during sim run (from node
9)
Number Rx Node 7 = 1614 // received packets during sim run (from node
9)
Number Rx Node 8 = 1614 // received packets during sim run (from node
9)
Number Rx Node 9 = 0


With latDistance = 500, these are the node locations:
X Y
Node 0 0 0
Node 1 500 0
Node 2 1000 0
Node 3 1500 0
Node 4 2000 0
Node 5 2500 0
Node 6 3000 0
Node 7 3500 0
Node 8 4000 0
Node 9 4500 0

**twoBroadcast = false
nWifi = 10
latDistance = 500 (4500 meters between node 0 and node 9)
Number Tx Node 0 = 2667 // node 0 broadcasts 2667 packets during the
sim run
Number Tx Node 9 = 0 // node 9 does not broadcast since
twoBroadcast = false
Number Rx Node 0 = 0 // no nodes within range of braodcasting nodes
Number Rx Node 1 = 0
Number Rx Node 2 = 0
Number Rx Node 3 = 0
Number Rx Node 4 = 0
Number Rx Node 5 = 0
Number Rx Node 6 = 0
Number Rx Node 7 = 0
Number Rx Node 8 = 0
Number Rx Node 9 = 0

**twoBroadcast = true
nWifi = 10
latDistance = 500 (4500 meters between node 0 and node 9)
Number Tx Node 0 = 1859 // node 0 broadcasts 1859 packets during the
sim run
Number Tx Node 9 = 1774 // node 0 broadcasts 1774 packets during the
sim run
Number Rx Node 0 = 0 // no nodes within range of braodcasting nodes
Number Rx Node 1 = 0
Number Rx Node 2 = 0
Number Rx Node 3 = 0
Number Rx Node 4 = 0
Number Rx Node 5 = 0
Number Rx Node 6 = 0
Number Rx Node 7 = 0
Number Rx Node 8 = 0
Number Rx Node 9 = 0

With latDistance = 1000, these are the node locations:
Node 0 0 0
Node 1 1000 0
Node 2 2000 0
Node 3 3000 0
Node 4 4000 0
Node 5 5000 0
Node 6 6000 0
Node 7 7000 0
Node 8 8000 0
Node 9 9000 0

**twoBroadcast = false
nWifi = 10
latDistance = 1000 (9000 meters between node 0 and node 9)
Number Tx Node 0 = 2667 // node 0 broadcasts 2667 packets during the
sim run
Number Tx Node 9 = 0 // node 9 does not broadcast since
twoBroadcast = false
Number Rx Node 0 = 0 // no nodes within range of braodcasting nodes
Number Rx Node 1 = 0
Number Rx Node 2 = 0
Number Rx Node 3 = 0
Number Rx Node 4 = 0
Number Rx Node 5 = 0
Number Rx Node 6 = 0
Number Rx Node 7 = 0
Number Rx Node 8 = 0
Number Rx Node 9 = 0

**twoBroadcast = true
nWifi = 10
latDistance = 1000 (9000 meters between node 0 and node 9)
Number Tx Node 0 = 2669 // node 0 broadcasts 2669 packets during the
sim run
Number Tx Node 9 = 2667 // node 0 broadcasts 2667 packets during the
sim run
Number Rx Node 0 = 0 // no nodes within range of braodcasting nodes
Number Rx Node 1 = 0
Number Rx Node 2 = 0
Number Rx Node 3 = 0
Number Rx Node 4 = 0
Number Rx Node 5 = 0
Number Rx Node 6 = 0
Number Rx Node 7 = 0
Number Rx Node 8 = 0
Number Rx Node 9 = 0

Mathieu Lacage

unread,
Sep 1, 2009, 3:06:30 AM9/1/09
to ns-3-...@googlegroups.com
I think that you want to play with
ns3::YansWifiPhy::EnergyDetectionThreshold. i.e., try
--ns3::YansWifiPhy::EnergyDetectionThreshold=-95 on the command-line.

What is really annoying is that a lot of people complain about this
default value but no one appears willing to bother with filing a bug
with a suggestion for what the default value should be.

Mathieu
--
Mathieu Lacage <mathieu...@gmail.com>

Michael

unread,
Sep 4, 2009, 11:58:48 PM9/4/09
to ns-3-users
After running quite a few iterations of values, the following seem to
provide pretty good results for my use. I am trying to have about a
300 meter reception range, so that is why the gains are set to 5.
With the default RxGain and TxGain of 1.0, the range goes down to
about 220 meters.

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (-100.0) );
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (-90.0) );
wifiPhy.Set ("TxGain", DoubleValue (5.0) );
wifiPhy.Set ("RxGain", DoubleValue (5.0) );
wifiPhy.Set ("TxPowerLevels", UintegerValue (1) );
wifiPhy.Set ("TxPowerEnd", DoubleValue (16.0206) );
wifiPhy.Set ("TxPowerStart", DoubleValue (16.0206) );
wifiPhy.Set ("RxNoiseFigure", DoubleValue (3) );

Michael

On Sep 1, 3:06 am, Mathieu Lacage <mathieu.lac...@gmail.com> wrote:
> I think that you want to play with
> ns3::YansWifiPhy::EnergyDetectionThreshold. i.e., try
> --ns3::YansWifiPhy::EnergyDetectionThreshold=-95 on the command-line.
>
> What is really annoying is that a lot of people complain about this
> default value but no one appears willing to bother with filing a bug
> with a suggestion for what the default value should be.
>
> Mathieu
>
> ...
>
> read more »

Michael

unread,
Sep 5, 2009, 10:03:38 AM9/5/09
to ns-3-users
Values based on previous research done by others using ns2 also gives
acceptable ranges. Here are two configurations:

From work done by Qi Chen, Felix Schmidt-Eisenlohr, Daniel Jiang, Marc
Torrent-Moreno, Luca Delgrossi, Hannes Hartenstein (web site:
http://dsn.tm.uni-karlsruhe.de/Overhaul_NS-2.php). The values are in
the tcl file here: http://dsn.tm.uni-karlsruhe.de/download/IEEE802-11p-2008-10-29.tcl
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (-99.0) );
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (-94.0) );
wifiPhy.Set ("TxGain", DoubleValue (5.0) ); // I used higher
gain to extend range to about 300 meters
wifiPhy.Set ("RxGain", DoubleValue (5.0) ); // I used higher
gain to extend range to about 300 meters
wifiPhy.Set ("RxNoiseFigure", DoubleValue (5) );


From a paper written by Marc Torrent-Moreno, Daniel Jiang, Hannes
Hartenstein "Broadcast Reception Rates and Effects of Priority Access
in 802.11-Based Vehicular Ad-Hoc Networks"
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (-96.0) );
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (-90.0) );
wifiPhy.Set ("TxGain", DoubleValue (5.0) ); // I used higher
gain to extend range to about 300 meters
wifiPhy.Set ("RxGain", DoubleValue (5.0) ); // I used higher
gain to extend range to about 300 meters
wifiPhy.Set ("RxNoiseFigure", DoubleValue (6) );

Michael
> ...
>
> read more »- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages