omnet++ - 如何更改静脉中的数据速率?
问题描述
我们可以在 Veins 中调整 Tx power 和 Tx rate,默认数据速率为 6Mbps,可以在 .ini 中设置,是否可以在模拟过程中调整数据速率?非常感谢!
解决方案
设置发射功率的功能是公开的,而设置比特率的功能是受保护的。这意味着如果您想在不是子类的类中设置比特率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)
推荐阅读
- regex - 匹配匹配字符串的最后一个“:”的子字符串
- xamarin - 如何使用命令而不是事件使 TapGestureRecognizer 在我的类中调用方法?
- python - 我如何操作/修改现有的嵌套 python 字典“dict”并具有下面需要的输出格式?
- flutter - 当卡片被点击时,如何使 beer_ciders 类中的文本出现在订单类中
- openxml - 一个运行元素是否可能包含多个文本元素
- angular - PrimeNG 动态对话框 - 单击即可关闭
- plot - 如何布置可变数量的面板?
- c# - 如何将具有时间跨度节点的 XML 对象文件转换为 .NET Standard 中的 C# 类
- php - 如何在 PHP 中使用 simpleXML 删除重复值
- symfony - Symfony 如何将 Mercure 与 Messenger + RabbitMQ 一起使用?