在模擬無線網路時需要對tcl模擬指令碼檔案的引數進行設定,比如pt, cpthresh, csthresh and rxthresh。 我們需要借助ns提供的threshold工具來計算相應的引數(extra utility called threshold,在 \ns-2.33\indep-utils\propagation中)
比如無線感測網路。
編譯threshold
g++ -o threshold threshold.cc
計算模式為tworayground 頻率為2.4e+9 power為5.35395e-05 範圍為10m 的csthresh, rxthresh等引數設定
./threshold -m tworayground -fr 2.4e+9 -pt 5.35395e-05 10
輸出為:
distance = 30
propagation model: tworayground
selected parameters:
transmit power: 5.35395e-05
frequency: 2.4e+09
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: 5.29754e-11
然後tcl檔案中, pt_=5.35395e-05 , rxthresh_設為5.88616e-12。
同理用./threshold -m tworayground -fr 2.4e+9 -pt 0.000214158 20
來計算通訊範圍為20m的rxthresh_值
以下是別人計算出來的pt值和對應的範圍(括號中的數值):
set power(10) 5.35395e-05 # range is 10m, pt=5.35395e-05
set power(20) 0.000214158
set power(30) 0.000481855
set power(40) 0.000856632
set power(50) 0.00133849
set power(60) 0.00192742
set power(70) 0.00262343
set power(80) 0.00342653
set power(90) 0.0047338
set power(100) 0.00721505
set power(250) 0.28183815
c++中呼叫tcl來修改節點的pt值的**:
#define power2 0.00045223;
tcl& tcl = tcl::instance();
tcl.evalf("[$node_(%d) set netif_(0)] set pt_ %f", node->address(),power2);
利用NS2進行無線網路模擬
本博文的實驗取材與 ns 2網路模擬基礎與應用 無線網路實驗。場景是三個節點,在乙個矩形區域,移動ad hoc網路使用dsdv路由演算法,然後在適當的時候設定它們的移動方向 速度,並在節點0和節點1之間嘗試建立ftp連線。指令碼 如下 set val chan channel wirelesscha...
A 無線網路
accept 29 submit 107 time limit 1000ms memory limit 65536kb description 現在無線網路愈來愈普及,人們對網路質量的要求也愈來愈高。我們假設要在一條筆直的公路上安置無線網路接入點,以方便兩旁的居民上網。設公路的乙個終點為起點,那麼居...
NS2相關學習 無線網(2)
在這裡,我們將完成乙個簡單的無線多跳場景 首先,定義的引數如下所示 set val chan channel wirelesschannel set val prop propagation tworayground set val netif phy wirelessphy set val mac...