A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
distributed-simulator-impl.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * Author: George Riley <riley@ece.gatech.edu>
17  *
18  */
19 
20 #ifndef NS3_DISTRIBUTED_SIMULATOR_IMPL_H
21 #define NS3_DISTRIBUTED_SIMULATOR_IMPL_H
22 
23 #include "ns3/simulator-impl.h"
24 #include "ns3/scheduler.h"
25 #include "ns3/event-impl.h"
26 #include "ns3/ptr.h"
27 
28 #include <list>
29 
30 namespace ns3 {
31 
38 {
39 public:
41  : m_txCount (0),
42  m_rxCount (0),
43  m_myId (0),
44  m_isFinished (false)
45  {
46  }
47 
55  LbtsMessage (uint32_t rxc, uint32_t txc, uint32_t id, bool isFinished, const Time& t)
56  : m_txCount (txc),
57  m_rxCount (rxc),
58  m_myId (id),
59  m_smallestTime (t),
60  m_isFinished (isFinished)
61  {
62  }
63 
64  ~LbtsMessage ();
65 
73  uint32_t GetTxCount ();
77  uint32_t GetRxCount ();
81  uint32_t GetMyId ();
85  bool IsFinished ();
86 
87 private:
88  uint32_t m_txCount;
89  uint32_t m_rxCount;
90  uint32_t m_myId;
93 };
94 
102 {
103 public:
104  static TypeId GetTypeId (void);
105 
108 
109  // virtual from SimulatorImpl
110  virtual void Destroy ();
111  virtual bool IsFinished (void) const;
112  virtual void Stop (void);
113  virtual void Stop (Time const &time);
114  virtual EventId Schedule (Time const &time, EventImpl *event);
115  virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event);
116  virtual EventId ScheduleNow (EventImpl *event);
117  virtual EventId ScheduleDestroy (EventImpl *event);
118  virtual void Remove (const EventId &ev);
119  virtual void Cancel (const EventId &ev);
120  virtual bool IsExpired (const EventId &ev) const;
121  virtual void Run (void);
122  virtual Time Now (void) const;
123  virtual Time GetDelayLeft (const EventId &id) const;
124  virtual Time GetMaximumSimulationTime (void) const;
125  virtual void SetScheduler (ObjectFactory schedulerFactory);
126  virtual uint32_t GetSystemId (void) const;
127  virtual uint32_t GetContext (void) const;
128 
129 private:
130  virtual void DoDispose (void);
131  void CalculateLookAhead (void);
132  bool IsLocalFinished (void) const;
133 
134  void ProcessOneEvent (void);
135  uint64_t NextTs (void) const;
136  Time Next (void) const;
137  typedef std::list<EventId> DestroyEvents;
138 
140  bool m_stop;
141  bool m_globalFinished; // Are all parallel instances completed.
143  uint32_t m_uid;
144  uint32_t m_currentUid;
145  uint64_t m_currentTs;
147  // number of events that have been inserted but not yet scheduled,
148  // not counting the "destroy" events; this is used for validation
150 
151  LbtsMessage* m_pLBTS; // Allocated once we know how many systems
152  uint32_t m_myId; // MPI Rank
153  uint32_t m_systemCount; // MPI Size
154  Time m_grantedTime; // Last LBTS
155  static Time m_lookAhead; // Lookahead value
156 
157 };
158 
159 } // namespace ns3
160 
161 #endif /* NS3_DISTRIBUTED_SIMULATOR_IMPL_H */
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 SetScheduler(ObjectFactory schedulerFactory)
virtual EventId ScheduleDestroy(EventImpl *event)
virtual Time GetMaximumSimulationTime(void) const
virtual Time Now(void) const
Return the "current simulation time".
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual Time GetDelayLeft(const EventId &id) const
virtual EventId ScheduleNow(EventImpl *event)
virtual void Remove(const EventId &ev)
Remove an event from the event list.
Distributed simulator implementation using lookahead.
virtual void Destroy()
This method is typically invoked at the end of a simulation to avoid false-positive reports by a leak...
virtual void ScheduleWithContext(uint32_t context, Time const &time, EventImpl *event)
virtual uint32_t GetSystemId(void) const
virtual uint32_t GetContext(void) const
Structure used for all-reduce LBTS computation.
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...
instantiate subclasses of ns3::Object.
a simulation event
Definition: event-impl.h:39
virtual EventId Schedule(Time const &time, EventImpl *event)
an identifier for simulation events.
Definition: event-id.h:46
LbtsMessage(uint32_t rxc, uint32_t txc, uint32_t id, bool isFinished, const Time &t)
virtual void Run(void)
Run the simulation until one of:
virtual void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::Run method bef...
virtual bool IsFinished(void) const
If there are no more events lefts to be scheduled, or if simulation time has already reached the "sto...
a unique identifier for an interface.
Definition: type-id.h:49
Doxygen introspection did not find any typical Config paths.
virtual bool IsExpired(const EventId &ev) const
This method has O(1) complexity.