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"
69 int main (
int argc,
char *argv[]) {
71 double distance = 50.0;
72 string format (
"omnet");
75 string strategy (
"wifi-default");
81 sstr <<
"run-" << time (NULL);
87 cmd.
AddValue (
"distance",
"Distance apart to place nodes (in meters).",
89 cmd.
AddValue (
"format",
"Format to use for data output.",
91 cmd.
AddValue (
"experiment",
"Identifier for experiment.",
93 cmd.
AddValue (
"strategy",
"Identifier for strategy.",
95 cmd.
AddValue (
"run",
"Identifier for run.",
97 cmd.
Parse (argc, argv);
99 if (format !=
"omnet" && format !=
"db") {
100 NS_LOG_ERROR (
"Unknown output format '" << format <<
"'");
104 #ifndef STATS_HAS_SQLITE3
105 if (format ==
"db") {
112 stringstream sstr (
"");
127 NS_LOG_INFO (
"Installing WiFi and Internet stack.");
130 wifiMac.
SetType (
"ns3::AdhocWifiMac");
139 ipAddrs.
SetBase (
"192.168.0.0",
"255.255.255.0");
140 ipAddrs.
Assign (nodeDevices);
148 NS_LOG_INFO (
"Installing static mobility; distance " << distance <<
" .");
151 CreateObject<ListPositionAllocator>();
152 positionAlloc->
Add (
Vector (0.0, 0.0, 0.0));
153 positionAlloc->
Add (
Vector (0.0, distance, 0.0));
174 Config::Set (
"/NodeList/*/ApplicationList/*/$Sender/Destination",
200 CreateObject<CounterCalculator<uint32_t> >();
201 totalTx->SetKey (
"wifi-tx-frames");
202 totalTx->SetContext (
"node[0]");
203 Config::Connect (
"/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx",
212 CreateObject<PacketCounterCalculator>();
213 totalRx->
SetKey (
"wifi-rx-frames");
215 Config::Connect (
"/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx",
227 CreateObject<PacketCounterCalculator>();
228 appTx->
SetKey (
"sender-tx-packets");
240 CreateObject<CounterCalculator<> >();
241 appRx->SetKey (
"receiver-rx-packets");
242 appRx->SetContext (
"node[1]");
267 CreateObject<PacketSizeMinMaxAvgTotalCalculator>();
268 appTxPkts->
SetKey (
"tx-pkt-size");
282 CreateObject<TimeMinMaxAvgTotalCalculator>();
283 delayStat->
SetKey (
"delay");
306 if (format ==
"omnet") {
307 NS_LOG_INFO (
"Creating omnet formatted data output.");
308 output = CreateObject<OmnetDataOutput>();
309 }
else if (format ==
"db") {
310 #ifdef STATS_HAS_SQLITE3
311 NS_LOG_INFO (
"Creating sqlite formatted data output.");
312 output = CreateObject<SqliteDataOutput>();
uint32_t AddApplication(Ptr< Application > application)
void experiment(bool enableCtsRts)
Run single 10 seconds experiment with enabled or disabled RTS/CTS mechanism.
smart pointer class similar to boost::intrusive_ptr
Ptr< YansWifiChannel > Create(void) const
virtual void Output(DataCollector &dc)=0
static Ptr< Node > GetNode(uint32_t n)
Make it easy to create and manage PHY objects for the yans model.
static YansWifiChannelHelper Default(void)
void SetKey(const std::string key)
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
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())
aggregate IP/TCP/UDP functionality to existing Nodes.
void Set(std::string path, const AttributeValue &value)
static YansWifiPhyHelper Default(void)
void Connect(std::string path, const CallbackBase &cb)
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)
NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
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)
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void AddMetadata(std::string key, std::string value)
static NqosWifiMacHelper Default(void)
create non QoS-enabled MAC layers for a ns3::WifiNetDevice.
Parse command-line arguments.
static void Destroy(void)
keep track of a set of node pointers.
void PacketUpdate(std::string path, Ptr< const Packet > packet)
void Install(std::string nodeName) const
void SetDelayTracker(Ptr< TimeMinMaxAvgTotalCalculator > delay)
manage and create wifi channel objects for the yans model.
hold objects of type ns3::Ipv4Address
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...
NS_LOG_COMPONENT_DEFINE("PacketLossCounter")
int main(int argc, char *argv[])
void AddValue(const std::string &name, const std::string &help, T &value)
void SetContext(const std::string context)
void DescribeRun(std::string experiment, std::string strategy, std::string input, std::string runID, std::string description="")
void Parse(int argc, char *argv[])
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
#define NS_LOG_ERROR(msg)
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
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.
static WifiHelper Default(void)
void SetCounter(Ptr< CounterCalculator<> > calc)