|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
35 #include <ns3/simulator.h>
36 #include <ns3/scheduler.h>
37 #include <ns3/event-impl.h>
38 #include <ns3/channel.h>
39 #include <ns3/node-container.h>
40 #include <ns3/double.h>
42 #include <ns3/pointer.h>
43 #include <ns3/assert.h>
62 static TypeId tid =
TypeId (
"ns3::NullMessageSimulatorImpl")
66 .AddAttribute (
"SchedulerTune",
"Null Message scheduler tuning parameter",
69 MakeDoubleChecker<double> (0.01,1.0))
130 if (!ev->IsCancelled ())
145 int num_local_nodes = 0;
159 for (uint32_t i = 0; i < (*iter)->GetNDevices (); ++i)
175 if (
channel->GetDevice (0) == localNetDevice)
177 remoteNode = (
channel->GetDevice (1))->GetNode ();
181 remoteNode = (
channel->GetDevice (0))->GetNode ();
194 if (!remoteChannelBundle)
200 channel->GetAttribute (
"Delay", delay);
201 remoteChannelBundle->AddChannel (
channel, delay.
Get () );
225 scheduler->Insert (next);
486 if (
id.GetUid () == 2)
504 event.
impl =
id.PeekEventImpl ();
505 event.key.m_ts =
id.GetTs ();
506 event.key.m_context =
id.GetContext ();
507 event.key.m_uid =
id.GetUid ();
509 event.impl->Cancel ();
511 event.impl->Unref ();
521 id.PeekEventImpl ()->Cancel ();
528 if (
id.GetUid () == 2)
530 if (
id.PeekEventImpl () == 0
531 ||
id.PeekEventImpl ()->IsCancelled ())
545 if (
id.PeekEventImpl () == 0
549 ||
id.PeekEventImpl ()->IsCancelled ())
564 return TimeStep (0x7fffffffffffffffLL);
DestroyEvents m_destroyEvents
The container of events to run at Destroy()
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void ProcessOneEvent(void)
Process the next event on the queue.
Declaration of classes ns3::NullMessageSentBuffer and ns3::NullMessageMpiInterface.
virtual bool IsFinished(void) const
Check if the simulation should finish.
#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,...
Declaration of class ns3::RemoteChannelBundle.
Collection of ns-3 channels between local and remote nodes.
virtual EventId ScheduleNow(EventImpl *event)
Schedule an event to run at the current virtual time.
uint32_t m_systemCount
MPI communicator size.
An identifier for simulation events.
static void ReceiveMessagesBlocking()
Blocking message receive.
static NullMessageSimulatorImpl * g_instance
Singleton instance.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void Destroy()
Execute the events scheduled with ScheduleDestroy().
int m_unscheduledEvents
Number of events that have been inserted but not yet scheduled, not counting the "destroy" events; th...
static void TestSendComplete()
Check for completed sends.
EventImpl * impl
Pointer to the event implementation.
Declaration of class ns3::MpiInterface.
static void Destroy()
Deletes storage used by the parallel environment.
uint32_t m_currentUid
Unique id of the current event.
static NodeContainer GetGlobal(void)
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
Time GetDelay(void) const
Get the minimum delay along any channel in this bundle.
static TypeId GetTypeId(void)
Register this type.
static Time GetSafeTime(void)
Get the safe time across all channels in this bundle.
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.
virtual void Run(void)
Run the simulation.
static Ptr< RemoteChannelBundle > Find(uint32_t systemId)
Get the bundle corresponding to a remote rank.
~NullMessageSimulatorImpl()
Destructor.
Time GetSafeTime(void)
Get the current SafeTime; the maximum time that events can be processed based on information received...
U * PeekPointer(const Ptr< U > &p)
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
virtual void Remove(const EventId &id)
Remove an event from the event list.
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.
void RescheduleNullMessageEvent(Ptr< RemoteChannelBundle > bundle)
static NullMessageSimulatorImpl * GetInstance(void)
virtual Time GetMaximumSimulationTime(void) const
Get the maximum representable simulation time.
static Ptr< RemoteChannelBundle > Add(uint32_t systemId)
Add RemoteChannelBundle from this task to MPI task on other side of the link.
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
Smart pointer class similar to boost::intrusive_ptr.
void HandleArrivingMessagesBlocking(void)
Blocking receive of arriving messages.
static void InitializeSendReceiveBuffers(void)
Initialize send and receive buffers.
bool m_stop
Flag calling for the end of the simulation.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
EventKey key
Key for sorting and ordering Events.
uint32_t m_context
Event context.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
uint64_t m_eventCount
The event count.
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...
uint64_t m_currentTs
Timestamp of the current event.
void Invoke(void)
Called by the simulation engine to notify the event that it is time to execute.
Simulator implementation using MPI and a Null Message algorithm.
Instantiate subclasses of ns3::Object.
void CalculateLookAhead(void)
Calculate the lookahead allowable for this MPI task.
uint32_t m_currentContext
Execution context of the current event.
uint32_t GetSystemId(void) const
virtual Time GetDelayLeft(const EventId &id) const
Get the remaining time until this event will execute.
Time CalculateGuaranteeTime(uint32_t systemId)
Simulation virtual time values and global simulation resolution.
virtual void Stop(void)
Tell the Simulator the calling event should be the last one executed.
void Unref(void) const
Decrement the reference count.
static void InitializeNullMessageEvents(void)
Setup initial Null Message events for every RemoteChannelBundle.
Time m_safeTime
The time for which it is safe for this task to execute events without danger of out-of-order events.
static void Destroy(void)
Destroy the singleton.
Ptr< Scheduler > m_events
The event priority queue.
void HandleArrivingMessagesNonBlocking(void)
Non blocking receive of pending messages.
virtual Ptr< Channel > GetChannel(void) const =0
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
virtual uint32_t GetContext(void) const
Get the current simulation context.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual void SetScheduler(ObjectFactory schedulerFactory)
Set the Scheduler to be used to manage the event list.
bool IsPositive(void) const
Exactly equivalent to t >= 0.
uint32_t m_uid
Next event unique id.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
virtual void ScheduleWithContext(uint32_t context, Time const &delay, EventImpl *event)
Schedule a future event execution (in a different context).
virtual bool IsExpired(const EventId &id) const
Check if an event has already run or been cancelled.
NullMessageSimulatorImpl()
Default constructor.
virtual Time Now(void) const
Return the current simulation virtual time.
The SimulatorImpl base class.
void NullMessageEventHandler(RemoteChannelBundle *bundle)
Time Seconds(double value)
Construct a Time in the indicated unit.
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 ",...
Declaration of class ns3::RemoteChannelBundleManager.
virtual uint64_t GetEventCount(void) const
Get the number of events executed.
keep track of a set of node pointers.
double m_schedulerTune
Null Message performance tuning parameter.
static void SendNullMessage(const Time &guaranteeUpdate, Ptr< RemoteChannelBundle > bundle)
Send a Null Message to across the specified bundle.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
virtual uint32_t GetSystemId(void) const
Get the system id of this simulator.
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...
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
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...
static void ReceiveMessagesNonBlocking()
Non-blocking check for received messages complete.
@ NO_CONTEXT
Flag for events not associated with any particular context.
virtual EventId Schedule(Time const &delay, EventImpl *event)
Schedule a future event execution (in the same context).
virtual void DoDispose(void)
Destructor implementation.
virtual void DoDispose(void)
Destructor implementation.
static uint32_t GetSystemId()
Get the id number of this rank.
Declaration of class ns3::NullMessageSimulatorImpl.
static uint32_t GetSize()
Get the number of ranks used by ns-3.
void ScheduleNullMessageEvent(Ptr< RemoteChannelBundle > bundle)
void CalculateSafeTime(void)
Calculate the SafeTime.
uint32_t m_uid
Event unique id.