OverSim
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
NoChurn.cc
Go to the documentation of this file.
1
//
2
// Copyright (C) 2008 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
#include <
TransportAddress.h
>
25
#include <
UnderlayConfigurator.h
>
26
27
#include "
NoChurn.h
"
28
29
Define_Module
(
NoChurn
);
30
31
void
NoChurn::initializeChurn
()
32
{
33
Enter_Method_Silent();
34
35
initialMean
= par(
"initPhaseCreationInterval"
);
36
initialDeviation
=
initialMean
/ 3;
37
targetOverlayTerminalNum
= par(
"targetOverlayTerminalNum"
);
38
39
initAddMoreTerminals
=
true
;
40
41
mobilityTimer
=
new
cMessage(
"mobilityTimer"
);
42
scheduleAt(simTime(),
mobilityTimer
);
43
}
44
45
void
NoChurn::handleMessage
(cMessage* msg)
46
{
47
if
(!msg->isSelfMessage()) {
48
throw
cRuntimeError(
"NoChurn::handleMessage(): "
49
"Unknown message received!"
);
50
delete
msg;
51
return
;
52
}
53
54
if
(msg ==
mobilityTimer
) {
55
if
(
terminalCount
<
targetOverlayTerminalNum
) {
56
TransportAddress
* ta =
underlayConfigurator
->
createNode
(
type
);
57
delete
ta;
// Address not needed in this churn model
58
}
59
60
if
(
terminalCount
>=
targetOverlayTerminalNum
) {
61
initAddMoreTerminals
=
false
;
62
underlayConfigurator
->
initFinished
();
63
}
else
{
64
scheduleAt(simTime()
65
+ truncnormal(
initialMean
,
initialDeviation
), msg);
66
}
67
}
68
}
69
70
void
NoChurn::updateDisplayString
()
71
{
72
char
buf[80];
73
sprintf(buf,
"No churn"
);
74
getDisplayString().setTagArg(
"t"
, 0, buf);
75
}
76
77
NoChurn::~NoChurn
() {
78
// destroy self timer messages
79
cancelAndDelete(
mobilityTimer
);
80
}
81
src
common
NoChurn.cc
Generated on Fri Dec 7 2012 13:37:53 for OverSim by
1.8.1.2