논문 시뮬레이션 tcl 파일
작성 : 2006.12.21 by 임헌정
http://www.4ellene.net
[결과 추출 하기]
trace2stats : http://www.4ellene.net/tt/1065
라우팅 오버헤드 & 패킷 전송률 : http://www.4ellene.net/tt/1078
[라우팅 오버헤드 구하기]
$1~/s/ && /AODV/ && /MAC/ { dsrpktno ++ ;
dsrbyte+=$8 ;}
$1~/s/ && /tcp/ && /MAC/ { cbrpktno ++ ;
cbrbyte+=$8; }
END { print ( dsrpktno, cbrpktno,dsrpktno/(dsrpktno+cbrpktno)) }
[end-to-end 패킷 전송률]
$1~/s/ && /_0_/ && /AGT/ { counter1 ++ }
$1~/r/ && /_29_/ && /AGT/ { counter2 ++ }
END { print ( counter2/counter1 ) }
이동성 없음_일렬
# ======================================================================
# Define options
# ======================================================================
set opt(chan) Channel/WirelessChannel ;# channel type
set opt(prop) Propagation/TwoRayGround ;# radio-propagation model
set opt(netif) Phy/WirelessPhy ;# network interface type
set opt(mac) Mac/802_11 ;# MAC type
set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type
set opt(ll) LL ;# link layer type
set opt(ant) Antenna/OmniAntenna ;# antenna model
set opt(ifqlen) 50 ;# max packet in ifq
set opt(nn) 30 ;# number of mobilenodes
set opt(adhocRouting) AODV ;# routing protocol
set opt(cp) "" ;# connection pattern file
set opt(sc) "" ;# node movement file.
set opt(x) [expr $opt(nn)*30] ;# x coordinate of topology Mn*30m
set opt(y) 100 ;# y coordinate of topology
set opt(seed) 0.0 ;# seed for random number gen.
set opt(stop) 100 ;# time to stop simulation
set opt(cbr-start) 0.0
# ============================================================================
ns-random 0.0
set ns_ [new Simulator]
#
# control DYMOUM behaviour from this script
#
#Agent/DYMOUM set debug_ true
#Agent/DYMOUM set no_path_acc_ false
#Agent/DYMOUM set reissue_rreq_ false
#Agent/DYMOUM set s_bit_ false
#Agent/DYMOUM set hello_ival_ 1
$ns_ use-newtrace
set tracefd [open $opt(adhocRouting)_$opt(nn).tr w]
$ns_ trace-all $tracefd
set namtrace [open $opt(adhocRouting)_$opt(nn).nam w]
$ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)
#
# create topography object
#
set topo [new Topography]
#
# define topology
#
$topo load_flatgrid $opt(x) $opt(y)
#
# create God
#
create-god $opt(nn)
#
# configure mobile nodes
#
$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channelType $opt(chan) \
-topoInstance $topo \
-wiredRouting OFF \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF
for {set i 0} {$i < $opt(nn)} {incr i} {
set node_($i) [$ns_ node]
}
#
# positions
#
$node_(0) set X_ 0.0
$node_(0) set Y_ 50.0
$node_(0) set Z_ 0.0
for {set i 1} {$i < ($opt(nn)-1) } {incr i} {
$node_($i) set X_ [expr rand()*$opt(x)]
#puts {expr rand()}
$node_($i) set Y_ 50.0
$node_($i) set Z_ 0.0
}
$node_([expr $opt(nn)-1]) set X_ $opt(x)
$node_([expr $opt(nn)-1]) set Y_ 50.0
$node_([expr $opt(nn)-1]) set Z_ 0.0
set tcp [new Agent/TCP]
$ns_ attach-agent $node_(0) $tcp
$tcp set fid_ 11
$tcp set packetSize_ 1140
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set packetSize_ 1140
$ftp set interval_ 1
set tcpsink [new Agent/TCPSink]
$ns_ attach-agent $node_([expr $opt(nn)-1]) $tcpsink
$tcpsink set fid_ 12
$ns_ connect $tcp $tcpsink
$ns_ at 0.0 "$ftp start"
#
# define initial node position in nam
#
for {set i 0} {$i < $opt(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 50
}
#
# tell all nodes when the simulation ends
#
for {set i 0} {$i < $opt(nn) } {incr i} {
$ns_ at $opt(stop).0 "$node_($i) reset";
}
$ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $opt(stop).0001 "stop"
proc stop {} {
global ns_ tracefd namtrace
$ns_ flush-trace
close $tracefd
close $namtrace
#set awkCode {
# {
# print $1, $7 >> "samole.out";
# }
#}
#exec awk $awkCode
}
#
# begin simulation
#
puts "==========================================="
puts "Starting Simulation..."
puts $opt(nn)
puts "awk -f avgStats.awk src=0 dst=[expr $opt(nn)-1] flow=11 pkt=1140 $opt(adhocRouting)_$opt(nn).tr > $opt(adhocRouting)_$opt(nn).tr.out && cat $opt
(adhocRouting)_$opt(nn).tr.out"
puts "==========================================="
$ns_ run
이동성 없음_x-y
# Define options
# ======================================================================
set opt(chan) Channel/WirelessChannel ;# channel type
set opt(prop) Propagation/TwoRayGround ;# radio-propagation model
set opt(netif) Phy/WirelessPhy ;# network interface type
set opt(mac) Mac/802_11 ;# MAC type
set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type
set opt(ll) LL ;# link layer type
set opt(ant) Antenna/OmniAntenna ;# antenna model
set opt(ifqlen) 50 ;# max packet in ifq
set opt(nn) 30 ;# number of mobilenodes
set opt(adhocRouting) AODV ;# routing protocol
set opt(cp) "" ;# connection pattern file
set opt(sc) "" ;# node movement file.
set opt(x) [expr $opt(nn)*30] ;# x coordinate of topology Mn*30m
set opt(y) [expr $opt(nn)*30] ;# y coordinate of topology
set opt(seed) 0.0 ;# seed for random number gen.
set opt(stop) 100 ;# time to stop simulation
set opt(cbr-start) 0.0
# ============================================================================
ns-random 0.0
set ns_ [new Simulator]
#
# control DYMOUM behaviour from this script
#
#Agent/DYMOUM set debug_ true
#Agent/DYMOUM set no_path_acc_ false
#Agent/DYMOUM set reissue_rreq_ false
#Agent/DYMOUM set s_bit_ false
#Agent/DYMOUM set hello_ival_ 1
$ns_ use-newtrace
set tracefd [open $opt(adhocRouting)_$opt(nn)_xy.tr w]
$ns_ trace-all $tracefd
set namtrace [open $opt(adhocRouting)_$opt(nn)_xy.nam w]
$ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)
#
# create topography object
#
set topo [new Topography]
#
# define topology
#
$topo load_flatgrid $opt(x) $opt(y)
#
# create God
#
create-god $opt(nn)
#
# configure mobile nodes
#
$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channelType $opt(chan) \
-topoInstance $topo \
-wiredRouting OFF \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF
for {set i 0} {$i < $opt(nn)} {incr i} {
set node_($i) [$ns_ node]
}
#
# positions
#
$node_(0) set X_ 0.0
$node_(0) set Y_ 50.0
$node_(0) set Z_ 0.0
for {set i 1} {$i < ($opt(nn)-1) } {incr i} {
$node_($i) set X_ [expr rand()*$opt(x)]
$node_($i) set Y_ [expr rand()*$opt(y)]
$node_($i) set Z_ 0.0
}
$node_([expr $opt(nn)-1]) set X_ $opt(x)
$node_([expr $opt(nn)-1]) set Y_ $opt(y)
$node_([expr $opt(nn)-1]) set Z_ 0.0
set tcp [new Agent/TCP]
$ns_ attach-agent $node_(0) $tcp
$tcp set fid_ 11
$tcp set packetSize_ 1140
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set packetSize_ 1140
$ftp set interval_ 1
set tcpsink [new Agent/TCPSink]
$ns_ attach-agent $node_([expr $opt(nn)-1]) $tcpsink
$tcpsink set fid_ 12
$ns_ connect $tcp $tcpsink
$ns_ at 0.0 "$ftp start"
#
# define initial node position in nam
#
for {set i 0} {$i < $opt(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 50
}
#
# tell all nodes when the simulation ends
#
for {set i 0} {$i < $opt(nn) } {incr i} {
$ns_ at $opt(stop).0 "$node_($i) reset";
}
$ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $opt(stop).0001 "stop"
proc stop {} {
global ns_ tracefd namtrace
$ns_ flush-trace
close $tracefd
close $namtrace
#set awkCode {
# {
# print $1, $7 >> "samole.out";
# }
#}
#exec awk $awkCode
}
#
# begin simulation
#
puts "==========================================="
puts "Starting Simulation..."
puts $opt(nn)
puts "awk -f avgStats.awk src=0 dst=[expr $opt(nn)-1] flow=11 pkt=1140 $opt(adhocRouting)_$opt(nn)_xy.tr > $opt(adhocRouting)_$opt(nn)_xy.tr.out && cat $opt(adhocRouting)_$opt(nn)_xy.tr.out"
puts "==========================================="
$ns_ run
이동성 있음 _x-y
이동성 파일명은 노드수로 ex) 30
이동성 관련 파일 생성은 : http://www.4ellene.net/tt/1066
ex ) /root/ns-allinone-2.28/ns-2.28/indep-utils/cmu-scen-gen/setdest/setdest -v 2 -n 30 -s 2 -m 4 -M 6 -t 100 -P 2 -p 0.0 -x 600 -y 600 > 30
# Define options
# ======================================================================
set opt(chan) Channel/WirelessChannel ;# channel type
set opt(prop) Propagation/TwoRayGround ;# radio-propagation model
set opt(netif) Phy/WirelessPhy ;# network interface type
set opt(mac) Mac/802_11 ;# MAC type
set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type
set opt(ll) LL ;# link layer type
set opt(ant) Antenna/OmniAntenna ;# antenna model
set opt(ifqlen) 50 ;# max packet in ifq
set opt(nn) 30 ;# number of mobilenodes
set opt(adhocRouting) AODV ;# routing protocol
set opt(cp) "" ;# connection pattern file
set opt(sc) "$opt(nn)" ;# node movement file.
set opt(x) [expr $opt(nn)*30] ;# x coordinate of topology Mn*30m
set opt(y) [expr $opt(nn)*30] ;# y coordinate of topology
set opt(seed) 0.0 ;# seed for random number gen.
set opt(stop) 100 ;# time to stop simulation
set opt(cbr-start) 0.0
# ============================================================================
#
# check for random seed
#
if {$opt(seed) > 0} {
puts "Seeding Random number generator with $opt(seed)\n"
ns-random $opt(seed)
}
set ns_ [new Simulator]
#
# control DYMOUM behaviour from this script
#
#Agent/DYMOUM set debug_ true
#Agent/DYMOUM set no_path_acc_ false
#Agent/DYMOUM set reissue_rreq_ false
#Agent/DYMOUM set s_bit_ false
#Agent/DYMOUM set hello_ival_ 1
$ns_ use-newtrace
set tracefd [open $opt(adhocRouting)_$opt(nn)_xy_move.tr w]
$ns_ trace-all $tracefd
set namtrace [open $opt(adhocRouting)_$opt(nn)_xy_move.nam w]
$ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)
#
# create topography object
#
set topo [new Topography]
#
# define topology
#
$topo load_flatgrid $opt(x) $opt(y)
#
# create God
#
##create-god $opt(nn)
set god_ [create-god $opt(nn)]
#
# configure mobile nodes
#
$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channelType $opt(chan) \
-topoInstance $topo \
-wiredRouting OFF \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF
for {set i 0} {$i < $opt(nn)} {incr i} {
set node_($i) [$ns_ node]
}
#
# positions
#
$node_(0) set X_ 0.0
$node_(0) set Y_ 50.0
$node_(0) set Z_ 0.0
for {set i 1} {$i < ($opt(nn)-1) } {incr i} {
$node_($i) set X_ [expr rand()*$opt(x)]
$node_($i) set Y_ [expr rand()*$opt(y)]
$node_($i) set Z_ 0.0
}
$node_([expr $opt(nn)-1]) set X_ $opt(x)
$node_([expr $opt(nn)-1]) set Y_ $opt(y)
$node_([expr $opt(nn)-1]) set Z_ 0.0
set tcp [new Agent/TCP]
$ns_ attach-agent $node_(0) $tcp
$tcp set fid_ 11
$tcp set packetSize_ 1140
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set packetSize_ 1140
$ftp set interval_ 1
set tcpsink [new Agent/TCPSink]
$ns_ attach-agent $node_([expr $opt(nn)-1]) $tcpsink
$tcpsink set fid_ 12
$ns_ connect $tcp $tcpsink
$ns_ at 0.0 "$ftp start"
#
# source connection-pattern and node-movement scripts
#
if { $opt(cp) == "" } {
puts "*** NOTE: no connection pattern specified."
set opt(cp) "none"
} else {
puts "Loading connection pattern..."
source $opt(cp)
}
if { $opt(sc) == "" } {
puts "*** NOTE: no scenario file specified."
set opt(sc) "none"
} else {
puts "Loading scenario file..."
source $opt(sc)
puts "Load complete..."
}
#
# define initial node position in nam
#
for {set i 0} {$i < $opt(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 50
}
#
# tell all nodes when the simulation ends
#
for {set i 0} {$i < $opt(nn) } {incr i} {
$ns_ at $opt(stop).0 "$node_($i) reset";
}
$ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $opt(stop).0001 "stop"
proc stop {} {
global ns_ tracefd namtrace
$ns_ flush-trace
close $tracefd
close $namtrace
#set awkCode {
# {
# print $1, $7 >> "samole.out";
# }
#}
#exec awk $awkCode
}
#
# begin simulation
#
puts "==========================================="
puts "Starting Simulation..."
puts $opt(nn)
puts "awk -f avgStats.awk src=0 dst=[expr $opt(nn)-1] flow=11 pkt=1140 $opt(adhocRouting)_$opt(nn)_xy_move.tr > $opt(adhocRouting)_$opt(nn)_xy_move.tr.out && cat $opt(adhocRouting)_$opt(nn)_xy_move.tr.out"
puts "==========================================="
$ns_ run

Comments List
醫