Using RSSI for distance comparisons

A simple way to obtain a value directly proportional to the RSSI of a message is editing the files ns-2.30/common/packet.h and ns-2.30/mac/wireless-phy.cc.

On packet.h just add a double type myRSSI variable on the class Packet. Then, add p->myRSSI = (double) Pr * 10e10 on file wireless-phy.cc, as on the following piece of the code:

[...]
if(modulation_) {
hdr_cmn *hdr = HDR_CMN(p);
hdr->error() = modulation_->BitError(Pr);
}

/*
* The MAC layer must be notified of the packet reception
* now - ie; when the first bit has been detected - so that
* it can properly do Collision Avoidance / Detection.
*/
pkt_recvd = 1;
p->myRSSI = (double) Pr * 10e10;
DONE:
p->txinfo_.getAntenna()->release();
[...]

Then you can access the rssi-like field from a Packet *p variable with p->myRSSI.