A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
distributed-simulator-impl.h
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation;
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 *
15 * Author: George Riley <riley@ece.gatech.edu>
16 *
17 */
18
25#ifndef NS3_DISTRIBUTED_SIMULATOR_IMPL_H
26#define NS3_DISTRIBUTED_SIMULATOR_IMPL_H
27
28#include "ns3/event-impl.h"
29#include "ns3/ptr.h"
30#include "ns3/scheduler.h"
31#include "ns3/simulator-impl.h"
32
33#include <list>
34
35namespace ns3
36{
37
44{
45 public:
47 : m_txCount(0),
48 m_rxCount(0),
49 m_myId(0),
50 m_isFinished(false)
51 {
52 }
53
61 LbtsMessage(uint32_t rxc, uint32_t txc, uint32_t id, bool isFinished, const Time& t)
62 : m_txCount(txc),
63 m_rxCount(rxc),
64 m_myId(id),
66 m_isFinished(isFinished)
67 {
68 }
69
71
79 uint32_t GetTxCount() const;
83 uint32_t GetRxCount() const;
87 uint32_t GetMyId() const;
91 bool IsFinished() const;
92
93 private:
99};
100
108{
109 public:
114 static TypeId GetTypeId();
115
119 ~DistributedSimulatorImpl() override;
120
121 // virtual from SimulatorImpl
122 void Destroy() override;
123 bool IsFinished() const override;
124 void Stop() override;
125 void Stop(const Time& delay) override;
126 EventId Schedule(const Time& delay, EventImpl* event) override;
127 void ScheduleWithContext(uint32_t context, const Time& delay, EventImpl* event) override;
128 EventId ScheduleNow(EventImpl* event) override;
129 EventId ScheduleDestroy(EventImpl* event) override;
130 void Remove(const EventId& id) override;
131 void Cancel(const EventId& id) override;
132 bool IsExpired(const EventId& id) const override;
133 void Run() override;
134 Time Now() const override;
135 Time GetDelayLeft(const EventId& id) const override;
136 Time GetMaximumSimulationTime() const override;
137 void SetScheduler(ObjectFactory schedulerFactory) override;
138 uint32_t GetSystemId() const override;
139 uint32_t GetContext() const override;
140 uint64_t GetEventCount() const override;
141
155 virtual void BoundLookAhead(const Time lookAhead);
156
157 private:
158 // Inherited from Object
159 void DoDispose() override;
160
169 void CalculateLookAhead();
176 bool IsLocalFinished() const;
177
179 void ProcessOneEvent();
187 uint64_t NextTs() const;
193 Time Next() const;
194
196 typedef std::list<EventId> DestroyEvents;
197
201 bool m_stop;
206
212 uint64_t m_currentTs;
216 uint64_t m_eventCount;
222
232};
233
234} // namespace ns3
235
236#endif /* NS3_DISTRIBUTED_SIMULATOR_IMPL_H */
Distributed simulator implementation using lookahead.
EventId Schedule(const Time &delay, EventImpl *event) override
Schedule a future event execution (in the same context).
uint64_t GetEventCount() const override
Get the number of events executed.
void Remove(const EventId &id) override
Remove an event from the event list.
static TypeId GetTypeId()
Register this type.
DestroyEvents m_destroyEvents
The container of events to run at Destroy()
void ScheduleWithContext(uint32_t context, const Time &delay, EventImpl *event) override
Schedule a future event execution (in a different context).
EventId ScheduleNow(EventImpl *event) override
Schedule an event to run at the current virtual time.
uint64_t NextTs() const
Get the timestep of the next event.
EventId ScheduleDestroy(EventImpl *event) override
Schedule an event to run at the end of the simulation, after the Stop() time or condition has been re...
Time m_grantedTime
End of current window.
uint32_t m_currentContext
Execution context of the current event.
Time GetMaximumSimulationTime() const override
Get the maximum representable simulation time.
LbtsMessage * m_pLBTS
Container for Lbts messages, one per rank.
uint64_t m_currentTs
Timestamp of the current event.
uint32_t GetSystemId() const override
Get the system id of this simulator.
void SetScheduler(ObjectFactory schedulerFactory) override
Set the Scheduler to be used to manage the event list.
bool IsFinished() const override
Check if the simulation should finish.
Ptr< Scheduler > m_events
The event priority queue.
Time Next() const
Get the time of the next event, as returned by NextTs().
void CalculateLookAhead()
Calculate lookahead constraint based on network latency.
uint32_t GetContext() const override
Get the current simulation context.
bool m_globalFinished
Are all parallel instances completed.
uint32_t m_uid
Next event unique id.
void Run() override
Run the simulation.
void ProcessOneEvent()
Process the next event.
std::list< EventId > DestroyEvents
Container type for the events to run at Simulator::Destroy().
void Cancel(const EventId &id) override
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
void Stop() override
Tell the Simulator the calling event should be the last one executed.
int m_unscheduledEvents
Number of events that have been inserted but not yet scheduled, not counting the "destroy" events; th...
void Destroy() override
Execute the events scheduled with ScheduleDestroy().
Time GetDelayLeft(const EventId &id) const override
Get the remaining time until this event will execute.
uint32_t m_systemCount
MPI communicator size.
virtual void BoundLookAhead(const Time lookAhead)
Add additional bound to lookahead constraints.
bool IsExpired(const EventId &id) const override
Check if an event has already run or been cancelled.
Time Now() const override
Return the current simulation virtual time.
bool IsLocalFinished() const
Check if this rank is finished.
bool m_stop
Flag calling for the end of the simulation.
static Time m_lookAhead
Current window size.
uint32_t m_currentUid
Unique id of the current event.
void DoDispose() override
Destructor implementation.
An identifier for simulation events.
Definition: event-id.h:55
A simulation event.
Definition: event-impl.h:46
Structure used for all-reduce LBTS computation.
uint32_t m_txCount
Count of transmitted messages.
uint32_t m_rxCount
Count of received messages.
uint32_t m_myId
System Id of the rank sending this LBTS.
Time m_smallestTime
Earliest next event timestamp.
bool m_isFinished
true when this rank has no more events.
LbtsMessage(uint32_t rxc, uint32_t txc, uint32_t id, bool isFinished, const Time &t)
Instantiate subclasses of ns3::Object.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
The SimulatorImpl base class.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.