LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2005,2006 INRIA | 3 * Copyright (c) 2005,2006 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 #include "ns3/simulator-impl.h" | 24 #include "ns3/simulator-impl.h" |
25 #include "ns3/scheduler.h" | 25 #include "ns3/scheduler.h" |
26 #include "ns3/event-impl.h" | 26 #include "ns3/event-impl.h" |
27 #include "ns3/ptr.h" | 27 #include "ns3/ptr.h" |
28 | 28 |
29 #include <list> | 29 #include <list> |
30 | 30 |
31 namespace ns3 { | 31 namespace ns3 { |
32 | 32 |
33 // Structure used for all-reduce LBTS computation | 33 // Structure used for all-reduce LBTS computation |
34 class LbtsMessage | 34 class LbtsMessage |
35 { | 35 { |
36 public: | 36 public: |
37 LbtsMessage() | 37 LbtsMessage () |
38 : m_txCount(0), m_rxCount(0), m_myId(0) | 38 : m_txCount (0), |
39 {} | 39 m_rxCount (0), |
40 ·· | 40 m_myId (0) |
41 LbtsMessage(uint32_t rxc, uint32_t txc, uint32_t id, const Time& t) | 41 { |
42 : m_txCount(txc), m_rxCount(rxc), m_myId(id), m_smallestTime(t) | 42 } |
43 {} | 43 |
| 44 LbtsMessage (uint32_t rxc, uint32_t txc, uint32_t id, const Time& t) |
| 45 : m_txCount (txc), |
| 46 m_rxCount (rxc), |
| 47 m_myId (id), |
| 48 m_smallestTime (t) |
| 49 { |
| 50 } |
44 | 51 |
45 ~LbtsMessage (); | 52 ~LbtsMessage (); |
46 | 53 |
47 Time GetSmallestTime (); | 54 Time GetSmallestTime (); |
48 uint32_t GetTxCount (); | 55 uint32_t GetTxCount (); |
49 uint32_t GetRxCount (); | 56 uint32_t GetRxCount (); |
50 uint32_t GetMyId (); | 57 uint32_t GetMyId (); |
51 | 58 |
52 private: | 59 private: |
53 uint32_t m_txCount; | 60 uint32_t m_txCount; |
54 uint32_t m_rxCount; | 61 uint32_t m_rxCount; |
55 uint32_t m_myId; | 62 uint32_t m_myId; |
56 Time m_smallestTime; | 63 Time m_smallestTime; |
57 }; | 64 }; |
58 | 65 |
59 class DistributedSimulatorImpl : public SimulatorImpl | 66 class DistributedSimulatorImpl : public SimulatorImpl |
60 { | 67 { |
61 public: | 68 public: |
62 static TypeId GetTypeId (void); | 69 static TypeId GetTypeId (void); |
63 | 70 |
64 DistributedSimulatorImpl (); | 71 DistributedSimulatorImpl (); |
65 ~DistributedSimulatorImpl (); | 72 ~DistributedSimulatorImpl (); |
66 | 73 |
67 virtual void Destroy (); | 74 virtual void Destroy (); |
68 virtual bool IsFinished (void) const; | 75 virtual bool IsFinished (void) const; |
69 virtual Time Next (void) const; | 76 virtual Time Next (void) const; |
70 virtual void Stop (void); | 77 virtual void Stop (void); |
71 virtual void Stop (Time const &time); | 78 virtual void Stop (Time const &time); |
72 virtual EventId Schedule (Time const &time, EventImpl *event); | 79 virtual EventId Schedule (Time const &time, EventImpl *event); |
73 virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImp
l *event); | 80 virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImp
l *event); |
74 virtual EventId ScheduleNow (EventImpl *event); | 81 virtual EventId ScheduleNow (EventImpl *event); |
75 virtual EventId ScheduleDestroy (EventImpl *event); | 82 virtual EventId ScheduleDestroy (EventImpl *event); |
76 virtual void Remove (const EventId &ev); | 83 virtual void Remove (const EventId &ev); |
77 virtual void Cancel (const EventId &ev); | 84 virtual void Cancel (const EventId &ev); |
78 virtual bool IsExpired (const EventId &ev) const; | 85 virtual bool IsExpired (const EventId &ev) const; |
79 virtual void Run (void); | 86 virtual void Run (void); |
80 virtual void RunOneEvent (void); | 87 virtual void RunOneEvent (void); |
81 virtual Time Now (void) const; | 88 virtual Time Now (void) const; |
82 virtual Time GetDelayLeft (const EventId &id) const; | 89 virtual Time GetDelayLeft (const EventId &id) const; |
83 virtual Time GetMaximumSimulationTime (void) const; | 90 virtual Time GetMaximumSimulationTime (void) const; |
84 virtual void SetScheduler (ObjectFactory schedulerFactory); | 91 virtual void SetScheduler (ObjectFactory schedulerFactory); |
85 virtual uint32_t GetSystemId (void) const; | 92 virtual uint32_t GetSystemId (void) const; |
86 virtual uint32_t GetContext (void) const; | 93 virtual uint32_t GetContext (void) const; |
87 | 94 |
88 private: | 95 private: |
| 96 virtual void DoDispose (void); |
89 void CalculateLookAhead (void); | 97 void CalculateLookAhead (void); |
90 | 98 |
91 void ProcessOneEvent (void); | 99 void ProcessOneEvent (void); |
92 uint64_t NextTs (void) const; | 100 uint64_t NextTs (void) const; |
93 typedef std::list<EventId> DestroyEvents; | 101 typedef std::list<EventId> DestroyEvents; |
94 | 102 |
95 DestroyEvents m_destroyEvents; | 103 DestroyEvents m_destroyEvents; |
96 bool m_stop; | 104 bool m_stop; |
97 Ptr<Scheduler> m_events; | 105 Ptr<Scheduler> m_events; |
98 uint32_t m_uid; | 106 uint32_t m_uid; |
99 uint32_t m_currentUid; | 107 uint32_t m_currentUid; |
100 uint64_t m_currentTs; | 108 uint64_t m_currentTs; |
101 uint32_t m_currentContext; | 109 uint32_t m_currentContext; |
102 // number of events that have been inserted but not yet scheduled, | 110 // number of events that have been inserted but not yet scheduled, |
103 // not counting the "destroy" events; this is used for validation | 111 // not counting the "destroy" events; this is used for validation |
104 int m_unscheduledEvents; | 112 int m_unscheduledEvents; |
105 | 113 |
106 LbtsMessage* m_pLBTS; // Allocated once we know how many systems | 114 LbtsMessage* m_pLBTS; // Allocated once we know how many systems |
107 uint32_t m_myId; // MPI Rank | 115 uint32_t m_myId; // MPI Rank |
108 uint32_t m_systemCount; // MPI Size | 116 uint32_t m_systemCount; // MPI Size |
109 Time m_grantedTime; // Last LBTS | 117 Time m_grantedTime; // Last LBTS |
110 static Time m_lookAhead; // Lookahead value | 118 static Time m_lookAhead; // Lookahead value |
111 | 119 |
112 }; | 120 }; |
113 | 121 |
114 } // namespace ns3 | 122 } // namespace ns3 |
115 | 123 |
116 #endif /* DISTRIBUTED_SIMULATOR_IMPL_H */ | 124 #endif /* DISTRIBUTED_SIMULATOR_IMPL_H */ |
LEFT | RIGHT |