4

I have been experimenting with wifi ad-hoc networks in NS-3 and am currently trying to demonstrate that the farther away the two nodes reside, the worse the connection gets. There are no compile or run-time errors when running WAF.

The Problem:

Though I have tried using the default constructor (which supposedly sets a propagation Loss model of ns3::LogDistancePropagationLossModel) There is no effect on the transmission bandwidth between nodes nor in the network jitter or lag when distance is changed. I then tried manually setting the propagation loss, which resulted in no connectivity when distance was set greater to 1.0. I am rather confused at this behavior. I feel that I am missing some value in my code that I should pass to ns-3 but cannot seem to find it. I have referenced example code but to no avail (http://www.nsnam.org/doxygen/wifi-example-sim_8cc_source.html).

I am using iperf in udp mode to measure the connection stats. I have two linux containers that are properly isolated and can communicate through ns-3 via the WAF script.

Source:

#include <iostream>
#include <fstream>
#include"ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/wifi-module.h"
#include "ns3/csma-module.h"
#include "ns3/tap-bridge-module.h"
#include "ns3/netanim-module.h"
#include "ns3/mobility-module.h"

using namespace ns3;

int main( int argc, char *argv[]){

uint32_t nNodes = 2;
CommandLine cmd;
cmd.Parse (argc, argv);

GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl"));
GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));

NodeContainer nodes;
nodes.Create(nNodes);

CsmaHelper csma;

//csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
WifiHelper wifi = WifiHelper::Default();
wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
wifiMac.SetType ("ns3::AdhocWifiMac");

YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
//wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
//wifiChannel.AddPropagationLoss("ns3::FriisPropagationLossModel");
wifiChannel.AddPropagationLoss("ns3::LogDistancePropagationLossModel","Exponent", DoubleValue (3.0));

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate54Mbps"), "ControlMode",StringValue ("OfdmRate54Mbps"));
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
positionAlloc->Add (Vector (10.0, 0.0, 0.0));
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install(nodes);
TapBridgeHelper wifiTapBridge;
wifiTapBridge.SetAttribute ("Mode", StringValue ("UseLocal"));


NodeContainer n_1 = NodeContainer(nodes.Get(0), nodes.Get(1));
NetDeviceContainer dev_1 = wifi.Install(wifiPhy,wifiMac,n_1);

wifiTapBridge.SetAttribute ("DeviceName", StringValue ("tap-0"));
wifiTapBridge.Install(nodes.Get(0), dev_1.Get(0));
wifiTapBridge.SetAttribute ("DeviceName", StringValue ("tap-1"));
wifiTapBridge.Install(nodes.Get(1), dev_1.Get(1));
// Run the simulation for 1 minute to give the user time to play around

Simulator::Stop (Seconds (600.));
csma.EnablePcapAll("radio",true);
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);Simulator::Run ();
Simulator::Destroy ();
}

Edit: Just wanted to update on the situation. By disabling fragmentation and not trying to override the default propagation loss model, I was able to notice a change in connectivity over distance. For reference, the distances with noted connectivity drops are 27-30 Meters for Ofdm Rate 54Mbps and 55-60m for Ofdm Rate 24Mbps.

This still leads me to point out that when I attempted to "override" or add a propagation loss model onto the sim, I would lose connectivity beyond a distance of 1m. I tried overriding with Friis, the default Log Distance, and Kun2600 and all had the same effect. Working Code is below.

Thanks, Mike

#include <iostream>
#include <fstream>
#include"ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/wifi-module.h"
#include "ns3/csma-module.h"
#include "ns3/tap-bridge-module.h"
#include "ns3/netanim-module.h"
#include "ns3/mobility-module.h"

using namespace ns3;

int main( int argc, char *argv[]){

uint32_t nNodes = 2;
CommandLine cmd;
cmd.Parse (argc, argv);

Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));


GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl"));
GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));
NodeContainer nodes;
nodes.Create(nNodes);

CsmaHelper csma;

//csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
WifiHelper wifi = WifiHelper::Default();
wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
//wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
wifiMac.SetType ("ns3::AdhocWifiMac");

YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
//wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
//wifiChannel.AddPropagationLoss("ns3::FriisPropagationLossModel");

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
//wifiPhy.Set ("RxGain", DoubleValue (0) );
//wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (-80));
//wifiChannel.AddPropagationLoss("ns3::Kun2600MhzPropagationLossModel");
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate24Mbps"));
//wifiChannel.AddPropagationLoss("ns3::ThreeLogDistancePropagationLossModel");
Ptr<YansWifiChannel> chan = wifiChannel.Create();
wifiPhy.SetChannel (chan);
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
positionAlloc->Add (Vector (58.0, 0.0, 0.0));
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install(nodes);
TapBridgeHelper wifiTapBridge;
wifiTapBridge.SetAttribute ("Mode", StringValue ("UseLocal"));


NodeContainer n_1 = NodeContainer(nodes.Get(0), nodes.Get(1));
NetDeviceContainer dev_1 = wifi.Install(wifiPhy,wifiMac,n_1);
wifiTapBridge.SetAttribute ("DeviceName", StringValue ("tap-0"));
wifiTapBridge.Install(nodes.Get(0), dev_1.Get(0));
wifiTapBridge.SetAttribute ("DeviceName", StringValue ("tap-1"));
wifiTapBridge.Install(nodes.Get(1), dev_1.Get(1));
// Run the simulation for 1 minute to give the user time to play around

Simulator::Stop (Seconds (600.));
csma.EnablePcapAll("radio",true);
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);Simulator::Run ();
Simulator::Destroy ();
}
Mike
  • 413
  • 2
  • 12
  • For those how might encounter this, there are some known issues with propagation models in NS-3, which the above seems to be one; however, given that the question was asked 6+ years ago things like this might've been solved. The NS-3 Users Google group is a good place to figure these things out – thenewjames Apr 15 '21 at 18:28

0 Answers0