ns2中无线通信距离的计算

来源:互联网 发布:centos ssh目录 编辑:程序博客网 时间:2024/05/15 23:47

ns2中无线网络的仿真支持不同的传播模型,不同传播模型对能量消耗是不一样的,Ns2实现了最常见的两种传播模型:Tworay和Freespace(见Propagation.h/cc)。

 

而通信距离与几个因素有关,说来如下:

(1) Pt_: transmitted signal power (W),即发射功率;

(2) Pr_: Received signal power(W),即接收功率。

比如,节点A和B距离20m,那么A给B发送一个数据包,到底怎么判断B能够接收得到呢? 首先我们假定知道节点A的发射功率,即Pt_,这个由节点硬件即发送器的功能决定。接收结点B根据收到的Pt_,再结合相应的传播模型,就可以计算出接收功率Pr_,这个计算方法可以用到下面提到的threshold工具。

 

Ns2目录下有一个小程序,threshold可以用来计算Pr_。即~ns/indep-utils/propagation/threshold.cc。该程序

1.threshold作用

ns手册上说:

在一些应用程序中,用户希望指定无线节点的通信范围。Ns 中可以在网络接口中通过设定接收阈值来指定通信范围,比如:

Phy/WirelessPhy set RXThresh_ <value>

 threshold.cc这个程序适用于本章讨论的所有传播模型。 假定此程序已经编译过得到一个可执行的文件, 命名为 threshold。你可以按照如下方法来计算阈值:

threshold -m <propagation-model> [other-options] distance

<propagation-model>可以是 Freespace、TwoRayGound 或 Shadowing; distance 就是通信范围(单位:m) ;

[other-options]用来指定一些参数,                                          

有一个必要的参数即: <receive-rate>  -r 而不是默认的参数值。 对于 Shadowing 模型,这个参数指定了在 distance 距离下正确接收的速率。因为在 Shadowing 模型中,  通信范围不再是一个理想的环,   所以在[29]中采用反向 Q 函数(inverse Q-function)来计算接收阈值。举例来说,如果希望在距离 50m 的地方能正确接收 95%的数据包,你可以按如下方法计算阈值:

    threshold -m Shadowing -r 0.95 50

    [other-options]中的其他值如下:

     -pl <path-loss-exponent 路径损耗指数>

     -std <shadowing-deviation 阴影方差>

     -Pt <transmit-power 发射功率>

     -fr <frequency 频率>

     -Gt <transmit-antenna-gain 发射天线增益>

     -Gr <receive-antenna-gain 接收天线增益>

     -L <system-loss 系统损耗>

     -ht <transmit-antenna-height 发射天线高度>

     -hr <receive-antenna-height 接收天线高度>

     -d0 <reference-distance 参考距离>

 

2.编译threshold

直接g++ -o threshold threshold.cc会抱错误,需要修改原文件的头部声明
修改如下:
 
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;

参考:http://findfunaax.com/2010/04/ns2%E7%BC%96%E8%AF%91threshold-cc.html
0 0
原创粉丝点击