OverSim
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
BasePastry.h
Go to the documentation of this file.
1
//
2
// Copyright (C) 2012 Institute of Telematics, Karlsruhe Institute of Technology (KIT)
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 __BASEPASTRY_H_
25
#define __BASEPASTRY_H_
26
27
#include <vector>
28
#include <map>
29
#include <queue>
30
#include <algorithm>
31
32
#include <omnetpp.h>
33
#include <IPvXAddress.h>
34
35
#include <
OverlayKey.h
>
36
#include <
NodeHandle.h
>
37
#include <
BaseOverlay.h
>
38
#include <
NeighborCache.h
>
39
40
#include "
PastryTypes.h
"
41
#include "
PastryMessage_m.h
"
42
#include "
PastryRoutingTable.h
"
43
#include "
PastryLeafSet.h
"
44
#include "
PastryNeighborhoodSet.h
"
45
46
class
PastryLeafSet
;
47
48
49
class
BasePastry
:
public
BaseOverlay
,
public
ProxListener
50
{
51
public
:
52
53
virtual
~BasePastry
();
54
55
// see BaseOverlay.h
56
int
getMaxNumSiblings
();
57
58
// see BaseOverlay.h
59
int
getMaxNumRedundantNodes
();
60
66
virtual
void
handleAppMessage
(
BaseOverlayMessage
* msg);
67
71
virtual
void
updateTooltip
();
72
73
// see BaseOverlay.h
74
virtual
NodeVector
*
findNode
(
const
OverlayKey
& key,
75
int
numRedundantNodes,
76
int
numSiblings,
77
BaseOverlayMessage
* msg);
78
84
virtual
void
handleStateMessage
(
PastryStateMessage
* msg) = 0;
85
86
// see BaseOverlay.h
87
virtual
void
finishOverlay
();
88
89
// see BaseOverlay.h
90
virtual
bool
isSiblingFor
(
const
NodeHandle
& node,
91
const
OverlayKey
& key,
92
int
numSiblings,
93
bool
* err);
94
95
// see BaseOverlay.h
96
virtual
AbstractLookup
*
createLookup
(
RoutingType
routingType =
DEFAULT_ROUTING
,
97
const
BaseOverlayMessage
* msg = NULL,
98
const
cPacket* dummy = NULL,
99
bool
appLookup =
false
);
100
101
uint8_t
getBitsPerDigit
() {
return
bitsPerDigit
; };
102
103
// statistics
104
int
joins
;
105
int
joinTries
;
106
int
joinPartial
;
107
int
joinSeen
;
108
int
joinBytesSeen
;
109
int
joinReceived
;
110
int
joinBytesReceived
;
111
int
joinSent
;
112
int
joinBytesSent
;
113
int
stateSent
;
114
int
stateBytesSent
;
115
int
stateReceived
;
116
int
stateBytesReceived
;
117
int
repairReqSent
;
118
int
repairReqBytesSent
;
119
int
repairReqReceived
;
120
int
repairReqBytesReceived
;
121
int
stateReqSent
;
122
int
stateReqBytesSent
;
123
int
stateReqReceived
;
124
int
stateReqBytesReceived
;
125
int
totalLookups
;
126
int
responsibleLookups
;
127
int
routingTableLookups
;
128
int
closerNodeLookups
;
129
int
closerNodeLookupsFromNeighborhood
;
130
131
int
leafsetReqSent
;
132
int
leafsetReqBytesSent
;
133
int
leafsetReqReceived
;
134
int
leafsetReqBytesReceived
;
135
int
leafsetSent
;
136
int
leafsetBytesSent
;
137
int
leafsetReceived
;
138
int
leafsetBytesReceived
;
139
140
int
routingTableRowReqSent
;
141
int
routingTableRowReqBytesSent
;
142
int
routingTableRowReqReceived
;
143
int
routingTableRowReqBytesReceived
;
144
int
routingTableRowSent
;
145
int
routingTableRowBytesSent
;
146
int
routingTableRowReceived
;
147
int
routingTableRowBytesReceived
;
148
149
void
proxCallback
(
const
TransportAddress
& node,
int
rpcId,
150
cPolymorphic *contextPointer,
Prox
prox);
151
152
// see BaseOverlay.h
153
virtual
OverlayKey
estimateMeanDistance
();
154
155
protected
:
156
162
virtual
void
changeState
(
int
toState) { };
163
164
virtual
bool
handleRpcCall
(
BaseCallMessage
* msg);
165
166
virtual
void
handleRpcResponse
(
BaseResponseMessage
* msg,
167
cPolymorphic* context,
int
rpcId,
168
simtime_t rtt);
169
170
virtual
void
handleRpcTimeout
(
BaseCallMessage
* call,
171
const
TransportAddress
& dest,
172
cPolymorphic* context,
int
rpcId,
173
const
OverlayKey
& key);
174
175
void
handleRequestLeafSetCall
(
RequestLeafSetCall
* call);
176
177
void
handleRequestRoutingRowCall
(
RequestRoutingRowCall
* call);
178
179
virtual
void
handleRequestLeafSetResponse
(
RequestLeafSetResponse
* response);
180
181
virtual
void
handleRequestRoutingRowResponse
(
RequestRoutingRowResponse
* response);
182
183
PastryStateMessage
*
createStateMessage
(
enum
PastryStateMsgType
type =
PASTRY_STATE_STD
,
184
simtime_t timestamp = -1,
185
int16_t row = -1,
186
bool
lastHop =
false
);
187
188
// parameters
189
uint32_t
bitsPerDigit
;
190
uint32_t
numberOfLeaves
;
191
uint32_t
numberOfNeighbors
;
192
double
readyWaitAmount
;
193
double
joinTimeoutAmount
;
194
double
repairTimeout
;
195
bool
enableNewLeafs
;
196
bool
useRegularNextHop
;
197
bool
alwaysSendUpdate
;
198
bool
optimizeLookup
;
199
bool
proximityNeighborSelection
;
200
201
simtime_t
nearNodeRtt
;
202
203
bool
nearNodeImproved
;
204
205
bool
periodicMaintenance
;
206
207
TransportAddress
*
leaf2ask
;
208
209
TransportAddress
bootstrapNode
;
210
TransportAddress
nearNode
;
211
212
simtime_t
lastStateChange
;
213
217
PastryStateMsgHandle
stateCache
;
218
222
std::queue<PastryStateMsgHandle>
stateCacheQueue
;
223
227
PastryStateMsgProximity
aliveTable
;
228
233
virtual
void
checkProxCache
(
void
) = 0;
234
235
uint32_t
joinHopCount
;
236
cMessage*
readyWait
;
237
cMessage*
joinUpdateWait
;
238
239
PastryRoutingTable
*
routingTable
;
240
PastryLeafSet
*
leafSet
;
241
PastryNeighborhoodSet
*
neighborhoodSet
;
242
247
virtual
void
purgeVectors
(
void
);
248
252
void
baseInit
(
void
);
253
258
void
baseChangeState
(
int
);
259
260
OverlayKey
distance
(
const
OverlayKey
& x,
261
const
OverlayKey
& y,
262
bool
useAlternative =
false
)
const
;
263
264
virtual
void
iterativeJoinHook
(
BaseOverlayMessage
* msg,
265
bool
incrHopCount) { };
266
267
enum
StateObject
268
{
269
ROUTINGTABLE
,
270
LEAFSET
,
271
NEIGHBORHOODSET
272
};
273
274
struct
PingContext
:
public
cPolymorphic
275
{
276
PingContext
(
StateObject
stateObject
, uint32_t
index
, uint32_t
nonce
)
277
: stateObject(stateObject), index(index), nonce(nonce)
278
{};
279
virtual
~PingContext
() {};
280
StateObject
stateObject
;
281
uint32_t
index
;
282
uint32_t
nonce
;
283
};
284
285
enum
286
{
287
PING_RECEIVED_STATE
= 1,
288
PING_NEXT_HOP
= 2,
289
PING_SINGLE_NODE
= 3,
290
PING_DISCOVERY
= 4
291
};
292
297
void
prePing
(
const
PastryStateMessage
* stateMsg);
298
303
void
pingNodes
(
void
);
304
312
void
determineAliveTable
(
const
PastryStateMessage
* stateMsg);
313
317
void
newLeafs
(
void
);
318
319
public
:
320
// neighborCache discovery support
321
uint8_t
getRTLastRow
()
const
;
322
std::vector<TransportAddress>*
getRTRow
(uint8_t index)
const
;
323
std::vector<TransportAddress>*
getLeafSet
()
const
;
324
325
friend
class
PastryLeafSet
;
326
};
327
332
bool
stateMsgIsSmaller
(
const
PastryStateMsgHandle
& hnd1,
333
const
PastryStateMsgHandle
& hnd2);
334
335
std::ostream&
operator<<
(std::ostream& os,
const
PastryStateMsgProximity
& pr);
336
337
#endif
338
src
overlay
pastry
BasePastry.h
Generated on Fri Dec 7 2012 13:37:52 for OverSim by
1.8.1.2