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);
411 if (
m_pLBTS[i].GetSmallestTime () < smallestTime)
448 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
487 ev.
key.
m_ts =
static_cast<uint64_t
> (tAbsolute.GetTimeStep ());
504 ev.key.m_context = context;
505 ev.key.m_uid =
m_uid;
560 if (
id.GetUid () == 2)
578 event.
impl =
id.PeekEventImpl ();
579 event.key.m_ts =
id.GetTs ();
580 event.key.m_context =
id.GetContext ();
581 event.key.m_uid =
id.GetUid ();
583 event.impl->Cancel ();
585 event.impl->Unref ();
595 id.PeekEventImpl ()->Cancel ();
602 if (
id.GetUid () == 2)
604 if (
id.PeekEventImpl () == 0
605 ||
id.PeekEventImpl ()->IsCancelled ())
619 if (
id.PeekEventImpl () == 0
623 ||
id.PeekEventImpl ()->IsCancelled ())
638 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()
virtual EventId Schedule(Time const &delay, EventImpl *event)
Schedule a future event execution (in the same context).
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.
static uint32_t GetTxCount()
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
virtual void DoDispose(void)
Destructor implementation.
virtual void SetMaximumLookAhead(const Time lookAhead)
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)
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
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
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.
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
Time TimeStep(uint64_t ts)
uint64_t NextTs(void) const
int64_t GetInteger(void) const
Get the raw time value, in the current resolution unit.
Flag for events not associated with any particular context.
virtual uint32_t GetSystemId(void) const
Get the system id of this simulator.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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.
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.
virtual void ScheduleWithContext(uint32_t context, Time const &delay, EventImpl *event)
Schedule a future event execution (in a different context).
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)
Set the parent TypeId.
static uint32_t GetSize()
uint32_t m_context
Event context.
The SimulatorImpl base class.