24 #include "ns3/simulator.h"
25 #include "ns3/scheduler.h"
26 #include "ns3/event-impl.h"
27 #include "ns3/channel.h"
28 #include "ns3/node-container.h"
30 #include "ns3/pointer.h"
31 #include "ns3/assert.h"
85 static TypeId tid =
TypeId (
"ns3::DistributedSimulatorImpl")
87 .AddConstructor<DistributedSimulatorImpl> ()
105 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
153 if (!ev->IsCancelled ())
188 for (uint32_t i = 0; i < (*iter)->GetNDevices (); ++i)
192 if (!localNetDevice->IsPointToPoint ())
204 if (channel->GetDevice (0) == localNetDevice)
206 remoteNode = (channel->GetDevice (1))->GetNode ();
210 remoteNode = (channel->GetDevice (0))->GetNode ();
223 channel->GetAttribute (
"Delay", delay);
262 MPI_Allreduce (&sendbuf, &recvbuf, 1, MPI_LONG, MPI_MAX, MPI_COMM_WORLD);
277 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
293 scheduler->Insert (next);
393 if (
m_pLBTS[i].GetSmallestTime () < smallestTime)
430 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
469 ev.
key.
m_ts =
static_cast<uint64_t
> (tAbsolute.GetTimeStep ());
486 ev.key.m_context = context;
487 ev.key.m_uid =
m_uid;
542 if (
id.GetUid () == 2)
560 event.
impl =
id.PeekEventImpl ();
561 event.key.m_ts =
id.GetTs ();
562 event.key.m_context =
id.GetContext ();
563 event.key.m_uid =
id.GetUid ();
565 event.impl->Cancel ();
567 event.impl->Unref ();
577 id.PeekEventImpl ()->Cancel ();
620 return TimeStep (0x7fffffffffffffffLL);
keep track of time values and allow control of global simulation resolution
~DistributedSimulatorImpl()
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
virtual void SetScheduler(ObjectFactory schedulerFactory)
Ptr< Scheduler > m_events
std::vector< Ptr< Node > >::const_iterator Iterator
Time TimeStep(uint64_t ts)
static uint32_t GetRxCount()
#define NS_ASSERT(condition)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual EventId ScheduleDestroy(EventImpl *event)
virtual Time GetMaximumSimulationTime(void) const
NS_LOG_COMPONENT_DEFINE("DistributedSimulatorImpl")
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
static uint32_t GetTxCount()
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 Time Now(void) const
Return the "current simulation time".
#define NS_FATAL_ERROR(msg)
fatal error handling
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
void Invoke(void)
Called by the simulation engine to notify the event that it has expired.
static void TestSendComplete()
Check for completed sends.
double GetSeconds(void) const
virtual Time GetDelayLeft(const EventId &id) const
void ProcessOneEvent(void)
uint32_t m_currentContext
static void Destroy()
Deletes storage used by the parallel environment.
hold objects of type ns3::Time
Ptr< Object > Create(void) const
DistributedSimulatorImpl()
virtual EventId ScheduleNow(EventImpl *event)
void Unref(void) const
Decrement the reference count.
uint32_t GetUid(void) const
DestroyEvents m_destroyEvents
#define NS_LOG_LOGIC(msg)
virtual void Remove(const EventId &ev)
Remove an event from the event list.
static TypeId GetTypeId(void)
keep track of a set of node pointers.
virtual void Destroy()
This method is typically invoked at the end of a simulation to avoid false-positive reports by a leak...
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
virtual void ScheduleWithContext(uint32_t context, Time const &time, EventImpl *event)
int64_t GetTimeStep(void) const
uint64_t NextTs(void) const
int64_t GetInteger(void) const
virtual uint32_t GetSystemId(void) const
virtual uint32_t GetContext(void) const
Structure used for all-reduce LBTS computation.
static NodeContainer GetGlobal(void)
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
void CalculateLookAhead(void)
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...
instantiate subclasses of ns3::Object.
virtual EventId Schedule(Time const &time, EventImpl *event)
static void ReceiveMessages()
Check for received messages complete.
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...
a base class which provides memory management and object aggregation
virtual void Run(void)
Run the simulation until one of:
virtual void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::Run method bef...
bool IsLocalFinished(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...
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
static uint32_t GetSize()
uint64_t GetTs(void) const
virtual bool IsExpired(const EventId &ev) const
This method has O(1) complexity.