26#include "ns3/core-module.h"
27#include "ns3/gnuplot-helper.h"
28#include "ns3/time-probe.h"
68 .SetGroupName(
"Stats")
70 .AddTraceSource(
"Interval",
73 "ns3::TracedValueCallback::Time");
108 std::cout <<
"context: " << context <<
" old " << oldVal.
As(
Time::S) <<
" new "
121 std::cout <<
"context: " << context <<
" old " << oldVal <<
" new " << newVal << std::endl;
126 "Whether to enable verbose output",
131main(
int argc,
char* argv[])
137 cmd.AddValue(
"stopTime",
"Time (seconds) to terminate simulation",
stopTime);
138 cmd.AddValue(
"verbose",
"Whether to enable verbose output",
verbose);
139 cmd.Parse(argc, argv);
172 probe1->SetName(
"probe1");
175 connected = probe1->ConnectByObject(
"Interval", emitter);
176 NS_ASSERT_MSG(connected,
"Trace source not connected to probe1");
182 NS_ASSERT_MSG(connected,
"Trace source not connected to probe1 Output");
191 probe2->SetName(
"probe2");
194 probe2->ConnectByPath(
"/Names/Emitter/Interval");
200 NS_ASSERT_MSG(connected,
"Trace source not connected to probe2 Output");
207 probe3->SetName(
"probe3");
216 NS_ASSERT_MSG(connected,
"Trace source not connected to probe3 Output");
221 "Emitter interarrivals vs. Time",
222 "Simulation time (Seconds)",
223 "Interarrival time (Seconds)",
230 "/Names/Emitter/Interval",
232 "Emitter Interarrival Time",
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.
Hold a so-called 'global value'.
static void Bind(std::string name, const AttributeValue &value)
Iterate over the set of GlobalValues until a matching name is found and then set its value with Globa...
static void GetValueByName(std::string name, AttributeValue &value)
Finds the GlobalValue with the given name and returns its 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)
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
A base class which provides memory management and object aggregation.
void Initialize()
Invoke DoInitialize on all Objects aggregated to this one.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
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.
static void SetValueByPath(std::string path, Time value)
Set a probe value by its name in the Config system.
Trace classes with value semantics.
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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
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)