OverSim
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
UnderlayConfigurator.h
Go to the documentation of this file.
1
//
2
// Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3
//
4
// This program is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU General Public License
6
// as published by the Free Software Foundation; either version 2
7
// of the License, or (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
//
18
24
#ifndef _UNDERLAYCONFIGURATOR_H_
25
#define _UNDERLAYCONFIGURATOR_H_
26
27
#include <omnetpp.h>
28
29
class
PeerInfo
;
30
class
ChurnGenerator
;
31
class
NodeType
;
32
class
TransportAddress
;
33
class
GlobalNodeList
;
34
class
GlobalStatistics
;
35
36
#ifndef timersub
37
# define timersub(a, b, result) \
38
do { \
39
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
40
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
41
if ((result)->tv_usec < 0) { \
42
--(result)->tv_sec; \
43
(result)->tv_usec += 1000000; \
44
} \
45
} while (0)
46
#endif
47
53
class
UnderlayConfigurator
:
public
cSimpleModule
54
{
55
public
:
56
57
UnderlayConfigurator
();
58
virtual
~UnderlayConfigurator
();
59
63
bool
isInInitPhase
() {
return
init
; };
64
68
bool
isSimulationEndingSoon
() {
return
simulationEndingSoon
; };
69
73
simtime_t
getGracefulLeaveDelay
() {
return
gracefulLeaveDelay
; };
74
75
76
bool
isTransitionTimeFinished
() {
return
transitionTimeFinished
; };
77
84
virtual
TransportAddress
*
createNode
(
NodeType
type,
bool
initialize
=
false
) = 0;
85
92
virtual
void
preKillNode
(
NodeType
type,
TransportAddress
* addr=NULL) = 0;
93
100
virtual
void
migrateNode
(
NodeType
type,
TransportAddress
* addr=NULL) = 0;
101
102
void
initFinished
();
103
104
ChurnGenerator
*
getChurnGenerator
(
int
typeID);
105
106
uint8_t
getChurnGeneratorNum
();
107
108
int
getOverlayTerminalCount
(){
return
overlayTerminalCount
;}
109
110
protected
:
111
115
int
numInitStages
()
const
;
116
120
virtual
void
initialize
(
int
stage);
121
125
virtual
void
initializeUnderlay
(
int
stage) = 0;
126
127
virtual
void
handleTimerEvent
(cMessage* msg);
128
132
void
finish
();
133
137
virtual
void
finishUnderlay
();
138
142
virtual
void
setDisplayString
() = 0;
143
149
void
handleMessage
(cMessage* msg);
150
151
int
overlayTerminalCount
;
152
int
firstNodeId
;
153
simtime_t
gracefulLeaveDelay
;
154
double
gracefulLeaveProbability
;
155
156
GlobalNodeList
*
globalNodeList
;
157
GlobalStatistics
*
globalStatistics
;
158
std::vector<ChurnGenerator*>
churnGenerator
;
159
160
cMessage*
endSimulationTimer
;
161
cMessage*
endSimulationNotificationTimer
;
162
cMessage*
endTransitionTimer
;
163
164
struct
timeval
initFinishedTime
;
165
struct
timeval
initStartTime
;
166
167
simtime_t
transitionTime
;
168
simtime_t
measurementTime
;
169
170
static
const
int
NUM_COLORS
;
171
static
const
char
*
colorNames
[];
172
173
private
:
174
bool
init
;
175
bool
simulationEndingSoon
;
176
bool
transitionTimeFinished
;
177
unsigned
int
initCounter
;
178
179
void
consoleOut
(
const
std::string& text);
180
};
181
182
#endif
src
common
UnderlayConfigurator.h
Generated on Fri Dec 7 2012 13:37:53 for OverSim by
1.8.1.2