Hello all,
PLZ I need help, I am looking for a two-dimensional coordinate system to locate a mobile node in MANET (to get its x y coordinates).
I would be thankful for any of your suggestions.
Position of the node
#include “ModuleAccess.h”
#include “IMobility.h”
cModule host getContainingNode(this);
IMobility *mod = check_and_cast<IMobility *>(host->getSubmodule("mobility"));
Coord pos = mod->getCurrentPosition();
If you want to have access to the position of all nodes
#include “ModuleAccess.h”
#include “IMobility.h”
#include <vector>
cTopology topo("topo");
topo.extractByProperty("node");
std::vector< IMobility *> posVect;
for (int i = 0; i < topo.getNumNodes(); i++)
{
cTopology::Node *destNode = topo.getNode(i);
IMobility *mod;
cModule *host = destNode->getModule();
mod = check_and_cast<IMobility *>(host->getSubmodule("mobility"));
posVect.push_back(mod);
}
// position of node i
Coord pos = posVec[i]->->getCurrentPosition();
--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/omnetpp.
For more options, visit https://groups.google.com/d/optout.
Yes, you can, there is other method getCurrentSpeed() that return the speed vector
Coord spVec = mob->getCurrentSpeed();
double speed = sqrt((spVec.x* spVec.x)+ (spVec.y* spVec.y)+ (spVec.z* spVec.z));
Inet 2.x
For inet 3.x, you can have access also, but the code change a bit,
This is an example that crate a vector with the address and mobility module of the nodes.
#include "inet/mobility/contract/IMobility.h
cTopology topo("topo");
topo.extractByProperty("networkNode");
for (int i = 0; i < topo.getNumNodes(); i++)
{
cTopology::Node *destNode = topo.getNode(i);
IMobility *mod;
IInterfaceTable* itable = L3AddressResolver().findInterfaceTableOf(destNode->getModule());
bool notfound = true;
uint64_t add;
for (int j = 0 ; j < itable->getNumInterfaces(); j++)
{
InterfaceEntry *e = itable->getInterface(j);
if (e->getMacAddress().isUnspecified())
continue;
if (e->isLoopback())
continue;
if (!notfound)
break;
for(auto it = segmentMap.begin(); it != segmentMap.end();++it)
{
if (it->first == e->getMacAddress().getInt())
{
notfound = false;
add = e->getMacAddress().getInt();
break;
}
}
}
if (notfound)
continue;
cModule *host = getContainingNode(destNode->getModule());
mod = check_and_cast<IMobility *>(host->getSubmodule("mobility"));
if (mod == nullptr)
throw cRuntimeError("node or mobility module not found");
vectorList[add] = mod;
}
De: omn...@googlegroups.com [mailto:omn...@googlegroups.com] En nombre de sifatm...@upesh.edu.pk
Enviado el: jueves, 09 de febrero de 2017 17:57
Para: OMNeT++ Users <omn...@googlegroups.com>
CC: aari...@hotmail.com
Visit this group at https://groups.google.com/group/omnetpp.
If you have declared segmentMap of the type vector, it doesn’t have the field first.
I recommend to consult a c++ book, this is a c++ error.