40 #include "ns3/core-module.h"
41 #include "ns3/time-probe.h"
42 #include "ns3/gnuplot-helper.h"
79 .SetGroupName (
"Stats")
81 .AddTraceSource (
"Interval",
84 "ns3::TracedValueCallback::Time")
93 m_var = CreateObject<ExponentialRandomVariable> ();
108 TimeProbe::SetValueByPath (
"/Names/probe3",
m_interval);
117 GlobalValue::GetValueByName (
"verbose",
verbose);
120 std::cout <<
"context: " << context <<
" old " << oldVal.
As (Time::S) <<
" new " << 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",
141 int main (
int argc,
char *argv[])
147 cmd.AddValue (
"stopTime",
"Time (seconds) to terminate simulation",
stopTime);
148 cmd.AddValue (
"verbose",
"Whether to enable verbose output",
verbose);
149 cmd.Parse (argc, argv);
160 Names::Add (
"/Names/Emitter", emitter);
181 probe1->SetName (
"probe1");
184 connected = probe1->ConnectByObject (
"Interval", emitter);
185 NS_ASSERT_MSG (connected,
"Trace source not connected to probe1");
191 NS_ASSERT_MSG (connected,
"Trace source not connected to probe1 Output");
200 probe2->SetName (
"probe2");
203 probe2->ConnectByPath (
"/Names/Emitter/Interval");
209 NS_ASSERT_MSG (connected,
"Trace source not connected to probe2 Output");
216 probe3->SetName (
"probe3");
219 Names::Add (
"/Names/probe3", probe3);
225 NS_ASSERT_MSG (connected,
"Trace source not connected to probe3 Output");
230 "Emitter interarrivals vs. Time",
231 "Simulation time (Seconds)",
232 "Interarrival time (Seconds)",
239 "/Names/Emitter/Interval",
241 "Emitter Interarrival Time",
242 GnuplotAggregator::KEY_INSIDE);
250 Simulator::Destroy ();
This is our test object, an object that increments counters at various times and emits one of them as...
static TypeId GetTypeId(void)
Register this type.
Time m_last
Current interarrival time.
void Emit(void)
Generate data.
TracedValue< Time > m_interval
Interarrival time between events.
void DoInitialize(void)
Initialize() implementation.
Ptr< ExponentialRandomVariable > m_var
Random number generator.
static TypeId GetTypeId(void)
Register this type.
AttributeValue implementation for Boolean.
Parse command-line arguments.
double GetValue(double mean, double bound)
Get the next random value, as a double from the exponential distribution with the specified mean and ...
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, enum GnuplotAggregator::KeyLocation keyLocation=GnuplotAggregator::KEY_INSIDE)
A base class which provides memory management and object aggregation.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const enum 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...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
#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(void)
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.
@ LOG_LEVEL_ALL
Print everything.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
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...
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)