NS2 2.34 计算接收功率阈值 threshold ,threshold.cc编译头文件问题(转)

ns 覆盖范围 RXThresh的计算

../tcl/lib/ns-default.tcl中,有如下几行:


# Initialize the SharedMedia interface with parameters to make

# it work like the 914MHz Lucent WaveLAN DSSS radio interface

Phy/WirelessPhy set CPThresh_ 10.0

Phy/WirelessPhy set CSThresh_ 1.559e-11 ;#550m

Phy/WirelessPhy set RXThresh_ 3.652e-10 ;#250m

Phy/WirelessPhy set bandwidth_ 2e6 ;#2Mbps

Phy/WirelessPhy set Pt_ 0.28183815 ;#传输功率

Phy/WirelessPhy set freq_ 914e+6

Phy/WirelessPhy set L_ 1.0



默认载波侦听距离为550米,无线节点覆盖范围250米,带宽2Mbps


RXThresh_ 门限的生成可以使用NS中的~ns/indep-utils/propagation/threshold.cc文件来生成可执行文件 a.out


具体方法如下:

先进入文件夹,找到threshold.cc文件

[root@localhost propagation]# g++ threshold.cc


生成了a.out文件


附:1. 要执行 ./a.out即可

   是因为环境变量 $PATH 中没有当前目录;

   也可以 $set $PATH=$PATH:当前目录(比如/home/you)



2. 编译c用 gcc 命令 

编译c++ 用 g++ 命令


然后假如要生成RXThresh_ 为 100m,则


使用的是TwoRayGround模型


[root@localhost propagation]# ./a.out -m TwoRayGround -r 0.95 100


则可得到要用的门限


[root@localhost propagation]# ./a.out -m TwoRayGround -r 0.95 100

distance = 100

propagation model: TwoRayGround


Selected parameters:

transmit power: 0.281838

frequency: 9.14e+08

transmit antenna gain: 1

receive antenna gain: 1

system loss: 1

transmit antenna height: 1.5

receive antenna height: 1.5


Receiving threshold RXThresh_ is: 1.42681e-08


红色的即为所要的值



附:使用说明


USAGE: find receiving threshold for certain communication range (distance)


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


<propagation-model>: FreeSpace, TwoRayGround or Shadowing

[other-options]: set parameters other than default values:


Common parameters:

-Pt <transmit-power>

-fr <frequency>

-Gt <transmit-antenna-gain>

-Gr <receive-antenna-gain>

-L <system-loss>


For two-ray ground model:

-ht <transmit-antenna-height>

-hr <receive-antenna-height>


For shadowing model:

-pl <path-loss-exponent>

-std <shadowing-deviation>

-d0 <reference-distance>

-r <receiving-rate>


  

NS2 2.34 threshold 编译问题 用法

NS-2 2010-10-12 15:59:10 阅读167 评论0   字号: 订阅

        threshold是NS2自带的一个用来计算不同的无线传输模型和传输矩离下的相关参数的小工具.
        用法如下 :
root@ubuntu:~/ns-allinone-2.34/ns-2.34/indep-utils/propagation$ ./threshold
USAGE: find receiving threshold for certain communication range (distance)

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

<propagation-model>: FreeSpace, TwoRayGround or Shadowing        //三种传输模型
[other-options]: set parameters other than default values:                   //以下参数均可自行配置

Common parameters:
-Pt <transmit-power>
-fr <frequency>
-Gt <transmit-antenna-gain>
-Gr <receive-antenna-gain>
-L <system-loss>

For two-ray ground model:
-ht <transmit-antenna-height>
-hr <receive-antenna-height>

For shadowing model:
-pl <path-loss-exponent>
-std <shadowing-deviation>
-d0 <reference-distance>
-r <receiving-rate>


        该程序的是用C++编写的,位于NS2文件夹下的 ns-allinone-2.34/ns-2.34/indep-utils/propagation/.
        程序源码需要编译才能运行:
                 $g++ -lm threshold.cc -o threshold
        然而本人在编译时出现问题:
root@ubuntu:~/ns-allinone-2.34/ns-2.34/indep-utils/propagation$ g++ -lm threshold.cc -o threshold
threshold.cc:56:22: error: iostream.h: 没有那个文件或目录
threshold.cc: In function ‘int main(int, char**)’:
threshold.cc:181: error: ‘cout’ was not declared in this scope
threshold.cc:181: error: ‘endl’ was not declared in this scope
threshold.cc:206: error: ‘cout’ was not declared in this scope
threshold.cc:206: error: ‘endl’ was not declared in this scope
threshold.cc:211: error: ‘strcmp’ was not declared in this scope
threshold.cc:215: error: ‘strcmp’ was not declared in this scope
threshold.cc:218: error: ‘strcmp’ was not declared in this scope
threshold.cc:221: error: ‘strcmp’ was not declared in this scope
threshold.cc:224: error: ‘strcmp’ was not declared in this scope
threshold.cc:227: error: ‘strcmp’ was not declared in this scope
threshold.cc:230: error: ‘strcmp’ was not declared in this scope
threshold.cc:233: error: ‘strcmp’ was not declared in this scope
threshold.cc:236: error: ‘strcmp’ was not declared in this scope
threshold.cc:239: error: ‘strcmp’ was not declared in this scope
threshold.cc:242: error: ‘strcmp’ was not declared in this scope
threshold.cc:245: error: ‘strcmp’ was not declared in this scope
threshold.cc:259: error: ‘strcmp’ was not declared in this scope

         排查问题发现,threshold.cc源文件中缺少相关头文件,或者头文件错误,原文如下:
#include <math.h>
#include <stdlib.h>
       修改成如下就可以正常编译了:
#include <math.h>
#include <stdlib.h>
#include <iostream>    //增加该头文件以引用输出函数
#include <string.h>      //增加该头文件以引用'strcmp'函数
using namespace std;  //增加命名空间的声明
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值