37 #include "ns3/core-module.h"
38 #include "ns3/gnuplot-helper.h"
39 #include "ns3/time-probe.h"
79 .SetGroupName(
"Stats")
81 .AddTraceSource(
"Interval",
84 "ns3::TracedValueCallback::Time");
92 m_var = CreateObject<ExponentialRandomVariable>();
107 TimeProbe::SetValueByPath(
"/Names/probe3",
m_interval);
116 GlobalValue::GetValueByName(
"verbose",
verbose);
119 std::cout <<
"context: " << context <<
" old " << oldVal.
As(Time::S) <<
" new "
120 << newVal.
As(Time::S) << std::endl;
129 GlobalValue::GetValueByName(
"verbose",
verbose);
132 std::cout <<
"context: " << context <<
" old " << oldVal <<
" new " << newVal << std::endl;
137 "Whether to enable verbose output",
142 main(
int argc,
char* argv[])
148 cmd.AddValue(
"stopTime",
"Time (seconds) to terminate simulation",
stopTime);
149 cmd.AddValue(
"verbose",
"Whether to enable verbose output",
verbose);
150 cmd.Parse(argc, argv);
161 Names::Add(
"/Names/Emitter", emitter);
183 probe1->SetName(
"probe1");
186 connected = probe1->ConnectByObject(
"Interval", emitter);
187 NS_ASSERT_MSG(connected,
"Trace source not connected to probe1");
193 NS_ASSERT_MSG(connected,
"Trace source not connected to probe1 Output");
202 probe2->SetName(
"probe2");
205 probe2->ConnectByPath(
"/Names/Emitter/Interval");
211 NS_ASSERT_MSG(connected,
"Trace source not connected to probe2 Output");
218 probe3->SetName(
"probe3");
221 Names::Add(
"/Names/probe3", probe3);
227 NS_ASSERT_MSG(connected,
"Trace source not connected to probe3 Output");
232 "Emitter interarrivals vs. Time",
233 "Simulation time (Seconds)",
234 "Interarrival time (Seconds)",
241 "/Names/Emitter/Interval",
243 "Emitter Interarrival Time",
244 GnuplotAggregator::KEY_INSIDE);
252 Simulator::Destroy();
This is our test object, an object that increments counters at various times and emits one of them as...
void DoInitialize() override
Initialize() implementation.
static TypeId GetTypeId()
Register this type.
void Emit()
Generate data.
static TypeId GetTypeId()
Register this type.
Time m_last
Current interarrival time.
TracedValue< Time > m_interval
Interarrival time between events.
Ptr< ExponentialRandomVariable > m_var
Random number generator.
Parse command-line arguments.
double GetValue(double mean, double bound)
Get the next random value drawn from the distribution.
Hold a so-called 'global value'.
Helper class used to make gnuplot plots.
void ConfigurePlot(const std::string &outputFileNameWithoutExtension, const std::string &title, const std::string &xLegend, const std::string &yLegend, const std::string &terminalType="png")
void PlotProbe(const std::string &typeId, const std::string &path, const std::string &probeTraceSource, const std::string &title, GnuplotAggregator::KeyLocation keyLocation=GnuplotAggregator::KEY_INSIDE)
A base class which provides memory management and object aggregation.
void Initialize()
Invoke DoInitialize on all Objects aggregated to this one.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#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.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
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.
static ns3::GlobalValue g_verbose("verbose", "Whether to enable verbose output", ns3::BooleanValue(false), ns3::MakeBooleanChecker())
void NotifyViaProbe(std::string context, double oldVal, double newVal)
void NotifyViaTraceSource(std::string context, Time oldVal, Time newVal)