How to change the data rate between two nodes during the simulation in NS-3?

情到浓时终转凉″ 提交于 2021-01-29 08:49:57

问题


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

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();

回答1:


Take a look at my answer here.

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.



来源:https://stackoverflow.com/questions/54129664/how-to-change-the-data-rate-between-two-nodes-during-the-simulation-in-ns-3

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