0

In order to measure the packet transmission/reception count, I declared a scalar variable and wrote a function related to record. It looks like this:

A.h

class VEINS_API A : public DemoBaseApplLayer
{
     private:
          long StaticsFrsaPacketCount;

          cOutVector frsaPacketCountVector;
     ...
}

A.cc

void A::initialize(int stage)
{
     DemoBaseApplLayer::initialize(stage);
     if(stage == 0)
     {
          StaticsFrsaPacketCount = 0; 
          frsaPacketCountVector.setName("fR_SA packet count");
          ...
     }
}

void A::finish()
{
     recordScalar("fR_SA Packet", StaticsFrsaPacketCount);
     ...
}

void A::handleSelfMsg(cMessage* msg)
{
     switch(msg -> getKind())
     {
          case SEND_FRSA_EVT:
          {
               ...
               StaticsFrsaPacketCount++; 
               frsaPacketCountVector.record(StaticsFrsaPacketCount);
               ... 
               sendDelayedDown(wsm, uniform(0.01, 0.50));
          }
          ...
     }
}

I wrote the code by referring to the statistics written in the official OMNeT++ Tictoc tutorial. However, the result of the scalar value through the generated .anf file after the simulation is finished is as shown in the image below.

enter image description here

In other words, it seems that the value is incremented 1 time and not incremented after that. What is the cause?

Minwoo Kim
  • 497
  • 1
  • 5
  • 21

1 Answers1

2

(this part) of your code looks fine. The most likely reason why you have 1 in the result because really just one packet was sent. The statistics are showing what is actually happening. If you expect several packets to be sent, I suggest to start the app in Qtenv and step over the simulation and make sure that it works as you expect.

Rudi
  • 6,418
  • 1
  • 16
  • 20
  • Thanks for the advice. As answered, there was a problem with the code logic. The `scheduleAt()` function is missing. So, it was confirmed that only one statistical data inserted unconditionally when running the simulation. – Minwoo Kim Apr 30 '21 at 10:23