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 #ifndef DISTRIBUTED_SIMULATOR_IMPL_H
20 #define DISTRIBUTED_SIMULATOR_IMPL_H
21 
22 #include "ns3/simulator-impl.h"
23 #include "ns3/scheduler.h"
24 #include "ns3/event-impl.h"
25 #include "ns3/ptr.h"
26 
27 #include <list>
28 
29 namespace ns3 {
30 
37 {
38 public:
40  : m_txCount (0),
41  m_rxCount (0),
42  m_myId (0),
43  m_isFinished (false)
44  {
45  }
46 
53  LbtsMessage (uint32_t rxc, uint32_t txc, uint32_t id, bool isFinished, const Time& t)
54  : m_txCount (txc),
55  m_rxCount (rxc),
56  m_myId (id),
57  m_smallestTime (t),
58  m_isFinished (isFinished)
59  {
60  }
61 
62  ~LbtsMessage ();
63 
71  uint32_t GetTxCount ();
75  uint32_t GetRxCount ();
79  uint32_t GetMyId ();
80 
81  bool IsFinished ();
82 
83 private:
84  uint32_t m_txCount;
85  uint32_t m_rxCount;
86  uint32_t m_myId;
89 };
90 
98 {
99 public:
100  static TypeId GetTypeId (void);
101 
104 
105  // virtual from SimulatorImpl
106  virtual void Destroy ();
107  virtual bool IsFinished (void) const;
108  virtual void Stop (void);
109  virtual void Stop (Time const &time);
110  virtual EventId Schedule (Time const &time, EventImpl *event);
111  virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event);
112  virtual EventId ScheduleNow (EventImpl *event);
113  virtual EventId ScheduleDestroy (EventImpl *event);
114  virtual void Remove (const EventId &ev);
115  virtual void Cancel (const EventId &ev);
116  virtual bool IsExpired (const EventId &ev) const;
117  virtual void Run (void);
118  virtual Time Now (void) const;
119  virtual Time GetDelayLeft (const EventId &id) const;
120  virtual Time GetMaximumSimulationTime (void) const;
121  virtual void SetScheduler (ObjectFactory schedulerFactory);
122  virtual uint32_t GetSystemId (void) const;
123  virtual uint32_t GetContext (void) const;
124 
125 private:
126  virtual void DoDispose (void);
127  void CalculateLookAhead (void);
128  bool IsLocalFinished (void) const;
129 
130  void ProcessOneEvent (void);
131  uint64_t NextTs (void) const;
132  Time Next (void) const;
133  typedef std::list<EventId> DestroyEvents;
134 
136  bool m_stop;
137  bool m_globalFinished; // Are all parallel instances completed.
139  uint32_t m_uid;
140  uint32_t m_currentUid;
141  uint64_t m_currentTs;
143  // number of events that have been inserted but not yet scheduled,
144  // not counting the "destroy" events; this is used for validation
146 
147  LbtsMessage* m_pLBTS; // Allocated once we know how many systems
148  uint32_t m_myId; // MPI Rank
149  uint32_t m_systemCount; // MPI Size
150  Time m_grantedTime; // Last LBTS
151  static Time m_lookAhead; // Lookahead value
152 
153 };
154 
155 } // namespace ns3
156 
157 #endif /* DISTRIBUTED_SIMULATOR_IMPL_H */
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
virtual void SetScheduler(ObjectFactory schedulerFactory)
virtual EventId ScheduleDestroy(EventImpl *event)
virtual Time GetMaximumSimulationTime(void) const
virtual Time GetDelayLeft(const EventId &id) const
virtual EventId ScheduleNow(EventImpl *event)
virtual void Remove(const EventId &ev)
distributed simulator implementation using lookahead
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)
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)
a unique identifier for an interface.
Definition: type-id.h:49
virtual bool IsExpired(const EventId &ev) const