43#include "ns3/applications-module.h"
44#include "ns3/callback.h"
45#include "ns3/config.h"
46#include "ns3/core-module.h"
48#include "ns3/mobility-module.h"
49#include "ns3/network-module.h"
50#include "ns3/stats-module.h"
51#include "ns3/uan-module.h"
168 while ((packet = socket->Recv()))
177 std::ostringstream buf;
178 buf << name <<
" " << kass;
235 uan.
SetPhy(
"ns3::UanPhyDual",
236 "SupportedModesPhy1",
238 "SupportedModesPhy2",
241 uan.
SetMac(
"ns3::UanMacRcGw",
260 uan.
SetMac(
"ns3::UanMacRc",
266 nodes.Create(nNodes);
277 for (
uint32_t i = 0; i < nNodes; i++)
279 double theta = utheta->GetValue(0, 2.0 * M_PI);
285 pos->Add(Vector(
x, y, depth));
288 mobility.SetPositionAllocator(pos);
289 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
290 mobility.Install(
sink);
291 mobility.Install(
nodes);
303 app.SetAttribute(
"OnTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=1]"));
304 app.SetAttribute(
"OffTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=0]"));
317 sinkSocket->Bind(socket);
330main(
int argc,
char* argv[])
336 cmd.AddValue(
"TotalRate",
"Total channel capacity", exp.m_totalRate);
337 cmd.AddValue(
"NumberRates",
338 "Number of divided rates ( (NumberRates+1)%TotalRate should be 0)",
340 cmd.AddValue(
"MaxRange",
"Maximum range between gateway and acoustic node", exp.m_maxRange);
341 cmd.AddValue(
"SimMin",
342 "Minimum parameter to test (nodes if DoNode=1, \"a\" param otherwise)",
344 cmd.AddValue(
"SimMax",
345 "Maximum parameter to test (nodes if DoNode=1, \"a\" param otherwise)",
347 cmd.AddValue(
"SimStep",
"Amount to increment param per trial", exp.m_simStep);
348 cmd.AddValue(
"DataFile",
"Filename for GnuPlot", exp.m_gnuplotfile);
349 cmd.AddValue(
"NumberNodes",
"Number of nodes (invalid for doNode=1)", exp.m_numNodes);
350 cmd.AddValue(
"SIFS",
"SIFS time duration", exp.m_sifs);
351 cmd.AddValue(
"PktSize",
"Packet size in bytes", exp.m_pktSize);
352 cmd.AddValue(
"SimTime",
"Simulation time per trial", exp.m_simTime);
353 cmd.AddValue(
"DoNode",
354 "1 for do max nodes simulation (invalidates AMin and AMax values)",
356 cmd.AddValue(
"Quiet",
"Run in quiet mode (disable logging)", quiet);
357 cmd.Parse(argc, argv);
364 exp.CreateDualModes(12000);
369 for (uint32_t param = exp.m_simMin; param <= exp.m_simMax; param += exp.m_simStep)
371 uint32_t bytesRx = exp.Run(param);
372 NS_LOG_DEBUG(
"param=" << param <<
": Received " << bytesRx <<
" bytes at sink");
374 double util = bytesRx * 8.0 / (exp.m_simTime.GetSeconds() * exp.m_totalRate);
383 std::ofstream of(exp.m_gnuplotfile);
386 NS_FATAL_ERROR(
"Can not open GNU Plot outfile: " << exp.m_gnuplotfile);
cairo_uint64_t x
_cairo_uint_96by64_32x64_divrem:
uint32_t m_simStep
Amount to increment param per trial.
uint32_t m_numRates
Number of divided rates ( (NumberRates+1)TotalRate should be 0).
Experiment()
Default constructor.
std::string m_gnuplotfile
Filename for GnuPlot.
uint32_t m_simMax
Maximum parameter to test.
uint32_t m_totalRate
Total channel capacity.
bool m_doNode
1 for do max nodes simulation (invalidates AMin and AMax values).
uint32_t m_pktSize
Packet size in bytes.
UanTxMode CreateMode(uint32_t kass, uint32_t fc, bool upperblock, std::string name) const
Create a UanTxMode.
uint32_t m_bytesTotal
Total number of bytes received in a simulation run.
uint32_t Run(uint32_t param)
Run a parametrized experiment.
void ReceivePacket(Ptr< Socket > socket)
Callback to receive a packet.
uint32_t m_simMin
Minimum parameter to test.
uint32_t m_numNodes
Number of nodes (invalid for m_doNode true).
UanModesList m_controlModes
List of UanTxModes used for control channels.
void CreateDualModes(uint32_t fc)
Create m_numRates matching control and data modes.
UanModesList m_dataModes
List of UanTxModes used for data channels.
Time m_simTime
Simulation time per trial.
Time m_sifs
SIFS time duration.
uint32_t m_maxRange
Maximum range between gateway and acoustic node.
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.
AttributeValue implementation for DataRate.
void Add(double x, double y)
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.
holds a vector of ns3::NetDevice pointers
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.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
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.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static uint64_t GetRun()
Get the current run number.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
UAN configuration helper.
void SetPhy(std::string phyType, Ts &&... args)
Set PHY attributes.
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.
AttributeValue implementation for UanModesList.
static UanTxMode CreateMode(UanTxMode::ModulationType type, uint32_t dataRateBps, uint32_t phyRateSps, uint32_t cfHz, uint32_t bwHz, uint32_t constSize, std::string name)
Abstraction of packet modulation information.
@ OTHER
Unspecified/undefined.
Hold an unsigned integer type.
void ReceivePacket(Ptr< Socket > socket)
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...
#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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
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.
@ LOG_LEVEL_ALL
Print everything.
Ptr< PacketSink > sink
Pointer to the packet sink application.