erro fatal: ns3/application-module.h:

275 views
Skip to first unread message

pri_liza

unread,
May 17, 2012, 3:50:16 PM5/17/12
to ns-3-users
Hi people,

I'm new in NS-3 and I was looking a algorithm and when run I got this
error:


erro fatal: ns3/traffic-application.h: Arquivo ou diretório não
encontrado

In English is: fatal error: ns3/traffic-application.h: File or
directory not found

I changed the ns3/traffic-application.h by ns3/application-module.h,
but the error persists.

Anybody know what the problem?

Konstantinos

unread,
May 17, 2012, 4:00:56 PM5/17/12
to ns-3-...@googlegroups.com
First of all, it is applications-module.h (you missed the 's' in the end)

Second, this traffic-application.h is something you created? If yes, have you updated the coresponding wscript ? (in the module you have stored it)
If you have it in the applications module and you don't update the wscript to include this header file and potentially any source file, then even when you will include applications-module.h you will have problem.

Regards,
Konstantinos

pri_liza

unread,
May 21, 2012, 2:42:05 PM5/21/12
to ns-3-users
Thanks Konstantinos.

Actually I got this algorithm on the internet to analyze the
functioning of it. I'll post it in full here so that they can help me
change it so that it runs.


// -*- mode: c++; c-file-style: "gnu"; indent-tabs-mode: nil; -*-

/*
* Test case: 6*n nodes on a six lane highway
*
* 6*n nodes are put on a highway with 6 lanes. Each lane is 5 meters
apart
* from neighboring lanes. Cars are spaced at 90 meters on each lane
(15 meters
* between two nodes along the x axis) yielding a total of 66.6 nodes
per kilometer.
*/

#include "ns3/core-module.h"
#include "ns3/simulator-module.h"
#include "ns3/node-module.h"
#include "ns3/wifi-module.h"
#include "ns3/helper-module.h"
#include "ns3/traffic-application.h"

#include <iostream>
#include <iomanip>
#include <numeric>

using namespace ns3;

NS_LOG_COMPONENT_DEFINE("Main");

class Experiment
{
public:

static const double m_simulatedTime = 60.0;

unsigned int m_appTxPackets;
unsigned int m_appRxPackets;
unsigned int m_phyRxErrors;

void
Run(unsigned int numNodes)
{
// Create nodes and store them in the container.

NodeContainer nodes;
nodes.Create(numNodes);

// Add packet socket handlers.

PacketSocketHelper packetSocket;
packetSocket.Install(nodes);

// Install wifi devices on the nodes.

Ns2ExtWifiChannelHelper wifiChannel;

wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");

wifiChannel.AddPropagationLoss("ns3::ThreeLogDistancePropagationLossModel");
wifiChannel.AddPropagationLoss("ns3::NakagamiPropagationLossModel",
"m0", DoubleValue(1.5),
"m1", DoubleValue(1.0),
"m2", DoubleValue(1.0));

Ns2ExtWifiPhyHelper wifiPhy = Ns2ExtWifiPhyHelper::Default();
wifiPhy.SetChannel(wifiChannel.Create());
wifiPhy.Set("UseConstantNoiseFloor", BooleanValue(true));
wifiPhy.Set("ConstantNoiseFloor", DoubleValue(-99.0));
wifiPhy.Set("PreambleCapture", BooleanValue(true));
wifiPhy.Set("DataCapture", BooleanValue(true));

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

wifi.Install(wifiPhy, nodes);

// Position nodes on to highway lanes.

Ptr<ListPositionAllocator> positionAlloc
= CreateObject<ListPositionAllocator>();
for (unsigned int i = 0; i < numNodes; ++i)
{
positionAlloc->Add(Vector(i * 15, (i % 6) * 5, 0.0));
}

MobilityHelper mobility;
mobility.SetPositionAllocator(positionAlloc);
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
mobility.Install(nodes);

// Use broadcast packet address for applications.

PacketSocketAddress socketBroadcast;
socketBroadcast.SetAllDevices();
socketBroadcast.SetPhysicalAddress(Mac48Address::GetBroadcast());
socketBroadcast.SetProtocol(1);

// Install TrafficApplication on each node.

Ptr<SimpleTrafficPacketFactory> packetFactory
= CreateObject<SimpleTrafficPacketFactory>("Size",
UintegerValue(400));

TrafficHelper trafficApp("ns3::PacketSocketFactory",
socketBroadcast);
trafficApp.SetAttribute("PacketFactory",
PointerValue(packetFactory) );
trafficApp.SetAttribute("OnTime",
RandomVariableValue( ConstantVariable(m_simulatedTime) ));
trafficApp.SetAttribute("OffTime",
RandomVariableValue( UniformVariable(0.0, 0.1) ));
trafficApp.SetAttribute("Interval",
RandomVariableValue( ConstantVariable(0.1) ));

ApplicationContainer app = trafficApp.Install(nodes);
app.Start( Seconds(0.0) );
app.Stop( Seconds(m_simulatedTime) );

// Add Trace callbacks to gather statistics.

Config::Connect("/NodeList/*/ApplicationList/*/
$ns3::TrafficApplication/Tx",
MakeCallback(&Experiment::AppTxTrace, this));
Config::Connect("/NodeList/*/ApplicationList/*/
$ns3::TrafficApplication/Rx",
MakeCallback(&Experiment::AppRxTrace, this));

Config::Connect("/NodeList/*/DeviceList/*/Phy/State/RxError",
MakeCallback(&Experiment::PhyRxErrorTrace, this));

// Zero counters and run simulation.

m_appTxPackets = 0;
m_appRxPackets = 0;
m_phyRxErrors = 0;

Simulator::Run();
Simulator::Destroy();
}

void
AppTxTrace(std::string context, Ptr<const Packet> p)
{
NS_LOG_DEBUG(context << " TX size=" << p->GetSize());
++m_appTxPackets;
}

void
AppRxTrace(std::string context, Ptr<const Packet> p, const Address&
from)
{
NS_LOG_DEBUG(context << " RX from=" << from << " size=" << p-
>GetSize());
++m_appRxPackets;
}

void
PhyRxErrorTrace(std::string context, Ptr<const Packet> p,
Ptr<const WifiPhyTag> phytag, WifiPhy::RxErrorReason reason)
{
NS_LOG_DEBUG(context << " PHYRXERROR"
<< " reason=" << WifiPhy::RxErrorReasonToString(reason)
<< " phytag={" << *phytag << "} p={" << *p << "}");
++m_phyRxErrors;
}
};

template <typename Container>
double meanValue(const Container& c)
{
return std::accumulate(c.begin(), c.end(), 0.0) / c.size();
}

template <typename Container>
double standardDeviation(const Container& c)
{
double squareSum = 0.0;
double sum = 0.0;

for (typename Container::const_iterator ei = c.begin();
ei != c.end(); ++ei)
{
squareSum += (double)(*ei) * (double)(*ei);
sum += *ei;
}

double mean = sum / c.size();
return sqrt( (squareSum / c.size()) - (mean * mean) );
}

template <typename Container>
double errorMargin(const Container& c)
{
return 2.576 * standardDeviation(c) / sqrt(c.size());
}

int main(int argc, char *argv[])
{
CommandLine cmd;
int replications = 1;
unsigned int fixedNumNodes = 0;
cmd.AddValue("Replications", "Perform independent replications.",
replications);
cmd.AddValue("NumNodes", "Run for a fixed number of node.",
fixedNumNodes);
cmd.Parse(argc, argv);

for (unsigned int numNodes = 6; numNodes <= 180; numNodes += 6)
{
if (fixedNumNodes != 0 && numNodes != fixedNumNodes) continue;

std::vector<unsigned int> appTxPackets;
std::vector<unsigned int> appRxPackets;
std::vector<unsigned int> phyRxErrors;

for(int rep = 0; rep < replications; ++rep)
{
SeedManager::SetRun(rep);

Experiment experiment;
experiment.Run(numNodes);

appTxPackets.push_back( experiment.m_appTxPackets );
appRxPackets.push_back( experiment.m_appRxPackets );
phyRxErrors.push_back( experiment.m_phyRxErrors );
}

std::cout << std::fixed
<< numNodes
<< " " << meanValue(appTxPackets) << " " << errorMargin(appTxPackets)
<< " " << meanValue(appRxPackets) << " " << errorMargin(appRxPackets)
<< " " << meanValue(phyRxErrors) << " " << errorMargin(phyRxErrors)
<< std::endl;
}

return 0;
}



I've done the following changes:

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/wifi-module.h"
#include "ns3/applications-module.h"

Konstantinos

unread,
May 21, 2012, 5:59:21 PM5/21/12
to ns-3-...@googlegroups.com
Hi, this is for a previous version of NS-3.
As of NS-3.11 the structure has changed.

With these changes, does it work?

pri_liza

unread,
May 22, 2012, 7:51:22 PM5/22/12
to ns-3-users
Thanks Konstantinos.

Do you know where I find algorithms in the new structure? I need
algorithms about Vanets or any ad hoc network.
Reply all
Reply to author
Forward
0 new messages