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"
70 m_slotTime (Seconds (0.2)),
71 m_simTime (Seconds (1000)),
72 m_gnudatfile (
"uan-cw-example.gpl"),
73 m_asciitracefile (
"uan-cw-example.asc"),
74 m_bhCfgFile (
"uan-apps/dat/default.cfg")
91 double avgThroughput = 0.0;
92 for (uint32_t i=0; i<
m_avgs; i++)
102 SeedManager::SetRun (SeedManager::GetRun () + 1);
104 NS_LOG_DEBUG (
"Average for cw=" << cw <<
" over " << m_avgs <<
" runs: " << avgThroughput);
113 for (; it != nodes.
End (); it++)
125 while ((packet = socket->
Recv ()))
145 #ifdef UAN_PROP_BH_INSTALLED
149 #endif //UAN_PROP_BH_INSTALLED
172 minr = std::min (minr, newr);
176 NS_LOG_DEBUG (
"Mean range from gateway: " << rsum / m_numNodes
177 <<
" min. range " << minr);
199 apps.
Start (Seconds (0.5));
200 Time nextEvent = Seconds (0.5);
206 for (uint32_t an = 0; an <
m_avgs; an++)
217 TypeId psfid = TypeId::LookupByName (
"ns3::PacketSocketFactory");
223 Ptr<Socket> sinkSocket = Socket::CreateSocket (sinkNode, psfid);
224 sinkSocket->
Bind (socket);
230 if (!ascii.is_open ())
243 for (uint32_t i=0; i < nc.
GetN (); i++)
247 for (uint32_t i=0; i < sink.
GetN (); i++)
252 for (uint32_t i=0; i < devices.GetN (); i++)
256 for (uint32_t i=0; i < sinkdev.
GetN (); i++)
261 Simulator::Destroy ();
274 std::string gnudatfile (
"cwexpgnuout.dat");
275 std::string perModel =
"ns3::UanPhyPerGenDefault";
276 std::string sinrModel =
"ns3::UanPhyCalcSinrDefault";
280 cmd.
AddValue (
"Depth",
"Depth of transmitting and sink nodes", exp.
m_depth);
287 cmd.
AddValue (
"Averages",
"Number of topologies to test for each cw point", exp.
m_avgs);
289 cmd.
AddValue (
"PerModel",
"PER model name", perModel);
290 cmd.
AddValue (
"SinrModel",
"SINR model name", sinrModel);
291 cmd.
Parse (argc, argv);
301 mode = UanTxModeFactory::CreateMode (UanTxMode::FSK, exp.
m_dataRate,
308 uan.SetPhy (
"ns3::UanPhyGen",
UAN configuration helper.
Helper class for UAN CW MAC example.
holds a vector of ns3::Application pointers.
int main(int argc, char **argv)
keep track of time values and allow control of global simulation resolution
uint32_t m_bytesTotal
Total bytes received.
Vector GetPosition(Ptr< Node > node)
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
Class to represent a 2D points plot.
std::vector< Ptr< Node > >::const_iterator Iterator
hold variables of type string
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Time m_slotTime
Slot time duration.
an address for a packet socket
#define NS_ASSERT(condition)
void SetTypeId(TypeId tid)
uint32_t GetSize(void) const
void IncrementCw(uint32_t cw)
Compute average throughput for a set of runs, then increment CW.
void AddDataset(const GnuplotDataset &dataset)
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
Container for UanTxModes.
uint32_t m_avgs
Number of topologies to test for each cw point.
void Set(std::string path, const AttributeValue &value)
void ReceivePacket(Ptr< Socket > socket)
Object to create transport layer instances that provide a socket API to applications.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Give ns3::PacketSocket powers to ns3::Node.
void SetSingleDevice(uint32_t device)
std::string m_gnudatfile
Name for GNU Plot output, default uan-cw-example.gpl.
#define NS_FATAL_ERROR(msg)
fatal error handling
a polymophic address class
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
Keep track of the current position and velocity of an object.
double GetSeconds(void) const
double m_depth
Depth of transmitting and sink nodes.
uint32_t m_cwMin
Min CW to simulate.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
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.
hold objects of type ns3::Time
Ptr< Object > Create(void) const
Hold an unsigned integer type.
Gnuplot2dDataset Run(const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility)
Abstraction of packet modulation information.
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
Calculate packet error probability, based on received SINR and modulation (mode). ...
Gnuplot2dDataset m_data
Container for the simulation data.
void Add(double x, double y)
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
std::vector< double > m_throughputs
Throughput for each run.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
void AggregateObject(Ptr< Object > other)
Parse command-line arguments.
Time m_simTime
Simulation run time, default 1000 s.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
void SetPhysicalAddress(const Address address)
std::string m_asciitracefile
Name for ascii trace file, default uan-cw-example.asc.
keep track of a set of node pointers.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void SetMobilityModel(std::string type, 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(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
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 SetPosition(const Vector &position)
Class used for calculating SINR of packet in UanPhy.
uint32_t m_cwMax
Max CW to simulate.
double m_boundary
Size of boundary in meters.
Helper class used to assign positions and mobility models to nodes.
instantiate subclasses of ns3::Object.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
uint32_t m_packetSize
Generated packet size in bytes.
hold objects of type ns3::DataRate
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
#define NS_LOG_DEBUG(msg)
void AppendMode(UanTxMode mode)
Add mode to this list.
uint32_t m_cwStep
CW step size, default 10.
void SetProtocol(uint16_t protocol)
void Parse(int argc, char *argv[])
Parse the program arguments.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
NetDeviceContainer Install(NodeContainer c) const
This method creates a simple ns3::UanChannel (with a default ns3::UanNoiseModelDefault and ns3::UanPr...
uint32_t m_dataRate
DataRate in bps.
void UpdatePositions(NodeContainer &nodes)
Assign new random positions to a set of nodes.
Ptr< T > GetObject(void) const
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
a unique identifier for an interface.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
uint32_t m_numNodes
Number of transmitting nodes.
void LogComponentEnable(char const *name, enum LogLevel level)
Attribute Value class for UanTxModes.
void ResetData()
Save the throughput from a single run.