52 error(
"this module doesn't handle messages, it runs only in initialize()");
59 this->overlay = overlay;
72 throw new cRuntimeError(
"ChordFingerTable::setFinger(): "
73 "Index out of bound");
76 uint32_t p = maxSize - pos - 1;
79 while (fingerTable.size() <= p) {
84 if (sucNodes != NULL) {
93 setFinger(pos, nodes.begin()->second, &nodes);
102 if (pos >= maxSize) {
103 throw new cRuntimeError(
"ChordFingerTable::updateFinger(): "
104 "Index out of bound");
107 uint32_t p = maxSize - pos - 1;
109 while (fingerTable.size() <= p) {
115 Successors::iterator it;
116 for (it = fingerTable[p].second.begin(); it != fingerTable[p].second.end();
119 if (it->second == node) {
124 if (it == fingerTable[p].second.end()) {
128 fingerTable[p].second.erase(it);
129 fingerTable[p].second.insert(std::make_pair(rtt, node));
137 for (
int p = fingerTable.size() - 1; p >= 0; p--) {
138 if (!fingerTable[p].first.isUnspecified() &&
139 failed == fingerTable[p].first) {
143 for (std::multimap<simtime_t, NodeHandle>::iterator it =
144 fingerTable[p].second.begin(); it != fingerTable[p].second.end();
146 if (failed == it->second) {
147 fingerTable[p].second.erase(it);
158 if (pos >= maxSize) {
159 throw new cRuntimeError(
"ChordFingerTable::removeFinger(): "
160 "Index out of bound");
163 uint32_t p = maxSize - pos - 1;
165 if (p >= fingerTable.size()) {
167 }
else if (p == (fingerTable.size() - 1)) {
168 fingerTable.pop_back();
178 if (pos >= maxSize) {
179 throw new cRuntimeError(
"ChordFingerTable::getFinger(): "
180 "Index out of bound");
183 uint32_t p = maxSize - pos - 1;
185 if (p >= fingerTable.size()) {
186 return overlay->successorList->getSuccessor();
188 while (fingerTable[p].first.isUnspecified() &&
189 (p < (fingerTable.size() - 1))) {
192 if (fingerTable[p].first.isUnspecified())
193 return overlay->successorList->getSuccessor();
194 return fingerTable[p].first;
199 if (pos >= maxSize) {
200 throw new cRuntimeError(
"ChordFingerTable::getFinger(): "
201 "Index out of bound");
205 uint32_t p = maxSize - pos - 1;
207 if (p < fingerTable.size()) {
208 for (Successors::const_iterator it = fingerTable[p].second.begin();
209 it != fingerTable[p].second.end(); it++) {
211 if(!key.
isBetweenLR(fingerTable[p].first.getKey(), it->second.getKey())) {
212 nextHop->push_back(it->second);
216 nextHop->push_back(overlay->successorList->getSuccessor());
220 if (nextHop->size() == 0) {
221 if (fingerTable[p].first.isUnspecified()) {
223 nextHop->push_back(overlay->successorList->getSuccessor());
225 nextHop->push_back(fingerTable[p].first);
235 using namespace oversim;
239 for (Successors::const_iterator i = suc.begin(); i != suc.end(); i++) {
240 if (i != suc.begin()) {
246 if (i->first == -1) {
248 }
else if (i->first == MAXTIME) {
251 os <<
"; RTT: " << i->first;
260 if (entry.second.size() > 0) {
261 os <<
"[ " << entry.first <<
" ]\n" << entry.second;