Skip to main content

Parametrized Simulations

Let us consider that our objective is to study how a given DTN performs (e.g., in terms of message delivery ratio) when three different routing protocols, say Epidemic, PRoPHET, and Spray-and-Wait (SnW), are used. In our previous tutorial, we learned how to simulate a simple scenario using the ONE simulator. For the current study, we can, for example, simply change the routing protocol in the settings file three times, and simulate the scenarios after each change. Done!

Now, let us try to extend our study. Let us consider two mobility models: Random Waypoint (RWP) and Random Walk (RW). We want to compare the delivery ratio of messages obtained for each routing policy and each mobility model used.

We can, again, take a similar approach. We can keep changing the movement model in the settings file every time. Here, we have 3 * 2 = 6 different combinations of settings:
  • Epidemic, RWP
  • SnW, RWP
  • Epidemic, RW
  • SnW, RW
So, this time we need to run the simulation six times.

Suppose, we are also interested to observe the behavior when the nodes have buffer sizes of 2M, 5M, 10M, 15M, and 20M. From our above calculation it follows that this time we have 3 * 2 * 5 = 30 different scenarios. And why not vary the number of nodes itself, say from 10 to 70, in steps of 10? That would amount to 30 * 7 = 210 scenarios.

This leads to the following question — how to manage simulations when the number of scenarios keep increasing? Surely, running them manually every time becomes tedious even when the number of parameters varied is slightly increased.

The ONE simulator comes with an excellent feature — it allows automating several simulation scenarios and therefore, eliminates the need for running each scenario manually. Continuing with the above example, the relevant contents of the settings file would look like: = %%Group.movementModel%%_%%Group.router%%_%%Group.bufferSize%%
Group.movementModel = [RandomWalk; RandomWaypoint;]
Group.router = [EpidemicRouter; ProphetRouter; SprayAndWaitRouter;]
Group.bufferSize = [2M; 5M; 10M; 15M; 20M;]

To simulate all these scenarios, type in the following in the terminal:
./ -b 30 multiple_scenarios.txt

The above command executes the simulator in the batch mode ("-b") and the GUI is not displayed. The number 30 tells how many times the simulator should run. The final argument is the name of the settings file. Notice that, our settings file specifies exactly 30 unique scenarios. Any report generated would have unique file names since our is always unique.

It is important to note that while running parametrized simulations, one should set the parameter appropriately. For example, in the aforementioned settings file, if we set the scenario name as:

To simulate all these scenarios, type in the following in the terminal: = sample_scenario
then irrespective of how many times the simulation is executed in batch mode, only a single report file will be generated by the name sample_scenario_MessageStatsReport.txt (or any other report files specified). Therefore, it is essential that the scenario name setting contains all desired parameters of the simulation to generate appropriate reports.


If you have developed a new routing or movement or any other module that has one or more (non-final) static member(s), you need to take extra care. If such a module is used in the batch mode of simulation for multiple, say 10 times, the static member(s) would retain the value(s) initialized at the first time. For example, if the static member is assigned a new ArrayList  all the 10 simulation instances would retain such an assignment. In reality,  you perhaps would want a new ArrayList created at every run-index of the simulation.

To mitigate such a scenario, static members should not be initialized inside a constructor. Rather, use a static block to initialize them. To mitigate this issue, you should provide a reset() method for your class. As an example, consider the following code snippet from the BusControlSystem class in the movement package:
static {

public static void reset() {
    systems = new HashMap<Integer, BusControlSystem>();

The registerForReset() method specifies that the concerned class must be reset at the beginning of any simulation. The reset() method does the actual resetting task. Inside this method, you should initialize all static members to be used.  In the above example, the reset() method prevents the systems member from using the same HashMap over and over again for the successive simulations executed in batch mode.

Further details on how resetting actually works can be found in the DTNSim class. The said problem with static members, however, does not arise if you are not running the simulation multiple times, i.e., either not using batch mode or using -b 1.

Continuing with our previous example, if one looks at the order of the execution of the above scenarios, one would find something like this:
  1. RandomWalk_EpidemicRouter_2M
  2. RandomWaypoint_ProphetRouter_5M
  3. RandomWalk_SprayAndWaiRoutert_10M
  4. RandomWaypoint_EpidemicRouter_15M
and so on. This order of execution is not similar to the nested for loops. Rather, the "array" of values of each parameter is treated somewhat like a cyclic array, and during each iteration, the value pointed by the current index is selected.

This results in a problem. Let us consider the modified settings file: = %%Group.movementModel%%_%%Group.router%%
Group.movementModel = [RandomWalk; RandomWaypoint;]
Group.router = [EpidemicRouter; ProphetRouter;]

And, say, we run the simulation as:
./ -b 4 multiple_scenarios.txt

In this case, although four simulations would be performed, only two scenarios would be simulated (instead of four, as desired)! The two simulated scenarios would be: RandomWalk_EpidemicRouter and RandomWaypoint_ProphetRouter.

The ONE simulator team has mentioned a simple work around for this. Let us consider that there are n parameters in our simulation namely, P1, P2, …, Pn. Let, v1, v2, …, vn, respectively, denote the number of values specified for each parameter. Thus, to simulate v1 * v2 * … * vn unique scenarios, one should ensure that the pairwise GCD of v1, v2, …, vn is 1. In our first example, we had GCD(2, 3) = 1, GCD(3, 5) = 1 and GCD(2, 5) = 1, and, therefore, resulted in 30 unique scenarios. In other words, the numbers in (v1, v2, …, vn) should be pairwise coprime.

In the latter example, however, we had GCD(2, 2) = 2, which does not satisfy the necessary criteria. As a consequence, all (four) simulation scenarios were not executed.

If this confuses you, simply specify prime number of values for each desired simulation parameter. However, if the number of such parameters is high, this would result in executing excess and unwanted scenarios!

Finally, let me mention a small trick here. Let us consider that there are 4 parameters say, P1, P2, P3 and P4. Let, the # of values for each parameter be 3, 4, 6, 9. Further, let us consider that the last parameter (P4) be the simulation duration. Note that although the numbers (3, 4, 6, 9) are unique, they are not pairwise coprime: GCD(3, 6) = 3. So, let us consider their nearest prime numbers: (3, 5, 7, 11). Clearly, all these are pairwise coprime numbers.

However, note that since we have increased the # of values of P4 from 9 to 11, total number of scenarios to simulate has also increased! This would make the simulations run for a long time.

The trick to save (real) time is to set the simulation duration of the two (or more) extra cases to, say 1 second. That would result in valid simulation scenarios, which, however, would terminate instantly. Another such example would be — if you are considering variable transmission range — to set the radio range to 0 for the extra cases. In such a case, no messages would be exchanged, and the simulation would terminate quite fast. Yet another example would be to use PassiveRouter when you need some extra cases for the routing protocol.

Please also look at question 5 and its answer at the ONE FAQs under the Reports section.

Revision History:

Published: 2013
09 June 2014: Updated example; added few tricks; added link to the ONE FAQ
16 June 2014: Updated description
06 February 2015: Fixed router names in the example code
02 December 2015: Added caution on static fields
06 May 2016: Some minor editing
12 June 2017: Updated explanation for reset()

Previous: The ONE tutorial


  1. I am getting error message called
    Can't start: error in configuration file(s)
    Couldn't find class 'routing.Epidemic'

    then I changed the file to
    Group.router = [EpidemicRouter; ProphetRouter; SprayAndWaitRouter;]

    after which i get the following error.
    Run 1/30
    Running simulation 'RandomWalk_EpidemicRouter_2M'
    2.8 5000: 1781.26 1/s
    Simulation done in 2.80s
    Run 2/30
    Can't start: error in configuration file(s)
    Can't find setting 'ProphetRouter.secondsInTimeUnit'


    1. found the answer. Thanks for tutorial.

    2. Can you post the answer pls i have the same problem.

    3. ProphetRouter.secondsInTimeUnit = 1

  2. Hello Barun,
    Have you run simulations for Spray and Focus? If you have did your results seem right? Any help would be highly appreciated. Thanks

    1. Hi VPit1,

      Sorry, I haven't worked with Spray and Focus.

  3. Hello
    Am a novies of ONE Simulator. i have been trying to run the tutorial on following links but i keep on getting error message
    pls help me out.

    the error message is:
    Can't start: error in configuration file(s)
    Couldn't find class 'routing.Epidemic'

    thank you very much.

    1. I have fixed the names of the router classes. Please check out the code again.

  4. Hi
    Very good tutorials and quite helpful.
    You are saying To simulate all these scenarios, type in the following in the terminal:
    ./ -b 30 multiple_scenarios.txt
    How to do this in Windows?

  5. Hai Mr Barun. Im working on Data Context forwarding approach. It works like this. If the node has similar interest or behavior then it can communicate by forwarding the message. How can I do this.

    1. This is a very broad topic. Would recommend you to look at materials relevant to content sharing. A simple technique is to modify a router class, exchange the interests, and then exchange messages based on interests.

  6. hello barun. thank you for your tutorial. i wanted to simulate prophet router so i changed the value of Group.router to ProphetRouter from EpidemicRouter. but i found that the simulation stops whenever the Scenario.endtime is > 18357. but when Group.router was EpidemicRouter, it was running perfectly for all the values of Scenario.endTime

    1. What error message do you get?

    2. Please I am wondering if you were able to solve this problem?


  7. Hello Barun. i wanted to introduce selfish attack (behaviour) in the network in one simulator to view the increase in average time delay. can you let know me how to do this OR just give a hint of how to proceed?
    (Selfish attack is the one in which 1 or more nodes do not participate in forwarding of messages across the network)

    1. Typically, selfish nodes forward messages that are created only by themselves. You can adapt the message transmission logic of any existing routing protocol by taking into account the source of a message.

    2. but how do i access the source of any message?

    3. Use the getFrom() method of a message.

  8. sorry barun but i cannot really understand what you are talking? (adapting the message transmission logic, with source of a message) Can you please elaborate in a simpler way.

  9. Hi Barun Saha... I want if is it possible for ONE simulator use in Bluetooth Low Energy cases?? I try to make BLEmesh using this simulator.. Im newbie using ONE, and anything that I should change inside ??please tell me.. Or mybe I can email you.. Thank you soo much

  10. I am using multiple scenario this way: = SAMR_Settings-%%Group.movementModel%%-%%Group.router%%-%%Group.nrofHosts%%-%%Group.bufferSize%%
    Scenario.endTime = 43200
    Group.movementModel = [RandomWalk;RandomWaypoint;]
    Group.router = [EpidemicRouter;SprayAndWaitRouter;EBRRouter;]
    Group.nrofHosts = [10;20;30;33;]
    Group.bufferSize = [10M;20M;30M;]
    Report.reportDir = Reports/%%Group.router%%

    Total run scenarios will be 72 so at cmd i am firing this command:

    one.bat -b 72 EPIDEMICbatch_settings.txt

    but getting following error:

    Run 1/72
    Running simulation 'SAMR_Settings-RandomWalk-EpidemicRouter-10-10M'
    core.SimError: No host for address 38. Address range of 0-35 is valid
    at core.World.getNodeByAddress(
    at input.MessageCreateEvent.processEvent(
    at core.World.update(
    at ui.DTNSimTextUI.runSim(
    at ui.DTNSimUI.start(
    at core.DTNSim.main(

    Please help me why this happens.

  11. Hi,
    I wanted to set a destination location for a node which will be active after a message of an "Emergency" type is received by it or its nearest relay node..
    So in this how can I set the node from an inactive state to active state dynamically and force it to move to my preferred location?
    Please help me out on this topic..

  12. hi mr. barun
    i need to run new protocol called as Improved Prophet, is there any coding script about that improved prophet?
    its using hop count and forwarding count parameters to simulate. but i don't have any idea how to create the .java and .class
    source :

  13. Hello there! I hope you're doing great!

    Can I ask you something please?

    Did you found out how to create the .java and .class files?

  14. hello barun
    Can u suggest me if i will change or add some new files in one_1.4.1 so it will accept it or not.
    please help me out.

  15. hi mr. barun
    can you help me how can simulate an attack? just i need a simple scenario..


Post a Comment

Popular posts from this blog

Text Highlighting in Latex

While preparing a manuscript with Latex, it is often useful to highlight the changes made in the current revision with a different color. This can be achieved using the \ textcolor command provided by Latex. For example, \textcolor {red}{Hello World} would display the string "Hello World" in red color. However, the final/published copy of the manuscript does not contain any highlighted text. Therefore, if a large volume of changes were made, it becomes tiresome at the end to find and remove all the individual portions of highlighted text. This can be circumvented by defining a utility command to switch highlighting on and off as desired. In the following, we define a new Latex command, highlighttext , for this purpose. The command takes only a single argument—the text to be highlighted.     \usepackage {color}    % For highlighting changes in this version with red color   \newcommand { \highlighttext }[1] { \textcolor {red}{#1}}   % Remove all text highlighting

The ONE Knowledge Base

The Opportunistic Network Environment (ONE) simulator has become largely popular and widely used in research on DTNs and Opportunistic Networks. The simulator has an associated friendly community, where users can ask questions and get their doubts clarified. Indeed, the community is vibrant and its members are useful. However, there are two issues with this community. First, the archives of the community's mailing list are not public. This is unlike many other similar lists hosted using Mailman, which are public and, therefore, can be searched using Google. Hence, time and again people have asked the question -- how to search the email archives? The second issue is largely due to the first. Due to the lack of searching facility over the archives, often same question tend to be asked by the new users repeatedly. People here are patient enough to reply to them. But such necessity could be entirely discounted had there been a facility to search the archives. In particular, it w

The ONE KB has a new home

The ONE Knowledge Base is now hosted at If you are unaware, the ONE KB allows you to search the old email archives of the simulator's community. Therefore, if you have any question related to simulation, you may query the existing database at the above link. Chances are good that your question might already have been answered previously. If not, you can still post an email to the community's mailing list. Have you tried the ONE KB already? How was your experience? Was it helpful? Let me know in the comments!