How to Get Neighbors of a Mobile Node in Wireless Simulation
来源:互联网 发布:毛笔字软件下载 编辑:程序博客网 时间:2024/05/20 07:32
1. Get the number of nodes in the network
#include <god.h>
God::instance()->nodes();
2. In order to use God object in C++ code, in your simluation script, you should have
# Create God
set god_ [create-god $opt(nn)]
for {set i 0} {$i < $opt(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0 ;# disable random motion
$god_ new_node $node_($i)
}
3. In order to check that if node j is node i's neighbor, use the following function.
God::instance()->IsNeighbor(i , j);
4. In oder to use IsNeighbor function in C++ code, either add EnergyModel in simulation script, (please refer to NS Manual Chapter 19 for detail)
$ns_ node-config -energyModel $energymodel \
-rxPower $p_rx \
-txPower $p_tx \
-initialEnergy $initialenergy \
or change the IsNeighbor function in mobile/god.cc (disable energy checking)
bool God::IsNeighbor(int i, int j)
{
assert(i<num_nodes && j<num_nodes);
/*
if (mb_node[i]->energy_model()->node_on() == false ||
mb_node[j]->energy_model()->node_on() == false ||
mb_node[i]->energy_model()->energy() <= 0.0 ||
mb_node[j]->energy_model()->energy() <= 0.0 ) {
return false;
}
*/
vector a(mb_node[i]->X(), mb_node[i]->Y(), mb_node[i]->Z());
vector b(mb_node[j]->X(), mb_node[j]->Y(), mb_node[j]->Z());
vector d = a - b;
if (d.length() < RANGE)
return true;
else
return false;
}
- How to Get Neighbors of a Mobile Node in Wireless Simulation
- How to Get a List of Class Attributes in Python
- An example of how to do a simulation by LAMMPS
- How to get the nearest parent node given a text node in jQuery?
- How to get information of .a/.so
- How to GET a Cup of Coffee
- How to Get the Frequency Table of a Categorical Variable as a Data Frame in R
- How to get request_id of previous request in a request set?
- SQL: How to get a series of dates in sql using connect by
- uiview 某点返回 色值 How to get the color of a pixel in an UIView?
- 得到坐标的颜色值 How to get the color of a pixel in an UIView?
- How to get the HTML source of a webpage in Ruby
- Get Level of a node in a Binary Tree
- How to Get Name of Months in ABAP/4
- How to Get Name of Months in ABAP/4
- How to Get Name of Months in ABAP/4
- How to Get Name of Months in ABAP/4
- How to Get Name of Months in ABAP/4
- [LeetCode] Median of Two Sorted Arrays
- Myeclipse中修改Web项目名称后如何在Tomcat中正常运行
- 浅谈HTTP中Get与Post的区别
- 微信5.0改变了哪些游戏规则?
- 读《企业应用架构模式》-锁
- How to Get Neighbors of a Mobile Node in Wireless Simulation
- Zoj 3529 A Game Between Alice and Bob (数学_博弈)
- 可重入函数与不可重入函数
- ivision (DP_斜率优化|四边形不等式优化)
- Firemonkey的旁门左道[三]
- 图解HTTPS
- Hdu 2888 Check Corners (数据结构_二维RMQ)
- Lucene 对搜索关键字进行高亮显示
- poj 1611 The Suspects