Talk:Ns-2
From Nsnam
- ! /bin/sh
- Copyright (c) 2003-2004 Samsung Advanced Institute of Technology and
- The City University of New York. All rights reserved.
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. All advertising materials mentioning features or use of this software
- must display the following acknowledgement:
- This product includes software developed by the Joint Lab of Samsung
- Advanced Institute of Technology and The City University of New York.
- 4. Neither the name of Samsung Advanced Institute of Technology nor of
- The City University of New York may be used to endorse or promote
- products derived from this software without specific prior written
- permission.
- THIS SOFTWARE IS PROVIDED BY THE JOINT LAB OF SAMSUNG ADVANCED INSTITUTE
- OF TECHNOLOGY AND THE CITY UNIVERSITY OF NEW YORK ``AS IS AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
- NO EVENT SHALL SAMSUNG ADVANCED INSTITUTE OR THE CITY UNIVERSITY OF NEW YORK
- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
remove-all-packet-headers ; # removes all except common add-packet-header Flags IP RTP TCP ARP LL Mac LRWPAN AODV ;
- hdrs reqd for validation
- FOR UPDATING GLOBAL DEFAULTS:
Class TestSuite
Class Test/wpan -superclass TestSuite
proc usage {} { global argv0 puts stderr "usage: ns $argv0 <test> " exit 1 }
- 333333
- #####################################################################
- loses energy consumption within walking distance? it is strange
proc default_values {} { global val set val(chan) Channel/WirelessChannel ;# channel type set val(prop) Propagation/TwoRayGround ;# radio-propagation model set val(netif) Phy/WirelessPhy/802_15_4 set val(mac) Mac/802_15_4 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(nn) 2 ;# number of mobilenodes set val(rp) AODV ;# routing set val(x) 50 set val(y) 50 set val(tr) pruebatopo3.txt ;# trace file set val(traffic) mix ;# traffic (mix/cbr/poisson/ftp)
set val(namtrace) pruebatopo3.nam
# For propagation 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(12m) Phy/WirelessPhy set RXThresh_ $dist(12m) }
TestSuite instproc topology {} { global node_
$node_(0) set X_ 1.0 $node_(0) set Y_ 11.0 $node_(0) set Z_ 0.0
$node_(1) set X_ 8.0 $node_(1) set Y_ 11.0 $node_(1) set Z_ 0.0
}
TestSuite instproc cbrtraffic { src dst interval starttime } {
global node_
$self instvar ns_
set udp_($src) [new Agent/UDP]
eval $ns_ attach-agent \$node_($src) \$udp_($src)
set null_($dst) [new Agent/Null]
eval $ns_ attach-agent \$node_($dst) \$null_($dst)
set cbr_($src) [new Application/Traffic/CBR]
eval \$cbr_($src) set packetSize_ 100
eval \$cbr_($src) set interval_ $interval
eval \$cbr_($src) set random_ 0
#eval \$cbr_($src) set maxpkts_ 10000
eval \$cbr_($src) attach-agent \$udp_($src)
eval $ns_ connect \$udp_($src) \$null_($dst)
$ns_ at $starttime "$cbr_($src) start"
}
TestSuite instproc poissontraffic { src dst interval starttime } { global node_ $self instvar ns_ set udp($src) [new Agent/UDP] eval $ns_ attach-agent \$node_($src) \$udp($src) set null($dst) [new Agent/Null] eval $ns_ attach-agent \$node_($dst) \$null($dst) set expl($src) [new Application/Traffic/Exponential] eval \$expl($src) set packetSize_ 1200 eval \$expl($src) set burst_time_ 0 eval \$expl($src) set idle_time_ [expr $interval*1000.0-70.0/100]ms ;# idle_time + pkt_tx_time = interval eval \$expl($src) set rate_ 76k eval \$expl($src) attach-agent \$udp($src) eval $ns_ connect \$udp($src) \$null($dst) $ns_ at $starttime "$expl($src) start" }
TestSuite instproc ftptraffic { src dst starttime } { global node_ $self instvar ns_ set tcp($src) [new Agent/TCP] eval \$tcp($src) set packetSize_ 1200 set sink($dst) [new Agent/TCPSink] eval $ns_ attach-agent \$node_($src) \$tcp($src) eval $ns_ attach-agent \$node_($dst) \$sink($dst) eval $ns_ connect \$tcp($src) \$sink($dst) set ftp($src) [new Application/FTP] eval \$ftp($src) attach-agent \$tcp($src) $ns_ at $starttime "$ftp($src) start" }
TestSuite instproc init {} { global val tracefd topo $self instvar ns_
set ns_ [new Simulator] set tracefd [open ./$val(tr) w] set namtracefd [open ./$val(namtrace) w]
$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtracefd $val(x) $val(y)
set topo [new Topography] $topo load_flatgrid $val(x) $val(y) }
TestSuite instproc finish {} { $self instvar ns_ global tracefd
$ns_ flush-trace close $tracefd exit 0 }
Test/wpan instproc init {} { global val node_ god_ chan topo $self instvar ns_ testName_
set testName_ wpan $self next
set god_ [create-god $val(nn)]
- Usamos el nuevo formato de traza
$ns_ use-newtrace
set chan [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 ON \ -macTrace ON \ -movementTrace ON \ -energyModel "EnergyModel" \ -initialEnergy 0.5 \ -rxPower 0.019 \ -txPower 0.0034 \ -channel $chan
for {set i 0} {$i < 2 } {incr i} { set node_($i) [$ns_ node] $node_($i) random-motion 0 }
$self topology
# === actual test begins here =======================
set appTime1 0.3 set appTime2 0.6 set stopTime 3600
$ns_ at 0.0 "$node_(0) sscs startPANCoord 1"
$ns_ at 0.3 "$node_(1) sscs startDevice 1 1 1"
$ns_ at 0.3 "$node_(0) sscs stopBeacon"
if { ("$val(traffic)" == "mix") || ("$val(traffic)" == "cbr") || ("$val(traffic)" == "poisson") } {
if { "$val(traffic)" == "mix" } { set trafficName "cbr + poisson" set traffic1 cbr set traffic2 poisson } else { set trafficName $val(traffic) set traffic1 $val(traffic) set traffic2 $val(traffic) }
}
# setup traffic flows between nodes
$self ${traffic1}traffic 0 1 0.1 $appTime1
$self ${traffic1}traffic 1 0 0.1 $appTime1
for {set i 0} {$i < $val(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 1 ;# 5
}
# tell nodes when the simulation ends for {set i 0} {$i < $val(nn) } {incr i} { $ns_ at $stopTime "$node_($i) reset"; }
$ns_ at $stopTime.1 "$self finish" }
Test/wpan instproc run {} { $self instvar ns_ $ns_ run }
proc runtest {arg} { global quiet set quiet 0
set b [llength $arg] if {$b == 1} { set test $arg } elseif {$b == 2} { set test [lindex $arg 0] if {[lindex $arg 1] == "QUIET"} { set quiet 1 } } else { usage } set t [new Test/$test]
$t run }
global argv arg0 default_values runtest $argv
- conserves energy consumption over long distances? it is strangee
-