Need Help about getting RSSI value in MixiM

451 views
Skip to first unread message

Amene Deljoo

unread,
Aug 21, 2014, 8:06:03 AM8/21/14
to omn...@googlegroups.com
I want to know that how can I get the RSSI value of the received message using the MixiM frame work? I would like to find out direct number of neighbour by this properties?
I would be grateful if anyone could help me?

Amene Deljoo

unread,
Aug 26, 2014, 9:06:25 AM8/26/14
to omn...@googlegroups.com
self reply.
I am trying to use Ieee802.15.4A for my simulation. I want to get the RSSI value.
I found these lines in CSMA802154.h to calculate the RSSI. 
But I don know how to print the RSSI when a packet receive in a node.

cPacket *CSMA802154::decapsMsg(macpkt_ptr_t macPkt) {

    cPacket * msg = csma::decapsMsg(macPkt);

    // get bit error rate
    PhyToMacControlInfo* cinfo = static_cast<PhyToMacControlInfo*> (macPkt->getControlInfo());
    const DeciderResult802154Narrow* result = static_cast<const DeciderResult802154Narrow*> (cinfo->getDeciderResult());
    double ber = result->getBER();
    double rssi = result->getRSSI();

    //get control info attached by base class decapsMsg method
    //and set its rssi and ber
    assert(dynamic_cast<MacToNetwControlInfo*>(msg->getControlInfo()));
    MacToNetwControlInfo* cInfo = static_cast<MacToNetwControlInfo*>(msg->getControlInfo());
    cInfo->setBitErrorRate(ber);
    cInfo->setRSSI(rssi);
    ev<<result->getRSSI()<<"\n";

    return msg;
}

Any help will be appreciate.

Michael Kirsche

unread,
Aug 28, 2014, 5:22:35 AM8/28/14
to omn...@googlegroups.com
Why not simply print the RSSI value at the decapMsg function?
For example with (when you enabled the debug switch in your omnetpp.ini): debugEV<< "CSMA802154::decapMsg => RSSI: " << rssi << endl;

If you want to log / print the value on a lower layer, you probably need to modify the Decider802154Narrow.cc, where (return new DeciderResult802154Narrow...) the RSSI value is actually calculated.

Amene Deljoo

unread,
Aug 28, 2014, 5:37:23 AM8/28/14
to omn...@googlegroups.com
Thanks for your help. Could you please explain it a bit more, What should I do?
what should I change in omnetpp.ini to print RSSI.
I am stuck here please help me.

Amene Deljoo

unread,
Aug 28, 2014, 6:19:30 AM8/28/14
to omn...@googlegroups.com

I followed the steps you mentioned.
in Ieeenarrow8021504 in omnet.ini
*.**.debug = true
and in CSMA802154.cc I add this line

debugEV<< "CSMA802154::decapMsg => RSSI: " << rssi << endl;
 but I don get the RSSI.
Did I miss the steps?
I am wondering if you could help me to solve this probelm.
thanks

Michael Kirsche

unread,
Aug 28, 2014, 6:36:13 AM8/28/14
to omn...@googlegroups.com
Where in CSMA802154.cc did you add the debugEV line?
Plus, did you re-compile MiXiM?

Amene Deljoo

unread,
Aug 28, 2014, 7:29:09 AM8/28/14
to omn...@googlegroups.com
I put the code here ,and yes I build the MixiM agin. but in the result folder I do not see the RSSI value.

cPacket *CSMA802154::decapsMsg(macpkt_ptr_t macPkt) {

    cPacket * msg = csma::decapsMsg(macPkt);

    // get bit error rate
    PhyToMacControlInfo* cinfo = static_cast<PhyToMacControlInfo*> (macPkt->getControlInfo());
    const DeciderResult802154Narrow* result = static_cast<const DeciderResult802154Narrow*> (cinfo->getDeciderResult());
    double ber = result->getBER();
    double rssi = result->getRSSI();

    //get control info attached by base class decapsMsg method
    //and set its rssi and ber
    assert(dynamic_cast<MacToNetwControlInfo*>(msg->getControlInfo()));
    MacToNetwControlInfo* cInfo = static_cast<MacToNetwControlInfo*>(msg->getControlInfo());
    cInfo->setBitErrorRate(ber);
    cInfo->setRSSI(rssi);
    debugEV<< "CSMA802154::decapMsg => RSSI: " << rssi << endl;

    return msg;

Michael Kirsche

unread,
Aug 28, 2014, 7:45:27 AM8/28/14
to omn...@googlegroups.com
Okay there's a serious misconception here...

I've written you a hint for printing the RSSI value on the debug output (a.k.a. OMNeT's terminal window).
If you want to log the RSSI value as a simulation outcome / result (like the BER), then you need to modify the Decider802154Narrow.cc.

Take a look at the following function:
DeciderResult* Decider802154Narrow::createResult(const airframe_ptr_t frame)

There you can see how BER and SNR values are calculated and eventually logged in OMNeT statistic constructs (cOutVector).

Learn from this how outputs are logged and enhance the code so that the RSSI value is also calculated inside the function and eventually logged in a similar way.

Amene Deljoo

unread,
Aug 28, 2014, 8:16:07 AM8/28/14
to omn...@googlegroups.com
thanks, I try to add these lines in this function but I got errors
double rssi = 10*log10(snirAvg);
        if (noErrors)
        {
                phy->sendUp(frame,new DeciderResult802154Narrow(true, bitrate, snirMin, avgBER, rssi));

Michael Kirsche

unread,
Aug 28, 2014, 8:27:05 AM8/28/14
to omn...@googlegroups.com
Again, take a look at the Decider802154Narrow::createResult function.
RSSI calculation is done by another function call (calcChannelSenseRSSI) right when a new DeciderResult802154Narrow is created (which eventually contains RSSI and the other values).
Check how for example the bit error rate is calculated and stored in the cOutVector. Adapt a similar procedure for the RSSI value.

I am just giving you hints so that you can help yourself... I am not a MiXiM expert.
I won't program it for you neither will I try to correct all possible errors.

Amene Deljoo

unread,
Aug 28, 2014, 8:36:13 AM8/28/14
to omn...@googlegroups.com
Thanks for sure i want to do it by myself.
I will post the code here.
thanks again :)

Amene Deljoo

unread,
Aug 28, 2014, 10:39:31 AM8/28/14
to omn...@googlegroups.com
@Michael Kirsche
I know I should add this line to the Decider802154Narrow::createResult function but to be honest I do know where
double rssi = calcChannelSenseRSSI(start, end);

thanks again

Michael Kirsche

unread,
Aug 29, 2014, 5:28:29 AM8/29/14
to omn...@googlegroups.com
Okay last time...

In createResult, you create your temporary double rssi just like ber, avgBer, ...

In the header file, you insert a new cOutVector rssilog just like berlog (do not forget to initialize it just like the other cOutVectors).

Insert the following line after the ber value is calculated (ber = getBERFromSNR...):
rssi = calcChannelSenseRSSI(start, end).first;

After berlog.record... insert:
rssilog.record(rssi);

That's pretty much it as far as I can tell from the code.

Do not forget to enable recording of statistics and vector recording, or else you probably won't see any data recorded in those cOutVectors!

Amene Deljoo

unread,
Aug 29, 2014, 6:11:28 AM8/29/14
to omn...@googlegroups.com
Thanks again,
I did all of these steps yesterday after I posted my last threat but I did not get any RSSI. Here are the codes. Also in Decider802154Narrow.h I added this line (mutable cOutVector rssilog;) and in omnet.ini from ieee802154narrow  I add  these lines. But I don get any value. Thanks and appreciate your reply.
tkenv-default-config =
*.**.coreDebug = false
*.**.debug = true
**.vector-recording=true


DeciderResult* Decider802154Narrow::createResult(const airframe_ptr_t frame) const
{
   
ConstMapping* snrMapping = calculateSnrMapping(frame);
   
const Signal& s          = frame->getSignal();
    simtime_t     start      
= s.getReceptionStart();
    simtime_t    
end        = s.getReceptionEnd();

   
AirFrameVector channel;
    getChannelInfo
(start, end, channel);
    calcChannelSenseRSSI
(start, end);
   
double bitrate  = s.getBitrate()->getValue(Argument(start));
   
double avgBER   = 0;
   
double bestBER  = 0.5;
   
double snirAvg  = 0;
   
bool   noErrors = true;
   
double ber;
   
double rssi;
   
double errorProbability;
   
double maxErrProb = 0.0;

    simtime_t             receivingStart
= MappingUtils::post(start);
   
Argument              argStart(receivingStart);
   
ConstMappingIterator* iter    = snrMapping->createConstIterator(argStart);
   
double                snirMin = iter->getValue();
       
//double                rssi=10*log(snirAvg);
   
// Evaluate bit errors for each snr value
   
// and stops as soon as we have an error.

    simtime_t curTime
= iter->getPosition().getTime();
    simtime_t snrDuration
;
   
while(curTime < end) {
       
//get SNR for this interval
       
double snr = iter->getValue();

       
//determine end of this interval
        simtime_t nextTime
= end;    //either the end of the signal...
       
if(iter->hasNext()) {        //or the position of the next entry
           
const Argument& argNext = iter->getNextPosition();
            nextTime
= std::min(argNext.getTime(), nextTime);
            iter
->next();    //the iterator will already point to the next entry
       
}

       
if (noErrors) {
            snrDuration
= nextTime - curTime;

           
int nbBits = int (SIMTIME_DBL(snrDuration) * bitrate);

           
// non-coherent detection of m-ary orthogonal signals in an AWGN
           
// Channel
           
// Digital Communications, John G. Proakis, section 4.3.2
           
// p. 212, (4.3.32)
           
//  Pm = sum(n=1,n=M-1){(-1)^(n+1)choose(M-1,n) 1/(n+1) exp(-nkgamma/(n+1))}
           
// Pb = 2^(k-1)/(2^k - 1) Pm

            ber    
= getBERFromSNR(snr);
            rssi
= calcChannelSenseRSSI(start, end).first;
            avgBER  
= ber*nbBits;
            snirAvg
= snirAvg + snr*SIMTIME_DBL(snrDuration);
           
if(recordStats) {
              berlog
.record(ber);
              snrlog
.record(MW2DBM(snr));
              rssilog
.record(rssi);
           
}

           
if(ber < bestBER) {
                bestBER
= ber;
           
}
            errorProbability
= 1.0 - pow((1.0 - ber), nbBits);
            noErrors        
= errorProbability < uniform(0, 1);
           
if(errorProbability > maxErrProb)
                maxErrProb
= errorProbability;
       
}
       
if (snr < snirMin)
            snirMin
= snr;

        curTime
= nextTime;
   
}
   
delete iter;
   
delete snrMapping;

    avgBER  
= avgBER / frame->getBitLength();
    snirAvg
= snirAvg / (end - start);
   
if(recordStats) {
      snirReceived
.record(MW2DBM(snirMin));  // in dB

   
}

   
return new DeciderResult802154Narrow(noErrors && !frame->hasBitError(), bitrate, snirMin, avgBER, calcChannelSenseRSSI(start, end).first, maxErrProb);
}

Michael Kirsche

unread,
Aug 29, 2014, 6:54:24 AM8/29/14
to omn...@googlegroups.com
You probably forgot the enable statistics recording for the Decider.

Add those line(s) in your omnetpp.ini:
**.recordStats = true
**.recordVectors = true  #(optional)

As you can see in the source of of the decider, statistics are only recorded if recordStats == true.
So you have to enable this of course.
<div st
...

Amene Deljoo

unread,
Aug 29, 2014, 7:15:11 AM8/29/14
to omn...@googlegroups.com


please have a look at the screen shot of the result, in the vector there is no RSSI published?
ber and snr or anything except RSSI.

Michael Kirsche

unread,
Aug 29, 2014, 7:23:10 AM8/29/14
to omn...@googlegroups.com
Okay you added the cOutVector for rssilog in Decider802154Narrow.h, but did you also created rssilog in the constructor of Decider802154Narrow and set the name of the cOutVector???

Take a look at the decider's constructor (in the header file) and add the necessary commands for the rssilog, if you didn't do this before.


Amene Deljoo

unread,
Aug 29, 2014, 7:45:01 AM8/29/14
to omn...@googlegroups.com
Yessss it works out. thanks. I have another question, I got the RSSI value= 238, I should change it to get the real number in dBm ?
Thanks for your support

Amene Deljoo

unread,
Aug 29, 2014, 8:46:15 AM8/29/14
to omn...@googlegroups.com
I found that this number is in mW and I should convert it to dBm. please correct me if I am wrong?

Michael Kirsche

unread,
Aug 29, 2014, 8:56:53 AM8/29/14
to omn...@googlegroups.com
I have no clue, as I am not a MiXiM expert / user. Maybe the publications on MiXiM can clear things up?

Amene Deljoo

unread,
Aug 29, 2014, 9:01:49 AM8/29/14
to omn...@googlegroups.com
thanks for every things. I will double check with the publication,

Muhammad Farouq Bin Suhaimi

unread,
Mar 9, 2016, 12:53:31 PM3/9/16
to OMNeT++ Users
Hello Amene Deljoo, can you show me where to put the next code? i have followed your post and do it step by step to get the rssi value. Can you help me to display the rssi value. Where did you modified/add to display the rssi ?
Reply all
Reply to author
Forward
0 new messages