36#include "ns3/basic-energy-source-helper.h"
37#include "ns3/command-line.h"
38#include "ns3/config.h"
39#include "ns3/internet-stack-helper.h"
40#include "ns3/ipv4-address-helper.h"
42#include "ns3/mobility-helper.h"
43#include "ns3/mobility-model.h"
44#include "ns3/on-off-helper.h"
45#include "ns3/packet-sink-helper.h"
46#include "ns3/string.h"
47#include "ns3/wifi-net-device.h"
48#include "ns3/wifi-radio-energy-model-helper.h"
49#include "ns3/wifi-utils.h"
50#include "ns3/yans-wifi-channel.h"
51#include "ns3/yans-wifi-helper.h"
70 ss <<
"energy_" << node <<
".log";
72 static std::fstream f(
ss.str(), std::ios::out);
91 ss <<
"state_" << node <<
".log";
93 static std::fstream f(
ss.str(), std::ios::out);
96 <<
" duration=" << duration << std::endl;
104 Time duration{
"10s"};
117 cmd.AddValue(
"packetSize",
"size of application packet sent",
packetSize);
118 cmd.AddValue(
"duration",
"duration of the experiment", duration);
119 cmd.AddValue(
"initialEnergy",
"Initial Energy (Joule) of each node",
initialEnergy);
120 cmd.AddValue(
"voltage",
"Supply voltage (Joule)",
voltage);
121 cmd.AddValue(
"txPowerStart",
"Minimum available transmission level (dbm)",
txPowerStart);
122 cmd.AddValue(
"txPowerEnd",
"Maximum available transmission level (dbm)",
txPowerEnd);
123 cmd.AddValue(
"nTxPowerLevels",
124 "Number of transmission power levels available between txPowerStart and "
125 "txPowerEnd included",
127 cmd.AddValue(
"txPowerLevel",
"Transmission power level", txPowerLevel);
128 cmd.AddValue(
"idleCurrent",
"The radio Idle current in Ampere",
idleCurrent);
129 cmd.AddValue(
"txCurrent",
"The radio Tx current in Ampere",
txCurrent);
130 cmd.AddValue(
"verbose",
"turn on all WifiNetDevice log components",
verbose);
154 wifi.SetRemoteStationManager(
"ns3::ArfWifiManager",
155 "DefaultTxPowerLevel",
158 wifiMac.SetType(
"ns3::AdhocWifiMac");
166 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
174 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
179 std::string
transportProto = std::string(
"ns3::UdpSocketFactory");
184 onOff.SetAttribute(
"OffTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=0.001]"));
221 for (
auto n =
c.Begin(); n !=
c.End(); n++)
242 eSources.Get(1)->TraceConnectWithoutContext(
"RemainingEnergy",
holds a vector of ns3::Application pointers.
Creates a BasicEnergySource object.
Parse command-line arguments.
Class for representing data rates.
AttributeValue implementation for DataRate.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetAny()
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
static void EnableLogComponents(LogLevel logLevel=LOG_LEVEL_ALL)
Helper to enable all WifiNetDevice log components with one statement.
create MAC layers for a ns3::WifiNetDevice.
Hold together all Wifi-related objects.
void Set(std::string name, const AttributeValue &v)
Assign WifiRadioEnergyModel to wifi devices.
void Set(std::string name, const AttributeValue &v) override
manage and create wifi channel objects for the YANS model.
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
Make it easy to create and manage PHY objects for the YANS model.
Holds a vector of ns3::EnergySource pointers.
void Connect(std::string path, const CallbackBase &cb)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiPhyState
The state of the PHY layer.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Watt_u DbmToW(dBm_u val)
Convert from dBm to Watts.
static const uint32_t packetSize
Packet size generated at the AP.
void RemainingEnergyTrace(double oldValue, double newValue)
Remaining energy trace sink.
void PhyStateTrace(std::string context, Time start, Time duration, WifiPhyState state)
PHY state trace sink.
Ptr< PacketSink > sink
Pointer to the packet sink application.