How to calculate the throughput in Cooja simulator

假装没事ソ 提交于 2021-01-28 18:00:45

问题



Hi All,

I work with example/ipv6/rpl-udp files in cooja simulator. How do I measure the amount of throughput in the network?

With the command "powertrace_start(CLOCK_SECOND * 60); " in the client.c code, I get the Powertrace output.

Can I use this method?

throughput= packet received / Simulation time

Simulation time = (ENERGEST_TYPE_TRANSMIT + ENERGEST_TYPE_LISTEN) / 32768

Is the method correct?

Thanks in advance,

Nasrin


回答1:


No, that is not correct as ENERGEST_TYPE_* are constants.

One way to do it is with Cooja simulator scripts.

For example, let's say you have a C program that prints "Message transmitted" every time the node sends a message to another node and "Message received" every time it receives as message.

A Cooja script can automatically run the simulation for a specific time and count the messages. This code works for me:

TIMEOUT(100000); // simulation duration in milliseconds

num_messages_tx = 0;
num_messages_rx = 0;

timeout_function = function () {
    log.log("Script timed out.\n");
    log.log("Messages transmitted: " + num_messages_tx + " \n");
    log.log("Messages received:    " + num_messages_rx + " \n");
    log.testOK();
}

while (true) {
    if (msg) {
        if(msg.startsWith("Message transmitted")) {
            num_messages_tx += 1;
        }
        if(msg.startsWith("Message received")) {
            num_messages_rx += 1;
        }
    }

    YIELD();
}

To start using it, save the code (its JavaScript) in a file test.js and add this to your .csc Cooja configuration file:

<plugin>
  org.contikios.cooja.plugins.ScriptRunner
  <plugin_config>
    <scriptfile>[CONFIG_DIR]/test.js</scriptfile>
    <active>true</active>
  </plugin_config>
  <width>457</width>
  <z>4</z>
  <height>427</height>
 <location_x>3</location_x>
 <location_y>404</location_y>
</plugin>


来源:https://stackoverflow.com/questions/48520328/how-to-calculate-the-throughput-in-cooja-simulator

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