20 #include "ns3/command-line.h"
21 #include "ns3/double.h"
22 #include "ns3/nstime.h"
23 #include "ns3/random-variable-stream.h"
24 #include "ns3/simulator.h"
53 void HandleEvent(
double eventValue);
63 MyModel::HandleEvent(
double value)
66 <<
"s started at " << value <<
"s" << std::endl;
96 std::cout <<
"I should never be called... " << std::endl;
102 main(
int argc,
char* argv[])
105 cmd.Parse(argc, argv);
Simple model object to illustrate event handling.
void Start()
Start model execution by scheduling a HandleEvent.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
An identifier for simulation events.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
void CancelledEvent()
Simple function event handler; the corresponding event is cancelled.
void ExampleFunction(MyModel *model)
Simple function event handler which Starts a MyModel object.
void RandomFunction()
Simple function event handler; this function is called randomly.
Every class exported by the ns3 library is enclosed in the ns3 namespace.