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"
84 static TypeId tid =
TypeId (
"ns3::DistributedSimulatorImpl")
86 .AddConstructor<DistributedSimulatorImpl> ()
104 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
152 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);
264 MPI_Allreduce (&sendbuf, &recvbuf, 1, MPI_LONG, MPI_MAX, MPI_COMM_WORLD);
279 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
293 NS_LOG_WARN (
"attempted to set look ahead negative: " << lookAhead);
309 scheduler->Insert (next);
409 if (
m_pLBTS[i].GetSmallestTime () < smallestTime)
446 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
485 ev.
key.
m_ts =
static_cast<uint64_t
> (tAbsolute.GetTimeStep ());
502 ev.key.m_context = context;
503 ev.key.m_uid =
m_uid;
558 if (
id.GetUid () == 2)
576 event.
impl =
id.PeekEventImpl ();
577 event.key.m_ts =
id.GetTs ();
578 event.key.m_context =
id.GetContext ();
579 event.key.m_uid =
id.GetUid ();
581 event.impl->Cancel ();
583 event.impl->Unref ();
593 id.PeekEventImpl ()->Cancel ();
636 return TimeStep (0x7fffffffffffffffLL);
Simulation virtual time values and global simulation resolution.
~DistributedSimulatorImpl()
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void SetScheduler(ObjectFactory schedulerFactory)
Ptr< Scheduler > m_events
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
static uint32_t GetRxCount()
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual EventId ScheduleDestroy(EventImpl *event)
virtual Time GetMaximumSimulationTime(void) const
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()
#define NS_FATAL_ERROR(msg)
fatal error handling
virtual void SetMaximumLookAhead(const Time lookAhead)
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".
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.
virtual Time GetDelayLeft(const EventId &id) const
void ProcessOneEvent(void)
uint32_t m_currentContext
static void Destroy()
Deletes storage used by the parallel environment.
Attribute for 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)
Use NS_LOG to output a message of level LOG_LOGIC.
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
Time TimeStep(uint64_t ts)
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()
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
Time Seconds(double value)
Construct a Time in the indicated unit.
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.