传播损失模型不能正常工作

时间:2015-02-02 17:25:36

标签: c++ network-programming waf ns-3

我一直在尝试使用NS-3中的wifi ad-hoc网络,目前我正在尝试证明两个节点所在的距离越远,连接就越糟糕。运行WAF时没有编译或运行时错误。

问题

虽然我尝试过使用默认构造函数(假设它设置了ns3::LogDistancePropagationLossModel的传播损耗模型)但是当距离改变时,节点之间的传输带宽以及网络抖动或滞后都没有影响。然后我尝试手动设置传播损耗,当距离设置为1.0时,导致无连接。我对此行为感到困惑。我觉得我在代码中遗漏了一些值,我应该传递给ns-3但似乎无法找到它。我引用了示例代码,但没有用(http://www.nsnam.org/doxygen/wifi-example-sim_8cc_source.html)。

我在udp模式下使用iperf来测量连接统计数据。我有两个正确隔离的Linux容器,可以通过WAF脚本通过ns-3进行通信。

来源:

#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 ();
}

修改 只想更新一下情况。通过禁用碎片而不是尝试覆盖默认的传播损耗模型,我能够注意到距离上的连接性变化。作为参考,具有显着连接性下降的距离为27-30米,Ofdm速率为54Mbps,而Ofdm速率为24Mbps,为55-60米。

这仍然让我指出,当我试图&#34;覆盖&#34;或者在SIM卡上添加传播损耗模型,我将失去超过1米距离的连接。我尝试用Friis,默认的Log Distance和Kun2600进行覆盖,所有都具有相同的效果。工作守则如下。

谢谢, 麦克

#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 ();
}

0 个答案:

没有答案