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")
105 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
153 if (!ev->IsCancelled ())
189 for (uint32_t i = 0; i < (*iter)->GetNDevices (); ++i)
193 if (!localNetDevice->IsPointToPoint ())
205 if (channel->GetDevice (0) == localNetDevice)
207 remoteNode = (channel->GetDevice (1))->GetNode ();
211 remoteNode = (channel->GetDevice (0))->GetNode ();
224 channel->GetAttribute (
"Delay", delay);
265 MPI_Allreduce (&sendbuf, &recvbuf, 1, MPI_LONG, MPI_MAX, MPI_COMM_WORLD);
280 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
294 NS_LOG_WARN (
"attempted to set look ahead negative: " << lookAhead);
310 scheduler->Insert (next);
410 if (
m_pLBTS[i].GetSmallestTime () < smallestTime)
447 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
486 ev.
key.
m_ts =
static_cast<uint64_t
> (tAbsolute.GetTimeStep ());
503 ev.key.m_context = context;
504 ev.key.m_uid =
m_uid;
559 if (
id.GetUid () == 2)
577 event.
impl =
id.PeekEventImpl ();
578 event.key.m_ts =
id.GetTs ();
579 event.key.m_context =
id.GetContext ();
580 event.key.m_uid =
id.GetUid ();
582 event.impl->Cancel ();
584 event.impl->Unref ();
594 id.PeekEventImpl ()->Cancel ();
601 if (
id.GetUid () == 2)
603 if (
id.PeekEventImpl () == 0
604 ||
id.PeekEventImpl ()->IsCancelled ())
618 if (
id.PeekEventImpl () == 0
622 ||
id.PeekEventImpl ()->IsCancelled ())
637 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)
Set the Scheduler to be used to manage the event list.
Ptr< Scheduler > m_events
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
uint64_t m_ts
Event time stamp.
static uint32_t GetRxCount()
EventImpl * impl
Pointer to the event implementation.
#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)
Schedule an event to run at the end of the simulation, after the Stop() time or condition has been re...
#define NS_UNUSED(x)
Mark a local variable as unused.
virtual Time GetMaximumSimulationTime(void) const
Get the maximum representable simulation time.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
virtual void DoDispose(void)
Destructor implementation.
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.
uint32_t GetSystemId(void) const
virtual Time Now(void) const
Return the current simulation virtual time.
virtual void DoDispose(void)
Destructor implementation.
void Invoke(void)
Called by the simulation engine to notify the event that it is time to execute.
static void TestSendComplete()
Check for completed sends.
virtual Time GetDelayLeft(const EventId &id) const
Get the remaining time until this event will execute.
void ProcessOneEvent(void)
EventKey key
Key for sorting and ordering Events.
uint32_t m_currentContext
static void Destroy()
Deletes storage used by the parallel environment.
AttributeValue implementation for Time.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
uint32_t m_uid
Event unique id.
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...
DistributedSimulatorImpl()
virtual EventId ScheduleNow(EventImpl *event)
Schedule an event to run at the current virtual time.
void Unref(void) const
Decrement the reference count.
DestroyEvents m_destroyEvents
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
static TypeId GetTypeId(void)
virtual bool IsExpired(const EventId &id) const
Check if an event has already run or been cancelled.
Distributed simulator implementation using lookahead.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
virtual void Destroy()
Execute the events scheduled with ScheduleDestroy().
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)
Schedule a future event execution (in a different context).
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
Get the system id of this simulator.
virtual uint32_t GetContext(void) const
Get the current simulation context.
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 Remove(const EventId &id)
Remove an event from the event list.
Instantiate subclasses of ns3::Object.
virtual EventId Schedule(Time const &time, EventImpl *event)
Schedule a future event execution (in the same context).
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)
Tell the Simulator the calling event should be the last one executed.
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.
virtual void Stop(void)
Tell the Simulator the calling event should be the last one executed.
bool IsLocalFinished(void) const
virtual bool IsFinished(void) const
Check if the simulation should finish.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
static uint32_t GetSize()
uint32_t m_context
Event context.