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
  • PRoPHET, RWP
  • SnW, RWP
  • Epidemic, RW
  • PRoPHET, 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:
Scenario.name = %%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:
./one.sh -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 Scenario.name is always unique.

It is important to note that while running parametrized simulations, one should set the Scenario.name 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:
Scenario.name = 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.

Caution:

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 {
    DTNSim.registerForReset(BusControlSystem.class
        .getCanonicalName());
    reset();
}

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:
Scenario.name = %%Group.movementModel%%_%%Group.router%%
Group.movementModel = [RandomWalk; RandomWaypoint;]
Group.router = [EpidemicRouter; ProphetRouter;]

And, say, we run the simulation as:
./one.sh -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

Comments

  1. I am getting error message called
    Can't start: error in configuration file(s)
    Couldn't find class 'routing.Epidemic'
    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'


    Thanks

    ReplyDelete
    Replies
    1. found the answer. Thanks for tutorial.

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

      Delete
    3. ProphetRouter.secondsInTimeUnit = 1
      https://theonekb-barunsaha.rhcloud.com/emails/31/

      Delete
  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

    ReplyDelete
    Replies
    1. Hi VPit1,

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

      Delete
  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.

    http://delay-tolerant-networks.blogspot.com/p/parametrized-simulations.html

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

    thank you very much.

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

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

    ReplyDelete
  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.

    ReplyDelete
    Replies
    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.

      Delete
  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

    ReplyDelete
    Replies
    1. What error message do you get?

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

      Thanks

      Delete
  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)

    ReplyDelete
    Replies
    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.

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

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

      Delete
  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.

    ReplyDelete
  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

    ReplyDelete
  10. I am using multiple scenario this way:

    Scenario.name = 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(World.java:256)
    at input.MessageCreateEvent.processEvent(MessageCreateEvent.java:41)
    at core.World.update(World.java:159)
    at ui.DTNSimTextUI.runSim(DTNSimTextUI.java:29)
    at ui.DTNSimUI.start(DTNSimUI.java:77)
    at core.DTNSim.main(DTNSim.java:85)

    Please help me why this happens.

    ReplyDelete
  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..

    ReplyDelete
  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 : https://www.hindawi.com/journals/tswj/2015/623090/abs/

    ReplyDelete
  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?

    ReplyDelete
  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.

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

    ReplyDelete

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...

Cohere Aya Dataset: Exploring the Split-by-language Collection

A snapshot of the Aya collection (Bengali) . Image taken from HuggingFace. In February 2024, Cohere launched Aya , a multilingual Large Language Model (LLM). Alongside, a set of datasets used to train Aya has also been released. For example, the aya_dataset consists around 205K examples annotated by humans. On the other hand, the recently released aya_collection_language_split is a gigantic dataset with more than 500 million data points spread across more than 100 languages. As the name suggests, this dataset is split by language. For example, all data points in Bengali, irrespective of the underlying task, can be found in a single split. Apart from the original human-annotated examples from the aya_dataset, aya_collection_language_split also contains a lot of translated and templated data. The dataset is released using an Apache-2.0 license, allowing academic and commercial use. The Bengali Language Split Each language split in the Aya collection has three splits. The Bengali split,...

Specifying Source and Destination of Messages

One of the frequently asked questions in the community is how to specify which particular nodes would act as source(s) and destination(s) of the messages created in the ONE simulator. The simulator, in fact, provides a pair of settings (shown below in bold face) aimed for this particular purpose. Let us consider that there are $n + 1$ nodes in an OMN.  Further, let the nodes with addresses from $x$ to $y$, both inclusive, would create messages. The nodes in the range $w$ to $z$, both inclusive, would be the destinations of those messages, where $0 \le x \le y \le n$, and $0 \le w \le z \le n$. Then, the corresponding simulation scenario can be configured as follows. ## Message creation parameters # How many event generators Events.nrof = 1 # Class of the first event generator Events1.class = MessageEventGenerator # (Following settings are specific for the MessageEventGenerator class) # Creation interval in seconds (one new message every 25 to 35 seconds) Events1.interval ...