如何在omnet ++中的模块上分别调用finish() [英] How to invoke finish() individually on modules in omnet++

查看:240
本文介绍了如何在omnet ++中的模块上分别调用finish()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Omnet ++并创建一个场景,其中发送方不断向接收方发送数据包(从发送方到接收方的单向通信),并且我在发送方和接收方的简单模块上都设置了一个计数器.

由于发送方的计数器比接收方的计数器先递减计数为零,因此模拟运行良好,但由于接收方在接收方进行的所有操作都无法记录统计信息.

将计数器减为零后,两个模块都调用finish()函数.

sender::finish()
{
 EV << "message limit reached \n";
 cancelAndDelete(myEvent);
}

接收器的完成功能:

void receiver::finish()
{
  EV << "mean:   "<< iatStats.getMean() << endl;
  EV << "std.dev:   " << iatStats.getStddev() << endl;
  EV << "variance:  " << iatStats.getVariance() << endl;

  iatStats.recordAs("Inter-Arrival Times");
  recordScalar("#IAT", interAT_diff);
}

此处iat是接收方数据包之间到达间隔时间的计算.

运行模拟后,将首先调用发送者的finish(),并且模拟停止并且/results文件夹中没有数据记录,只有空白的.vec.sca文件存在.

终端也说simulation fault: core dumped

问题是,一旦计数器用完,如何才能暂停"发送方块,并让接收方调用它的finish()函数,这样我就可以查看统计信息并记录我需要的所有数据?

希望说明很清楚. 谢谢

解决方案

因此,事实证明,对单个模块调用两个finish是不正确的. 因此,为了解决这种情况,我将发送方块中的finish()函数重命名为done().这有助于模拟器提供更好的功能,并且当接收器上的计数器归零时,会调用finish()函数,并且所有数据收集都会完美进行,甚至会显示在消息控制台上.

使用单独的模块时,例如,需要使用

而不是finish()的任何其他名称. stopBlock()done()或任何通用名称.确保在完整的模拟中仅一次调用finish() .

原因是finish()函数用于完整的Omnet ++环境,如果任何一个块/模块首先调用它,则其他模块将停止运行.

I am using Omnet++ and creating a scenario where a sender keeps sending packets to a receiver (uni-directional communication from sender to receiver) and I have set a counter on both the simple modules of sender and receiver.

Since the sender's counter counts down to zero first than the receiver, the simulation run well but it does not record statistics since all that is done at the receiver.

after the counter is decreased to zero both the modules invoke a finish() function.

sender::finish()
{
 EV << "message limit reached \n";
 cancelAndDelete(myEvent);
}

receiver's finish function:

void receiver::finish()
{
  EV << "mean:   "<< iatStats.getMean() << endl;
  EV << "std.dev:   " << iatStats.getStddev() << endl;
  EV << "variance:  " << iatStats.getVariance() << endl;

  iatStats.recordAs("Inter-Arrival Times");
  recordScalar("#IAT", interAT_diff);
}

here iat is calculation for inter-arrival time between the packets at the receiver.

After the simulation runs, the sender's finish() is invoked first and the simulation stops and no data is recorded in /results folder only blank .vec or .sca files exist.

also the terminal says simulation fault: core dumped

The problem is how can I "pause" the sender block once the counter is run out and let the receiver invoke it's finish() function so that I could see the stats and also record all the data I need?

Hope the description is clear enough. Thanks

解决方案

So it turns out that calling two finishes for individual modules isn't the right thing to. hence, to tackle the situation I renamed the finish() function in the sender block to done(). This helps the simulator to provide a better functionality and the when the counter on the receiver comes to zero the finish() function is invoked and all the data collection occurs perfectly and it even gets displayed on the message console.

any other name instead of finish() needs to be used when using separate modules e.g. stopBlock() or done() or any generic name. Make sure that finish() is invoked ONLY ONCE in the complete simulation.

The reason is finish() function is for the complete Omnet++ environment and if any one block/module invokes it first the other modules will stop functioning.

这篇关于如何在omnet ++中的模块上分别调用finish()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆