Re: [ns] how to set different transmit range for different node

2009-01-04 Thread Mustafa Kamal

Hi,

I think you can get Pt_ value directly from wireless-phy.cc file with getPt() 
function which definition is given in the wireless-phy.h.

its better to check out the value using a separate trace file rather than using 
the default trace file generated from NS2.

we can do as like

../ns example.txt  MyTrace.txt

To get the Pt_ value you need to write down a single line of printf(..) inside 
the wireless-phy.cc file.

Thanks,

Joarder

--- On Sun, 1/4/09, Phenix phenix...@hhu.edu.cn wrote:
From: Phenix phenix...@hhu.edu.cn
Subject: Re: [ns] how to set different transmit range for different node
To: Sidney Doria ssdo...@gmail.com
Cc: ns users ns-users@ISI.EDU
Date: Sunday, January 4, 2009, 9:15 AM

Hi Sidney,

After times of trials, I've succeeded in letting different nodes own
different 
Tx Range by configuring different value of Pt_ for each node. I get different 
values of Pt_ from a script:
   # The transimssion radio range 
 Pt_ 6.9872e-4;# ?m
 Pt_ 8.5872e-4;# 40m
 Pt_ 1.33826e-3   ;# 50m
 Pt_ 7.214e-3 ;# 100m
 Pt_ 0.2818   ;# 250m

And in my script, I have test range of 250m and 40m. It really works well.
But It's a pity that I don't know how to obtain these values. The tool
threshold
(~ns/lidep-utils/propagation/threshold.cc) only generate RXThresh_ other than
Pt_.

Is there somebody knowing how to get value of Pt_?


[Here is my test script]

# ==
# Define options
# ==
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 2  ;# number of mobilenodes
set val(rp)MFlood  ;# routing
protocol,DumbAgent
set val(chan)   Channel/WirelessChannel
set val(prop)   Propagation/TwoRayGround
set val(netif)  Phy/WirelessPhy
set val(mac)Mac/802_11
set val(ifq)Queue/DropTail/PriQueue
set val(ll) LL
set val(ant)Antenna/OmniAntenna
set val(stop) 150

# 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 Rb_ 2*1e6
Phy/WirelessPhy set freq_ 914e+6 
Phy/WirelessPhy set L_ 1.0

# Pt_
set txpower_(0)  0.2818   ;# 250m
set txpower_(1)  8.5872e-4;# 40m
set txpower_(2)  7.214e-3 ;# 100m

# ==
# Main Program
# ==

#ns-random 0

# Initialize Global Variables
set ns_ [new Simulator]
set tracefd [open mflood_txRange.tr w]
$ns_ trace-all $tracefd

set namtrace[open mflood_txRange.nam w]
$ns_ namtrace-all-wireless $namtrace 1000 500

# set up topography
set topo [new Topography]
$topo load_flatgrid 1000 500

# Create God
create-god $val(nn)


# Create the specified number of mobilenodes [$val(nn)] and attach
them
# to the channel. 
# configure node
set channel [new Channel/WirelessChannel]
$channel set errorProbability_ 0.0

$ns_ node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channel $channel \
-topoInstance $topo \
-agentTrace ON \
-routerTrace OFF\
-macTrace OFF \
-movementTrace OFF  

 for {set i 0} {$i  $val(nn) } {incr i} {
  Phy/WirelessPhy set Pt_ $txpower_($i)
  set node_($i) [$ns_ node]
  $node_($i) random-motion 0; 
 }

# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes
# 
#  N_0 -- d --- N_2 
#  srcdst

$node_(0) set X_ 0.0
$node_(0) set Y_ 200.0
$node_(0) set Z_ 0.0

$node_(1) set X_ 1.0
$node_(1) set Y_ 200.0
$node_(1) set Z_ 0.0

$ns_ at 1.5 $node_(1) setdest 255.0 200.0 2.0

# Define node initial position in nam
for {set i 0} {$i  $val(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 20
}

set udp_(0) [new Agent/UDP]
set udp_(1) [new Agent/UDP]
$ns_ attach-agent $node_(0) $udp_(0)
$ns_ attach-agent $node_(1) $udp_(1)

set null_(0) [new Agent/Null]
set null_(1) [new Agent/Null]
$ns_ attach-agent $node_(1) $null_(0)
$ns_ attach-agent $node_(0) $null_(1)

$ns_ connect $udp_(0) $null_(0)
$ns_ connect $udp_(1) $null_(1)

for {set i 0} {$i  $val(nn)} {incr i} {
 set cbr_($i) [new Application/Traffic/CBR]
 $cbr_($i) set packetSize_ 512
 $cbr_($i) set interval_ 2
 $cbr_($i) set random_ 1
 $cbr_($i) attach-agent $udp_($i)
 
}
$ns_ at 1.0 $cbr_(0) start
$ns_ at 1.1 $cbr_(1) start

# Tell nodes when the simulation ends
for {set i 0} {$i  $val(nn) } {incr i} {
$ns_ at $val(stop).0 $node_($i) reset;
}
$ns_ at $val(stop).0 stop
$ns_ at $val(stop).01 puts \NS EXITING...\ ; $ns_
halt
proc stop {} {
global ns_

Re: [ns] how to set different transmit range for different node

2009-01-03 Thread Phenix

Hi Sidney,

After times of trials, I've succeeded in letting different nodes own different 
Tx Range by configuring different value of Pt_ for each node. I get different 
values of Pt_ from a script:
   # The transimssion radio range 
 Pt_ 6.9872e-4;# ?m
 Pt_ 8.5872e-4;# 40m
 Pt_ 1.33826e-3   ;# 50m
 Pt_ 7.214e-3 ;# 100m
 Pt_ 0.2818   ;# 250m

And in my script, I have test range of 250m and 40m. It really works well.
But It's a pity that I don't know how to obtain these values. The tool threshold
(~ns/lidep-utils/propagation/threshold.cc) only generate RXThresh_ other than 
Pt_.

Is there somebody knowing how to get value of Pt_?


[Here is my test script]

# ==
# Define options
# ==
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 2  ;# number of mobilenodes
set val(rp)MFlood  ;# routing protocol,DumbAgent
set val(chan)   Channel/WirelessChannel
set val(prop)   Propagation/TwoRayGround
set val(netif)  Phy/WirelessPhy
set val(mac)Mac/802_11
set val(ifq)Queue/DropTail/PriQueue
set val(ll) LL
set val(ant)Antenna/OmniAntenna
set val(stop) 150

# 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 Rb_ 2*1e6
Phy/WirelessPhy set freq_ 914e+6 
Phy/WirelessPhy set L_ 1.0

# Pt_
set txpower_(0)  0.2818   ;# 250m
set txpower_(1)  8.5872e-4;# 40m
set txpower_(2)  7.214e-3 ;# 100m

# ==
# Main Program
# ==

#ns-random 0

# Initialize Global Variables
set ns_ [new Simulator]
set tracefd [open mflood_txRange.tr w]
$ns_ trace-all $tracefd

set namtrace[open mflood_txRange.nam w]
$ns_ namtrace-all-wireless $namtrace 1000 500

# set up topography
set topo [new Topography]
$topo load_flatgrid 1000 500

# Create God
create-god $val(nn)


# Create the specified number of mobilenodes [$val(nn)] and attach them
# to the channel. 
# configure node
set channel [new Channel/WirelessChannel]
$channel set errorProbability_ 0.0

$ns_ node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channel $channel \
-topoInstance $topo \
-agentTrace ON \
-routerTrace OFF\
-macTrace OFF \
-movementTrace OFF  

 for {set i 0} {$i  $val(nn) } {incr i} {
  Phy/WirelessPhy set Pt_ $txpower_($i)
  set node_($i) [$ns_ node]
  $node_($i) random-motion 0; 
 }

# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes
# 
#  N_0 -- d --- N_2 
#  srcdst

$node_(0) set X_ 0.0
$node_(0) set Y_ 200.0
$node_(0) set Z_ 0.0

$node_(1) set X_ 1.0
$node_(1) set Y_ 200.0
$node_(1) set Z_ 0.0

$ns_ at 1.5 $node_(1) setdest 255.0 200.0 2.0

# Define node initial position in nam
for {set i 0} {$i  $val(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 20
}

set udp_(0) [new Agent/UDP]
set udp_(1) [new Agent/UDP]
$ns_ attach-agent $node_(0) $udp_(0)
$ns_ attach-agent $node_(1) $udp_(1)

set null_(0) [new Agent/Null]
set null_(1) [new Agent/Null]
$ns_ attach-agent $node_(1) $null_(0)
$ns_ attach-agent $node_(0) $null_(1)

$ns_ connect $udp_(0) $null_(0)
$ns_ connect $udp_(1) $null_(1)

for {set i 0} {$i  $val(nn)} {incr i} {
 set cbr_($i) [new Application/Traffic/CBR]
 $cbr_($i) set packetSize_ 512
 $cbr_($i) set interval_ 2
 $cbr_($i) set random_ 1
 $cbr_($i) attach-agent $udp_($i)
 
}
$ns_ at 1.0 $cbr_(0) start
$ns_ at 1.1 $cbr_(1) start

# Tell nodes when the simulation ends
for {set i 0} {$i  $val(nn) } {incr i} {
$ns_ at $val(stop).0 $node_($i) reset;
}
$ns_ at $val(stop).0 stop
$ns_ at $val(stop).01 puts \NS EXITING...\ ; $ns_ halt
proc stop {} {
global ns_ tracefd namtrace
$ns_ flush-trace
close $tracefd
 close $namtrace
}

puts Starting Simulation...
$ns_ run




Regards,
Phenix


From: Sidney Doria 
Sent: Saturday, January 03, 2009 12:01 AM
To: Phenix 
Subject: Re: [ns] how to set different transmit range for different node


Hi Phenix, 


In the TCL file, there's a loop for node creation. So, you can break this node 
in a manual creation, each node with specific characteristics.


Sidney Doria


UFCG / BRAZIL


2009/1/2 Phenix phenix...@hhu.edu.cn



  Hi all,

  I'd like how to set different transmit range for different node in MANET.

  eg.
   Three nodes,N0,N1 and N2 are in a line:
 (N0) (N1)(N2)
   |---  200m