time2 = simTime() - time1;
time1 = simTime();
statsInterPacketDelay = (statsInterPacketDelay + time2)/2;
I have this code inside reseivedMessage function in my application class.
When The vehicle exists the simulation, finish() method is called and then I record statsInterPacketDelay.