28 #include <NotificationBoard.h>
43 for (AddrPerOverlayVector::const_iterator it2 = entry.
addrVector.begin();
48 os <<
"Overlay " << it2->overlayId <<
": " << *(it2->ta);
51 os <<
" (" << nodeHandle->
getKey() <<
")";
54 if (it2->bootstrapped ==
false) {
55 os <<
" [NOT BOOTSTRAPPED]";
59 os <<
" " << *(entry.
info);
81 if (par(
"maliciousNodeChange")) {
82 if ((
double) par(
"maliciousNodeProbability") > 0)
83 error(
"maliciousNodeProbability and maliciousNodeChange are not supported concurrently");
85 cMessage* msg =
new cMessage(
"maliciousNodeChange");
86 scheduleAt(simTime() + (
int) par(
"maliciousNodeChangeStartTime"), msg);
100 cMessage* timer =
new cMessage(
"oracleTimer");
102 scheduleAt(simTime(), timer);
107 if (msg->isName(
"maliciousNodeChange")) {
110 newRatio = (double) par(
"maliciousNodeChangeStartValue");
112 if (newRatio < (
double) par(
"maliciousNodeChangeStopValue"))
113 scheduleAt(simTime() + (int) par(
"maliciousNodeChangeInterval"), msg);
115 int nodesNeeded = (int) (((
double) par(
"maliciousNodeChangeRate")) *
peerStorage.
size());
117 EV <<
"[GlobalNodeList::handleMessage()]\n"
118 <<
" Changing " << nodesNeeded <<
" nodes to be malicious"
121 for (
int i = 0; i < nodesNeeded; i++) {
137 else if (msg->isName(
"oracleTimer")) {
140 scheduleAt(simTime() + 50, msg);
142 opp_error(
"GlobalNodeList::handleMessage: Unknown message type!");
150 PeerHashMap::iterator it;
163 nodeType = it->second.info->getTypeID();
189 bool bootstrappedNeeded,
190 bool inoffensiveNeeded)
202 if (overlayId >= 0) {
203 addr = it->second.addrVector.getAddrForOverlayId(overlayId);
207 addr = it->second.addrVector[0].ta;
210 if (dynamic_cast<NodeHandle*>(addr)) {
219 PeerHashMap::iterator it;
221 NotificationBoard* nb = check_and_cast<NotificationBoard*>(
222 simulation.getModule(it->second.info->getModuleID())
223 ->getSubmodule(
"notificationBoard"));
225 nb->fireChangeNotification(category);
237 if (uniform(0, 1) < (
double) par(
"maliciousNodeProbability") ||
254 throw cRuntimeError(
"GlobalNodeList::registerPeer(): "
255 "Peer is not in peer set");
268 throw cRuntimeError(
"GlobalNodeList::refreshEntry(): "
269 "Peer is not in peer set");
290 if (it->second.info->isPreKilled()) {
291 it->second.info->setPreKilled(
false);
296 PeerInfo* peerInfo = it->second.info;
318 return it->second.info;
323 bool bootstrappedNeeded)
332 return it->second.info;
358 if (!it->second.info->isPreKilled()) {
360 if (it->second.addrVector.size()) {
361 return it->second.addrVector[0].ta;
418 getDisplayString().setTagArg(
"i2", 1, color);
426 throw cRuntimeError(
"GlobalNodeList::areNodeTypesConnected(): nodeType "
427 "bigger then MAX_NODETYPES");
436 throw cRuntimeError(
"GlobalNodeList::connectNodeTypes(): nodeType "
437 "bigger then MAX_NODETYPES");
442 EV <<
"[GlobalNodeList::connectNodeTypes()]\n"
443 <<
" Connecting " << a <<
"->" << b
451 throw cRuntimeError(
"GlobalNodeList::disconnectNodeTypes(): nodeType "
452 "bigger then MAX_NODETYPES");
457 EV <<
"[GlobalNodeList::disconnectNodeTypes()]\n"
458 <<
" Disconnecting " << a <<
"->" << b
469 getSubmodule(
"bootstrapList"));
479 for (uint32_t i = 0; i < size; i++)
486 if (maximumKeys >
keyList.size()) {
493 for (uint32_t i=0; i <
keyList.size(); i++) {
494 tmpKeyList.push_back(
keyList[i]);
499 for (uint32_t i=0; i < ((float)maximumKeys *
keyProbability); i++) {
500 uint32_t index = intuniform(0, tmpKeyList.size()-1);
502 returnList->push_back(tmpKeyList[index]);
503 tmpKeyList.erase(tmpKeyList.begin()+index);
519 std::vector<IPvXAddress>* ips =
new std::vector<IPvXAddress>;
524 ips->push_back(it->first);
533 throw cRuntimeError(
"GlobalNodeList::getNodeHandle(const IPvXAddress& address): "
534 "Peer is not in peer set");
539 if ((tempEntry == NULL) || (tempEntry->
addrVector.empty()) ||