A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
distributed-simulator-impl.h
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:
39  LbtsMessage ()
40  : m_txCount (0),
41  m_rxCount (0),
42  m_myId (0)
43  {
44  }
45 
52  LbtsMessage (uint32_t rxc, uint32_t txc, uint32_t id, const Time& t)
53  : m_txCount (txc),
54  m_rxCount (rxc),
55  m_myId (id),
56  m_smallestTime (t)
57  {
58  }
59 
60  ~LbtsMessage ();
61 
69  uint32_t GetTxCount ();
73  uint32_t GetRxCount ();
77  uint32_t GetMyId ();
78 
79 private:
80  uint32_t m_txCount;
81  uint32_t m_rxCount;
82  uint32_t m_myId;
83  Time m_smallestTime;
84 };
85 
92 {
93 public:
94  static TypeId GetTypeId (void);
95 
98 
99  // virtual from SimulatorImpl
100  virtual void Destroy ();
101  virtual bool IsFinished (void) const;
102  virtual void Stop (void);
103  virtual void Stop (Time const &time);
104  virtual EventId Schedule (Time const &time, EventImpl *event);
105  virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event);
106  virtual EventId ScheduleNow (EventImpl *event);
107  virtual EventId ScheduleDestroy (EventImpl *event);
108  virtual void Remove (const EventId &ev);
109  virtual void Cancel (const EventId &ev);
110  virtual bool IsExpired (const EventId &ev) const;
111  virtual void Run (void);
112  virtual Time Now (void) const;
113  virtual Time GetDelayLeft (const EventId &id) const;
114  virtual Time GetMaximumSimulationTime (void) const;
115  virtual void SetScheduler (ObjectFactory schedulerFactory);
116  virtual uint32_t GetSystemId (void) const;
117  virtual uint32_t GetContext (void) const;
118 
119 private:
120  virtual void DoDispose (void);
121  void CalculateLookAhead (void);
122 
123  void ProcessOneEvent (void);
124  uint64_t NextTs (void) const;
125  Time Next (void) const;
126  typedef std::list<EventId> DestroyEvents;
127 
128  DestroyEvents m_destroyEvents;
129  bool m_stop;
130  Ptr<Scheduler> m_events;
131  uint32_t m_uid;
132  uint32_t m_currentUid;
133  uint64_t m_currentTs;
134  uint32_t m_currentContext;
135  // number of events that have been inserted but not yet scheduled,
136  // not counting the "destroy" events; this is used for validation
137  int m_unscheduledEvents;
138 
139  LbtsMessage* m_pLBTS; // Allocated once we know how many systems
140  uint32_t m_myId; // MPI Rank
141  uint32_t m_systemCount; // MPI Size
142  Time m_grantedTime; // Last LBTS
143  static Time m_lookAhead; // Lookahead value
144 
145 };
146 
147 } // namespace ns3
148 
149 #endif /* DISTRIBUTED_SIMULATOR_IMPL_H */
keep track of time unit.
Definition: nstime.h:149
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
LbtsMessage(uint32_t rxc, uint32_t txc, uint32_t id, const Time &t)
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
a unique identifier for an interface.
Definition: type-id.h:44
virtual bool IsExpired(const EventId &ev) const