如何在 NS3 中 运行 时间内更改点对点 link 数据速率
How to change pointopoint link datarate during run time in NS3
我是 NS3 新手。我有一个关于在运行时更改点对点 link 数据速率的查询。我尝试了 中提到的解决方案。但是这里的SetDeviceAttribute并没有为我解决。
void
ModifyLinkRate(PointToPointNetDevice *dev) {
dev->SetDeviceAttribute("DataRate", StringValue ("1Mbps"));
//dev->SetAttribute("DataRate", StringValue ("1Mbps"));
}
int
main (int argc, char *argv[])
{
...
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue (linkRate));
...
Simulator::Schedule(Seconds(2.0), &ModifyLinkRate, &pointToPoint );
}
为了更改 pointTopoint 的数据速率 link,必须检索安装在节点中的 PointToPointNetDevice。这可以使用节点关联的 NetDeviceContainer 来完成。示例代码如下,
void
ModifyLinkRate(NetDeviceContainer *ptp, DataRate lr) {
StaticCast<PointToPointNetDevice>(ptp->Get(0))->SetDataRate(lr);
}
int
main (int argc, char *argv[])
{
...
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue (linkRate));
...
NetDeviceContainer p2pDevices = pointToPoint.Install (p2pNodes);
...
Simulator::Schedule(Seconds(2.0), &ModifyLinkRate, &p2pDevices,DataRate("20Mbps"));
}
我是 NS3 新手。我有一个关于在运行时更改点对点 link 数据速率的查询。我尝试了
void
ModifyLinkRate(PointToPointNetDevice *dev) {
dev->SetDeviceAttribute("DataRate", StringValue ("1Mbps"));
//dev->SetAttribute("DataRate", StringValue ("1Mbps"));
}
int
main (int argc, char *argv[])
{
...
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue (linkRate));
...
Simulator::Schedule(Seconds(2.0), &ModifyLinkRate, &pointToPoint );
}
为了更改 pointTopoint 的数据速率 link,必须检索安装在节点中的 PointToPointNetDevice。这可以使用节点关联的 NetDeviceContainer 来完成。示例代码如下,
void
ModifyLinkRate(NetDeviceContainer *ptp, DataRate lr) {
StaticCast<PointToPointNetDevice>(ptp->Get(0))->SetDataRate(lr);
}
int
main (int argc, char *argv[])
{
...
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue (linkRate));
...
NetDeviceContainer p2pDevices = pointToPoint.Install (p2pNodes);
...
Simulator::Schedule(Seconds(2.0), &ModifyLinkRate, &p2pDevices,DataRate("20Mbps"));
}