A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
simulator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
20#ifndef SIMULATOR_H
21#define SIMULATOR_H
22
23#include "event-id.h"
24#include "event-impl.h"
25#include "make-event.h"
26#include "nstime.h"
27#include "object-factory.h"
28
29#include <stdint.h>
30#include <string>
31
32/**
33 * @file
34 * @ingroup simulator
35 * ns3::Simulator declaration.
36 */
37
38namespace ns3
39{
40
41class SimulatorImpl;
42class Scheduler;
43
44/**
45 * @ingroup core
46 * @defgroup simulator Simulator
47 * @brief Control the virtual time and the execution of simulation events.
48 */
49/**
50 * @ingroup simulator
51 *
52 * @brief Control the scheduling of simulation events.
53 *
54 * The internal simulation clock is maintained
55 * as a 64-bit integer in a unit specified by the user
56 * through the Time::SetResolution function. This means that it is
57 * not possible to specify event expiration times with anything better
58 * than this user-specified accuracy. Events whose expiration time is
59 * the same modulo this accuracy are scheduled in FIFO order: the
60 * first event inserted in the scheduling queue is scheduled to
61 * expire first.
62 *
63 * A simple example of how to use the Simulator class to schedule events
64 * is shown in sample-simulator.cc:
65 * @include src/core/examples/sample-simulator.cc
66 */
68{
69 public:
70 // Delete default constructor and destructor to avoid misuse
71 Simulator() = delete;
72 ~Simulator() = delete;
73
74 /**
75 * @param [in] impl A new simulator implementation.
76 *
77 * The simulator provides a mechanism to swap out different implementations.
78 * For example, the default implementation is a single-threaded simulator
79 * that performs no realtime synchronization. By calling this method, you
80 * can substitute in a new simulator implementation that might be multi-
81 * threaded and synchronize events to a realtime clock.
82 *
83 * The simulator implementation can be set when the simulator is not
84 * running.
85 */
86 static void SetImplementation(Ptr<SimulatorImpl> impl);
87
88 /**
89 * @brief Get the SimulatorImpl singleton.
90 *
91 * @internal
92 * If the SimulatorImpl singleton hasn't been created yet,
93 * this function does so. At the same time it also creates
94 * the Scheduler. Both of these respect the global values
95 * which may have been set from the command line or through
96 * the Config system.
97 *
98 * As a side effect we also call LogSetTimePrinter() and
99 * LogSetNodePrinter() with the default implementations
100 * since we can't really do any logging until we have
101 * a SimulatorImpl and Scheduler.
102
103 * @return The SimulatorImpl singleton.
104 */
106
107 /**
108 * @brief Set the scheduler type with an ObjectFactory.
109 * @param [in] schedulerFactory The configured ObjectFactory.
110 *
111 * The event scheduler can be set at any time: the events scheduled
112 * in the previous scheduler will be transferred to the new scheduler
113 * before we start to use it.
114 */
115 static void SetScheduler(ObjectFactory schedulerFactory);
116
117 /**
118 * Execute the events scheduled with ScheduleDestroy().
119 *
120 * This method is typically invoked at the end of a simulation
121 * to avoid false-positive reports by a leak checker.
122 * After this method has been invoked, it is actually possible
123 * to restart a new simulation with a set of calls to Simulator::Run,
124 * Simulator::Schedule and Simulator::ScheduleWithContext.
125 */
126 static void Destroy();
127
128 /**
129 * Check if the simulation should finish.
130 *
131 * Reasons to finish are because there are
132 * no more events lefts to be scheduled, or if simulation
133 * time has already reached the "stop time" (see Simulator::Stop()).
134 *
135 * @return @c true if no more events or stop time reached.
136 */
137 static bool IsFinished();
138
139 /**
140 * Run the simulation.
141 *
142 * The simulation will run until one of:
143 * - No events are present anymore
144 * - The user called Simulator::Stop
145 * - The user called Simulator::Stop with a stop time and the
146 * expiration time of the next event to be processed
147 * is greater than or equal to the stop time.
148 */
149 static void Run();
150
151 /**
152 * Tell the Simulator the calling event should be the last one
153 * executed.
154 *
155 * If a running event invokes this method, it will be the last
156 * event executed by the Simulator::Run method before
157 * returning to the caller.
158 */
159 static void Stop();
160
161 /**
162 * Schedule the time delay until the Simulator should stop.
163 *
164 * Force the Simulator::Run method to return to the caller when the
165 * expiration time of the next event to be processed is greater than
166 * or equal to the stop time. The stop time is relative to the
167 * current simulation time.
168 * @param [in] delay The stop time, relative to the current time.
169 * @return The stop EventId.
170 */
171 static EventId Stop(const Time& delay);
172
173 /**
174 * Returns the Stop Event, or an invalid event if the simulation
175 * does not have a scheduled stop time.
176 * @return The stop EventId.
177 */
178 static EventId GetStopEvent();
179
180 /**
181 * Get the current simulation context.
182 *
183 * The simulation context is the ns-3 notion of a Logical Process.
184 * Events in a single context should only modify state associated with
185 * that context. Events for objects in other contexts should be
186 * scheduled with ScheduleWithContext() to track the context switches.
187 * In other words, events in different contexts should be mutually
188 * thread safe, by not modify overlapping model state.
189 *
190 * In circumstances where the context can't be determined, such as
191 * during object initialization, the \c enum value \c NO_CONTEXT
192 * should be used.
193 *
194 * @return The current simulation context
195 */
196 static uint32_t GetContext();
197
198 /**
199 * Context enum values.
200 *
201 * \internal
202 * This enum type is fixed to match the representation size
203 * of simulation context.
204 */
205 enum : uint32_t
206 {
207 /**
208 * Flag for events not associated with any particular context.
209 */
210 NO_CONTEXT = 0xffffffff
211 };
212
213 /**
214 * Get the number of events executed.
215 * \returns The total number of events executed.
216 */
217 static uint64_t GetEventCount();
218
219 /**
220 * @name Schedule events (in the same context) to run at a future time.
221 */
222 /** @{ */
223 /**
224 * Schedule an event to expire after @p delay.
225 * This can be thought of as scheduling an event
226 * for the current simulation time plus the @p delay passed as a
227 * parameter.
228 *
229 * We leverage SFINAE to discard this overload if the second argument is
230 * convertible to Ptr<EventImpl> or is a function pointer.
231 *
232 * @tparam FUNC @deduced Template type for the function to invoke.
233 * @tparam Ts @deduced Argument types.
234 * @param [in] delay The relative expiration time of the event.
235 * @param [in] f The function to invoke.
236 * @param [in] args Arguments to pass to MakeEvent.
237 * @returns The id for the scheduled event.
238 */
239 template <typename FUNC,
240 std::enable_if_t<!std::is_convertible_v<FUNC, Ptr<EventImpl>>, int> = 0,
241 std::enable_if_t<!std::is_function_v<std::remove_pointer_t<FUNC>>, int> = 0,
242 typename... Ts>
243 static EventId Schedule(const Time& delay, FUNC f, Ts&&... args);
244
245 /**
246 * Schedule an event to expire after @p delay.
247 * This can be thought of as scheduling an event
248 * for the current simulation time plus the @p delay passed as a
249 * parameter.
250 *
251 * @tparam Us @deduced Formal function argument types.
252 * @tparam Ts @deduced Actual function argument types.
253 * When the event expires (when it becomes due to be run), the
254 * function will be invoked with any supplied arguments.
255 * @param [in] delay The relative expiration time of the event.
256 * @param [in] f The function to invoke.
257 * @param [in] args Arguments to pass to the invoked function.
258 * @returns The id for the scheduled event.
259 */
260 template <typename... Us, typename... Ts>
261 static EventId Schedule(const Time& delay, void (*f)(Us...), Ts&&... args);
262 /** @} */ // Schedule events (in the same context) to run at a future time.
263
264 /**
265 * @name Schedule events (in a different context) to run now or at a future time.
266 *
267 * See @ref main-test-sync.cc for example usage.
268 */
269 /** @{ */
270 /**
271 * Schedule an event with the given context.
272 * A context of 0xffffffff means no context is specified.
273 * This method is thread-safe: it can be called from any thread.
274 *
275 * We leverage SFINAE to discard this overload if the second argument is
276 * convertible to Ptr<EventImpl> or is a function pointer.
277 *
278 * @tparam FUNC @deduced Template type for the function to invoke.
279 * @tparam Ts @deduced Argument types.
280 * @param [in] context User-specified context parameter
281 * @param [in] delay The relative expiration time of the event.
282 * @param [in] f The function to invoke.
283 * @param [in] args Arguments to pass to MakeEvent.
284 */
285 template <typename FUNC,
286 std::enable_if_t<!std::is_convertible_v<FUNC, Ptr<EventImpl>>, int> = 0,
287 std::enable_if_t<!std::is_function_v<std::remove_pointer_t<FUNC>>, int> = 0,
288 typename... Ts>
289 static void ScheduleWithContext(uint32_t context, const Time& delay, FUNC f, Ts&&... args);
290
291 /**
292 * Schedule an event with the given context.
293 * A context of 0xffffffff means no context is specified.
294 * This method is thread-safe: it can be called from any thread.
295 *
296 * @tparam Us @deduced Formal function argument types.
297 * @tparam Ts @deduced Actual function argument types.
298 * @param [in] context User-specified context parameter
299 * @param [in] delay The relative expiration time of the event.
300 * @param [in] f The function to invoke.
301 * @param [in] args Arguments to pass to the invoked function.
302 */
303 template <typename... Us, typename... Ts>
304 static void ScheduleWithContext(uint32_t context,
305 const Time& delay,
306 void (*f)(Us...),
307 Ts&&... args);
308 /** @} */ // Schedule events (in a different context) to run now or at a future time.
309
310 /**
311 * @name Schedule events (in the same context) to run now.
312 */
313 /** @{ */
314 /**
315 * Schedule an event to expire Now. All events scheduled to
316 * to expire "Now" are scheduled FIFO, after all normal events
317 * have expired.
318 *
319 * We leverage SFINAE to discard this overload if the second argument is
320 * convertible to Ptr<EventImpl> or is a function pointer.
321 *
322 * @tparam FUNC @deduced Template type for the function to invoke.
323 * @tparam Ts @deduced Actual function argument types.
324 * @param [in] f The function to invoke.
325 * @param [in] args Arguments to pass to the invoked function.
326 * @return The EventId of the scheduled event.
327 */
328 template <typename FUNC,
329 std::enable_if_t<!std::is_convertible_v<FUNC, Ptr<EventImpl>>, int> = 0,
330 std::enable_if_t<!std::is_function_v<std::remove_pointer_t<FUNC>>, int> = 0,
331 typename... Ts>
332 static EventId ScheduleNow(FUNC f, Ts&&... args);
333
334 /**
335 * Schedule an event to expire Now. All events scheduled to
336 * to expire "Now" are scheduled FIFO, after all normal events
337 * have expired.
338 *
339 * @tparam Us @deduced Formal function argument types.
340 * @tparam Ts @deduced Actual function argument types.
341 * @param [in] f The function to invoke.
342 * @param [in] args Arguments to pass to MakeEvent.
343 * @return The EventId of the scheduled event.
344 */
345 template <typename... Us, typename... Ts>
346 static EventId ScheduleNow(void (*f)(Us...), Ts&&... args);
347
348 /** @} */ // Schedule events (in the same context) to run now.
349
350 /**
351 * @name Schedule events to run at the end of the simulation, when Simulator:Destroy() is
352 * called.
353 */
354 /** @{ */
355 /**
356 * Schedule an event to run at the end of the simulation, when Simulator::Destroy() is called.
357 * All events scheduled to expire at "Destroy" time are scheduled FIFO,
358 * after all normal events have expired and only when
359 * Simulator::Destroy is invoked.
360 *
361 * We leverage SFINAE to discard this overload if the second argument is
362 * convertible to Ptr<EventImpl> or is a function pointer.
363 *
364 * @tparam FUNC @deduced Template type for the function to invoke.
365 * @tparam Ts @deduced Actual function argument types.
366 * @param [in] f The function to invoke.
367 * @param [in] args Arguments to pass to MakeEvent.
368 * @return The EventId of the scheduled event.
369 */
370 template <typename FUNC,
371 std::enable_if_t<!std::is_convertible_v<FUNC, Ptr<EventImpl>>, int> = 0,
372 std::enable_if_t<!std::is_function_v<std::remove_pointer_t<FUNC>>, int> = 0,
373 typename... Ts>
374 static EventId ScheduleDestroy(FUNC f, Ts&&... args);
375
376 /**
377 * Schedule an event to run at the end of the simulation, when Simulator::Destroy() is called.
378 * All events scheduled to expire at "Destroy" time are scheduled FIFO,
379 * after all normal events have expired and only when
380 * Simulator::Destroy is invoked.
381 *
382 * @tparam Us @deduced Formal function argument types.
383 * @tparam Ts @deduced Actual function argument types.
384 * @param [in] f The function to invoke.
385 * @param [in] args Arguments to pass to MakeEvent.
386 * @return The EventId of the scheduled event.
387 */
388 template <typename... Us, typename... Ts>
389 static EventId ScheduleDestroy(void (*f)(Us...), Ts&&... args);
390
391 /** @} */ // Schedule events to run when Simulator:Destroy() is called.
392
393 /**
394 * Remove an event from the event list.
395 *
396 * This method has the same visible effect as the
397 * ns3::EventId::Cancel method
398 * but its algorithmic complexity is much higher: it has often
399 * O(log(n)) complexity, sometimes O(n), sometimes worse.
400 * Note that it is not possible to remove events which were scheduled
401 * for the "destroy" time. Doing so will result in a program error (crash).
402 *
403 * @param [in] id The event to remove from the list of scheduled events.
404 */
405 static void Remove(const EventId& id);
406
407 /**
408 * Set the cancel bit on this event: the event's associated function
409 * will not be invoked when it expires.
410 *
411 * This method has the same visible effect as the
412 * ns3::Simulator::Remove method but its algorithmic complexity is
413 * much lower: it has O(1) complexity.
414 * This method has the exact same semantics as ns3::EventId::Cancel.
415 * Note that it is not possible to cancel events which were scheduled
416 * for the "destroy" time. Doing so will result in a program error (crash).
417 *
418 * @param [in] id the event to cancel
419 */
420 static void Cancel(const EventId& id);
421
422 /**
423 * Check if an event has already run or been cancelled.
424 *
425 * This method has O(1) complexity.
426 * Note that it is not possible to test for the expiration of
427 * events which were scheduled for the "destroy" time. Doing so
428 * will result in a program error (crash).
429 * An event is said to "expire" when it starts being scheduled
430 * which means that if the code executed by the event calls
431 * this function, it will get true.
432 *
433 * @param [in] id The event to test for expiration.
434 * @returns @c true if the event has expired, false otherwise.
435 */
436 static bool IsExpired(const EventId& id);
437
438 /**
439 * Return the current simulation virtual time.
440 *
441 * @returns The current virtual time.
442 */
443 static Time Now();
444
445 /**
446 * Get the remaining time until this event will execute.
447 *
448 * @param [in] id The event id to analyse.
449 * @return The delay left until the input event id expires.
450 * if the event is not running, this method returns
451 * zero.
452 */
453 static Time GetDelayLeft(const EventId& id);
454
455 /**
456 * Get the maximum representable simulation time.
457 *
458 * @return The maximum simulation time at which an event
459 * can be scheduled.
460 *
461 * The returned value will always be bigger than or equal to Simulator::Now.
462 */
464
465 /**
466 * Schedule a future event execution (in the same context).
467 *
468 * @param [in] delay Delay until the event expires.
469 * @param [in] event The event to schedule.
470 * @returns A unique identifier for the newly-scheduled event.
471 */
472 static EventId Schedule(const Time& delay, const Ptr<EventImpl>& event);
473
474 /**
475 * Schedule a future event execution (in a different context).
476 * This method is thread-safe: it can be called from any thread.
477 *
478 * @param [in] delay Delay until the event expires.
479 * @param [in] context Event context.
480 * @param [in] event The event to schedule.
481 */
482 static void ScheduleWithContext(uint32_t context, const Time& delay, EventImpl* event);
483
484 /**
485 * Schedule an event to run at the end of the simulation, after
486 * the Stop() time or condition has been reached.
487 *
488 * @param [in] event The event to schedule.
489 * @returns A unique identifier for the newly-scheduled event.
490 */
491 static EventId ScheduleDestroy(const Ptr<EventImpl>& event);
492
493 /**
494 * Schedule an event to run at the current virtual time.
495 *
496 * @param [in] event The event to schedule.
497 * @returns A unique identifier for the newly-scheduled event.
498 */
499 static EventId ScheduleNow(const Ptr<EventImpl>& event);
500
501 /**
502 * Get the system id of this simulator.
503 *
504 * The system id is the identifier for this simulator instance
505 * in a distributed simulation. For MPI this is the MPI rank.
506 * @return The system id for this simulator.
507 */
508 static uint32_t GetSystemId();
509
510 private:
511 /**
512 * Implementation of the various Schedule methods.
513 * @param [in] delay Delay until the event should execute.
514 * @param [in] event The event to execute.
515 * @return The EventId.
516 */
517 static EventId DoSchedule(const Time& delay, EventImpl* event);
518 /**
519 * Implementation of the various ScheduleNow methods.
520 * @param [in] event The event to execute.
521 * @return The EventId.
522 */
523 static EventId DoScheduleNow(EventImpl* event);
524 /**
525 * Implementation of the various ScheduleDestroy methods.
526 * @param [in] event The event to execute.
527 * @return The EventId.
528 */
529 static EventId DoScheduleDestroy(EventImpl* event);
530
531 /**
532 * Stop event (if present)
533 */
535
536}; // class Simulator
537
538/**
539 * @ingroup simulator
540 * @brief create an ns3::Time instance which contains the
541 * current simulation time.
542 *
543 * This is really a shortcut for the ns3::Simulator::Now method.
544 * It is typically used as shown below to schedule an event
545 * which expires at the absolute time "2 seconds":
546 * @code
547 * Simulator::Schedule (Seconds (2.0) - Now (), &my_function);
548 * @endcode
549 * @return The current simulation time.
550 */
551Time Now();
552
553} // namespace ns3
554
555/********************************************************************
556 * Implementation of the templates declared above.
557 ********************************************************************/
558
559namespace ns3
560{
561
562// Doxygen has trouble with static template functions in a class:
563// it treats the in-class declaration as different from the
564// out of class definition, so makes two entries in the member list. Ugh
565
566template <typename FUNC,
567 std::enable_if_t<!std::is_convertible_v<FUNC, Ptr<EventImpl>>, int>,
568 std::enable_if_t<!std::is_function_v<std::remove_pointer_t<FUNC>>, int>,
569 typename... Ts>
570EventId
571Simulator::Schedule(const Time& delay, FUNC f, Ts&&... args)
572{
573 return DoSchedule(delay, MakeEvent(f, std::forward<Ts>(args)...));
574}
575
576template <typename... Us, typename... Ts>
578Simulator::Schedule(const Time& delay, void (*f)(Us...), Ts&&... args)
579{
580 return DoSchedule(delay, MakeEvent(f, std::forward<Ts>(args)...));
581}
582
583template <typename FUNC,
584 std::enable_if_t<!std::is_convertible_v<FUNC, Ptr<EventImpl>>, int>,
585 std::enable_if_t<!std::is_function_v<std::remove_pointer_t<FUNC>>, int>,
586 typename... Ts>
587void
588Simulator::ScheduleWithContext(uint32_t context, const Time& delay, FUNC f, Ts&&... args)
589{
590 return ScheduleWithContext(context, delay, MakeEvent(f, std::forward<Ts>(args)...));
591}
592
593template <typename... Us, typename... Ts>
594void
595Simulator::ScheduleWithContext(uint32_t context, const Time& delay, void (*f)(Us...), Ts&&... args)
596{
597 return ScheduleWithContext(context, delay, MakeEvent(f, std::forward<Ts>(args)...));
598}
599
600template <typename FUNC,
601 std::enable_if_t<!std::is_convertible_v<FUNC, Ptr<EventImpl>>, int>,
602 std::enable_if_t<!std::is_function_v<std::remove_pointer_t<FUNC>>, int>,
603 typename... Ts>
605Simulator::ScheduleNow(FUNC f, Ts&&... args)
606{
607 return DoScheduleNow(MakeEvent(f, std::forward<Ts>(args)...));
608}
609
610template <typename... Us, typename... Ts>
612Simulator::ScheduleNow(void (*f)(Us...), Ts&&... args)
613{
614 return DoScheduleNow(MakeEvent(f, std::forward<Ts>(args)...));
615}
616
617template <typename FUNC,
618 std::enable_if_t<!std::is_convertible_v<FUNC, Ptr<EventImpl>>, int>,
619 std::enable_if_t<!std::is_function_v<std::remove_pointer_t<FUNC>>, int>,
620 typename... Ts>
622Simulator::ScheduleDestroy(FUNC f, Ts&&... args)
623{
624 return DoScheduleDestroy(MakeEvent(f, std::forward<Ts>(args)...));
625}
626
627template <typename... Us, typename... Ts>
629Simulator::ScheduleDestroy(void (*f)(Us...), Ts&&... args)
630{
631 return DoScheduleDestroy(MakeEvent(f, std::forward<Ts>(args)...));
632}
633
634} // namespace ns3
635
636#endif /* SIMULATOR_H */
An identifier for simulation events.
Definition: event-id.h:55
A simulation event.
Definition: event-impl.h:46
Instantiate subclasses of ns3::Object.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Control the scheduling of simulation events.
Definition: simulator.h:68
static EventId DoScheduleDestroy(EventImpl *event)
Implementation of the various ScheduleDestroy methods.
Definition: simulator.cc:269
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
static Ptr< SimulatorImpl > GetImplementation()
Get the SimulatorImpl singleton.
Definition: simulator.cc:373
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...
Definition: simulator.cc:285
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition: simulator.h:588
static EventId m_stopEvent
Stop event (if present)
Definition: simulator.h:534
static bool IsFinished()
Check if the simulation should finish.
Definition: simulator.cc:171
static uint32_t GetSystemId()
Get the system id of this simulator.
Definition: simulator.cc:330
@ NO_CONTEXT
Flag for events not associated with any particular context.
Definition: simulator.h:210
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
static void Run()
Run the simulation.
Definition: simulator.cc:178
static bool IsExpired(const EventId &id)
Check if an event has already run or been cancelled.
Definition: simulator.cc:295
Simulator()=delete
static EventId ScheduleDestroy(FUNC f, Ts &&... args)
Schedule an event to run at the end of the simulation, when Simulator::Destroy() is called.
Definition: simulator.h:622
static void SetScheduler(ObjectFactory schedulerFactory)
Set the scheduler type with an ObjectFactory.
Definition: simulator.cc:164
static EventId DoScheduleNow(EventImpl *event)
Implementation of the various ScheduleNow methods.
Definition: simulator.cc:260
static uint64_t GetEventCount()
Get the number of events executed.
Definition: simulator.cc:324
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:605
~Simulator()=delete
static EventId DoSchedule(const Time &delay, EventImpl *event)
Implementation of the various Schedule methods.
Definition: simulator.cc:251
static Time GetMaximumSimulationTime()
Get the maximum representable simulation time.
Definition: simulator.cc:311
static void Remove(const EventId &id)
Remove an event from the event list.
Definition: simulator.cc:275
static EventId GetStopEvent()
Returns the Stop Event, or an invalid event if the simulation does not have a scheduled stop time.
Definition: simulator.cc:202
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
static void SetImplementation(Ptr< SimulatorImpl > impl)
Definition: simulator.cc:345
static uint32_t GetContext()
Get the current simulation context.
Definition: simulator.cc:318
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:217
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
ns3::EventId declarations.
ns3::EventImpl declarations.
std::enable_if_t< std::is_member_pointer_v< MEM >, EventImpl * > MakeEvent(MEM mem_ptr, OBJ obj, Ts... args)
Make an EventImpl from class method members which take varying numbers of arguments.
Definition: make-event.h:144
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:305
ns3::MakeEvent function declarations and template implementation.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Declaration of classes ns3::Time and ns3::TimeWithUnit, and the TimeValue implementation classes.
ns3::ObjectFactory class declaration.