37 #include "ns3/core-module.h"
38 #include "ns3/network-module.h"
39 #include "ns3/mobility-module.h"
40 #include "ns3/wifi-module.h"
41 #include "ns3/internet-module.h"
43 #include "ns3/stats-module.h"
66 int main (
int argc,
char *argv[]) {
68 double distance = 50.0;
69 string format (
"omnet");
72 string strategy (
"wifi-default");
78 sstr <<
"run-" << time (NULL);
84 cmd.
AddValue (
"distance",
"Distance apart to place nodes (in meters).",
86 cmd.
AddValue (
"format",
"Format to use for data output.",
88 cmd.
AddValue (
"experiment",
"Identifier for experiment.",
90 cmd.
AddValue (
"strategy",
"Identifier for strategy.",
92 cmd.
AddValue (
"run",
"Identifier for run.",
94 cmd.
Parse (argc, argv);
96 if (format !=
"omnet" && format !=
"db") {
97 NS_LOG_ERROR (
"Unknown output format '" << format <<
"'");
101 #ifndef STATS_HAS_SQLITE3
102 if (format ==
"db") {
109 stringstream sstr (
"");
124 NS_LOG_INFO (
"Installing WiFi and Internet stack.");
127 wifiMac.
SetType (
"ns3::AdhocWifiMac");
136 ipAddrs.
SetBase (
"192.168.0.0",
"255.255.255.0");
137 ipAddrs.
Assign (nodeDevices);
145 NS_LOG_INFO (
"Installing static mobility; distance " << distance <<
" .");
148 CreateObject<ListPositionAllocator>();
149 positionAlloc->
Add (Vector (0.0, 0.0, 0.0));
150 positionAlloc->
Add (Vector (0.0, distance, 0.0));
171 Config::Set (
"/NodeList/*/ApplicationList/*/$Sender/Destination",
197 CreateObject<CounterCalculator<uint32_t> >();
198 totalTx->SetKey (
"wifi-tx-frames");
199 totalTx->SetContext (
"node[0]");
200 Config::Connect (
"/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx",
209 CreateObject<PacketCounterCalculator>();
210 totalRx->
SetKey (
"wifi-rx-frames");
212 Config::Connect (
"/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx",
224 CreateObject<PacketCounterCalculator>();
225 appTx->
SetKey (
"sender-tx-packets");
237 CreateObject<CounterCalculator<> >();
238 appRx->SetKey (
"receiver-rx-packets");
239 appRx->SetContext (
"node[1]");
264 CreateObject<PacketSizeMinMaxAvgTotalCalculator>();
265 appTxPkts->
SetKey (
"tx-pkt-size");
279 CreateObject<TimeMinMaxAvgTotalCalculator>();
280 delayStat->
SetKey (
"delay");
303 if (format ==
"omnet") {
304 NS_LOG_INFO (
"Creating omnet formatted data output.");
305 output = CreateObject<OmnetDataOutput>();
306 }
else if (format ==
"db") {
307 #ifdef STATS_HAS_SQLITE3
308 NS_LOG_INFO (
"Creating sqlite formatted data output.");
309 output = CreateObject<SqliteDataOutput>();
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Smart pointer class similar to boost::intrusive_ptr.
Ptr< YansWifiChannel > Create(void) const
virtual void Output(DataCollector &dc)=0
Outputs information from the provided DataCollector.
static Ptr< Node > GetNode(uint32_t n)
Make it easy to create and manage PHY objects for the yans model.
static YansWifiChannelHelper Default(void)
Create a channel helper in a default working state.
void Set(std::string path, const AttributeValue &value)
void SetKey(const std::string key)
Sets the DataCalculator key to the provided key.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
static void Run(void)
Run the simulation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
static YansWifiPhyHelper Default(void)
Create a phy helper in a default working state.
helps to create WifiNetDevice objects
void TxCallback(Ptr< CounterCalculator< uint32_t > > datac, std::string path, Ptr< const Packet > packet)
void PacketUpdate(std::string path, Ptr< const Packet > packet)
Increments the packet stats by the size of the packet.
void SetChannel(Ptr< YansWifiChannel > channel)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void AddDataCalculator(Ptr< DataCalculator > datac)
Add a DataCalculator object to the DataCollector.
holds a vector of ns3::NetDevice pointers
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void AddMetadata(std::string key, std::string value)
Add the key and the value as a pair of strings to the metadata list.
Parse command-line arguments.
void Connect(std::string path, const CallbackBase &cb)
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
void PacketUpdate(std::string path, Ptr< const Packet > packet)
Increments the packet counter by one.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void SetDelayTracker(Ptr< TimeMinMaxAvgTotalCalculator > delay)
manage and create wifi channel objects for the yans model.
AttributeValue implementation for Ipv4Address.
create MAC layers for a ns3::WifiNetDevice.
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
Helper class used to assign positions and mobility models to nodes.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
void SetContext(const std::string context)
Sets the DataCalculator context to the provided context.
Time Seconds(double value)
Construct a Time in the indicated unit.
void Add(Vector v)
Add a position to the list of positions.
void DescribeRun(std::string experiment, std::string strategy, std::string input, std::string runID, std::string description="")
Provide specific parameters to the DataCollector.
void Parse(int argc, char *argv[])
Parse the program arguments.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
void SetStartTime(Time start)
Specify application start time.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
void experiment(bool enableCtsRts, std::string wifiManager)
Run single 10 seconds experiment.
void SetCounter(Ptr< CounterCalculator<> > calc)