Traditionally, in earlier days, a batch of ns-2 simulations were run using suitable scripting languages and the trace analysis was also done using scripts written in different scripting languages such as Perl. The following article [4] presented the classical way of doing ns-3 batch simulations and analysis.
Generating Genuine, Quality Tables & Graphs for Publication.
SEM(Simulation Execution Manager) is a Python library designed to help manage and streamline the execution of multiple ns-3 simulations, handle the results, and organize them in a manner conducive to further analysis. This tool is particularly useful when running extensive simulations with ns-3, where you need to automate processes, manage multiple runs, and collect outputs for post-processing. This article explains what is SEM and how to install it under Linux.
Installation of SEM
As mentioned in [3], we can easily install SEM using pip as follows:
$ pip3 install --user sem
This command will install all the dependencies required for running sem. This will install the sem package and its dependencies in the system’s Python library path. The following screenshot shows the progress of the installation process.
The following screenshot shows the successful installation :
Alternatively, we can install the latest development version, directly from the latest commit on the master branch of the Github repository:
pip3 install --user -U https://github.com/signetlabdei/sem/archive/master.zip
Testing SEM
After successful installation, one can follow [5] to start with SEM based ns-3 batch simulation and analysis.
We can test the working of our installation of SEM with a few lines of Python code:
import sem ns_path = 'ns-3-dev/' script = 'wifi-multi-tos' campaign_dir = 'testResults' campaign = sem.CampaignManager.new(ns_path, script, campaign_dir, overwrite=True, max_parallel_processes=2)
If we run the above command then it will start building ns-3 (if ns-3 is newly installed, then it will compile everything – so, it may take lot of time)
Building ns-3: 100%|████████████████████████████| 2/2 [00:00<00:00, 15.16file/s]
Display the campaign
print(campaign)
--- Campaign info --- script: wifi-multi-tos params: {'nWifi': 4.0, 'distance': 1.0, 'simulationTime': '+10s', 'useRts': False, 'mcs': 7.0, 'channelWidth': 20.0, 'useShortGuardInterval': False} HEAD: Runner type:-----------
Now set some parameters :
param_combination = { 'nWifi': 1, 'distance': 1, 'simulationTime': 10, 'useRts': False, 'mcs': 7, 'channelWidth': 20, 'useShortGuardInterval': False, 'RngRun': 0 }
And run the campaign again :
retults=campaign.run_simulations([param_combination])
may build and run the simulation again:
Building ns-3: 100%|████████████████████████████| 2/2 [00:00<00:00, 14.28file/s] Running simulations: 100%|████████████████| 1/1 [00:00<00:00, 1.41simulation/s]
Display the a sample result from the campaign:
example_result = campaign.db.get_complete_results()[0] print(example_result)
This may show a result like this :
{'params': {'nWifi': 1, 'distance': 1, 'simulationTime': 10, 'useRts': False, 'mcs': 7, 'channelWidth': 20, 'useShortGuardInterval': False, 'RngRun': 0}, 'meta': {'id': 'bd00321f-4836-4a07-b658-fe5e3bbbad48', 'elapsed_time': 6.03503942489624, 'exitcode': 0}, 'output': {'stdout': 'Aggregated throughput: 46.9038 Mbit/s\n', 'stderr': ''}}
We may plot different graphs using the stored results. We may see the way of generating grphs and doing trace analysis in another article.
Summary