29 #include <ns3/simulator.h> 30 #include <ns3/scheduler.h> 31 #include <ns3/event-impl.h> 32 #include <ns3/channel.h> 33 #include <ns3/node-container.h> 34 #include <ns3/double.h> 36 #include <ns3/pointer.h> 37 #include <ns3/assert.h> 56 static TypeId tid =
TypeId (
"ns3::NullMessageSimulatorImpl")
60 .AddAttribute (
"SchedulerTune",
"Null Message scheduler tuning parameter",
63 MakeDoubleChecker<double> (0.01,1.0))
124 if (!ev->IsCancelled ())
139 int num_local_nodes = 0;
153 for (uint32_t i = 0; i < (*iter)->GetNDevices (); ++i)
157 if (!localNetDevice->IsPointToPoint ())
169 if (
channel->GetDevice (0) == localNetDevice)
171 remoteNode = (
channel->GetDevice (1))->GetNode ();
175 remoteNode = (
channel->GetDevice (0))->GetNode ();
188 if (!remoteChannelBundle)
194 channel->GetAttribute (
"Delay", delay);
195 remoteChannelBundle->AddChannel (
channel, delay.
Get () );
219 scheduler->Insert (next);
258 return TimeStep (ev.key.m_ts);
410 ev.
key.
m_ts =
static_cast<uint64_t
> (tAbsolute.GetTimeStep ());
431 ev.
key.
m_ts = tAbsolute.GetTimeStep ();
488 if (
id.GetUid () == 2)
506 event.
impl =
id.PeekEventImpl ();
507 event.key.m_ts =
id.GetTs ();
508 event.key.m_context =
id.GetContext ();
509 event.key.m_uid =
id.GetUid ();
511 event.impl->Cancel ();
513 event.impl->Unref ();
523 id.PeekEventImpl ()->Cancel ();
530 if (
id.GetUid () == 2)
532 if (
id.PeekEventImpl () == 0
533 ||
id.PeekEventImpl ()->IsCancelled ())
547 if (
id.PeekEventImpl () == 0
551 ||
id.PeekEventImpl ()->IsCancelled ())
566 return TimeStep (0x7fffffffffffffffLL);
Time CalculateGuaranteeTime(uint32_t systemId)
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
virtual void Remove(const EventId &id)
Remove an event from the event list.
Simulation virtual time values and global simulation resolution.
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 "...
void Unref(void) const
Decrement the reference count.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
virtual void Destroy()
Execute the events scheduled with ScheduleDestroy().
uint64_t m_ts
Event time stamp.
void HandleArrivingMessagesNonBlocking(void)
Non blocking receive of pending messages.
virtual EventId ScheduleNow(EventImpl *event)
Schedule an event to run at the current virtual time.
Ptr< Scheduler > m_events
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...
U * PeekPointer(const Ptr< U > &p)
~NullMessageSimulatorImpl()
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual bool IsFinished(void) const
Check if the simulation should finish.
static void ReceiveMessagesNonBlocking()
Non-blocking check for received messages complete.
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
void ProcessOneEvent(void)
Process the next event on the queue.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
void RescheduleNullMessageEvent(Ptr< RemoteChannelBundle > bundle)
virtual void DoDispose(void)
Destructor implementation.
Collection of NS3 channels between local and remote nodes.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
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...
virtual uint32_t GetContext(void) const
Get the current simulation context.
void CalculateSafeTime(void)
Calculate the SafeTime.
void Invoke(void)
Called by the simulation engine to notify the event that it is time to execute.
static NullMessageSimulatorImpl * GetInstance(void)
static void TestSendComplete()
Check for completed sends.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
static Time GetSafeTime(void)
EventKey key
Key for sorting and ordering Events.
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.
static void SendNullMessage(const Time &guaranteeUpdate, Ptr< RemoteChannelBundle > bundle)
Send a Null Message to across the specified bundle.
virtual void RunOneEvent(void)
static void InitializeNullMessageEvents(void)
Setup initial Null Message events for every RemoteChannelBundle.
DestroyEvents m_destroyEvents
Time GetSafeTime(void)
Get the current SafeTime; the maximum time that events can be processed based on information received...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
virtual uint64_t GetEventCount(void) const
Get the number of events executed.
static void Destroy(void)
Destroy the singleton.
virtual void Run(void)
Run the simulation.
static NullMessageSimulatorImpl * g_instance
uint64_t m_eventCount
The event count.
virtual bool IsExpired(const EventId &id) const
Check if an event has already run or been cancelled.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void CalculateLookAhead(void)
Calculate the look ahead allowable for this MPI task.
keep track of a set of node pointers.
static void ReceiveMessagesBlocking()
Blocking message receive.
virtual void ScheduleWithContext(uint32_t context, Time const &delay, EventImpl *event)
Schedule a future event execution (in a different context).
uint32_t GetSystemId(void) const
static Ptr< RemoteChannelBundle > Find(uint32_t systemId)
void HandleArrivingMessagesBlocking(void)
Blocking receive of arriving messages.
virtual Time Now(void) const
Return the current simulation virtual time.
NullMessageSimulatorImpl()
static Ptr< RemoteChannelBundle > Add(uint32_t systemId)
Add RemoteChannelBundle from this task to MPI task on other side of the link.
Simulator implementation using MPI and a Null Message algorithm.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static NodeContainer GetGlobal(void)
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
Instantiate subclasses of ns3::Object.
virtual uint32_t GetSystemId(void) const
Get the system id of this simulator.
An identifier for simulation events.
static uint32_t GetSystemId()
virtual Time GetMaximumSimulationTime(void) const
Get the maximum representable simulation time.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
virtual void Stop(void)
Tell the Simulator the calling event should be the last one executed.
uint32_t m_currentContext
Time Seconds(double value)
Construct a Time in the indicated unit.
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...
void ScheduleNullMessageEvent(Ptr< RemoteChannelBundle > bundle)
Flag for events not associated with any particular context.
void NullMessageEventHandler(RemoteChannelBundle *bundle)
virtual EventId Schedule(Time const &delay, EventImpl *event)
Schedule a future event execution (in the same context).
virtual void DoDispose(void)
Destructor implementation.
static void InitializeSendReceiveBuffers(void)
Initialize send and receive buffers.
Time GetDelay(void) const
This class can be used to hold variables of floating point type such as 'double' or 'float'...
a unique identifier for an interface.
virtual void SetScheduler(ObjectFactory schedulerFactory)
Set the Scheduler to be used to manage the event list.
virtual Time GetDelayLeft(const EventId &id) const
Get the remaining time until this event will execute.
static TypeId GetTypeId(void)
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.