|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
46 #include "ns3/core-module.h"
47 #include "ns3/network-module.h"
48 #include "ns3/mobility-module.h"
49 #include "ns3/stats-module.h"
50 #include "ns3/applications-module.h"
71 m_gnudatfile (
"uan-cw-example.gpl"),
72 m_asciitracefile (
"uan-cw-example.asc"),
73 m_bhCfgFile (
"uan-apps/dat/default.cfg")
90 double avgThroughput = 0.0;
91 for (uint32_t i=0; i<
m_avgs; i++)
101 SeedManager::SetRun (SeedManager::GetRun () + 1);
103 NS_LOG_DEBUG (
"Average for cw=" << cw <<
" over " <<
m_avgs <<
" runs: " << avgThroughput);
112 for (; it !=
nodes.End (); it++)
124 while ((packet = socket->
Recv ()))
144 #ifdef UAN_PROP_BH_INSTALLED
148 #endif //UAN_PROP_BH_INSTALLED
176 <<
" min. range " << minr);
178 mobility.SetPositionAllocator (pos);
179 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
205 for (uint32_t an = 0; an <
m_avgs; an++)
216 TypeId psfid = TypeId::LookupByName (
"ns3::PacketSocketFactory");
222 Ptr<Socket> sinkSocket = Socket::CreateSocket (sinkNode, psfid);
223 sinkSocket->
Bind (socket);
229 if (!ascii.is_open ())
242 for (uint32_t i=0; i < nc.
GetN (); i++)
246 for (uint32_t i=0; i <
sink.GetN (); i++)
251 for (uint32_t i=0; i <
devices.GetN (); i++)
255 for (uint32_t i=0; i < sinkdev.
GetN (); i++)
260 Simulator::Destroy ();
266 main (
int argc,
char **argv)
272 std::string gnudatfile (
"cwexpgnuout.dat");
273 std::string perModel =
"ns3::UanPhyPerGenDefault";
274 std::string sinrModel =
"ns3::UanPhyCalcSinrDefault";
277 cmd.AddValue (
"NumNodes",
"Number of transmitting nodes", exp.
m_numNodes);
278 cmd.AddValue (
"Depth",
"Depth of transmitting and sink nodes", exp.
m_depth);
279 cmd.AddValue (
"RegionSize",
"Size of boundary in meters", exp.
m_boundary);
280 cmd.AddValue (
"PacketSize",
"Generated packet size in bytes", exp.
m_packetSize);
281 cmd.AddValue (
"DataRate",
"DataRate in bps", exp.
m_dataRate);
282 cmd.AddValue (
"CwMin",
"Min CW to simulate", exp.
m_cwMin);
283 cmd.AddValue (
"CwMax",
"Max CW to simulate", exp.
m_cwMax);
284 cmd.AddValue (
"SlotTime",
"Slot time duration", exp.
m_slotTime);
285 cmd.AddValue (
"Averages",
"Number of topologies to test for each cw point", exp.
m_avgs);
286 cmd.AddValue (
"GnuFile",
"Name for GNU Plot output", exp.
m_gnudatfile);
287 cmd.AddValue (
"PerModel",
"PER model name", perModel);
288 cmd.AddValue (
"SinrModel",
"SINR model name", sinrModel);
289 cmd.AddValue (
"Quiet",
"Run in quiet mode (disable logging)", quiet);
290 cmd.Parse (argc, argv);
305 mode = UanTxModeFactory::CreateMode (UanTxMode::FSK, exp.
m_dataRate,
312 uan.SetPhy (
"ns3::UanPhyGen",
holds a vector of ns3::NetDevice pointers
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
AttributeValue implementation for DataRate.
Parse command-line arguments.
void Add(Vector v)
Add a position to the list of positions.
void Set(std::string path, const AttributeValue &value)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void UpdatePositions(NodeContainer &nodes)
Assign new random positions to a set of nodes.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
uint32_t m_bytesTotal
Total bytes received.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
virtual Address GetAddress(void) const =0
void ReceivePacket(Ptr< Socket > socket)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
void SetMac(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())
Set MAC attributes.
UAN configuration helper.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
@ LOG_LEVEL_ALL
Print everything.
void SetPosition(const Vector &position)
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
std::string m_gnudatfile
Name for GNU Plot output, default uan-cw-example.gpl.
Hold objects of type Ptr<T>.
an address for a packet socket
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
uint32_t m_avgs
Number of topologies to test for each cw point.
void AppendMode(UanTxMode mode)
Add mode to this list.
Container for UanTxModes.
void Add(double x, double y)
double m_depth
Depth of transmitting and sink nodes.
AttributeValue implementation for UanModesList.
Class to represent a 2D points plot.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Time m_slotTime
Slot time duration.
static void EnableAsciiAll(std::ostream &os)
Enable ascii output on each device which is of the ns3::UanNetDevice type and dump that to the specif...
void IncrementCw(uint32_t cw)
Compute average throughput for a set of runs, then increment CW.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Calculate packet error probability, based on received SINR and modulation (mode).
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
uint32_t m_cwMin
Min CW to simulate.
std::string m_asciitracefile
Name for ascii trace file, default uan-cw-example.asc.
Gnuplot2dDataset m_data
Container for the simulation data.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
a polymophic address class
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Instantiate subclasses of ns3::Object.
Helper class for UAN CW MAC example.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Object to create transport layer instances that provide a socket API to applications.
Gnuplot2dDataset Run(const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel)
Simulation virtual time values and global simulation resolution.
Abstraction of packet modulation information.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
void AddDataset(const GnuplotDataset &dataset)
Give ns3::PacketSocket powers to ns3::Node.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Hold variables of type string.
std::vector< double > m_throughputs
Throughput for each run.
double m_boundary
Size of boundary in meters.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Time m_simTime
Simulation run time, default 1000 s.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
Time Seconds(double value)
Construct a Time in the indicated unit.
holds a vector of ns3::Application pointers.
uint32_t m_cwStep
CW step size, default 10.
void SetPhysicalAddress(const Address address)
Set the destination address.
AttributeValue implementation for Time.
Class used for calculating SINR of packet in UanPhy.
Keep track of the current position and velocity of an object.
keep track of a set of node pointers.
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Hold an unsigned integer type.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
uint32_t m_cwMax
Max CW to simulate.
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
uint32_t m_packetSize
Generated packet size in bytes.
NetDeviceContainer Install(NodeContainer c) const
This method creates a simple ns3::UanChannel (with a default ns3::UanNoiseModelDefault and ns3::UanPr...
uint32_t m_numNodes
Number of transmitting nodes.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Vector GetPosition(void) const
virtual uint32_t GetIfIndex(void) const =0
void ResetData()
Save the throughput from a single run.
uint32_t m_dataRate
DataRate in bps.
Helper class used to assign positions and mobility models to nodes.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.