forest-net
an overlay networks for large-scale virtual worlds
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
RouterCoreDoowon.h
1
9
#ifndef ROUTERCORE_H
10
#define ROUTERCORE_H
11
12
#include <queue>
13
#include <map>
14
15
#include "stdinc.h"
16
#include "
Forest.h
"
17
18
#include "
IfaceTable.h
"
19
#include "
LinkTable.h
"
20
#include "
ComtreeTable.h
"
21
#include "
RouteTable.h
"
22
#include "PacketStore.h"
23
#include "
CtlPkt.h
"
24
#include "QuManager.h"
25
#include "
IoProcessor.h
"
26
#include "
StatsModule.h
"
27
#include "
PacketLog.h
"
28
29
namespace
forest {
30
32
struct
RouterInfo {
33
string
mode
;
34
35
fAdr_t
myAdr
;
36
ipa_t
bootIp
;
37
ipp_t
portNum
;
38
fAdr_t
nmAdr
;
39
ipa_t
nmIp
;
40
fAdr_t
ccAdr
;
41
fAdr_t
firstLeafAdr
;
42
fAdr_t
lastLeafAdr
;
43
44
string
ifTbl
;
45
string
lnkTbl
;
46
string
comtTbl
;
47
string
rteTbl
;
48
string
statSpec
;
49
50
int
finTime
;
51
};
52
53
class
RouterCore {
54
public
:
55
RouterCore
(
bool
,
const
RouterInfo&);
56
~
RouterCore
();
57
58
bool
readTables
(
const
RouterInfo&);
59
bool
setup
();
60
bool
setBooting(
bool
state) {
return
booting
= state; }
61
void
run
(uint64_t);
62
void
dump
(ostream& os);
63
private
:
64
ipa_t
bootIp
;
65
fAdr_t
myAdr
;
66
ipa_t
nmIp
;
67
fAdr_t
nmAdr
;
68
fAdr_t
ccAdr
;
69
70
bool
booting
;
71
72
uint64_t
now
;
73
74
uint64_t
seqNum
;
75
76
fAdr_t
firstLeafAdr
;
77
UiSetPair *
leafAdr
;
78
80
struct
CpInfo
{
81
pktx
px
;
82
int
nSent
;
83
uint64_t
timestamp
;
84
};
85
map<uint64_t,CpInfo> *
pending
;
86
87
int
nIfaces
;
88
int
nLnks
;
89
int
nComts
;
90
int
nRts
;
91
int
nPkts
;
92
int
nBufs
;
93
int
nQus
;
94
95
IfaceTable
*
ift
;
96
LinkTable
*
lt
;
97
ComtreeTable
*
ctt
;
98
RouteTable
*
rt
;
99
PacketStore
*
ps
;
100
QuManager
*
qm
;
101
IoProcessor
*
iop
;
102
StatsModule
*
sm
;
103
PacketLog
*
pktLog
;
104
106
struct
nuClient
{
107
uint64_t
nonce
;
108
time_t
timestamp
;
109
int
iface
;
110
int
link
;
111
};
112
list<nuClient> *
pendingClients
;
113
115
// setup
116
bool
setupIfaces
();
117
bool
setupLeafAddresses
();
118
bool
setupQueues
();
119
bool
checkTables
();
120
bool
setAvailRates
();
121
void
addLocalRoutes
();
122
123
fAdr_t
allocLeafAdr
();
124
bool
allocLeafAdr
(
fAdr_t
);
125
void
freeLeafAdr
(
fAdr_t
);
126
bool
validLeafAdr
(
fAdr_t
)
const
;
127
bool
isFreeLeafAdr
(
fAdr_t
)
const
;
128
129
// basic forwarding
130
void
forward
(pktx,
int
);
131
bool
pktCheck
(pktx,
int
);
132
void
multiSend
(pktx,
int
,
int
);
133
134
// inband control
135
void
handleConnDisc
(pktx);
136
void
handleRteReply
(pktx,
int
);
137
void
sendRteReply
(pktx,
int
);
138
void
subUnsub
(pktx,
int
);
139
140
// signalling packets
141
void
handleCtlPkt
(pktx);
142
143
bool
addIface
(
CtlPkt
&,
CtlPkt
&);
144
bool
dropIface(
CtlPkt
&,
CtlPkt
&);
145
bool
getIface(
CtlPkt
&,
CtlPkt
&);
146
bool
modIface(
CtlPkt
&,
CtlPkt
&);
147
148
bool
addLink(
CtlPkt
&,
CtlPkt
&);
149
bool
dropLink(
CtlPkt
&,
CtlPkt
&);
150
void
dropLink(
int
,
fAdr_t
=0);
151
bool
getLink(
CtlPkt
&,
CtlPkt
&);
152
bool
modLink(
CtlPkt
&,
CtlPkt
&);
153
154
bool
addComtree(
CtlPkt
&,
CtlPkt
&);
155
bool
dropComtree(
CtlPkt
&,
CtlPkt
&);
156
bool
getComtree(
CtlPkt
&,
CtlPkt
&);
157
bool
modComtree(
CtlPkt
&,
CtlPkt
&);
158
bool
addComtreeLink(
CtlPkt
&,
CtlPkt
&);
159
bool
dropComtreeLink(
CtlPkt
&,
CtlPkt
&);
160
void
dropComtreeLink(
int
,
int
,
int
);
161
bool
modComtreeLink(
CtlPkt
&,
CtlPkt
&);
162
bool
getComtreeLink(
CtlPkt
&,
CtlPkt
&);
163
164
bool
addRoute(
CtlPkt
&,
CtlPkt
&);
165
bool
dropRoute(
CtlPkt
&,
CtlPkt
&);
166
bool
getRoute(
CtlPkt
&,
CtlPkt
&);
167
bool
modRoute(
CtlPkt
&,
CtlPkt
&);
168
//feng
169
bool
getLinkSet
(
CtlPkt
&,
CtlPkt
&);
170
bool
setLeafRange
(
CtlPkt
&,
CtlPkt
&);
171
172
void
sendConnDisc
(
int
,
Forest::ptyp_t
);
173
bool
sendCpReq
(
CtlPkt
&,
fAdr_t
);
174
void
resendCpReq
();
175
void
handleCpReply
(pktx,
CtlPkt
&);
176
177
void
returnToSender
(pktx,
CtlPkt
&);
178
};
179
184
inline
fAdr_t
RouterCore::allocLeafAdr
() {
185
int
offset =
leafAdr
->firstOut();
186
if
(offset == 0)
return
0;
187
leafAdr
->swap(offset);
188
return
firstLeafAdr
+ offset - 1;
189
}
190
196
inline
bool
RouterCore::allocLeafAdr
(
fAdr_t
adr) {
197
int
offset = (adr -
firstLeafAdr
) + 1;
198
if
(!
leafAdr
->isOut(offset))
return
false
;
199
leafAdr
->swap(offset);
200
return
true
;
201
}
202
206
inline
void
RouterCore::freeLeafAdr
(
fAdr_t
adr) {
207
int
offset = (adr -
firstLeafAdr
) + 1;
208
if
(!
leafAdr
->isIn(offset))
return
;
209
leafAdr
->swap(offset);
210
return
;
211
}
212
217
inline
bool
RouterCore::validLeafAdr
(
fAdr_t
adr)
const
{
218
int
offset = (adr -
firstLeafAdr
) + 1;
219
return
leafAdr
->isIn(offset);
220
}
221
226
inline
bool
RouterCore::isFreeLeafAdr
(
fAdr_t
adr)
const
{
227
int
offset = (adr -
firstLeafAdr
) + 1;
228
return
leafAdr
->isOut(offset);
229
}
230
231
}
// ends namespace
232
233
#endif
forest-net
cpp
include
RouterCoreDoowon.h
Generated on Mon Aug 4 2014 11:13:35 for forest-net by
1.8.4