NS-3中移动路径追踪
来源:互联网 发布:nginx php pathinfo 编辑:程序博客网 时间:2024/05/17 22:12
在NS-3中要实现移动路径追踪,首先应该想到MobilityModel移动模型,要实现追踪分析,就要用到trace sources.
The list of all trace sources:
http://www.nsnam.org/doxygen/group___trace_source_list.html
在trace sources中找到MobilityModel,看到下面有一个可以trace的属性:
CourseChange: The value of the position and/or velocity vector changed
表示可以分析移动后的速度、位置。
进入MobilityModel的TypeId ns3::MobilityModel::GetTypeId
http://www.nsnam.org/doxygen/classns3_1_1_mobility_model.html#a3d1346ba74cc805812fac131070ba439
可以看到: This object is accessible through the following paths with Config::Set and Config::Connect:
- /NodeList/[i]/$ns3::MobilityModel
- /NodeList/[i]/DeviceList/[i]/$ns3::AlohaNoackNetDevice/Phy/$ns3::HierarchicalMobilityModel/Child
- /NodeList/[i]/DeviceList/[i]/$ns3::AlohaNoackNetDevice/Phy/$ns3::HierarchicalMobilityModel/Parent
- /NodeList/[i]/DeviceList/[i]/$ns3::AlohaNoackNetDevice/Phy/$ns3::MobilityModel
- /NodeList/[i]/DeviceList/[i]/$ns3::NonCommunicatingNetDevice/Phy/$ns3::HierarchicalMobilityModel/Child
- /NodeList/[i]/DeviceList/[i]/$ns3::NonCommunicatingNetDevice/Phy/$ns3::HierarchicalMobilityModel/Parent
- /NodeList/[i]/DeviceList/[i]/$ns3::NonCommunicatingNetDevice/Phy/$ns3::MobilityModel
我们先来看一下Config::Connect方法:
http://www.nsnam.org/doxygen/namespacens3_1_1_config.html#a4014f151241cd0939b6cb64409605736
void ns3::Config::Connect ( std::string path, const CallbackBase & cb )
第一项 path,就对应上面的 /NodeList/[i]/...这个路径。
上面这么多路径,应该选择哪一个呢? 根据你使用的网络来定,比如用的是Aloha网络,就用那个了。
我用的是Wifi网络,第一个是通用的,所以用第一个/NodeList/[i]/$ns3::MobilityModel
Config::Connect第二个参数是CallbackBase
所以,我们要调用一个MakeCallback函数,才能返回CallbackBase类型
一个例子:
#include ...
...
//自定义一个全局函数,用于MakeCallback调用
void
CourseChange (std::string context, Ptr<const MobilityModel> model)
{
Vector position = model->GetPosition ();
NS_LOG_UNCOND (context << "x = " << position.x << ", y= " << position.y);
}
...
int main (int argc ,char *argv[])
{
...
std::ostringstream oss;
/** 下面的 wifiStaNodes.Get (nWifi - 1)->GetId ()的方法,就是得到节点的编号,
*比如: Ptr<Node> m_node;
* m_node->GetId ();
* 方法见: http://www.nsnam.org/doxygen/classns3_1_1_node.html
*路径与/NodeList/[i]/$ns3::MobilityModel 相同
*/
oss << "/NodeList/" << wifiStaNodes.Get (nWifi - 1)->GetId ()
<< "/$ns3::MobilityModel/CourseChange";
Config::Connect (oss.str (), MakeCallback (&CourseChange));
...
}
- NS-3中移动路径追踪
- NS-3中Ipv4Header说明
- 关于NS-2仿真中移动节点的设置
- NS-2仿真中移动节点的设置
- NS中如何生成移动场景和流量场景
- 安装cygwin+ns-2 过程中home路径问题
- 在ns-3中运行程序
- ns-3 中 Utils 模块介绍
- ns-3
- android 追踪手势移动
- 关于NS-2仿真中移动节点的设置 [转载]
- ns-2中Tcl语言中类的使用<3>
- 在ns-3中添加自己编写的模块
- 在ns-3中 允许和禁止例子的执行
- NS-3中wifi的主要层次结构
- NS-3中wifi传输中的常见模型
- NS-3 中 Callback与MakeCallback的简单说明
- NS-3中Config::Connect与Config::ConnectWithoutContext的区别
- Java实现最小生成树Kruskal算法
- 慢起手倒立
- ubuntu中文输入法ibus/fcitx4
- ASP.NET数据库编程
- Oracle新创建用户无法以normal登录问题的解决办法
- NS-3中移动路径追踪
- OTSU算法提取图像阈值的C语言实现
- Css 选择器 命名规则
- Administrative等待事件
- 移动设备浏览器HTML5兼容性列表
- 高效 JavaScript 单元测试工具----JsTestDriver
- MFC中updatedata(true)和updatedata(false)的用法
- 项目管理各环节实践经验
- 编写基于Linux的lcd驱动