45 #include "ns3/applications-module.h"
46 #include "ns3/core-module.h"
47 #include "ns3/mobility-module.h"
48 #include "ns3/network-module.h"
49 #include "ns3/stats-module.h"
70 m_gnudatfile(
"uan-cw-example.gpl"),
71 m_asciitracefile(
"uan-cw-example.asc"),
72 m_bhCfgFile(
"uan-apps/dat/default.cfg")
89 double avgThroughput = 0.0;
90 for (uint32_t i = 0; i <
m_avgs; i++)
100 SeedManager::SetRun(SeedManager::GetRun() + 1);
102 NS_LOG_DEBUG(
"Average for cw=" << cw <<
" over " <<
m_avgs <<
" runs: " << avgThroughput);
123 while ((packet = socket->
Recv()))
143 #ifdef UAN_PROP_BH_INSTALLED
145 CreateObjectWithAttributes<UanPropModelBh>(
"ConfigFile",
StringValue(
"exbhconfig.cfg"));
150 CreateObjectWithAttributes<UanChannel>(
"PropagationModel",
PointerValue(prop));
178 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
191 app.SetAttribute(
"OnTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=1]"));
192 app.SetAttribute(
"OffTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=0]"));
202 for (uint32_t an = 0; an <
m_avgs; an++)
213 TypeId psfid = TypeId::LookupByName(
"ns3::PacketSocketFactory");
219 Ptr<Socket> sinkSocket = Socket::CreateSocket(sinkNode, psfid);
220 sinkSocket->
Bind(socket);
226 if (!ascii.is_open())
230 UanHelper::EnableAsciiAll(ascii);
234 sinkSocket =
nullptr;
238 for (uint32_t i = 0; i < nc.
GetN(); i++)
242 for (uint32_t i = 0; i <
sink.GetN(); i++)
244 sink.Get(i) =
nullptr;
247 for (uint32_t i = 0; i <
devices.GetN(); i++)
251 for (uint32_t i = 0; i < sinkdev.
GetN(); i++)
253 sinkdev.
Get(i) =
nullptr;
256 Simulator::Destroy();
262 main(
int argc,
char** argv)
267 std::string gnudatfile(
"cwexpgnuout.dat");
268 std::string perModel =
"ns3::UanPhyPerGenDefault";
269 std::string sinrModel =
"ns3::UanPhyCalcSinrDefault";
272 cmd.AddValue(
"NumNodes",
"Number of transmitting nodes", exp.
m_numNodes);
273 cmd.AddValue(
"Depth",
"Depth of transmitting and sink nodes", exp.
m_depth);
274 cmd.AddValue(
"RegionSize",
"Size of boundary in meters", exp.
m_boundary);
275 cmd.AddValue(
"PacketSize",
"Generated packet size in bytes", exp.
m_packetSize);
277 cmd.AddValue(
"CwMin",
"Min CW to simulate", exp.
m_cwMin);
278 cmd.AddValue(
"CwMax",
"Max CW to simulate", exp.
m_cwMax);
279 cmd.AddValue(
"SlotTime",
"Slot time duration", exp.
m_slotTime);
280 cmd.AddValue(
"Averages",
"Number of topologies to test for each cw point", exp.
m_avgs);
282 cmd.AddValue(
"PerModel",
"PER model name", perModel);
283 cmd.AddValue(
"SinrModel",
"SINR model name", sinrModel);
284 cmd.AddValue(
"Quiet",
"Run in quiet mode (disable logging)", quiet);
285 cmd.Parse(argc, argv);
300 mode = UanTxModeFactory::CreateMode(UanTxMode::FSK,
310 uan.SetPhy(
"ns3::UanPhyGen",
316 UanModesListValue(myModes));
WiFi adhoc experiment class.
uint32_t m_packetSize
Packet size.
double m_depth
Depth of transmitting and sink nodes.
Gnuplot2dDataset Run(const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel)
Run an experiment.
std::string m_asciitracefile
Name for ascii trace file, default uan-cw-example.asc.
uint32_t m_cwMin
Min CW to simulate.
uint32_t m_bytesTotal
The number of received bytes.
Time m_simTime
Simulation run time, default 1000 s.
uint32_t m_cwMax
Max CW to simulate.
uint32_t m_avgs
Number of topologies to test for each cw point.
void ResetData()
Save the throughput from a single run.
uint32_t m_dataRate
DataRate in bps.
Gnuplot2dDataset m_data
Container for the simulation data.
void ReceivePacket(Ptr< Socket > socket)
Receive a packet.
Time m_slotTime
Slot time duration.
std::string m_gnudatfile
Name for GNU Plot output, default uan-cw-example.gpl.
std::vector< double > m_throughputs
Throughput for each run.
void IncrementCw(uint32_t cw)
Compute average throughput for a set of runs, then increment CW.
uint32_t m_numNodes
Number of transmitting nodes.
double m_boundary
Size of boundary in meters.
void UpdatePositions(NodeContainer &nodes) const
Assign new random positions to a set of nodes.
uint32_t m_cwStep
CW step size, default 10.
a polymophic address class
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
Parse command-line arguments.
Class to represent a 2D points plot.
void Add(double x, double y)
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
void AddDataset(const GnuplotDataset &dataset)
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
Vector GetPosition() const
void SetPosition(const Vector &position)
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
an address for a packet socket
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetPhysicalAddress(const Address address)
Set the destination address.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Give ns3::PacketSocket powers to ns3::Node.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Hold objects of type Ptr<T>.
Object to create transport layer instances that provide a socket API to applications.
void SetRecvCallback(Callback< void, Ptr< Socket >> receivedData)
Notify application when new data is available to be read.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
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.
a unique identifier for an interface.
UAN configuration helper.
void SetMac(std::string type, Ts &&... args)
Set MAC attributes.
NetDeviceContainer Install(NodeContainer c) const
This method creates a simple ns3::UanChannel (with a default ns3::UanNoiseModelDefault and ns3::UanPr...
Container for UanTxModes.
void AppendMode(UanTxMode mode)
Add mode to this list.
Class used for calculating SINR of packet in UanPhy.
Calculate packet error probability, based on received SINR and modulation (mode).
Abstraction of packet modulation information.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void Set(std::string path, const AttributeValue &value)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
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...
@ LOG_LEVEL_ALL
Print everything.
Ptr< PacketSink > sink
Pointer to the packet sink application.