首页 > 解决方案 > 如何更改静脉中的数据速率?

问题描述

我们可以在 Veins 中调整 Tx power 和 Tx rate,默认数据速率为 6Mbps,可以在 .ini 中设置,是否可以在模拟过程中调整数据速率?非常感谢!

标签: omnet++veins

解决方案


设置发射功率的功能是公开的,而设置比特率的功能是受保护的。这意味着如果您想在不是子类的类中设置比特率Mac1609_4,例如,如果您想在应用层(例如,DemoBaseAppLayer)中设置比特率,则无法设置比特率。

但是,如果你真的想强制它在应用层设置比特率,这里是步骤。

转到Mac1609_4.h文件 (veins/modules/mac/ieee80211p/Mac1609_4.h) 并将函数设置void setParametersForBitrate(uint64_t bitrate);public而不是protected.

DemoBaseAppLayer.cc然后这里是设置我在(veins/modules/application/ieee80211p/DemoBaseApplLayer.cc)中运行和测试的 Tx 功率和比特率的代码

要包含的头文件:

#include "veins/modules/mac/ieee80211p/Mac1609_4.h"  

设置发送功率和比特率的代码:

Mac1609_4* mac1609 = FindModule<Mac1609_4*>::findSubModule(getParentModule());

double powerToSet = 5;  // 5mW
uint64_t bitrateToSet = 9000000; // 9Mbps

mac1609->setTxPower(powerToSet);
mac1609->setParametersForBitrate(bitrateToSet);

请注意,有效比特率为 3、4.5、6、9、12、18、24 和 27 Mbps。要查看有关可接受比特率的更多详细信息,请访问ConstsPhy.h(invenes/modules/utility/ConstsPhy.h)


推荐阅读