[ns] udp forward packets

2010-05-01 Thread alessandro lazzara


hello, I want use udp agent for a script tcl for 802.11.for example I have node 
0 node 1 and node2 and I want that 0(udp agent) send to 1 and 1 forward to 2 
that is sink(null agent)but when 1 receive, how can forward to 2?   
 
_
Naviga al sicuro. Scarica gratis Internet Explorer 8 per MSN
http://www.microsoft.com/italy/windows/internet-explorer/msn.aspx


[ns] Please reply me!!!Add AODV in this script

2010-04-19 Thread alessandro lazzara


set MESSAGE_PORT 42 
set ACK_SIZE 12 
set HEADER_SIZE 12 
set PAYLOAD_UNIT 6 
set DIFS 0.0; 
set AckTimeout 0.02; 
set BER 1e-6; 

set val(Nsink) 2 ;#numbers of nodes for sink 
set val(L) 3  ;# numbers of sink 

set val(chan)   Channel/WirelessChannel;# Channel Type 
set val(prop)   Propagation/TwoRayGround   ;# radio-propagation model 
set val(netif)  Phy/WirelessPhy 
set val(mac)Mac/802_11 
set val(ifq)Queue/DropTail/PriQueue;# interface queue type 
set val(ll) LL ;# link layer type 
set val(ant)Antenna/OmniAntenna;# antenna model 
set val(ifqlen) 50 ;# max packet in ifq 
set val(rp) DumbAgent  ;# routing protocol 
set val(x)   10 
set val(y)   10 

Mac/802_11 set RTSThreshold_  1500 


global defaultRNG 
set the_seed [eval exec /bin/date \+%s\] 
puts stderr Il seed è $the_seed 
$defaultRNG seed $the_seed 


#read command line arguments 
proc getCmdArgu {argc argv} { 
global val 
for {set i 0} {$i  $argc} {incr i} { 
set arg [lindex $argv $i] 
if {[string range $arg 0 0] != -} continue 
set name [string range $arg 1 end] 
set val($name) [lindex $argv [expr $i+1]] 
} 
} 
getCmdArgu $argc $argv 

set N_tot [expr $val(Nsink) + $val(Nsink)*$val(L)] 

source SimpleMSTP_agent.tcl 

# Create scheduler 
set ns [new Simulator] 

set filename scenario-$val(Nsink)x$val(L) 
set tracefd [open ./$filename.tr w] 
$ns trace-all $tracefd 
set namtrace [open ./$filename.nam w] 
$ns namtrace-all-wireless $namtrace $val(x) $val(y) 

$ns puts-nam-traceall {# nam4wpan #} ;# inform nam that this is a trace 
file for wpan (special handling needed) 

Mac/802_15_4 wpanNam namStatus on;# default = off (should be turned on 
before other 'wpanNam' commands can work) 
#Mac/802_15_4 wpanNam ColFlashClr gold   ;# default = gold 
#Mac/802_15_4 wpanNam NodeFailClr grey   ;# default = grey 

Mac/802_15_4 wpanCmd ack4data off 

proc finish {} { 
#   global ns namfile tracefile 
#   $ns flush-trace 
#   close $namfile 

global ns tracefd 
$ns flush-trace 
close $tracefd 

#   exec nam prova_wireless.nam  
exit 0 
} 

# For model 'TwoRayGround' 
set dist(5m)  7.69113e-06 
set dist(9m)  2.37381e-06 
set dist(10m) 1.92278e-06 
set dist(11m) 1.58908e-06 
set dist(12m) 1.33527e-06 
set dist(13m) 1.13774e-06 
set dist(14m) 9.81011e-07 
set dist(15m) 8.54570e-07 
set dist(16m) 7.51087e-07 
set dist(20m) 4.80696e-07 
set dist(25m) 3.07645e-07 
set dist(30m) 2.13643e-07 
set dist(35m) 1.56962e-07 
set dist(40m) 1.20174e-07 
Phy/WirelessPhy set CSThresh_ $dist(15m) 
Phy/WirelessPhy set RXThresh_ $dist(15m) 

# set up topography object 
set topo   [new Topography] 
$topo load_flatgrid $val(x) $val(y) 

# Create God 
set god_ [create-god $N_tot] 

set chan_1_ [new $val(chan)] 

# configure node 

$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) \ 
-topoInstance $topo \ 
-agentTrace ON \ 
-routerTrace OFF \ 
-macTrace ON \ 
-movementTrace OFF \ 
#-energyModel EnergyModel \ 
#-initialEnergy 1 \ 
#-rxPower 0.3 \ 
#-txPower 0.3 \ 
-channel $chan_1_ 

set u [new RandomVariable/Uniform] 
$u set min_ 0 
for {set i 0} {$i  $N_tot} {incr i} { 
set n($i) [$ns node] 

$n($i) random-motion 0   ;# disable random motion 
$u set max_ $val(x) 
$n($i) set X_ [$u value] 
$u set max_ $val(y) 
$n($i) set Y_ [$u value] 
} 


for {set i 0} {$i  $N_tot} {incr i} { 
set agent($i) [new Agent/MessagePassing/SimpleMSTP] 
if [expr ($i%(1+$val(L))) != 0] {$agent($i) set type_ Node} 

$agent($i) set successor_ [expr ($i+1)%$N_tot] 
if {$i != 0} { 
$agent($i) set predecessor_ [expr $i-1] 
} else { 
$agent($i) set predecessor_ [expr $N_tot-1] 
} 

$n($i) attach  $agent($i) $MESSAGE_PORT 
} 



$ns at 0.1 $agent(0) send-token 



$ns at 100 finish 


$ns run 



If I only modify routing protocol line to AODV doesn't work!!!how can i Modify? 
also how can I modify to use a static routing?thanks
  
_
Carica, scarica e condividi i tuoi file. Fino a 25 GB e in tutta sicurezza.
http://www.windowslive.it/skyDrive.aspx


[ns] static routing help!!!

2010-04-14 Thread alessandro lazzara


Hello.I am a noob of NS2.I must be some simulations, but i must modify in this 
tcl routing.I must usiing a statiic routing.How modify this tcl to work static 
routing leaving the rest?thanks 

set MESSAGE_PORT 42 
set ACK_SIZE 12 
set HEADER_SIZE 12 
set PAYLOAD_UNIT 6 
set DIFS 0.0; 
set AckTimeout 0.02; 
set BER 1e-6; 

set val(Nsink) 2 ;# sink number 
set val(L) 3  ; # node number 

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(ifqlen) 50 ; 
set val(rp) DumbAgent  ; 
set val(x)   10 
set val(y)   10 

Mac/802_11 set RTSThreshold_  1500 

global defaultRNG 
set the_seed [eval exec /bin/date \+%s\] 
puts stderr Il seed è $the_seed 
$defaultRNG seed $the_seed 


#read command line arguments 
proc getCmdArgu {argc argv} { 
global val 
for {set i 0} {$i  $argc} {incr i} { 
set arg [lindex $argv $i] 
if {[string range $arg 0 0] != -} continue 
set name [string range $arg 1 end] 
set val($name) [lindex $argv [expr $i+1]] 
} 
} 
getCmdArgu $argc $argv 

set N_tot [expr $val(Nsink) + $val(Nsink)*$val(L)] 

source SimpleMSTP_agent.tcl 

# Create scheduler 
set ns [new Simulator] 

set filename scenario-$val(Nsink)x$val(L) 
set tracefd [open ./$filename.tr w] 
$ns trace-all $tracefd 
set namtrace [open ./$filename.nam w] 
$ns namtrace-all-wireless $namtrace $val(x) $val(y) 

$ns puts-nam-traceall {# nam4wpan #} ;# inform nam that this is a trace 
file for wpan (special handling needed) 

Mac/802_15_4 wpanNam namStatus on;# default = off (should be turned on 
before other 'wpanNam' commands can work) 
#Mac/802_15_4 wpanNam ColFlashClr gold   ;# default = gold 
#Mac/802_15_4 wpanNam NodeFailClr grey   ;# default = grey 

Mac/802_15_4 wpanCmd ack4data off 

proc finish {} { 
#   global ns namfile tracefile 
#   $ns flush-trace 
#   close $namfile 

global ns tracefd 
$ns flush-trace 
close $tracefd 

#   exec nam prova_wireless.nam  
exit 0 
} 

# For model 'TwoRayGround' 
set dist(5m)  7.69113e-06 
set dist(9m)  2.37381e-06 
set dist(10m) 1.92278e-06 
set dist(11m) 1.58908e-06 
set dist(12m) 1.33527e-06 
set dist(13m) 1.13774e-06 
set dist(14m) 9.81011e-07 
set dist(15m) 8.54570e-07 
set dist(16m) 7.51087e-07 
set dist(20m) 4.80696e-07 
set dist(25m) 3.07645e-07 
set dist(30m) 2.13643e-07 
set dist(35m) 1.56962e-07 
set dist(40m) 1.20174e-07 
Phy/WirelessPhy set CSThresh_ $dist(15m) 
Phy/WirelessPhy set RXThresh_ $dist(15m) 

# set up topography object 
set topo   [new Topography] 
$topo load_flatgrid $val(x) $val(y) 

# Create God 
set god_ [create-god $N_tot] 

set chan_1_ [new $val(chan)] 

# configure node 

$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) \ 
-topoInstance $topo \ 
-agentTrace ON \ 
-routerTrace OFF \ 
-macTrace ON \ 
-movementTrace OFF \ 
#-energyModel EnergyModel \ 
#-initialEnergy 1 \ 
#-rxPower 0.3 \ 
#-txPower 0.3 \ 
-channel $chan_1_ 

set u [new RandomVariable/Uniform] 
$u set min_ 0 
for {set i 0} {$i  $N_tot} {incr i} { 
set n($i) [$ns node] 

$n($i) random-motion 0   ;# disable random motion 
$u set max_ $val(x) 
$n($i) set X_ [$u value] 
$u set max_ $val(y) 
$n($i) set Y_ [$u value] 
} 


for {set i 0} {$i  $N_tot} {incr i} { 
set agent($i) [new Agent/MessagePassing/SimpleMSTP] 
if [expr ($i%(1+$val(L))) != 0] {$agent($i) set type_ Node} 

$agent($i) set successor_ [expr ($i+1)%$N_tot] 
if {$i != 0} { 
$agent($i) set predecessor_ [expr $i-1] 
} else { 
$agent($i) set predecessor_ [expr $N_tot-1] 
} 

$n($i) attach  $agent($i) $MESSAGE_PORT 
} 



$ns at 0.1 $agent(0) send-token 



$ns at 100 finish 


$ns run 



THANKS
_
Messenger e Hotmail in tasca. Provali sul tuo cellulare!
http://new.windowslivemobile.msn.com/it-it/Default.aspx