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");
154 if (!ev->IsCancelled ())
190 for (uint32_t i = 0; i < (*iter)->GetNDevices (); ++i)
194 if (!localNetDevice->IsPointToPoint ())
206 if (
channel->GetDevice (0) == localNetDevice)
208 remoteNode = (
channel->GetDevice (1))->GetNode ();
212 remoteNode = (
channel->GetDevice (0))->GetNode ();
225 channel->GetAttribute (
"Delay", delay);
266 MPI_Allreduce (&sendbuf, &recvbuf, 1, MPI_LONG, MPI_MAX, MPI_COMM_WORLD);
281 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
288 if (lookAhead >
Time (0))
295 NS_LOG_WARN (
"attempted to set look ahead negative: " << lookAhead);
311 scheduler->Insert (next);
413 if (
m_pLBTS[i].GetSmallestTime () < smallestTime)
450 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
489 ev.
key.
m_ts =
static_cast<uint64_t
> (tAbsolute.GetTimeStep ());
506 ev.key.m_context = context;
507 ev.key.m_uid =
m_uid;
562 if (
id.GetUid () == 2)
580 event.
impl =
id.PeekEventImpl ();
581 event.key.m_ts =
id.GetTs ();
582 event.key.m_context =
id.GetContext ();
583 event.key.m_uid =
id.GetUid ();
585 event.impl->Cancel ();
587 event.impl->Unref ();
597 id.PeekEventImpl ()->Cancel ();
604 if (
id.GetUid () == 2)
606 if (
id.PeekEventImpl () == 0
607 ||
id.PeekEventImpl ()->IsCancelled ())
621 if (
id.PeekEventImpl () == 0
625 ||
id.PeekEventImpl ()->IsCancelled ())
640 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.
virtual uint32_t GetContext(void) const
Get the current simulation context.
Ptr< Scheduler > m_events
void Unref(void) const
Decrement the reference count.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
int64_t GetInteger(void) const
Get the raw time value, in the current resolution unit.
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).
bool IsLocalFinished(void) const
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.
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)
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
uint64_t m_eventCount
The event count.
virtual Time GetDelayLeft(const EventId &id) const
Get the remaining time until this event will execute.
virtual void DoDispose(void)
Destructor implementation.
void Invoke(void)
Called by the simulation engine to notify the event that it is time to execute.
virtual Time GetMaximumSimulationTime(void) const
Get the maximum representable simulation time.
static void TestSendComplete()
Check for completed sends.
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.
virtual bool IsFinished(void) const
Check if the simulation should finish.
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.
virtual uint64_t GetEventCount(void) const
Get the number of events executed.
DestroyEvents m_destroyEvents
virtual bool IsExpired(const EventId &id) const
Check if an event has already run or been cancelled.
static TypeId GetTypeId(void)
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 uint32_t GetSystemId(void) const
Get the system id of this simulator.
virtual void Destroy()
Execute the events scheduled with ScheduleDestroy().
uint32_t GetSystemId(void) const
Time TimeStep(uint64_t ts)
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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.
Flag for events not associated with any particular context.
virtual void ScheduleWithContext(uint32_t context, Time const &delay, EventImpl *event)
Schedule a future event execution (in a different context).
virtual Time Now(void) const
Return the current simulation virtual time.
virtual void Run(void)
Run the simulation.
virtual void Stop(void)
Tell the Simulator the calling event should be the last one executed.
a unique identifier for an interface.
uint64_t NextTs(void) const
TypeId SetParent(TypeId tid)
Set the parent TypeId.
static uint32_t GetSize()
uint32_t m_context
Event context.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
The SimulatorImpl base class.
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.