#include #include #include #include static class SimpleDistanceClass: public TclClass { public: SimpleDistanceClass() : TclClass("Propagation/SimpleDistance") {} TclObject* create(int, const char*const*) { return (new SimpleDistance); } } class_simpledistance; SimpleDistance::SimpleDistance() { } double SimpleDistance::Pr(PacketStamp *t, PacketStamp *r, WirelessPhy *ifp) { double rX, rY, rZ; // loc of receiver double tX, tY, tZ; // loc of xmitter double d; // dist r->getNode()->getLoc(&rX, &rY, &rZ); t->getNode()->getLoc(&tX, &tY, &tZ); rX += r->getAntenna()->getX(); rY += r->getAntenna()->getY(); tX += t->getAntenna()->getX(); tY += t->getAntenna()->getY(); d = sqrt((rX - tX) * (rX - tX) + (rY - tY) * (rY - tY) + (rZ - tZ) * (rZ - tZ)); return (t->getTxPr() >= d) ? ifp->getRXThresh() * 2 : 0.0; // XXX *2 just to be on the safe side }