'Calculating Dropped Packet using trace.json for a simulation in UnetStack3

I want to calculate the number of the dropped packet for a simulation in UnetStack using trace.json file. I know that, in trace.nam file, there is an event recorded with 'd' for every dropped packet but how do I calculate the no of the dropped packet for a simulation in UnetStack3 using trace.json

I have written a python script to calculate the tolat transferred packet and total received packet.

The pseudo-code is:-

for every event { // transfered packet count if(stimulus[sender] == phy and stimulus[recipient] == phy and response[clazz] == TxFrameNtf) { transfered_packet_count ++; save the message_id of the event to match with the receiving packet event } //Receiveing packet count if(stimulus[sender] == phy and stimulus[recipient] == phy and you get a matching message_id event) { if(response[recipient] != '#phy__snoop__ntf' and response[clazz] != 'BadFrameNtf' and res['clazz'] == 'RxFrameNtf'): received_packet_count ++; } }

I tested this code on the aloha simulation trace file. I am getting a little more packet_transfered_count and packet_receiving_count. please, help me with what condition I am missing?

get the whole python script here



Solution 1:[1]

Unlike trace.nam, currently there aren't any entries in trace.json corresponding to dropped packets.

You may, however, infer dropped packets by comparing the HalfDuplexModem$TX entries in trace.json (which correspond to the arrival of a frame at a node) with corresponding RxFrameNtf/BadFrameNtf entries (which correspond to whether the frame was successfully received or damaged).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mandar Chitre