|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
30 #include "ns3/simulator.h"
31 #include "ns3/scheduler.h"
32 #include "ns3/event-impl.h"
33 #include "ns3/channel.h"
34 #include "ns3/node-container.h"
36 #include "ns3/pointer.h"
37 #include "ns3/assert.h"
92 static TypeId tid =
TypeId (
"ns3::DistributedSimulatorImpl")
157 if (!ev->IsCancelled ())
187 for (uint32_t i = 0; i < (*iter)->GetNDevices (); ++i)
203 if (
channel->GetDevice (0) == localNetDevice)
205 remoteNode = (
channel->GetDevice (1))->GetNode ();
209 remoteNode = (
channel->GetDevice (0))->GetNode ();
222 channel->GetAttribute (
"Delay", delay);
281 if (lookAhead >
Time (0))
288 NS_LOG_WARN (
"attempted to set lookahead to a negative time: " << lookAhead);
304 scheduler->Insert (next);
360 return TimeStep (
NextTs ());
405 if (
m_pLBTS[i].GetSmallestTime () < smallestTime)
556 if (
id.GetUid () == 2)
574 event.
impl =
id.PeekEventImpl ();
575 event.key.m_ts =
id.GetTs ();
576 event.key.m_context =
id.GetContext ();
577 event.key.m_uid =
id.GetUid ();
579 event.impl->Cancel ();
581 event.impl->Unref ();
591 id.PeekEventImpl ()->Cancel ();
598 if (
id.GetUid () == 2)
600 if (
id.PeekEventImpl () == 0
601 ||
id.PeekEventImpl ()->IsCancelled ())
615 if (
id.PeekEventImpl () == 0
619 ||
id.PeekEventImpl ()->IsCancelled ())
634 return TimeStep (0x7fffffffffffffffLL);
static void TestSendComplete()
Check for completed sends.
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t m_currentUid
Unique id of the current event.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Time m_grantedTime
End of current window.
virtual void ScheduleWithContext(uint32_t context, Time const &delay, EventImpl *event)
Schedule a future event execution (in a different context).
An identifier for simulation events.
virtual EventId ScheduleDestroy(EventImpl *event)
Schedule an event to run at the end of the simulation, after the Stop() time or condition has been re...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
EventImpl * impl
Pointer to the event implementation.
uint64_t m_eventCount
The event count.
Distributed simulator implementation using lookahead.
virtual EventId Schedule(Time const &delay, EventImpl *event)
Schedule a future event execution (in the same context).
Declaration of class ns3::MpiInterface.
~DistributedSimulatorImpl()
Destructor.
static void Destroy()
Deletes storage used by the parallel environment.
virtual Time GetMaximumSimulationTime(void) const
Get the maximum representable simulation time.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
DistributedSimulatorImpl()
Default constructor.
static void ReceiveMessages()
Check for received messages complete.
void ProcessOneEvent(void)
Process the next event.
virtual 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 NodeContainer GetGlobal(void)
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
virtual uint32_t GetContext(void) const
Get the current simulation context.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
int64_t GetInteger(void) const
Get the raw time value, in the current resolution unit.
bool IsLocalFinished(void) const
Check if this rank is finished.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual uint64_t GetEventCount(void) const
Get the number of events executed.
virtual EventId ScheduleNow(EventImpl *event)
Schedule an event to run at the current virtual time.
virtual Time GetDelayLeft(const EventId &id) const
Get the remaining time until this event will execute.
virtual bool IsPointToPoint(void) const =0
Return true if the net device is on a point-to-point link.
uint64_t m_ts
Event time stamp.
Time m_smallestTime
Earliest next event timestamp.
virtual void DoDispose(void)
Destructor implementation.
Time Next(void) const
Get the time of the next event, as returned by NextTs().
static MPI_Comm GetCommunicator()
Return the communicator used to run ns-3.
virtual bool IsFinished(void) const
Check if the simulation should finish.
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
static uint32_t GetRxCount()
Structure used for all-reduce LBTS computation.
Smart pointer class similar to boost::intrusive_ptr.
virtual void Destroy()
Execute the events scheduled with ScheduleDestroy().
virtual bool IsExpired(const EventId &id) const
Check if an event has already run or been cancelled.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
EventKey key
Key for sorting and ordering Events.
bool m_stop
Flag calling for the end of the simulation.
uint32_t m_currentContext
Execution context of the current event.
Declaration of classes ns3::SentBuffer and ns3::GrantedTimeWindowMpiInterface.
uint32_t m_context
Event context.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void Invoke(void)
Called by the simulation engine to notify the event that it is time to execute.
bool m_isFinished
true when this rank has no more events.
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Instantiate subclasses of ns3::Object.
virtual uint32_t GetSystemId(void) const
Get the system id of this simulator.
int m_unscheduledEvents
Number of events that have been inserted but not yet scheduled, not counting the "destroy" events; th...
uint32_t GetSystemId(void) const
virtual void Remove(const EventId &id)
Remove an event from the event list.
Simulation virtual time values and global simulation resolution.
DestroyEvents m_destroyEvents
The container of events to run at Destroy()
void Unref(void) const
Decrement the reference count.
uint32_t m_txCount
Count of transmitted messages.
virtual Ptr< Channel > GetChannel(void) const =0
uint32_t m_myId
System Id of the rank sending this LBTS.
static TypeId GetTypeId(void)
Register this type.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
virtual void BoundLookAhead(const Time lookAhead)
Add additional bound to lookahead constraints.
bool IsPositive(void) const
Exactly equivalent to t >= 0.
uint64_t m_currentTs
Timestamp of the current event.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
bool m_globalFinished
Are all parallel instances completed.
The SimulatorImpl base class.
uint32_t m_uid
Next event unique id.
Time Seconds(double value)
Construct a Time in the indicated unit.
LbtsMessage * m_pLBTS
Container for Lbts messages, one per rank.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
keep track of a set of node pointers.
void CalculateLookAhead(void)
Calculate lookahead constraint based on network latency.
static Time m_lookAhead
Current window size.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
Declaration of classes ns3::LbtsMessage and ns3::DistributedSimulatorImpl.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
uint64_t NextTs(void) const
Get the timestep of the next event.
virtual void Stop(void)
Tell the Simulator the calling event should be the last one executed.
uint32_t m_systemCount
MPI communicator size.
@ NO_CONTEXT
Flag for events not associated with any particular context.
static uint32_t GetTxCount()
virtual void SetScheduler(ObjectFactory schedulerFactory)
Set the Scheduler to be used to manage the event list.
virtual void DoDispose(void)
Destructor implementation.
static uint32_t GetSystemId()
Get the id number of this rank.
virtual Time Now(void) const
Return the current simulation virtual time.
static uint32_t GetSize()
Get the number of ranks used by ns-3.
uint32_t m_rxCount
Count of received messages.
uint32_t m_uid
Event unique id.
virtual void Run(void)
Run the simulation.
Ptr< Scheduler > m_events
The event priority queue.