How do I decide the right number of events in TinyOS and TOSSIM?

不问归期 提交于 2019-12-11 10:35:23

问题


I noticed that the function t.runNextEvent() has a big impact in the time of the simulation. To be sure all events are simulated I call it a lot of times. In some cases(especially when I use flooding to disseminate information) it is not enough.

Hence if this number is too large I have to wait more to obtain the results. If instead the number of calls is too small the simulation becomes useless.

There is any way to know the right number of calls? Here we have to consider the highly randomness and the fact that flooding may be used.


回答1:


By default TOSSIM simulates low-level TinyOS components that potentially generate a lot of events. The only way to know the exact number of times you need to call t.runNextEvent() is to know what exactly is going on in those layers. But this is a) probably impossible and b) unnecessary.

I have been using following approach:

  1. Estimate how long (in seconds/minutes/hours) I want my simulation to run. This can depend on the project requirements or nature of code you are simulating.
  2. Find out how many ticks are there per simulated second using t.ticksPerSecond(). Note that I said simulated second (Usefull paper on TOSSIM, see top of page 3).
  3. Call t.runNextEvent() inside a loop that iterates t.ticksPerSecond() * simulation_length times. Although there is no direct link between the amount of time your code would run on real motes and the time it will take to simulate it using TOSSIM, I have found that using real time intervals is quite good for sizing the number of iterations required for a particular simulation.

Example:

simLength = 60*5 #run code for simulated 5 minutes

while True:
    t.runNextEvent()  
    if t.time() > simLength * t.ticksPerSecond():
        break


来源:https://stackoverflow.com/questions/17817255/how-do-i-decide-the-right-number-of-events-in-tinyos-and-tossim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!