# attach a new Agent/MessagePassing/Flooding to each node on port $MESSAGE_PORT
for {set i 0} {$i < $num_nodes} {incr i} {
set a($i) [new Agent/MessagePassing/Flooding]
$n($i) attach $a($i) $MESSAGE_PORT
$a($i) set messages_seen {}
set if_($i) [$n($i) set netif_(0)]
}
# then you can set the transmission power for each node individually :
for {set i 0} {$i < 10} {incr i} {
if { $i < 5} {
# transmission range: 40m
$if_($i) set Pt_ 8.5872e-4
} else {
# transmission range: 100m
$if_($i) set Pt_ 7.214e-3
}
}
for {set i 0} {$i < $num_nodes} {incr i} {
set a($i) [new Agent/MessagePassing/Flooding]
$n($i) attach $a($i) $MESSAGE_PORT
$a($i) set messages_seen {}
set if_($i) [$n($i) set netif_(0)]
}
# then you can set the transmission power for each node individually :
for {set i 0} {$i < 10} {incr i} {
if { $i < 5} {
# transmission range: 40m
$if_($i) set Pt_ 8.5872e-4
} else {
# transmission range: 100m
$if_($i) set Pt_ 7.214e-3
}
}
from http://blog.empas.com/blhole/read.html?a=1 0042170
$NS_HOME/indep-utils/propagation/thresho ld.cc
$NS_HOME/indep-utils/propagation/thresho
를 다음 명령으로 컴파일한다.
$ g++ -o threshold threshold.cc
Phy/WirelessPhy set RXThresh_ 3.652e-10
위의 기본 RXThresh_값을 기준으로 하여 거리에 대한 Pt를 결정한다.
예제
예제
$ ./threshold -m TwoRayGround -Pt 7.214e-3 100m
distance = 100
propagation model: TwoRayGround
distance = 100
propagation model: TwoRayGround
Selected parameters:
transmit power: 0.007214
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
transmit power: 0.007214
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: 3.65209e-10
-Pt 0.11542 200m
-Pt 0.58432 300m
// Assume AT&T's Wavelan PCMCIA card -- Chalermek
// Pt_ = 8.5872e-4; // For 40m transmission range.
// Pt_ = 7.214e-3; // For 100m transmission range.
// Pt_ = 8.5872e-4; // For 40m transmission range.
// Pt_ = 7.214e-3; // For 100m transmission range.
// Pt_ = 1.7615e-2 ;# 125m
// Pt_ = 0.2818; // For 250m transmission range.
// Pt_ = 0.2818; // For 250m transmission range.
$NS2/mac/wireless-phy.cc
# 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
Phy/WirelessPhy set RXThresh_ 3.652e-10
Phy/WirelessPhy set bandwidth_ 2e6
Phy/WirelessPhy set Pt_ 0.28183815
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0
Phy/WirelessPhy set debug_ false
# it work like the 914MHz Lucent WaveLAN DSSS radio interface
Phy/WirelessPhy set CPThresh_ 10.0
Phy/WirelessPhy set CSThresh_ 1.559e-11
Phy/WirelessPhy set RXThresh_ 3.652e-10
Phy/WirelessPhy set bandwidth_ 2e6
Phy/WirelessPhy set Pt_ 0.28183815
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0
Phy/WirelessPhy set debug_ false
위의 값들중에서 Pt_ (transmission power)만을 변경하여 간단하게 transmission range를 조정할 수 있다.
