A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
null-message-simulator-impl.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright 2013. Lawrence Livermore National Security, LLC.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Steven Smith <smith84@llnl.gov>
19  *
20  */
21 
22 #ifndef NULLMESSAGE_SIMULATOR_IMPL_H
23 #define NULLMESSAGE_SIMULATOR_IMPL_H
24 
25 #include <ns3/simulator-impl.h>
26 #include <ns3/scheduler.h>
27 #include <ns3/event-impl.h>
28 #include <ns3/ptr.h>
29 
30 #include <list>
31 #include <iostream>
32 #include <fstream>
33 
34 namespace ns3 {
35 
36 class NullMessageEvent;
37 class NullMessageMpiInterface;
38 class RemoteChannelBundle;
39 
46 {
47 public:
48  static TypeId GetTypeId (void);
49 
51 
53 
54  // virtual from SimulatorImpl
55  virtual void Destroy ();
56  virtual bool IsFinished (void) const;
57  virtual void Stop (void);
58  virtual void Stop (Time const &time);
59  virtual EventId Schedule (Time const &time, EventImpl *event);
60  virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event);
61  virtual EventId ScheduleNow (EventImpl *event);
62  virtual EventId ScheduleDestroy (EventImpl *event);
63  virtual void Remove (const EventId &ev);
64  virtual void Cancel (const EventId &ev);
65  virtual bool IsExpired (const EventId &ev) const;
66  virtual void Run (void);
67  virtual void RunOneEvent (void);
68  virtual Time Now (void) const;
69  virtual Time GetDelayLeft (const EventId &id) const;
70  virtual Time GetMaximumSimulationTime (void) const;
71  virtual void SetScheduler (ObjectFactory schedulerFactory);
72  virtual uint32_t GetSystemId (void) const;
73  virtual uint32_t GetContext (void) const;
74 
80  static NullMessageSimulatorImpl * GetInstance (void);
81 
82 private:
83  friend class NullMessageEvent;
86 
91 
96 
97  virtual void DoDispose (void);
98 
103  void CalculateLookAhead (void);
104 
108  void ProcessOneEvent (void);
109 
113  Time Next (void) const;
114 
118  void CalculateSafeTime (void);
119 
125  Time GetSafeTime (void);
126 
133 
141 
148  void RescheduleNullMessageEvent (uint32_t nodeSysId);
149 
159  Time CalculateGuaranteeTime (uint32_t systemId);
160 
169 
170  typedef std::list<EventId> DestroyEvents;
171 
173  bool m_stop;
175  uint32_t m_uid;
176  uint32_t m_currentUid;
177  uint64_t m_currentTs;
179  // number of events that have been inserted but not yet scheduled,
180  // not counting the "destroy" events; this is used for validation
182 
183  uint32_t m_myId; // MPI Rank
184  uint32_t m_systemCount; // MPI Size
185 
186  /*
187  * The time for which it is safe for this task to execute events
188  * without danger of out-of-order events.
189  */
191 
192  /*
193  * Null Message performance tuning parameter. Controls when Null
194  * messages are sent. When value is 1 the minimum number of Null
195  * messages are sent conserving bandwidth. The delay in arrival of
196  * lookahead information is the greatest resulting in maximum
197  * unnecessary blocking of the receiver. When the value is near 0
198  * Null Messages are sent with high frequency, costing more
199  * bandwidth and Null Message processing time, but there is minimum
200  * unnecessary block of the receiver.
201  */
203 
204  /*
205  * Singleton instance.
206  */
208 };
209 
210 } // namespace ns3
211 
212 #endif /* NULLMESSAGE_SIMULATOR_IMPL_H */
Time CalculateGuaranteeTime(uint32_t systemId)
virtual Time GetMaximumSimulationTime(void) const
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
virtual void Cancel(const EventId &ev)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
virtual void Destroy()
This method is typically invoked at the end of a simulation to avoid false-positive reports by a leak...
void HandleArrivingMessagesNonBlocking(void)
Non blocking receive of pending messages.
virtual EventId ScheduleNow(EventImpl *event)
virtual EventId Schedule(Time const &time, EventImpl *event)
void ProcessOneEvent(void)
Process the next event on the queue.
void RescheduleNullMessageEvent(Ptr< RemoteChannelBundle > bundle)
Collection of NS3 channels between local and remote nodes.
virtual EventId ScheduleDestroy(EventImpl *event)
void CalculateSafeTime(void)
Calculate the SafeTime.
static NullMessageSimulatorImpl * GetInstance(void)
virtual uint32_t GetSystemId(void) const
virtual bool IsFinished(void) const
If there are no more events lefts to be scheduled, or if simulation time has already reached the "sto...
Time GetSafeTime(void)
Get the current SafeTime; the maximum time that events can be processed based on information received...
static NullMessageSimulatorImpl * g_instance
virtual void Run(void)
Run the simulation until one of:
void CalculateLookAhead(void)
Calculate the look ahead allowable for this MPI task.
virtual uint32_t GetContext(void) const
void HandleArrivingMessagesBlocking(void)
Blocking receive of arriving messages.
virtual Time GetDelayLeft(const EventId &id) const
virtual void ScheduleWithContext(uint32_t context, Time const &time, EventImpl *event)
Simulator implementation using MPI and a Null Message algorithm.
instantiate subclasses of ns3::Object.
a simulation event
Definition: event-impl.h:39
an identifier for simulation events.
Definition: event-id.h:46
virtual void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::Run method bef...
virtual Time Now(void) const
Return the "current simulation time".
void ScheduleNullMessageEvent(Ptr< RemoteChannelBundle > bundle)
void NullMessageEventHandler(RemoteChannelBundle *bundle)
virtual bool IsExpired(const EventId &ev) const
This method has O(1) complexity.
virtual void Remove(const EventId &ev)
Remove an event from the event list.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
a unique identifier for an interface.
Definition: type-id.h:49
virtual void SetScheduler(ObjectFactory schedulerFactory)
Doxygen introspection did not find any typical Config paths.
Interface between ns-3 and MPI for the Null Message distributed simulation implementation.