问题描述
我使用OnOffApplication运行脚本,并在执行./waf
时获得以下输出:Build Failed
-> task in 'basicVideostreaming' Failed with exit status 1:
{task 140001722681272: cxx basicVideostreaming.cc -> basicVideostreaming.cc.4.o}
['/usr/bin/g++','-Wall','-std=c++11','-pthread','-I.','-I..','-DNS3_BUILD_PROFILE_DEBUG','-DNS3_ASSERT_ENABLE','-DNS3_LOG_ENABLE','-DHAVE_SYS_IOCTL_H=1','-DHAVE_IF_NETS_H=1','-DHAVE_NET_ETHERNET_H=1','-DHAVE_PACKET_H=1','-DHAVE_SEMAPHORE_H=1','-DHAVE_IF_TUN_H=1','../scratch/basicVideostreaming.cc','-c','-o/home/ubuntu/ns-3-allinone/ns-3-dev/build/scratch/basicVideostreaming.cc.4.o']
我要执行的代码是这样:
#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
// Default Network Topology
//
// Wifi 10.1.3.0
// AP
// * * * *
// | | | | 10.1.1.0
// n5 n6 n7 n0 -------------- n1 n2 n3 n4
// point-to-point | | | |
// ================
// LAN 10.1.2.0
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("Pm2Example");
int
main (int argc,char *argv[])
{
bool verbose = true;
uint32_t nCsma = 3;
uint32_t nWifi = 3;
CommandLine cmd;
cmd.AddValue ("nCsma","Number of \"extra\" CSMA nodes/devices",nCsma);
cmd.AddValue ("nWifi","Number of wifi STA devices",nWifi);
cmd.AddValue ("verbose","Tell echo applications to log if true",verbose);
cmd.Parse (argc,argv);
if (nWifi > 18)
{
std::cout << "Number of wifi nodes " << nWifi <<
" specified exceeds the mobility bounding Box" << std::endl;
exit (1);
}
if (verbose)
{
LogComponentEnable ("UdpEchoClientApplication",LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServerApplication",LOG_LEVEL_INFO);
}
NodeContainer p2pNodes;
p2pNodes.Create (2);
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("Datarate",StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay",StringValue ("2ms"));
NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);
NodeContainer csmaNodes;
csmaNodes.Add (p2pNodes.Get (1));
csmaNodes.Create (nCsma);
CsmaHelper csma;
csma.SetChannelAttribute ("Datarate",StringValue ("100Mbps"));
csma.SetChannelAttribute ("Delay",TimeValue (NanoSeconds (6560)));
NetDeviceContainer csmaDevices;
csmaDevices = csma.Install (csmaNodes);
NodeContainer wifiStaNodes;
wifiStaNodes.Create (nWifi);
NodeContainer wifiApNode = p2pNodes.Get (0);
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
phy.SetChannel (channel.Create ());
WifiHelper wifi = WifiHelper::Default ();
wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
Ssid ssid = Ssid ("ns-3-ssid");
mac.SetType ("ns3::StaWifiMac","Ssid",SsidValue (ssid),"ActiveProbing",BooleanValue (false));
NetDeviceContainer staDevices;
staDevices = wifi.Install (phy,mac,wifiStaNodes);
mac.SetType ("ns3::ApWifiMac",SsidValue (ssid));
NetDeviceContainer apDevices;
apDevices = wifi.Install (phy,wifiApNode);
mobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::GridPositionAllocator","MinX",DoubleValue (0.0),"MinY","DeltaX",DoubleValue (5.0),"DeltaY",DoubleValue (10.0),"GridWidth",UintegerValue (3),"LayoutType",StringValue ("RowFirst"));
mobility.SetmobilityModel ("ns3::RandomWalk2dmobilityModel","Bounds",RectangleValue (Rectangle (-50,50,-50,50)));
mobility.Install (wifiStaNodes);
mobility.SetmobilityModel ("ns3::ConstantPositionmobilityModel");
mobility.Install (wifiApNode);
InternetStackHelper stack;
stack.Install (csmaNodes);
stack.Install (wifiApNode);
stack.Install (wifiStaNodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0","255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces;
p2pInterfaces = address.Assign (p2pDevices);
address.SetBase ("10.1.2.0","255.255.255.0");
Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces = address.Assign (csmaDevices);
address.SetBase ("10.1.3.0","255.255.255.0");
address.Assign (staDevices);
address.Assign (apDevices);
uint16_t port = 9;
OnOffhelper onoff(
"ns3::UdpSocketFactory",InetSocketAddress("10.1.2.4",port));
onoff.SetAttribute("OnTime",StringValue("ns3::ConstantRandomVariable[Constant=1]"));
onoff.SetAttribute("OffTime",StringValue("ns3::ConstantRandomVariable[Constant=0]"));
onoff.SetAttribute("Datarate",StringValue("512Kbps"));
onoff.SetAttribute("PacketSize",StringValue("512"));
onoff.Install(wifiStaNodes.Get(nWifi - 1));
ApplicationContainer apps = onoff.Install(wifiStaNodes.Get(nWifi-1));
apps.Start(Seconds(5.0));
apps.Stop(Seconds(20.0));
PacketSinkHelper sink(
"ns3::UdpSocketFactory",port));
sink.Install(csmaNodes.Get(nCsma));
Simulator::Stop(Seconds(25.0));
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
pointToPoint.EnablePcapAll ("pm-ex2");
phy.EnablePcap ("pm-ex2",apDevices.Get (0));
csma.EnablePcap ("pm-ex2",csmaDevices.Get (0),true);
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
我是ns-3的新用户,我不明白为什么会失败以及如何解决。谢谢您的帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)