在 NS-3 中的模拟过程中,如何更改两个节点之间的数据速率? [英] How to change the data rate between two nodes during the simulation in NS-3?

查看:53
本文介绍了在 NS-3 中的模拟过程中,如何更改两个节点之间的数据速率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务器通过 10Mb/s 的点对点链接连接到接入点.

A Server is connected to an Access point via point to point link of 10Mb/s.

PointToPointHelper p2p;
p2p.SetDeviceAttribute ("DataRate", StringValue("10Mbps"));
wanIpDevices = p2p.Install (ServerNode, ApNode);
//only relevant code added

如何在模拟 100 秒后将此链路的数据速率更改为 5Mb/s.我尝试了下面的代码,但没有用.

How can I change the data rate of this link to 5Mb/s after 100 seconds of simulation. I tried the code below but it didn't work.

double timeNow = Simulator::Now().GetSeconds();
Simulator::Run();
if (timeNow==100.0)
{
  p2p.SetDeviceAttribute ("DataRate", StringValue("5Mbps"));
}
Simulator::Destroy();

推荐答案

看看我的回答这里.

它的要点是您需要创建一个设置 PointToPointNetDevice 属性的函数.然后,使用 Simulator::Schedule() 安排该函数在您想要进入模拟的秒数内被调用.

The gist of it is that you need to create a function that sets the PointToPointNetDevice's Attribute. Then, use Simulator::Schedule() to schedule that function to be called the number of seconds you want into the simulation.

这篇关于在 NS-3 中的模拟过程中,如何更改两个节点之间的数据速率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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