A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
* Some updates to this code were developed under a research contract
19
* sponsored by the Army Research Laboratory. (April 30, 2013)
20
*/
21
22
#ifndef DISTRIBUTED_SIMULATOR_IMPL_H
23
#define DISTRIBUTED_SIMULATOR_IMPL_H
24
25
#include "ns3/simulator-impl.h"
26
#include "ns3/scheduler.h"
27
#include "ns3/event-impl.h"
28
#include "ns3/ptr.h"
29
30
#include <list>
31
32
namespace
ns3 {
33
39
class
LbtsMessage
40
{
41
public
:
42
LbtsMessage
()
43
:
m_txCount
(0),
44
m_rxCount
(0),
45
m_myId
(0),
46
m_isFinished
(false)
47
{
48
}
49
56
LbtsMessage
(uint32_t rxc, uint32_t txc, uint32_t
id
,
bool
isFinished,
const
Time
& t)
57
:
m_txCount
(txc),
58
m_rxCount
(rxc),
59
m_myId
(id),
60
m_smallestTime
(t),
61
m_isFinished
(isFinished)
62
{
63
}
64
65
~LbtsMessage
();
66
70
Time
GetSmallestTime
();
74
uint32_t
GetTxCount
();
78
uint32_t
GetRxCount
();
82
uint32_t
GetMyId
();
83
84
bool
IsFinished
();
85
86
private
:
87
uint32_t
m_txCount
;
88
uint32_t
m_rxCount
;
89
uint32_t
m_myId
;
90
Time
m_smallestTime
;
91
bool
m_isFinished
;
92
};
93
100
class
DistributedSimulatorImpl
:
public
SimulatorImpl
101
{
102
public
:
103
static
TypeId
GetTypeId
(
void
);
104
105
DistributedSimulatorImpl
();
106
~DistributedSimulatorImpl
();
107
108
// virtual from SimulatorImpl
109
virtual
void
Destroy
();
110
virtual
bool
IsFinished
(
void
)
const
;
111
virtual
void
Stop
(
void
);
112
virtual
void
Stop
(
Time
const
&time);
113
virtual
EventId
Schedule
(
Time
const
&time,
EventImpl
*event);
114
virtual
void
ScheduleWithContext
(uint32_t context,
Time
const
&time,
EventImpl
*event);
115
virtual
EventId
ScheduleNow
(
EventImpl
*event);
116
virtual
EventId
ScheduleDestroy
(
EventImpl
*event);
117
virtual
void
Remove
(
const
EventId
&ev);
118
virtual
void
Cancel
(
const
EventId
&ev);
119
virtual
bool
IsExpired
(
const
EventId
&ev)
const
;
120
virtual
void
Run
(
void
);
121
virtual
Time
Now
(
void
)
const
;
122
virtual
Time
GetDelayLeft
(
const
EventId
&
id
)
const
;
123
virtual
Time
GetMaximumSimulationTime
(
void
)
const
;
124
virtual
void
SetScheduler
(
ObjectFactory
schedulerFactory);
125
virtual
uint32_t
GetSystemId
(
void
)
const
;
126
virtual
uint32_t
GetContext
(
void
)
const
;
127
128
private
:
129
virtual
void
DoDispose
(
void
);
130
void
CalculateLookAhead
(
void
);
131
bool
IsLocalFinished
(
void
)
const
;
132
133
void
ProcessOneEvent
(
void
);
134
uint64_t
NextTs
(
void
)
const
;
135
Time
Next
(
void
)
const
;
136
typedef
std::list<EventId>
DestroyEvents
;
137
138
DestroyEvents
m_destroyEvents
;
139
bool
m_stop
;
140
bool
m_globalFinished
;
// Are all parallel instances completed.
141
Ptr<Scheduler>
m_events
;
142
uint32_t
m_uid
;
143
uint32_t
m_currentUid
;
144
uint64_t
m_currentTs
;
145
uint32_t
m_currentContext
;
146
// number of events that have been inserted but not yet scheduled,
147
// not counting the "destroy" events; this is used for validation
148
int
m_unscheduledEvents
;
149
150
LbtsMessage
*
m_pLBTS
;
// Allocated once we know how many systems
151
uint32_t
m_myId
;
// MPI Rank
152
uint32_t
m_systemCount
;
// MPI Size
153
Time
m_grantedTime
;
// Last LBTS
154
static
Time
m_lookAhead
;
// Lookahead value
155
156
};
157
158
}
// namespace ns3
159
160
#endif
/* DISTRIBUTED_SIMULATOR_IMPL_H */
src
mpi
model
distributed-simulator-impl.h
Generated on Fri Aug 30 2013 01:42:59 for ns-3 by
1.8.1.2