ns3不使用Ipv4AddressHelper的替代方法
来源:互联网 发布:vs php 扩展 编辑:程序博客网 时间:2024/06/11 23:51
不使用IPv4AddressHelper,那么就要自己手工分配,如下是我写的分配代码
int32_t AssignAddress (Ptr<NetDevice> device, uint32_t u32Addr, uint32_t u32Mask ){ NS_LOG_FUNCTION_NOARGS (); //Ipv4InterfaceContainer retval; Ptr<Node> node = device->GetNode (); NS_ASSERT_MSG (node, "Ipv4AddressHelper::Assign(): NetDevice is not not associated " "with any node -> fail"); Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> (); NS_ASSERT_MSG (ipv4, "Ipv4AddressHelper::Assign(): NetDevice is associated" " with a node without IPv4 stack installed -> fail " "(maybe need to use InternetStackHelper?)"); int32_t interface = ipv4->GetInterfaceForDevice (device); if (interface == -1) { interface = ipv4->AddInterface (device); } NS_ASSERT_MSG (interface >= 0, "Ipv4AddressHelper::Assign(): " "Interface index not found"); Ipv4Address stAddr ( u32Addr); Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (stAddr, u32Mask); ipv4->AddAddress (interface, ipv4Addr); ipv4->SetMetric (interface, 1); ipv4->SetUp (interface); //retval.Add (ipv4, interface); return interface;}
使用方法如下,
Ipv4Address stAddr = Ipv4Address("10.0.0.1"); uint32_t u32Addr = stAddr.Get(); Ipv4Mask stMask = Ipv4Mask("255.255.255.0"); uint32_t u32Mask = stMask.Get(); for(int j = 0; j< nNodes; j++) { AssignAddress(devices.Get(j), u32Addr+j, u32Mask); }
0 0
- ns3不使用Ipv4AddressHelper的替代方法
- Ipv4AddressHelper向网卡分配地址的方法
- 不使用vector<bool>的原因和替代方法
- 不使用vector<bool>的原因和替代方法
- float计算不准确的替代方法
- NS3中NetAnim的使用
- 使用函数替代宏的好方法
- 关于Winform中SendKeys不生效的替代方法
- 解决System.out.println不好使的替代方法
- win7下不能用DNW下载的替代方法
- ObjectAnimator不包含百分比移动的替代方法
- 替代goto的方法
- Externalizable 的替代方法
- 替代setLatestEventInfo()的方法
- 使用Doxygen获取NS3的帮助文档
- NS3-logging 日志模块的使用
- replace()方法使用函数做替代字符串的说明
- 使用C#的扩展方法替代For循环
- iOS the file "xxx.app" couldn't be opened because you don't have permission to view it.
- Ubuntu下apt-get安装软件时缺少依赖包解决方法
- matlab制作聚类数据
- eclipse-android-activity_main/fragment_main文件处理
- C#获取程序的当前路径,启动和关闭一个Process
- ns3不使用Ipv4AddressHelper的替代方法
- android 关于listView 显示不全的问题
- Objective C面向对象
- StringUtils.isBlank()函数
- 伪随机数生成器
- ant打包jar的build.xml配置
- api 和sdk 有什么区别
- 因果图法设计测试用例
- 如何正确的使用SharedPreferences?