40 #include "ns3/core-module.h"
41 #include "ns3/time-probe.h"
42 #include "ns3/gnuplot-helper.h"
56 static TypeId GetTypeId (
void);
59 void DoInitialize (
void);
76 .AddTraceSource (
"Interval",
79 "ns3::Time::TracedValueCallback")
88 m_var = CreateObject<ExponentialRandomVariable> ();
103 TimeProbe::SetValueByPath (
"/Names/probe3",
m_interval);
112 GlobalValue::GetValueByName (
"verbose", verbose);
115 std::cout <<
"context: " << context <<
" old " << oldVal.
GetSeconds () <<
" new " << newVal.
GetSeconds () << std::endl;
124 GlobalValue::GetValueByName (
"verbose", verbose);
127 std::cout <<
"context: " << context <<
" old " << oldVal <<
" new " << newVal << std::endl;
132 "Whether to enable verbose output",
136 int main (
int argc,
char *argv[])
142 cmd.
AddValue (
"stopTime",
"Time (seconds) to terminate simulation", stopTime);
143 cmd.
AddValue (
"verbose",
"Whether to enable verbose output", verbose);
144 cmd.
Parse (argc, argv);
155 Names::Add (
"/Names/Emitter", emitter);
180 NS_ASSERT_MSG (connected,
"Trace source not connected to probe1");
186 NS_ASSERT_MSG (connected,
"Trace source not connected to probe1 Output");
204 NS_ASSERT_MSG (connected,
"Trace source not connected to probe2 Output");
214 Names::Add (
"/Names/probe3", probe3);
220 NS_ASSERT_MSG (connected,
"Trace source not connected to probe3 Output");
225 "Emitter interarrivals vs. Time",
226 "Simulation time (Seconds)",
227 "Interarrival time (Seconds)",
234 "/Names/Emitter/Interval",
236 "Emitter Interarrival Time",
237 GnuplotAggregator::KEY_INSIDE);
243 Simulator::Stop (
Seconds (stopTime));
245 Simulator::Destroy ();
virtual bool ConnectByObject(std::string traceSource, Ptr< Object > obj)
connect to a trace source attribute provided by a given object
Simulation virtual time values and global simulation resolution.
TypeId AddConstructor(void)
AttributeValue implementation for Boolean.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
std::string GetName(void) const
Get the object's name.
void PlotProbe(const std::string &typeId, const std::string &path, const std::string &probeTraceSource, const std::string &title, enum GnuplotAggregator::KeyLocation keyLocation=GnuplotAggregator::KEY_INSIDE)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
hold a so-called 'global value'.
static TypeId GetTypeId(void)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
TracedValue< Time > m_interval
void ConfigurePlot(const std::string &outputFileNameWithoutExtension, const std::string &title, const std::string &xLegend, const std::string &yLegend, const std::string &terminalType="png")
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
virtual void ConnectByPath(std::string path)
connect to a trace source provided by a config path
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Ptr< ExponentialRandomVariable > m_var
void NotifyViaProbe(std::string context, double oldVal, double newVal)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Parse command-line arguments.
void DoInitialize(void)
Initialize() implementation.
Helper class used to make gnuplot plots.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
static ns3::GlobalValue g_verbose("verbose","Whether to enable verbose output", ns3::BooleanValue(false), ns3::MakeBooleanChecker())
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
void SetName(std::string name)
Set the object's name. All spaces are replaced by underscores.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
double GetValue(double mean, double bound)
Returns a random double from an exponential distribution with the specified mean and upper bound...
bool TraceConnect(std::string name, std::string context, const CallbackBase &cb)
Connect a TraceSource to a Callback with a context.
void Parse(int argc, char *argv[])
Parse the program arguments.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
A base class which provides memory management and object aggregation.
void NotifyViaTraceSource(std::string context, Time oldVal, Time newVal)
a unique identifier for an interface.