0

I'm working οn a project using OMNeT++ (v5.6.2) with Veins (v5.1) and I need to export the results/datasets after every run in JSON format.

I'm familiar with exporting the data manually in JSON but is there any way to export the data automatically, with a specific name and save them in a certain folder?

Christina
  • 70
  • 7

2 Answers2

1

For converting from OMNeT++ .sca and .vec format to .json, I would recommend using opp_scavetool, which is part of OMNeT++.

For example, running the following command after having run the Veins 5.1 example simulation...

opp_scavetool x examples/veins/results/General-\#0.sca -F JSON -o -

...results in output that contains the following:

            {
                "module" : "RSUExampleScenario.rsu[0].nic.mac1609_4",
                "name" : "SlotsBackoff",
                "value" : 38
            },

That said, if you are looking to use this output for statistical evaluation or plotting, I would recommend using .csv over .json, which allows for a more structured representation of data. This can be done using opp_scavetool or using more powerful scripts such as the ones in https://github.com/veins/veins_scripts

Christoph Sommer
  • 6,893
  • 1
  • 17
  • 35
  • This looks similar to the scavetool x *.sca -o aloha.csv from the tic toc tutorial. I'm trying to use the results of the simulation as an input in a different module. Apart from running the above command is there any way to create the .json simultaneously along with the results? Maybe trigger it somehow in OMNeT++? – Christina Mar 16 '21 at 14:54
  • I am not aware of any built-in methods of OMNeT++ to directly write `.json` files. Because OMNeT++ simulations are C++ programs, you can, of course extend the OMNeT++ simulation kernel with a `.json` result writer of your own design. Or, even simpler, you could have your simulation run a C++ method that executes a shell script to do the conversion at a given time. – Christoph Sommer Mar 16 '21 at 14:57
0

I think you can write a program in any language that calls the scavetool command line command periodically based on your need to export the ongoing .sca and .vec files to json files as you want.

Moreover, another option is you can choose the option to output directly to Sqllite file directly instead of exporting to JSON. I tested it and it worked. Reference: https://doc.omnetpp.org/omnetpp/manual/#sec:ana-sim:sqlite-result-files.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Hugo Tran
  • 11
  • 3