问题
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