29 #include <ns3/simulator.h>
30 #include <ns3/scheduler.h>
31 #include <ns3/event-impl.h>
32 #include <ns3/channel.h>
33 #include <ns3/node-container.h>
34 #include <ns3/double.h>
36 #include <ns3/pointer.h>
37 #include <ns3/assert.h>
56 static TypeId tid =
TypeId (
"ns3::NullMessageSimulatorImpl")
58 .AddConstructor<NullMessageSimulatorImpl> ()
59 .AddAttribute (
"SchedulerTune",
"Null Message scheduler tuning parameter",
62 MakeDoubleChecker<double> (0.01,1.0))
94 NS_FATAL_ERROR (
"Can't use Null Message simulator without MPI compiled in");
127 if (!ev->IsCancelled ())
142 int num_local_nodes = 0;
156 for (uint32_t i = 0; i < (*iter)->GetNDevices (); ++i)
160 if (!localNetDevice->IsPointToPoint ())
172 if (channel->GetDevice (0) == localNetDevice)
174 remoteNode = (channel->GetDevice (1))->GetNode ();
178 remoteNode = (channel->GetDevice (0))->GetNode ();
191 if (!remoteChannelBundle)
197 channel->GetAttribute (
"Delay", delay);
198 remoteChannelBundle->AddChannel (channel, delay.
Get () );
222 scheduler->Insert (next);
412 ev.
key.
m_ts =
static_cast<uint64_t
> (tAbsolute.GetTimeStep ());
433 ev.
key.
m_ts = tAbsolute.GetTimeStep ();
490 if (
id.GetUid () == 2)
508 event.
impl =
id.PeekEventImpl ();
509 event.key.m_ts =
id.GetTs ();
510 event.key.m_context =
id.GetContext ();
511 event.key.m_uid =
id.GetUid ();
513 event.impl->Cancel ();
515 event.impl->Unref ();
525 id.PeekEventImpl ()->Cancel ();
568 return TimeStep (0x7fffffffffffffffLL);
Time CalculateGuaranteeTime(uint32_t systemId)
virtual Time GetMaximumSimulationTime(void) const
keep track of time values and allow control of global simulation resolution
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
virtual void Cancel(const EventId &ev)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
std::vector< Ptr< Node > >::const_iterator Iterator
Time TimeStep(uint64_t ts)
virtual void Destroy()
This method is typically invoked at the end of a simulation to avoid false-positive reports by a leak...
void HandleArrivingMessagesNonBlocking(void)
Non blocking receive of pending messages.
virtual EventId ScheduleNow(EventImpl *event)
Ptr< Scheduler > m_events
#define NS_ASSERT(condition)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
~NullMessageSimulatorImpl()
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
static void ReceiveMessagesNonBlocking()
Non-blocking check for received messages complete.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual EventId Schedule(Time const &time, EventImpl *event)
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...
void ProcessOneEvent(void)
Process the next event on the queue.
void RescheduleNullMessageEvent(Ptr< RemoteChannelBundle > bundle)
Collection of NS3 channels between local and remote nodes.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
EventImpl * PeekEventImpl(void) const
uint32_t GetSystemId(void) const
virtual EventId ScheduleDestroy(EventImpl *event)
#define NS_FATAL_ERROR(msg)
fatal error handling
void CalculateSafeTime(void)
Calculate the SafeTime.
void Invoke(void)
Called by the simulation engine to notify the event that it has expired.
static NullMessageSimulatorImpl * GetInstance(void)
static void TestSendComplete()
Check for completed sends.
virtual uint32_t GetSystemId(void) const
virtual bool IsFinished(void) const
If there are no more events lefts to be scheduled, or if simulation time has already reached the "sto...
static Time GetSafeTime(void)
Time GetDelay(void) const
static void Destroy()
Deletes storage used by the parallel environment.
hold objects of type ns3::Time
Ptr< Object > Create(void) const
void Unref(void) const
Decrement the reference count.
T * PeekPointer(const Ptr< T > &p)
static void SendNullMessage(const Time &guaranteeUpdate, Ptr< RemoteChannelBundle > bundle)
Send a Null Message to across the specified bundle.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
uint32_t GetUid(void) const
virtual void RunOneEvent(void)
NS_LOG_COMPONENT_DEFINE("NullMessageSimulatorImpl")
static void InitializeNullMessageEvents(void)
Setup initial Null Message events for every RemoteChannelBundle.
DestroyEvents m_destroyEvents
Time GetSafeTime(void)
Get the current SafeTime; the maximum time that events can be processed based on information received...
#define NS_LOG_LOGIC(msg)
static void Destroy(void)
Destroy the singleton.
virtual void Run(void)
Run the simulation until one of:
static NullMessageSimulatorImpl * g_instance
void CalculateLookAhead(void)
Calculate the look ahead allowable for this MPI task.
keep track of a set of node pointers.
static void ReceiveMessagesBlocking()
Blocking message receive.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
virtual uint32_t GetContext(void) const
static Ptr< RemoteChannelBundle > Find(uint32_t systemId)
void HandleArrivingMessagesBlocking(void)
Blocking receive of arriving messages.
int64_t GetTimeStep(void) const
virtual Time GetDelayLeft(const EventId &id) const
NullMessageSimulatorImpl()
virtual void ScheduleWithContext(uint32_t context, Time const &time, EventImpl *event)
static Ptr< RemoteChannelBundle > Add(uint32_t systemId)
Add RemoteChannelBundle from this task to MPI task on other side of the link.
Simulator implementation using MPI and a Null Message algorithm.
static NodeContainer GetGlobal(void)
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
instantiate subclasses of ns3::Object.
an identifier for simulation events.
static uint32_t GetSystemId()
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
virtual void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::Run method bef...
uint32_t m_currentContext
virtual Time Now(void) const
Return the "current simulation time".
void ScheduleNullMessageEvent(Ptr< RemoteChannelBundle > bundle)
void NullMessageEventHandler(RemoteChannelBundle *bundle)
virtual bool IsExpired(const EventId &ev) const
This method has O(1) complexity.
virtual void Remove(const EventId &ev)
Remove an event from the event list.
a base class which provides memory management and object aggregation
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
static void InitializeSendReceiveBuffers(void)
Initialize send and receive buffers.
Hold a floating point type.
a unique identifier for an interface.
virtual void SetScheduler(ObjectFactory schedulerFactory)
static TypeId GetTypeId(void)
TypeId SetParent(TypeId tid)
static uint32_t GetSize()
uint64_t GetTs(void) const