30 #include "ns3/assert.h"
31 #include "ns3/channel.h"
32 #include "ns3/event-impl.h"
34 #include "ns3/node-container.h"
35 #include "ns3/pointer.h"
37 #include "ns3/scheduler.h"
38 #include "ns3/simulator.h"
94 static TypeId tid =
TypeId(
"ns3::DistributedSimulatorImpl")
153 if (!ev->IsCancelled())
175 for (
auto iter = c.
Begin(); iter != c.
End(); ++iter)
182 for (uint32_t i = 0; i < (*iter)->GetNDevices(); ++i)
186 if (!localNetDevice->IsPointToPoint())
198 if (
channel->GetDevice(0) == localNetDevice)
200 remoteNode = (
channel->GetDevice(1))->GetNode();
204 remoteNode = (
channel->GetDevice(0))->GetNode();
217 channel->GetAttribute(
"Delay", delay);
276 if (lookAhead >
Time(0))
283 NS_LOG_WARN(
"attempted to set lookahead to a negative time: " << lookAhead);
299 scheduler->Insert(next);
357 return TimeStep(
NextTs());
410 if (
m_pLBTS[i].GetSmallestTime() < smallestTime)
553 if (
id.GetUid() == EventId::UID::DESTROY)
571 event.
impl =
id.PeekEventImpl();
572 event.key.m_ts =
id.GetTs();
573 event.key.m_context =
id.GetContext();
574 event.key.m_uid =
id.GetUid();
576 event.impl->Cancel();
588 id.PeekEventImpl()->Cancel();
595 if (
id.GetUid() == EventId::UID::DESTROY)
597 if (
id.PeekEventImpl() ==
nullptr ||
id.PeekEventImpl()->IsCancelled())
611 return id.PeekEventImpl() ==
nullptr ||
id.GetTs() <
m_currentTs ||
613 id.PeekEventImpl()->IsCancelled();
621 return TimeStep(0x7fffffffffffffffLL);
Distributed simulator implementation using lookahead.
EventId Schedule(const Time &delay, EventImpl *event) override
Schedule a future event execution (in the same context).
uint64_t GetEventCount() const override
Get the number of events executed.
void Remove(const EventId &id) override
Remove an event from the event list.
static TypeId GetTypeId()
Register this type.
DestroyEvents m_destroyEvents
The container of events to run at Destroy()
void ScheduleWithContext(uint32_t context, const Time &delay, EventImpl *event) override
Schedule a future event execution (in a different context).
EventId ScheduleNow(EventImpl *event) override
Schedule an event to run at the current virtual time.
uint64_t NextTs() const
Get the timestep of the next event.
EventId ScheduleDestroy(EventImpl *event) override
Schedule an event to run at the end of the simulation, after the Stop() time or condition has been re...
Time m_grantedTime
End of current window.
uint32_t m_currentContext
Execution context of the current event.
Time GetMaximumSimulationTime() const override
Get the maximum representable simulation time.
LbtsMessage * m_pLBTS
Container for Lbts messages, one per rank.
uint64_t m_currentTs
Timestamp of the current event.
uint32_t GetSystemId() const override
Get the system id of this simulator.
void SetScheduler(ObjectFactory schedulerFactory) override
Set the Scheduler to be used to manage the event list.
bool IsFinished() const override
Check if the simulation should finish.
Ptr< Scheduler > m_events
The event priority queue.
Time Next() const
Get the time of the next event, as returned by NextTs().
void CalculateLookAhead()
Calculate lookahead constraint based on network latency.
uint32_t GetContext() const override
Get the current simulation context.
bool m_globalFinished
Are all parallel instances completed.
uint32_t m_uid
Next event unique id.
void Run() override
Run the simulation.
void ProcessOneEvent()
Process the next event.
DistributedSimulatorImpl()
Default constructor.
void Cancel(const EventId &id) override
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
void Stop() override
Tell the Simulator the calling event should be the last one executed.
int m_unscheduledEvents
Number of events that have been inserted but not yet scheduled, not counting the "destroy" events; th...
void Destroy() override
Execute the events scheduled with ScheduleDestroy().
Time GetDelayLeft(const EventId &id) const override
Get the remaining time until this event will execute.
uint32_t m_systemCount
MPI communicator size.
virtual void BoundLookAhead(const Time lookAhead)
Add additional bound to lookahead constraints.
bool IsExpired(const EventId &id) const override
Check if an event has already run or been cancelled.
uint64_t m_eventCount
The event count.
~DistributedSimulatorImpl() override
Destructor.
Time Now() const override
Return the current simulation virtual time.
bool IsLocalFinished() const
Check if this rank is finished.
bool m_stop
Flag calling for the end of the simulation.
static Time m_lookAhead
Current window size.
uint32_t m_currentUid
Unique id of the current event.
void DoDispose() override
Destructor implementation.
An identifier for simulation events.
void Invoke()
Called by the simulation engine to notify the event that it is time to execute.
static void ReceiveMessages()
Check for received messages complete.
static uint32_t GetRxCount()
static void TestSendComplete()
Check for completed sends.
static uint32_t GetTxCount()
Structure used for all-reduce LBTS computation.
uint32_t m_txCount
Count of transmitted messages.
uint32_t m_rxCount
Count of received messages.
uint32_t GetTxCount() const
uint32_t m_myId
System Id of the rank sending this LBTS.
Time m_smallestTime
Earliest next event timestamp.
uint32_t GetRxCount() const
bool m_isFinished
true when this rank has no more events.
static MPI_Comm GetCommunicator()
Return the communicator used to run ns-3.
static void Destroy()
Deletes storage used by the parallel environment.
static uint32_t GetSystemId()
Get the id number of this rank.
static uint32_t GetSize()
Get the number of ranks used by ns-3.
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
static NodeContainer GetGlobal()
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
uint32_t GetSystemId() const
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
virtual void DoDispose()
Destructor implementation.
Smart pointer class similar to boost::intrusive_ptr.
void Unref() const
Decrement the reference count.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
@ NO_CONTEXT
Flag for events not associated with any particular context.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
The SimulatorImpl base class.
virtual void PreEventHook(const EventId &id)
Hook called before processing each event.
Simulation virtual time values and global simulation resolution.
bool IsPositive() const
Exactly equivalent to t >= 0.
int64_t GetInteger() const
Get the raw time value, in the current resolution unit.
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
int64_t GetTimeStep() const
Get the raw time value, in the current resolution unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Declaration of classes ns3::LbtsMessage and ns3::DistributedSimulatorImpl.
Declaration of classes ns3::SentBuffer and ns3::GrantedTimeWindowMpiInterface.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Declaration of class ns3::MpiInterface.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
EventKey key
Key for sorting and ordering Events.
EventImpl * impl
Pointer to the event implementation.
uint32_t m_context
Event context.
uint64_t m_ts
Event time stamp.
uint32_t m_uid
Event unique id.