#include <Nps.h>
Public Member Functions | |
| Nps () | |
| void | init (NeighborCache *neighborCache) |
| void | handleTimerEvent (cMessage *msg) |
| virtual bool | handleRpcCall (BaseCallMessage *msg) |
| Prox | getCoordinateBasedProx (const AbstractNcsNodeInfo &info) const |
| AbstractNcsNodeInfo * | getUnvalidNcsInfo () const |
| AbstractNcsNodeInfo * | createNcsInfo (const std::vector< double > &coords) const |
| virtual const AbstractNcsNodeInfo & | getOwnNcsInfo () const |
| const std::vector< double > & | getOwnCoordinates () const |
| double | getOwnCoordinates (uint8_t i) const |
| uint8_t | getOwnLayer () const |
Protected Member Functions | |
| void | computeOwnLayer (const std::vector< LandmarkDataEntry > &landmarks) |
| computes this node's NPS layer (max of reference points' layers + 1) | |
| void | computeOwnCoordinates (const std::vector< LandmarkDataEntry > &landmarks) |
| methods for computing own coordinates with the received data | |
| void | setOwnLayer (int8_t layer) |
| announces node's NPS layer to Bootstrap Oracle and Neighbor Cache | |
| void | setOwnCoordinates (const std::vector< double > &coords) |
| void | sendCoordRequests () |
| Get a random set of landmarks / NPS reference node and send coordinate requests to them. | |
| void | sendCoordRequests (const std::vector< TransportAddress > &landmarks) |
| void | sendCoordsReqCall (const TransportAddress &dest, simtime_t timeout) |
| void | handleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt) |
| void | handleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &destKey) |
| void | coordsReqRpcResponse (CoordsReqResponse *response, cPolymorphic *context, int rpcId, simtime_t rtt) |
| void | coordsReqRpc (CoordsReqCall *msg) |
| std::vector< LandmarkDataEntry > | getLandmarkData () const |
| std::vector< TransportAddress > | getLandmarks (uint8_t howmany) |
| Askes GlobalNodeList for appropriate landmark nodes. | |
| const std::vector < TransportAddress > & | getLandmarkSet () const |
| uint16_t | getLandmarkSetSize () const |
| bool | setLandmarkSet (uint8_t howManyLM, uint8_t maxLayer, std::vector< TransportAddress > *landmarkSet) |
| bool | enoughLandmarks () |
| void | updateNodeMeasurement (const TransportAddress &node, uint8_t pending=0, uint8_t sent=0, uint8_t passed=0) |
| void | deleteNodeMeasurement (const TransportAddress &node) |
| uint16_t | getReceivedCalls () const |
Protected Attributes | |
| std::vector< RttMeasurement > | nodeMeasurements |
Private Attributes | |
| NeighborCache * | neighborCache |
| BaseOverlay * | overlay |
| GlobalNodeList * | globalNodeList |
| CoordBasedRouting * | coordBasedRouting |
| uint8_t | maxLayer |
| uint8_t | dimensions |
| simtime_t | landmarkTimeout |
| GnpNpsCoordsInfo * | ownCoords |
| int16_t | pendingRequests |
| uint8_t | coordCalcRuns |
| std::vector< TransportAddress > | landmarkSet |
| uint16_t | receivedCalls |
| cMessage * | landmarkTimer |
Friends | |
| class | Landmark |
Definition at line 76 of file Nps.h.
| void Nps::computeOwnCoordinates | ( | const std::vector< LandmarkDataEntry > & | landmarks | ) | [protected] |
methods for computing own coordinates with the received data
Definition at line 495 of file Nps.cc.
Referenced by coordsReqRpcResponse().
{
CoordCalcFunction coordcalcf(landmarks);
Vec_DP initCoordinates(dimensions);
Vec_DP bestCoordinates(dimensions);
std::vector<double> computedCoordinatesStdVector(dimensions);
double bestval;
double resval;
for (uint runs = 0; runs < coordCalcRuns; runs++) {
// start with random coordinates (-100..100 in each dim)
for (uint i = 0; i < dimensions; i++) {
initCoordinates[i] = uniform(-100, 100);
}
// compute minimum coordinates via Simplex-Downhill minimum
// function value is returned, coords are written into initCoordinates
// (call by reference)
resval = CoordCalcFunction::simplex_min(&coordcalcf, initCoordinates);
if (runs == 0 || (runs > 0 && resval < bestval) ) {
bestval = resval;
bestCoordinates = initCoordinates;
}
}
for (uint i = 0; i < dimensions; i++) {
computedCoordinatesStdVector[i] = bestCoordinates[i];
}
setOwnCoordinates(computedCoordinatesStdVector);
}
| void Nps::computeOwnLayer | ( | const std::vector< LandmarkDataEntry > & | landmarks | ) | [protected] |
computes this node's NPS layer (max of reference points' layers + 1)
Definition at line 449 of file Nps.cc.
Referenced by coordsReqRpcResponse().
{
int8_t computedLayer = getOwnLayer();
for (uint i = 0; i < landmarks.size(); i++) {
if (computedLayer <= landmarks[i].layer) {
computedLayer = landmarks[i].layer + 1;
}
}
setOwnLayer(computedLayer);
}
| void Nps::coordsReqRpc | ( | CoordsReqCall * | msg | ) | [protected] |
Definition at line 160 of file Nps.cc.
Referenced by handleRpcCall().
{
receivedCalls++;
CoordsReqResponse* coordResp = new CoordsReqResponse("CoordsReqResp");
coordResp->setLayer(getOwnLayer()); //TODO
coordResp->setNcsInfoArraySize(dimensions + 1);
//if (getOwnLayer() != 0) {
// ordinary node
const std::vector<double>& ownCoordinates = getOwnCoordinates();
uint8_t i;
for (i = 0; i < ownCoordinates.size(); ++i) {
coordResp->setNcsInfo(i, ownCoordinates[i]);
}
coordResp->setNcsInfo(i, getOwnLayer());
/*} else {
// landmark node
Landmark* landmark = check_and_cast<Landmark*>(neighborCache->getParentModule()
->getModuleByRelativePath("tier1.landmark"));
assert(landmark);
const std::vector<double>& ownCoordinates = landmark->getOwnNpsCoords();
uint8_t i;
for (i = 0; i < ownCoordinates.size(); ++i) {
coordResp->setNcsInfo(i, ownCoordinates[i]);
}
coordResp->setNcsInfo(i, getOwnLayer());
}*/
coordResp->setBitLength(COORDSREQRESPONSE_L(coordResp));
neighborCache->sendRpcResponse(msg, coordResp);
}
| void Nps::coordsReqRpcResponse | ( | CoordsReqResponse * | response, | |
| cPolymorphic * | context, | |||
| int | rpcId, | |||
| simtime_t | rtt | |||
| ) | [protected] |
Definition at line 207 of file Nps.cc.
Referenced by handleRpcResponse().
{
pendingRequests--;
NodeHandle& srcNode = response->getSrcNode();
std::vector<double> tempCoords;
for (uint8_t i = 0; i < response->getNcsInfoArraySize(); i++) {
tempCoords.push_back(response->getNcsInfo(i));
}
GnpNpsCoordsInfo* coordsInfo =
static_cast<GnpNpsCoordsInfo*>(createNcsInfo(tempCoords));
EV << "[Nps::coordsReqRpcResponse() @ " << neighborCache->thisNode.getIp()
<< " (" << neighborCache->thisNode.getKey().toString(16) << ")]\n received landmark coords: "
<< tempCoords[0];
for (uint8_t i = 1; i < dimensions; i++) {
EV << ", " << tempCoords[i];
}
EV << " (rtt = " << rtt << ")" << endl;
#ifdef EXTJOIN_DISCOVERY
if (doingDiscovery()) {
//if in Discovery insert RTT only if lower then already set RTT
if ((isEntry(srcNode) && rtt < getNodeRtt(srcNode))
|| (isEntry(srcNode) && getNodeRtt(srcNode) < 0) ) {
updateNode(srcNode, rtt, tempCoords, 0);
} else if (!(isEntry(srcNode))) {
updateNode(srcNode, rtt, tempCoords, 0);
} else {
updateNode(srcNode, getNodeRtt(srcNode), tempCoords, 0);
}
setNodeLayer(srcNode, tempLayer);
}
else if (doingNodeMeasurement()) {
if (getPendingRttsReq(srcNode) == -1) {
updateNode(srcNode, rtt, tempCoords, 0);
setNodeLayer(srcNode, tempLayer);
RttToNodeCall* prevCall = getNodeMessage(srcNode);
RttToNodeResponse* rttRes = new RttToNodeResponse("RttToNodeXRes");
rttRes->setPingedNode(srcNode);
rttRes->setRttToNode(rtt);
std::vector<double> tempOwnCoords;
tempOwnCoords = getOwnCoordinates();
rttRes->setOwnCoordinatesArraySize(tempOwnCoords.size());
for (uint i = 0; i < tempOwnCoords.size(); i++) {
rttRes->setOwnCoordinates(i, tempOwnCoords[i]);
}
sendRpcResponse(prevCall, rttRes);
deleteNodeMeasurement(srcNode);
} else {
updateNode(srcNode, rtt, tempCoords, 0);
setNodeLayer(srcNode, tempLayer);
if (checkCoordinates(getOwnCoordinates(), tempCoords, rtt)) {
updateNodeMeasurement(srcNode, -1, 0, 1);
} else {
updateNodeMeasurement(srcNode, -1, 0, 0);
}
}
}
else
#endif
if (pendingRequests == 0) {
// got all responses, now compute own coordinates and join overlay
neighborCache->updateNode(srcNode, rtt, NodeHandle::UNSPECIFIED_NODE,
coordsInfo);
std::vector<LandmarkDataEntry> probedLandmarks;
if (getLandmarkSetSize() < dimensions + 1) {
setLandmarkSet(dimensions + 1, maxLayer, &landmarkSet);
}
for (std::vector<TransportAddress>::iterator it = landmarkSet.begin();
it != landmarkSet.end(); ++it) {
const GnpNpsCoordsInfo* tempInfo =
dynamic_cast<const GnpNpsCoordsInfo*>(neighborCache->getNodeCoordsInfo(*it));
assert(tempInfo);
LandmarkDataEntry temp;
temp.coordinates.resize(tempInfo->getDimension());
temp.rtt = neighborCache->getNodeRtt(*it).first;
temp.layer = tempInfo->getLayer();
for (uint8_t i = 0; i < tempInfo->getDimension(); ++i) {
temp.coordinates[i] = tempInfo->getCoords(i);
}
temp.ip = NULL;
probedLandmarks.push_back(temp);
}
assert(probedLandmarks.size() > 0);
computeOwnCoordinates(probedLandmarks);
computeOwnLayer(probedLandmarks);
std::vector<double> coords = getOwnCoordinates();
EV << "[Nps::coordsReqRpcResponse() @ " << neighborCache->thisNode.getIp()
<< " (" << neighborCache->thisNode.getKey().toString(16) << ")]\n setting own coords: "
<< coords[0];
for (uint8_t i = 1; i < dimensions; i++) {
EV << ", " << coords[i];
}
EV << endl;
//test
/*
ChurnGenerator* lmChurnGen = NULL;
for (uint8_t i = 0; i < neighborCache->underlayConfigurator->getChurnGeneratorNum(); i++) {
ChurnGenerator* searchedGen;
searchedGen = neighborCache->underlayConfigurator->getChurnGenerator(i);
if (searchedGen->getNodeType().overlayType != "oversim.common.cbr.LandmarkModules") {
lmChurnGen = searchedGen;
}
}
*/
SimpleNodeEntry* entry =
dynamic_cast<SimpleInfo*>(globalNodeList->
getPeerInfo(neighborCache->thisNode.getIp()))->getEntry();
double error = 0;
for (uint8_t i = 1; i < entry->getDim(); i++) {
error += pow(coords[i] - entry->getCoords(i), 2);
}
error = sqrt(error);
neighborCache->globalStatistics
->addStdDev("NPS: Coordinate difference", error);
neighborCache->neighborCache.clear(); //TODO
neighborCache->neighborCacheExpireMap.clear(); //TODO
neighborCache->getParentModule()
->bubble("GNP/NPS coordinates calculated -> JOIN overlay!");
if (coordBasedRouting) {
int bitsPerDigit = neighborCache->overlay->getBitsPerDigit();
neighborCache->thisNode.setKey(
coordBasedRouting->getNodeId(coords, bitsPerDigit,
OverlayKey::getLength()));
EV << "[Nps::coordsReqRpcResponse() @ "
<< neighborCache->thisNode.getIp()
<< " (" << neighborCache->thisNode.getKey().toString(16) << ")]"
<< "\n -> nodeID ( 2): "
<< neighborCache->thisNode.getKey().toString(2)
<< "\n -> nodeID (16): "
<< neighborCache->thisNode.getKey().toString(16) << endl;
// returning to BaseOverlay
neighborCache->overlay->join(neighborCache->thisNode.getKey());
} else {
// returning to BaseOverlay
neighborCache->overlay->join();
}
} else {
neighborCache->updateNode(srcNode, rtt, NodeHandle::UNSPECIFIED_NODE,
coordsInfo);
}
}
| AbstractNcsNodeInfo * Nps::createNcsInfo | ( | const std::vector< double > & | coords | ) | const [virtual] |
Implements AbstractNcs.
Definition at line 633 of file Nps.cc.
Referenced by coordsReqRpcResponse().
{
assert(coords.size() > 1);
GnpNpsCoordsInfo* info = new GnpNpsCoordsInfo();
uint8_t i;
for (i = 0; i < coords.size() - 1; ++i) {
info->setCoords(i, coords[i]);
}
info->setLayer(coords[i]);
return info;
}
| void Nps::deleteNodeMeasurement | ( | const TransportAddress & | node | ) | [protected] |
Definition at line 616 of file Nps.cc.
Referenced by coordsReqRpcResponse(), and handleRpcTimeout().
{
for(uint i = 0; i < nodeMeasurements.size(); i++) {
if (nodeMeasurements[i].measuredNode == node) {
#ifdef EXTJOIN_DISCOVERY
delete nodeMeasurements[i].message;
#endif
nodeMeasurements.erase(nodeMeasurements.begin()+i);
i--;
}
}
if (nodeMeasurements.size() == 0) {
//stopNodeMeasurement();
}
}
| bool Nps::enoughLandmarks | ( | ) | [protected] |
Definition at line 555 of file Nps.cc.
Referenced by handleTimerEvent().
{
return (globalNodeList->getLandmarkPeerSize() > dimensions);
}
| Prox Nps::getCoordinateBasedProx | ( | const AbstractNcsNodeInfo & | info | ) | const [virtual] |
Implements AbstractNcs.
Definition at line 561 of file Nps.cc.
{
return ownCoords->getDistance(abstractInfo);
/*
if (!dynamic_cast<const GnpNpsCoordsInfo*>(&abstractInfo)) {
throw cRuntimeError("GNP/NPS coords needed!");
}
const GnpNpsCoordsInfo& info =
*(static_cast<const GnpNpsCoordsInfo*>(&abstractInfo));
double dist = 0.0;
uint32_t size = info.getDimension();
for (uint32_t i = 0; i < size; i++) {
dist += pow(ownCoords->getCoords(i) - info.getCoords(i), 2);
}
dist = sqrt(dist);
return Prox(dist, 0.0); //TODO accuracy
*/
}
| std::vector<LandmarkDataEntry> Nps::getLandmarkData | ( | ) | const [protected] |
| std::vector< TransportAddress > Nps::getLandmarks | ( | uint8_t | howmany | ) | [protected] |
Askes GlobalNodeList for appropriate landmark nodes.
| howmany | number of needed landmark nodes |
Definition at line 528 of file Nps.cc.
Referenced by sendCoordRequests().
{
std::vector<TransportAddress> returnPool;
if (howmany > globalNodeList->getLandmarkPeerSize()) {
throw cRuntimeError("Not enough landmarks available in network!");
}
while (returnPool.size() < howmany) {
TransportAddress* lm = globalNodeList->getRandomAliveNode();
PeerInfo* lmInfo = globalNodeList->getPeerInfo(lm->getIp());
if (lmInfo->getNpsLayer() >= 0 &&
lmInfo->getNpsLayer() < maxLayer) {
// already in returnPool?
bool alreadyin = false;
for (uint8_t i = 0; i < returnPool.size(); i++) {
if (returnPool[i] == *lm)
alreadyin = true;
}
if (alreadyin == false) {
returnPool.push_back(*lm);
}
}
}
return returnPool;
}
| const std::vector<TransportAddress>& Nps::getLandmarkSet | ( | ) | const [inline, protected] |
Definition at line 171 of file Nps.h.
{ return landmarkSet; };
| uint16_t Nps::getLandmarkSetSize | ( | ) | const [inline, protected] |
Definition at line 172 of file Nps.h.
Referenced by coordsReqRpcResponse().
{ return landmarkSet.size(); };
| double Nps::getOwnCoordinates | ( | uint8_t | i | ) | const [inline] |
| const std::vector<double>& Nps::getOwnCoordinates | ( | ) | const [inline] |
Definition at line 113 of file Nps.h.
Referenced by coordsReqRpc(), coordsReqRpcResponse(), and handleRpcTimeout().
| uint8_t Nps::getOwnLayer | ( | ) | const [inline] |
Definition at line 115 of file Nps.h.
Referenced by computeOwnLayer(), and coordsReqRpc().
| virtual const AbstractNcsNodeInfo& Nps::getOwnNcsInfo | ( | ) | const [inline, virtual] |
| uint16_t Nps::getReceivedCalls | ( | ) | const [inline, protected] |
Definition at line 187 of file Nps.h.
{ return receivedCalls; };
| AbstractNcsNodeInfo* Nps::getUnvalidNcsInfo | ( | ) | const [inline, virtual] |
| bool Nps::handleRpcCall | ( | BaseCallMessage * | msg | ) | [virtual] |
Reimplemented from AbstractNcs.
Definition at line 150 of file Nps.cc.
{
RPC_SWITCH_START( msg );
RPC_DELEGATE( CoordsReq, coordsReqRpc );
//if (discovery)
RPC_SWITCH_END( );
return RPC_HANDLED;
}
| void Nps::handleRpcResponse | ( | BaseResponseMessage * | msg, | |
| cPolymorphic * | context, | |||
| int | rpcId, | |||
| simtime_t | rtt | |||
| ) | [protected] |
Definition at line 87 of file Nps.cc.
{
// call rpc stubs
RPC_SWITCH_START( msg );
RPC_ON_RESPONSE( CoordsReq ) {
coordsReqRpcResponse(_CoordsReqResponse, context, rpcId, rtt);
}
#ifdef EXTJOIN_DISCOVERY
RPC_ON_RESPONSE( RttToNode ) {
rttToNodeRpcResponse(_RttToNodeResponse, context, rpcId, rtt);
}
#endif
RPC_SWITCH_END( );
return;
}
| void Nps::handleRpcTimeout | ( | BaseCallMessage * | msg, | |
| const TransportAddress & | dest, | |||
| cPolymorphic * | context, | |||
| int | rpcId, | |||
| const OverlayKey & | destKey | |||
| ) | [protected] |
Definition at line 106 of file Nps.cc.
{
RPC_SWITCH_START( msg ) {
RPC_ON_CALL( CoordsReq ) {
if (true/*doingNodeMeasurement()*/) {//TODO
#ifdef EXTJOIN_DISCOVERY
if (getPendingRttsReq(dest) == -1) {
RttToNodeCall* call = getNodeMessage(dest);
RttToNodeResponse* rttRes = new RttToNodeResponse("RttToNodeXRes");
rttRes->setPingedNode(dest);
rttRes->setRttToNode(0);
std::vector<double> tempOwnCoords;
tempOwnCoords = getOwnCoordinates();
rttRes->setOwnCoordinatesArraySize(tempOwnCoords.size());
for (uint i = 0; i < tempOwnCoords.size(); i++) {
rttRes->setOwnCoordinates(i, tempOwnCoords[i]);
}
sendRpcResponse(call, rttRes);
deleteNodeMeasurement(dest);
} else {
#endif
updateNodeMeasurement(dest, -1);
#ifdef EXTJOIN_DISCOVERY
}
#endif
} else {
pendingRequests--;
}
}
#ifdef EXTJOIN_DISCOVERY
RPC_ON_CALL( RttToNode ) {
updateNodeMeasurement(dest, -1);
}
#endif
}
RPC_SWITCH_END( )
}
| void Nps::handleTimerEvent | ( | cMessage * | msg | ) | [virtual] |
Reimplemented from AbstractNcs.
Definition at line 73 of file Nps.cc.
{
// process landmark timer message
if (msg == landmarkTimer) {
if (enoughLandmarks()) {
delete msg;
//std::cout << "[" << getThisNode().getIp() << "] (Re-)Trying to contact landmarks" << std::endl;
sendCoordRequests();
} else {
neighborCache->scheduleAt(simTime() + landmarkTimeout, msg);
}
}
}
| void Nps::init | ( | NeighborCache * | neighborCache | ) | [virtual] |
Implements AbstractNcs.
Definition at line 41 of file Nps.cc.
{
this->neighborCache = neighborCache;
overlay = neighborCache->overlay;
maxLayer = neighborCache->par("npsMaxLayer");
dimensions = neighborCache->par("gnpDimensions");
landmarkTimeout = neighborCache->par("gnpLandmarkTimeout");
GnpNpsCoordsInfo::setDimension(dimensions);
ownCoords = new GnpNpsCoordsInfo();
receivedCalls = 0;
pendingRequests = 0;
coordCalcRuns = neighborCache->par("npsCoordCalcRuns");
WATCH(*ownCoords);
WATCH_VECTOR(landmarkSet);
coordBasedRouting = CoordBasedRoutingAccess().get();
globalNodeList = GlobalNodeListAccess().get();
if (neighborCache->getParentModule()->getModuleByRelativePath("tier1")
->getModuleByRelativePath("landmark") == NULL) {
landmarkTimer = new cMessage("landmarkTimer");
neighborCache->scheduleAt(simTime() + landmarkTimeout, landmarkTimer);
} else {
// GNP-landmark or NPS-Layer-0-landmark
ownCoords->setLayer(0); //TODO double, see Landmark.cc
}
}
| void Nps::sendCoordRequests | ( | ) | [protected] |
Get a random set of landmarks / NPS reference node and send coordinate requests to them.
Definition at line 422 of file Nps.cc.
Referenced by handleTimerEvent().
{
std::vector <TransportAddress> landmarks;
landmarks = getLandmarks(dimensions + 1);
simtime_t timeout = -1;
if (landmarks.size() > 0) {
for (size_t i = 0; i < landmarks.size(); i++) {
const TransportAddress& tolm = landmarks[i];
sendCoordsReqCall(tolm, timeout);
}
setLandmarkSet(dimensions + 1, maxLayer, &landmarkSet);
}
}
| void Nps::sendCoordRequests | ( | const std::vector< TransportAddress > & | landmarks | ) | [protected] |
| void Nps::sendCoordsReqCall | ( | const TransportAddress & | dest, | |
| simtime_t | timeout | |||
| ) | [protected] |
Definition at line 438 of file Nps.cc.
Referenced by sendCoordRequests().
{
CoordsReqCall* coordReq = new CoordsReqCall("CoordsReq");
coordReq->setBitLength(COORDSREQCALL_L(coordReq));
neighborCache->sendRouteRpcCall(neighborCache->getThisCompType(), dest,
coordReq, NULL, NO_OVERLAY_ROUTING,
timeout, 0, -1, this);
pendingRequests++;
}
| bool Nps::setLandmarkSet | ( | uint8_t | howManyLM, | |
| uint8_t | maxLayer, | |||
| std::vector< TransportAddress > * | landmarkSet | |||
| ) | [protected] |
Definition at line 392 of file Nps.cc.
Referenced by coordsReqRpcResponse(), and sendCoordRequests().
{
landmarkSet->clear();
NeighborCache::NeighborCacheIterator it;
uint availableLM = 0;
TransportAddress landmark;
for(it = neighborCache->neighborCache.begin(); it != neighborCache->neighborCache.end(); it++ ) {
if (dynamic_cast<GnpNpsCoordsInfo*>(it->second.coordsInfo) &&
static_cast<GnpNpsCoordsInfo*>(it->second.coordsInfo)->getLayer()
< maxLayer) {
landmark.setIp(it->first.getIp());
landmark.setPort(it->second.nodeRef.getPort());
landmarkSet->push_back(landmark);
availableLM++;
}
}
if (availableLM < howManyLM) {
return false;
} else {
uint i = availableLM;
while (i > howManyLM) {
uint randomNumber = (intuniform(0, landmarkSet->size()));
landmarkSet->erase(landmarkSet->begin() + randomNumber);
i--;
}
return true;
}
}
| void Nps::setOwnCoordinates | ( | const std::vector< double > & | coords | ) | [inline, protected] |
Definition at line 132 of file Nps.h.
Referenced by computeOwnCoordinates(), and Landmark::initializeApp().
| void Nps::setOwnLayer | ( | int8_t | layer | ) | [protected] |
announces node's NPS layer to Bootstrap Oracle and Neighbor Cache
Definition at line 460 of file Nps.cc.
Referenced by computeOwnLayer(), and Landmark::initializeApp().
{
ownCoords->setLayer(layer);
// Update in BootstrapOracle
PeerInfo* thisInfo = globalNodeList->getPeerInfo(neighborCache->getThisNode());
thisInfo->setNpsLayer(layer);
// Workaround against -1 ports in BS oracle
if (layer > 0) globalNodeList->refreshEntry(neighborCache->overlay->getThisNode());
if (layer < maxLayer) {
globalNodeList->incLandmarkPeerSize();
globalNodeList->incLandmarkPeerSizePerType(thisInfo->getTypeID());
}
}
| void Nps::updateNodeMeasurement | ( | const TransportAddress & | node, | |
| uint8_t | pending = 0, |
|||
| uint8_t | sent = 0, |
|||
| uint8_t | passed = 0 | |||
| ) | [protected] |
Definition at line 585 of file Nps.cc.
Referenced by coordsReqRpcResponse(), and handleRpcTimeout().
{
bool alreadySet = false;
for(uint i = 0; i < nodeMeasurements.size(); i++) {
if (nodeMeasurements[i].measuredNode == node && sent == 0) {
nodeMeasurements[i].rttsPending += pending;
nodeMeasurements[i].rttsSent += sent;
nodeMeasurements[i].coordsPassed += passed;
alreadySet = true;
i = nodeMeasurements.size();
} else if (nodeMeasurements[i].measuredNode == node) {
nodeMeasurements[i].rttsPending = pending;
nodeMeasurements[i].rttsSent = sent;
nodeMeasurements[i].coordsPassed = passed;
alreadySet = true;
i = nodeMeasurements.size();
}
}
if (!alreadySet) {
RttMeasurement newNode;
newNode.measuredNode = node;
newNode.rttsPending = pending;
newNode.rttsSent = sent;
newNode.coordsPassed = passed;
nodeMeasurements.push_back(newNode);
}
}
CoordBasedRouting* Nps::coordBasedRouting [private] |
Definition at line 84 of file Nps.h.
Referenced by coordsReqRpcResponse(), and init().
uint8_t Nps::coordCalcRuns [private] |
Definition at line 93 of file Nps.h.
Referenced by computeOwnCoordinates(), and init().
uint8_t Nps::dimensions [private] |
Definition at line 87 of file Nps.h.
Referenced by computeOwnCoordinates(), coordsReqRpc(), coordsReqRpcResponse(), enoughLandmarks(), init(), and sendCoordRequests().
GlobalNodeList* Nps::globalNodeList [private] |
Definition at line 83 of file Nps.h.
Referenced by coordsReqRpcResponse(), enoughLandmarks(), getLandmarks(), init(), and setOwnLayer().
std::vector<TransportAddress> Nps::landmarkSet [private] |
Definition at line 95 of file Nps.h.
Referenced by coordsReqRpcResponse(), getLandmarkSet(), getLandmarkSetSize(), init(), and sendCoordRequests().
simtime_t Nps::landmarkTimeout [private] |
Definition at line 88 of file Nps.h.
Referenced by handleTimerEvent(), and init().
cMessage* Nps::landmarkTimer [private] |
Definition at line 99 of file Nps.h.
Referenced by handleTimerEvent(), and init().
uint8_t Nps::maxLayer [private] |
Definition at line 86 of file Nps.h.
Referenced by coordsReqRpcResponse(), getLandmarks(), init(), sendCoordRequests(), and setOwnLayer().
NeighborCache* Nps::neighborCache [private] |
Definition at line 81 of file Nps.h.
Referenced by coordsReqRpc(), coordsReqRpcResponse(), handleTimerEvent(), sendCoordsReqCall(), setLandmarkSet(), and setOwnLayer().
std::vector<RttMeasurement> Nps::nodeMeasurements [protected] |
Definition at line 178 of file Nps.h.
Referenced by deleteNodeMeasurement(), and updateNodeMeasurement().
BaseOverlay* Nps::overlay [private] |
GnpNpsCoordsInfo* Nps::ownCoords [private] |
Definition at line 90 of file Nps.h.
Referenced by getCoordinateBasedProx(), getOwnCoordinates(), getOwnLayer(), getOwnNcsInfo(), init(), setOwnCoordinates(), and setOwnLayer().
int16_t Nps::pendingRequests [private] |
Definition at line 92 of file Nps.h.
Referenced by coordsReqRpcResponse(), handleRpcTimeout(), init(), and sendCoordsReqCall().
uint16_t Nps::receivedCalls [private] |
Definition at line 97 of file Nps.h.
Referenced by coordsReqRpc(), getReceivedCalls(), and init().
1.7.1