#===================================
# Simulation parameters setup
#===================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
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) 16 ;# number of mobilenodes
set val(rp) DSDV ;# routing protocol
set val(x) 881 ;# X dimension of topography
set val(y) 652 ;# Y dimension of topography
set val(stop) 250.0 ;# time of simulation end
#===================================
# Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]
#Setup topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
#Open the NS trace file
set tracefile [open out1.tr w]
$ns trace-all $tracefile
#Open the NAM trace file
set namfile [open out1.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y)
set chan [new $val(chan)];#Create wireless channel
#===================================
# Mobile node parameter setup
#===================================
$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 $chan \
-topoInstance $topo \
-agentTrace OFF \
-routerTrace ON \
-macTrace ON \
-movementTrace ON
#===================================
# Nodes Definition
#===================================
#Create 16 nodes
set n0 [$ns node]
$n0 set X_ 437
$n0 set Y_ 301
$n0 set Z_ 0.0
$n0 color orange
$ns at 0.0 "$n0 color orange"
$ns initial_node_pos $n0 20
set n1 [$ns node]
$n1 set X_ 324
$n1 set Y_ 337
$n1 set Z_ 0.0
$n1 color orange
$ns at 0.0 "$n1 color orange"
$ns initial_node_pos $n1 20
set n2 [$ns node]
$n2 set X_ 274
$n2 set Y_ 257
$n2 set Z_ 0.0
$n2 color orange
$ns at 0.0 "$n2 color orange"
$ns initial_node_pos $n2 20
set n3 [$ns node]
$n3 set X_ 291
$n3 set Y_ 456
$n3 set Z_ 0.0
$n3 color orange
$ns at 0.0 "$n3 color orange"
$ns initial_node_pos $n3 20
set n4 [$ns node]
$n4 set X_ 478
$n4 set Y_ 390
$n4 set Z_ 0.0
$n4 color orange
$ns at 0.0 "$n4 color orange"
$ns initial_node_pos $n4 20
set n5 [$ns node]
$n5 set X_ 150
$n5 set Y_ 357
$n5 set Z_ 0.0
$n5 color orange
$ns at 0.0 "$n5 color orange"
$ns initial_node_pos $n5 20
set n6 [$ns node]
$n6 set X_ 436
$n6 set Y_ 153
$n6 set Z_ 0.0
$n6 color orange
$ns at 0.0 "$n6 color orange"
$ns initial_node_pos $n6 20
set n7 [$ns node]
$n7 set X_ 451
$n7 set Y_ 509
$n7 set Z_ 0.0
$n7 color orange
$ns at 0.0 "$n7 color orange"
$ns initial_node_pos $n7 20
set n8 [$ns node]
$n8 set X_ 150
$n8 set Y_ 166
$n8 set Z_ 0.0
$n8 color orange
$ns at 0.0 "$n8 color orange"
$ns initial_node_pos $n8 20
set n9 [$ns node]
$n9 set X_ 566
$n9 set Y_ 305
$n9 set Z_ 0.0
$n9 color orange
$ns at 0.0 "$n9 color orange"
$ns initial_node_pos $n9 20
set n10 [$ns node]
$n10 set X_ 611
$n10 set Y_ 462
$n10 set Z_ 0.0
$n10 color orange
$ns at 0.0 "$n10 color orange"
$ns initial_node_pos $n10 20
set n11 [$ns node]
$n11 set X_ 244
$n11 set Y_ 552
$n11 set Z_ 0.0
$n11 color orange
$ns at 0.0 "$n11 color orange"
$ns initial_node_pos $n11 20
set n12 [$ns node]
$n12 set X_ 298
$n12 set Y_ 76
$n12 set Z_ 0.0
$n12 color orange
$ns at 0.0 "$n12 color orange"
$ns initial_node_pos $n12 20
set n13 [$ns node]
$n13 set X_ 544
$n13 set Y_ 213
$n13 set Z_ 0.0
$n13 color orange
$ns at 0.0 "$n13 color orange"
$ns initial_node_pos $n13 20
set n14 [$ns node]
$n14 set X_ 663
$n14 set Y_ 355
$n14 set Z_ 0.0
$n14 color orange
$ns at 0.0 "$n14 color orange"
$ns initial_node_pos $n14 20
set n15 [$ns node]
$n15 set X_ 503
$n15 set Y_ 119
$n15 set Z_ 0.0
$n15 color red
$ns at 0.0 "$n15 color red"
$ns initial_node_pos $n15 20
$ns at 0.5 "$n0 setdest 741.222 219.713 15.0"
$ns at 0.5 "$n1 setdest 661.911 293.578 15.0"
$ns at 0.5 "$n2 setdest 720.195 368.71 15.0"
$ns at 0.5 "$n3 setdest 841.832 311.792 15.0"
$ns at 0.5 "$n4 setdest 846.279 231.381 15.0"
$ns at 0.5 "$n5 setdest 154.962 76.1411 15.0"
$ns at 0.5 "$n6 setdest 277.55 146.965 15.0"
$ns at 0.5 "$n7 setdest 218.432 229.934 15.0"
$ns at 0.5 "$n8 setdest 58.4876 147.719 15.0"
$ns at 0.5 "$n9 setdest 113.938 245.951 15.0"
$ns at 0.5 "$n10 setdest 497.792 404.879 15.0"
$ns at 0.5 "$n11 setdest 356.954 425.859 15.0"
$ns at 0.5 "$n12 setdest 355.962 535.156 15.0"
$ns at 0.5 "$n13 setdest 459.874 558.361 15.0"
$ns at 0.5 "$n14 setdest 546.27 490.731 15.0"
$ns at 70.0 "$n0 setdest 546.22 499.713 15.0"
$ns at 75.0 "$n7 setdest 741.222 219.713 15.0"
$ns at 65.5 "$n12 setdest 845.222 319.713 15.0"
$ns at 80.5 "$n3 setdest 355.222 519.713 15.0"
$ns at 75.0 "$n14 setdest 218.422 229.713 15.0"
$ns at 75.5 "$n4 setdest 720.195 368.71 15.0"
$ns at 75.5 "$n2 setdest 846.279 231.381 15.0"
$ns at 80.5 "$n9 setdest 58.4876 147.719 15.0"
$ns at 80.5 "$n8 setdest 113.938 245.951 15.0"
$ns at 77.5 "$n13 setdest 356.954 425.859 15.0"
$ns at 77.5 "$n11 setdest 459.874 558.361 15.0"
#$ns at 138.0 "$n10 setdest 656.26 181.573 15.0"
#$ns at 162.0 "$n10 add-mark N2 white circle"
#$n10 color darkgreen
#$ns at 162.0 "$n10 color darkgreen"
$ns at 0.0 "$n15 label Host"
#$ns at 39.0 "$n1 label High-Power-Cluster"
#$ns at 39.0 "$n6 label High-Power-Cluster"
#$ns at 108.0 "$n11 label High-Power-Cluster"
#$ns at 39.0 "$n10 label High-Power-Cluster"
#$ns at 108.0 "$n10 label ordinary node"
#$ns at 99.1 "$n10 color orange"
#$ns at 99.1 "$n14 color darkgreen"
#$ns at 118.0 "$n1 color orange"
#$ns at 118.0 "$n0 color darkgreen"
$n1 color darkgreen
$ns at 64.1 "$n1 color darkgreen"
$n6 color darkgreen
$ns at 47.1 "$n6 color darkgreen"
$n10 color darkgreen
$ns at 56.1 "$n10 color darkgreen"
$n1 color darkgreen
$ns at 134.1 "$n1 color darkgreen"
$n6 color darkgreen
$ns at 140.1 "$n6 color darkgreen"
$n10 color darkgreen
$ns at 146.1 "$n10 color darkgreen"
$ns at 64.1 "$n1 add-mark N2 white circle"
$ns at 47.1 "$n6 add-mark N2 white circle"
$ns at 56.1 "$n10 add-mark N2 white circle"
$ns at 130.1 "$n1 add-mark N2 white circle"
$ns at 137.1 "$n6 add-mark N2 white circle"
$ns at 142.1 "$n10 add-mark N2 white circle"
$ns at 120.1 "$n10 color darkgreen"
$ns at 115.1 "$n1 add-mark N2 white circle"
$ns at 109.1 "$n6 add-mark N2 white circle"
$ns at 190.1 "$n10 add-mark N2 white circle"
$ns at 199.1 "$n1 add-mark N2 white circle"
$ns at 210.1 "$n6 add-mark N2 white circle"
$ns at 220.1 "$n10 add-mark N2 white circle"
#$ns at 99.1 "$n10 delete-mark N2"
#$ns at 99.1 "$n14 add-mark N2 white circle"
#$ns at 118.0 "$n1 delete-mark N2"
#$ns at 118.0 "$n0 add-mark N2 white circle"
#$ns at 157.0 "$n0 delete-mark N2"
#$ns at 157.0 "$n0 add-mark N2 pink circle"
#$ns at 185.1 "$n10 delete-mark N2"
#$ns at 185.1 "$n14 add-mark N2 white circle"
#$ns at 168.0 "$n1 delete-mark N2"
#$ns at 168.0 "$n0 add-mark N2 white circle"
#$ns at 177.0 "$n0 delete-mark N2"
#$ns at 177.0 "$n0 add-mark N2 pink circle"
proc create_cluster_head_node {
} {
global val ns_ node_ topo contador_nodos rng
Phy/WirelessPhy set Pt_ $val(pt_cluster_head)
$ns_ node-config -sensorNode ON \
-adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-energyModel $val(en) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-rxPower 0.3 \
-txPower 0.6 \
-initialEnergy 100.0 \
-movementTrace OFF
set node_($contador_nodos) [$ns_ node]
$node_($contador_nodos) random-motion 0
set x [$rng uniform 0.0 $val(x)]
set y [$rng uniform 0.0 $val(y)]
$node_($contador_nodos) set X_ $x
$node_($contador_nodos) set Y_ $y
$node_($contador_nodos) set Z_ 0.0
set interval [$rng uniform 0.0 1.0]
Node/MobileNode/SensorNode set processingPower 0.36
Node/MobileNode/SensorNode set instructionsPerSecond_ 150000000
Phy/WirelessPhy set bandwidth_ 1000000.0
set udp_($contador_nodos) [new Agent/UDP]
set app_($contador_nodos) [create_cluster_head_app [$node_(1) node-addr] $val(disseminating_type) $val(cluster_head_disseminating_interval)]
$node_($contador_nodos) attach $udp_($contador_nodos) $val(port)
$node_($contador_nodos) add-app $app_($contador_nodos)
set processing_($contador_nodos) [new Processing/AggregateProcessing]
$app_($contador_nodos) node $node_($contador_nodos)
$app_($contador_nodos) attach-agent $udp_($contador_nodos)
$app_($contador_nodos) attach-processing $processing_($contador_nodos)
$processing_($contador_nodos) node $node_($contador_nodos)
$ns_ at [expr $val(start) + 1 + $interval] "$app_($contador_nodos) start"
$ns_ at $val(stop) "$app_($contador_nodos) stop"
incr contador_nodos
}
set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $n0 $tcp
$ns attach-agent $n1 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
#$ftp set rate_ 1.0Mb
#$ftp set random_ null
#$ftp set interval_ 0.4
$ns at 64.2 "$ftp start"
$ns at 68.0 "$ftp stop"
set tcp1 [new Agent/TCP]
$tcp1 set class_ 2
set sink1 [new Agent/TCPSink]
$ns attach-agent $n2 $tcp1
$ns attach-agent $n1 $sink1
$ns connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
#$ftp1 set rate_ 1.0Mb
#$ftp1 set random_ null
#$ftp1 set interval_ 0.4
$ns at 68.2 "$ftp1 start"
$ns at 72.0 "$ftp1 stop"
set tcp2 [new Agent/TCP]
$tcp2 set class_ 2
set sink2 [new Agent/TCPSink]
$ns attach-agent $n3 $tcp2
$ns attach-agent $n1 $sink2
$ns connect $tcp2 $sink2
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2
#$ftp2 set rate_ 1.0Mb
#$ftp2 set random_ null
#$ftp2 set interval_ 0.4
$ns at 72.2 "$ftp2 start"
$ns at 76.0 "$ftp2 stop"
set tcp3 [new Agent/TCP]
$tcp3 set class_ 2
set sink3 [new Agent/TCPSink]
$ns attach-agent $n4 $tcp3
$ns attach-agent $n1 $sink3
$ns connect $tcp3 $sink3
set ftp3 [new Application/FTP]
$ftp3 attach-agent $tcp3
#$ftp3 set rate_ 1.0Mb
#$ftp3 set random_ null
#$ftp3 set interval_ 0.4
$ns at 76.2 "$ftp3 start"
$ns at 80.0 "$ftp3 stop"
set tcp4 [new Agent/TCP]
$tcp4 set class_ 2
set sink4 [new Agent/TCPSink]
$ns attach-agent $n1 $tcp4
$ns attach-agent $n15 $sink4
$ns connect $tcp4 $sink4
set ftp4 [new Application/FTP]
$ftp4 attach-agent $tcp4
#$ftp4 set rate_ 1.0Mb
#$ftp4 set random_ null
#$ftp4 set interval_ 0.4
$ns at 80.2 "$ftp4 start"
$ns at 84.0 "$ftp4 stop"
set tcp5 [new Agent/TCP]
$tcp5 set class_ 2
set sink5 [new Agent/TCPSink]
$ns attach-agent $n5 $tcp5
$ns attach-agent $n6 $sink5
$ns connect $tcp5 $sink5
set ftp5 [new Application/FTP]
$ftp5 attach-agent $tcp5
#$ftp5 set rate_ 1.0Mb
#$ftp5 set random_ null
#$ftp5 set interval_ 0.4
$ns at 84.2 "$ftp5 start"
$ns at 88.0 "$ftp5 stop"
set tcp6 [new Agent/TCP]
$tcp6 set class_ 2
set sink6 [new Agent/TCPSink]
$ns attach-agent $n7 $tcp6
$ns attach-agent $n6 $sink6
$ns connect $tcp6 $sink6
set ftp6 [new Application/FTP]
$ftp6 attach-agent $tcp6
#$ftp6 set rate_ 1.0Mb
#$ftp6 set random_ null
#$ftp6 set interval_ 0.4
$ns at 88.2 "$ftp6 start"
$ns at 92.0 "$ftp6 stop"
set tcp7 [new Agent/TCP]
$tcp7 set class_ 2
set sink7 [new Agent/TCPSink]
$ns attach-agent $n8 $tcp7
$ns attach-agent $n6 $sink7
$ns connect $tcp7 $sink7
set ftp7 [new Application/FTP]
$ftp7 attach-agent $tcp7
#$ftp7 set rate_ 1.0Mb
#$ftp7 set random_ null
#$ftp7 set interval_ 0.4
$ns at 92.2 "$ftp7 start"
$ns at 96.0 "$ftp7 stop"
set tcp8 [new Agent/TCP]
$tcp8 set class_ 2
set sink8 [new Agent/TCPSink]
$ns attach-agent $n9 $tcp8
$ns attach-agent $n6 $sink8
$ns connect $tcp8 $sink8
set ftp8 [new Application/FTP]
$ftp8 attach-agent $tcp8
#$ftp8 set rate_ 1.0Mb
#$ftp8 set random_ null
#$ftp8 set interval_ 0.4
$ns at 96.2 "$ftp8 start"
$ns at 100.0 "$ftp8 stop"
set tcp9 [new Agent/TCP]
$tcp9 set class_ 2
set sink9 [new Agent/TCPSink]
$ns attach-agent $n6 $tcp9
$ns attach-agent $n15 $sink9
$ns connect $tcp9 $sink9
set ftp9 [new Application/FTP]
$ftp9 attach-agent $tcp9
#$ftp9 set rate_ 1.0Mb
#$ftp9 set random_ null
#$ftp9 set interval_ 0.4
$ns at 100.2 "$ftp9 start"
$ns at 104.0 "$ftp9 stop"
set tcp10 [new Agent/TCP]
$tcp10 set class_ 2
set sink10 [new Agent/TCPSink]
$ns attach-agent $n11 $tcp10
$ns attach-agent $n10 $sink10
$ns connect $tcp10 $sink10
set ftp10 [new Application/FTP]
$ftp10 attach-agent $tcp10
#$ftp10 set rate_ 1.0Mb
#$ftp10 set random_ null
#$ftp10 set interval_ 0.4
$ns at 104.2 "$ftp10 start"
$ns at 108.0 "$ftp10 stop"
set tcp11 [new Agent/TCP]
$tcp11 set class_ 2
set sink11 [new Agent/TCPSink]
$ns attach-agent $n12 $tcp11
$ns attach-agent $n10 $sink11
$ns connect $tcp11 $sink11
set ftp11 [new Application/FTP]
$ftp11 attach-agent $tcp11
#$ftp11 set rate_ 1.0Mb
#$ftp11 set random_ null
#$ftp11 set interval_ 0.4
$ns at 108.2 "$ftp11 start"
$ns at 112.0 "$ftp11 stop"
set tcp12 [new Agent/TCP]
$tcp12 set class_ 2
set sink12 [new Agent/TCPSink]
$ns attach-agent $n13 $tcp12
$ns attach-agent $n10 $sink12
$ns connect $tcp12 $sink12
set ftp12 [new Application/FTP]
$ftp12 attach-agent $tcp12
#$ftp12 set rate_ 1.0Mb
#$ftp12 set random_ null
#$ftp12 set interval_ 0.4
$ns at 112.2 "$ftp12 start"
$ns at 116.0 "$ftp12 stop"
set tcp13 [new Agent/TCP]
$tcp13 set class_ 2
set sink13 [new Agent/TCPSink]
$ns attach-agent $n14 $tcp13
$ns attach-agent $n10 $sink13
$ns connect $tcp13 $sink13
set ftp13 [new Application/FTP]
$ftp13 attach-agent $tcp13
#$ftp13 set rate_ 1.0Mb
#$ftp13 set random_ null
#$ftp13 set interval_ 0.4
$ns at 116.2 "$ftp13 start"
$ns at 120.0 "$ftp13 stop"
set tcp14 [new Agent/TCP]
$tcp14 set class_ 2
set sink14 [new Agent/TCPSink]
$ns attach-agent $n10 $tcp14
$ns attach-agent $n15 $sink14
$ns connect $tcp14 $sink14
set ftp14 [new Application/FTP]
$ftp14 attach-agent $tcp14
#$ftp14 set rate_ 1.0Mb
#$ftp14 set random_ null
#$ftp14 set interval_ 0.4
$ns at 120.2 "$ftp14 start"
$ns at 124.0 "$ftp14 stop"
set tcp15 [new Agent/TCP]
$tcp15 set class_ 2
set sink15 [new Agent/TCPSink]
$ns attach-agent $n7 $tcp15
$ns attach-agent $n6 $sink15
$ns connect $tcp15 $sink15
set ftp15 [new Application/FTP]
$ftp15 attach-agent $tcp15
#$ftp15 set rate_ 1.0Mb
#$ftp15 set random_ null
#$ftp15 set interval_ 0.4
$ns at 39.2 "$ftp15 start"
$ns at 41.0 "$ftp15 stop"
set tcp16 [new Agent/TCP]
$tcp16 set class_ 2
set sink16 [new Agent/TCPSink]
$ns attach-agent $n8 $tcp16
$ns attach-agent $n6 $sink16
$ns connect $tcp16 $sink16
set ftp16 [new Application/FTP]
$ftp16 attach-agent $tcp16
#$ftp16 set rate_ 1.0Mb
#$ftp16 set random_ null
#$ftp16 set interval_ 0.4
$ns at 41.2 "$ftp16 start"
$ns at 43.0 "$ftp16 stop"
set tcp17 [new Agent/TCP]
$tcp17 set class_ 2
set sink17 [new Agent/TCPSink]
$ns attach-agent $n9 $tcp17
$ns attach-agent $n6 $sink17
$ns connect $tcp17 $sink17
set ftp17 [new Application/FTP]
$ftp17 attach-agent $tcp17
#$ftp17 set rate_ 1.0Mb
#$ftp17 set random_ null
#$ftp17 set interval_ 0.4
$ns at 43.2 "$ftp17 start"
$ns at 45.0 "$ftp17 stop"
set tcp18 [new Agent/TCP]
$tcp18 set class_ 2
set sink18 [new Agent/TCPSink]
$ns attach-agent $n5 $tcp18
$ns attach-agent $n8 $sink18
$ns connect $tcp18 $sink18
set ftp18 [new Application/FTP]
$ftp18 attach-agent $tcp18
#$ftp18 set rate_ 1.0Mb
#$ftp18 set random_ null
#$ftp18 set interval_ 0.4
$ns at 45.2 "$ftp18 start"
$ns at 47.0 "$ftp18 stop"
set tcp19 [new Agent/TCP]
$tcp19 set class_ 2
set sink19 [new Agent/TCPSink]
$ns attach-agent $n11 $tcp19
$ns attach-agent $n10 $sink19
$ns connect $tcp19 $sink19
set ftp19 [new Application/FTP]
$ftp19 attach-agent $tcp19
#$ftp19 set rate_ 1.0Mb
#$ftp19 set random_ null
#$ftp19 set interval_ 0.4
$ns at 47.2 "$ftp19 start"
$ns at 49.0 "$ftp19 stop"
set tcp20 [new Agent/TCP]
$tcp20 set class_ 2
set sink20 [new Agent/TCPSink]
$ns attach-agent $n12 $tcp20
$ns attach-agent $n10 $sink20
$ns connect $tcp20 $sink20
set ftp20 [new Application/FTP]
$ftp20 attach-agent $tcp20
#$ftp20 set rate_ 1.0Mb
#$ftp20 set random_ null
#$ftp20 set interval_ 0.4
$ns at 50.2 "$ftp20 start"
$ns at 52.0 "$ftp20 stop"
set tcp21 [new Agent/TCP]
$tcp21 set class_ 2
set sink21 [new Agent/TCPSink]
$ns attach-agent $n13 $tcp21
$ns attach-agent $n10 $sink21
$ns connect $tcp21 $sink21
set ftp21 [new Application/FTP]
$ftp21 attach-agent $tcp21
#$ftp21 set rate_ 1.0Mb
#$ftp21 set random_ null
#$ftp21 set interval_ 0.4
$ns at 52.2 "$ftp21 start"
$ns at 54.0 "$ftp21 stop"
set tcp22 [new Agent/TCP]
$tcp22 set class_ 2
set sink22 [new Agent/TCPSink]
$ns attach-agent $n14 $tcp22
$ns attach-agent $n11 $sink22
$ns connect $tcp22 $sink22
set ftp22 [new Application/FTP]
$ftp22 attach-agent $tcp22
#$ftp22 set rate_ 1.0Mb
#$ftp22 set random_ null
#$ftp22 set interval_ 0.4
$ns at 54.2 "$ftp22 start"
$ns at 56.0 "$ftp22 stop"
set tcp23 [new Agent/TCP]
$tcp23 set class_ 2
set sink23 [new Agent/TCPSink]
$ns attach-agent $n4 $tcp23
$ns attach-agent $n1 $sink23
$ns connect $tcp23 $sink23
set ftp23 [new Application/FTP]
$ftp23 attach-agent $tcp23
#$ftp23 set rate_ 1.0Mb
#$ftp23 set random_ null
#$ftp23 set interval_ 0.4
$ns at 56.2 "$ftp23 start"
$ns at 58.0 "$ftp23 stop"
set tcp24 [new Agent/TCP]
$tcp24 set class_ 2
set sink24 [new Agent/TCPSink]
$ns attach-agent $n0 $tcp24
$ns attach-agent $n1 $sink24
$ns connect $tcp24 $sink24
set ftp24 [new Application/FTP]
$ftp24 attach-agent $tcp24
#$ftp24 set rate_ 1.0Mb
#$ftp24 set random_ null
#$ftp24 set interval_ 0.4
$ns at 59.2 "$ftp24 start"
$ns at 60.0 "$ftp24 stop"
set tcp25 [new Agent/TCP]
$tcp25 set class_ 2
set sink25 [new Agent/TCPSink]
$ns attach-agent $n2 $tcp25
$ns attach-agent $n1 $sink25
$ns connect $tcp25 $sink25
set ftp25 [new Application/FTP]
$ftp25 attach-agent $tcp25
#$ftp24 set rate_ 1.0Mb
#$ftp24 set random_ null
#$ftp24 set interval_ 0.4
$ns at 60.2 "$ftp25 start"
$ns at 62.0 "$ftp25 stop"
set tcp26 [new Agent/TCP]
$tcp26 set class_ 2
set sink26 [new Agent/TCPSink]
$ns attach-agent $n1 $tcp26
$ns attach-agent $n0 $sink26
$ns connect $tcp26 $sink26
set ftp26 [new Application/FTP]
$ftp26 attach-agent $tcp26
#$ftp24 set rate_ 1.0Mb
#$ftp24 set random_ null
#$ftp24 set interval_ 0.4
$ns at 62.2 "$ftp26 start"
$ns at 64.0 "$ftp26 stop"
#Define a 'finish' procedure
proc finish {
} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam out1.nam &
exit 0
}
for {
set i 0
} {
$i < $val(nn)
} {
incr i
} {
$ns at $val(stop) "\$n$i reset"
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run
# Simulation parameters setup
#===================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
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) 16 ;# number of mobilenodes
set val(rp) DSDV ;# routing protocol
set val(x) 881 ;# X dimension of topography
set val(y) 652 ;# Y dimension of topography
set val(stop) 250.0 ;# time of simulation end
#===================================
# Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]
#Setup topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
#Open the NS trace file
set tracefile [open out1.tr w]
$ns trace-all $tracefile
#Open the NAM trace file
set namfile [open out1.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y)
set chan [new $val(chan)];#Create wireless channel
#===================================
# Mobile node parameter setup
#===================================
$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 $chan \
-topoInstance $topo \
-agentTrace OFF \
-routerTrace ON \
-macTrace ON \
-movementTrace ON
#===================================
# Nodes Definition
#===================================
#Create 16 nodes
set n0 [$ns node]
$n0 set X_ 437
$n0 set Y_ 301
$n0 set Z_ 0.0
$n0 color orange
$ns at 0.0 "$n0 color orange"
$ns initial_node_pos $n0 20
set n1 [$ns node]
$n1 set X_ 324
$n1 set Y_ 337
$n1 set Z_ 0.0
$n1 color orange
$ns at 0.0 "$n1 color orange"
$ns initial_node_pos $n1 20
set n2 [$ns node]
$n2 set X_ 274
$n2 set Y_ 257
$n2 set Z_ 0.0
$n2 color orange
$ns at 0.0 "$n2 color orange"
$ns initial_node_pos $n2 20
set n3 [$ns node]
$n3 set X_ 291
$n3 set Y_ 456
$n3 set Z_ 0.0
$n3 color orange
$ns at 0.0 "$n3 color orange"
$ns initial_node_pos $n3 20
set n4 [$ns node]
$n4 set X_ 478
$n4 set Y_ 390
$n4 set Z_ 0.0
$n4 color orange
$ns at 0.0 "$n4 color orange"
$ns initial_node_pos $n4 20
set n5 [$ns node]
$n5 set X_ 150
$n5 set Y_ 357
$n5 set Z_ 0.0
$n5 color orange
$ns at 0.0 "$n5 color orange"
$ns initial_node_pos $n5 20
set n6 [$ns node]
$n6 set X_ 436
$n6 set Y_ 153
$n6 set Z_ 0.0
$n6 color orange
$ns at 0.0 "$n6 color orange"
$ns initial_node_pos $n6 20
set n7 [$ns node]
$n7 set X_ 451
$n7 set Y_ 509
$n7 set Z_ 0.0
$n7 color orange
$ns at 0.0 "$n7 color orange"
$ns initial_node_pos $n7 20
set n8 [$ns node]
$n8 set X_ 150
$n8 set Y_ 166
$n8 set Z_ 0.0
$n8 color orange
$ns at 0.0 "$n8 color orange"
$ns initial_node_pos $n8 20
set n9 [$ns node]
$n9 set X_ 566
$n9 set Y_ 305
$n9 set Z_ 0.0
$n9 color orange
$ns at 0.0 "$n9 color orange"
$ns initial_node_pos $n9 20
set n10 [$ns node]
$n10 set X_ 611
$n10 set Y_ 462
$n10 set Z_ 0.0
$n10 color orange
$ns at 0.0 "$n10 color orange"
$ns initial_node_pos $n10 20
set n11 [$ns node]
$n11 set X_ 244
$n11 set Y_ 552
$n11 set Z_ 0.0
$n11 color orange
$ns at 0.0 "$n11 color orange"
$ns initial_node_pos $n11 20
set n12 [$ns node]
$n12 set X_ 298
$n12 set Y_ 76
$n12 set Z_ 0.0
$n12 color orange
$ns at 0.0 "$n12 color orange"
$ns initial_node_pos $n12 20
set n13 [$ns node]
$n13 set X_ 544
$n13 set Y_ 213
$n13 set Z_ 0.0
$n13 color orange
$ns at 0.0 "$n13 color orange"
$ns initial_node_pos $n13 20
set n14 [$ns node]
$n14 set X_ 663
$n14 set Y_ 355
$n14 set Z_ 0.0
$n14 color orange
$ns at 0.0 "$n14 color orange"
$ns initial_node_pos $n14 20
set n15 [$ns node]
$n15 set X_ 503
$n15 set Y_ 119
$n15 set Z_ 0.0
$n15 color red
$ns at 0.0 "$n15 color red"
$ns initial_node_pos $n15 20
$ns at 0.5 "$n0 setdest 741.222 219.713 15.0"
$ns at 0.5 "$n1 setdest 661.911 293.578 15.0"
$ns at 0.5 "$n2 setdest 720.195 368.71 15.0"
$ns at 0.5 "$n3 setdest 841.832 311.792 15.0"
$ns at 0.5 "$n4 setdest 846.279 231.381 15.0"
$ns at 0.5 "$n5 setdest 154.962 76.1411 15.0"
$ns at 0.5 "$n6 setdest 277.55 146.965 15.0"
$ns at 0.5 "$n7 setdest 218.432 229.934 15.0"
$ns at 0.5 "$n8 setdest 58.4876 147.719 15.0"
$ns at 0.5 "$n9 setdest 113.938 245.951 15.0"
$ns at 0.5 "$n10 setdest 497.792 404.879 15.0"
$ns at 0.5 "$n11 setdest 356.954 425.859 15.0"
$ns at 0.5 "$n12 setdest 355.962 535.156 15.0"
$ns at 0.5 "$n13 setdest 459.874 558.361 15.0"
$ns at 0.5 "$n14 setdest 546.27 490.731 15.0"
$ns at 70.0 "$n0 setdest 546.22 499.713 15.0"
$ns at 75.0 "$n7 setdest 741.222 219.713 15.0"
$ns at 65.5 "$n12 setdest 845.222 319.713 15.0"
$ns at 80.5 "$n3 setdest 355.222 519.713 15.0"
$ns at 75.0 "$n14 setdest 218.422 229.713 15.0"
$ns at 75.5 "$n4 setdest 720.195 368.71 15.0"
$ns at 75.5 "$n2 setdest 846.279 231.381 15.0"
$ns at 80.5 "$n9 setdest 58.4876 147.719 15.0"
$ns at 80.5 "$n8 setdest 113.938 245.951 15.0"
$ns at 77.5 "$n13 setdest 356.954 425.859 15.0"
$ns at 77.5 "$n11 setdest 459.874 558.361 15.0"
#$ns at 138.0 "$n10 setdest 656.26 181.573 15.0"
#$ns at 162.0 "$n10 add-mark N2 white circle"
#$n10 color darkgreen
#$ns at 162.0 "$n10 color darkgreen"
$ns at 0.0 "$n15 label Host"
#$ns at 39.0 "$n1 label High-Power-Cluster"
#$ns at 39.0 "$n6 label High-Power-Cluster"
#$ns at 108.0 "$n11 label High-Power-Cluster"
#$ns at 39.0 "$n10 label High-Power-Cluster"
#$ns at 108.0 "$n10 label ordinary node"
#$ns at 99.1 "$n10 color orange"
#$ns at 99.1 "$n14 color darkgreen"
#$ns at 118.0 "$n1 color orange"
#$ns at 118.0 "$n0 color darkgreen"
$n1 color darkgreen
$ns at 64.1 "$n1 color darkgreen"
$n6 color darkgreen
$ns at 47.1 "$n6 color darkgreen"
$n10 color darkgreen
$ns at 56.1 "$n10 color darkgreen"
$n1 color darkgreen
$ns at 134.1 "$n1 color darkgreen"
$n6 color darkgreen
$ns at 140.1 "$n6 color darkgreen"
$n10 color darkgreen
$ns at 146.1 "$n10 color darkgreen"
$ns at 64.1 "$n1 add-mark N2 white circle"
$ns at 47.1 "$n6 add-mark N2 white circle"
$ns at 56.1 "$n10 add-mark N2 white circle"
$ns at 130.1 "$n1 add-mark N2 white circle"
$ns at 137.1 "$n6 add-mark N2 white circle"
$ns at 142.1 "$n10 add-mark N2 white circle"
$ns at 120.1 "$n10 color darkgreen"
$ns at 115.1 "$n1 add-mark N2 white circle"
$ns at 109.1 "$n6 add-mark N2 white circle"
$ns at 190.1 "$n10 add-mark N2 white circle"
$ns at 199.1 "$n1 add-mark N2 white circle"
$ns at 210.1 "$n6 add-mark N2 white circle"
$ns at 220.1 "$n10 add-mark N2 white circle"
#$ns at 99.1 "$n10 delete-mark N2"
#$ns at 99.1 "$n14 add-mark N2 white circle"
#$ns at 118.0 "$n1 delete-mark N2"
#$ns at 118.0 "$n0 add-mark N2 white circle"
#$ns at 157.0 "$n0 delete-mark N2"
#$ns at 157.0 "$n0 add-mark N2 pink circle"
#$ns at 185.1 "$n10 delete-mark N2"
#$ns at 185.1 "$n14 add-mark N2 white circle"
#$ns at 168.0 "$n1 delete-mark N2"
#$ns at 168.0 "$n0 add-mark N2 white circle"
#$ns at 177.0 "$n0 delete-mark N2"
#$ns at 177.0 "$n0 add-mark N2 pink circle"
proc create_cluster_head_node {
} {
global val ns_ node_ topo contador_nodos rng
Phy/WirelessPhy set Pt_ $val(pt_cluster_head)
$ns_ node-config -sensorNode ON \
-adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-energyModel $val(en) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-rxPower 0.3 \
-txPower 0.6 \
-initialEnergy 100.0 \
-movementTrace OFF
set node_($contador_nodos) [$ns_ node]
$node_($contador_nodos) random-motion 0
set x [$rng uniform 0.0 $val(x)]
set y [$rng uniform 0.0 $val(y)]
$node_($contador_nodos) set X_ $x
$node_($contador_nodos) set Y_ $y
$node_($contador_nodos) set Z_ 0.0
set interval [$rng uniform 0.0 1.0]
Node/MobileNode/SensorNode set processingPower 0.36
Node/MobileNode/SensorNode set instructionsPerSecond_ 150000000
Phy/WirelessPhy set bandwidth_ 1000000.0
set udp_($contador_nodos) [new Agent/UDP]
set app_($contador_nodos) [create_cluster_head_app [$node_(1) node-addr] $val(disseminating_type) $val(cluster_head_disseminating_interval)]
$node_($contador_nodos) attach $udp_($contador_nodos) $val(port)
$node_($contador_nodos) add-app $app_($contador_nodos)
set processing_($contador_nodos) [new Processing/AggregateProcessing]
$app_($contador_nodos) node $node_($contador_nodos)
$app_($contador_nodos) attach-agent $udp_($contador_nodos)
$app_($contador_nodos) attach-processing $processing_($contador_nodos)
$processing_($contador_nodos) node $node_($contador_nodos)
$ns_ at [expr $val(start) + 1 + $interval] "$app_($contador_nodos) start"
$ns_ at $val(stop) "$app_($contador_nodos) stop"
incr contador_nodos
}
set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $n0 $tcp
$ns attach-agent $n1 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
#$ftp set rate_ 1.0Mb
#$ftp set random_ null
#$ftp set interval_ 0.4
$ns at 64.2 "$ftp start"
$ns at 68.0 "$ftp stop"
set tcp1 [new Agent/TCP]
$tcp1 set class_ 2
set sink1 [new Agent/TCPSink]
$ns attach-agent $n2 $tcp1
$ns attach-agent $n1 $sink1
$ns connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
#$ftp1 set rate_ 1.0Mb
#$ftp1 set random_ null
#$ftp1 set interval_ 0.4
$ns at 68.2 "$ftp1 start"
$ns at 72.0 "$ftp1 stop"
set tcp2 [new Agent/TCP]
$tcp2 set class_ 2
set sink2 [new Agent/TCPSink]
$ns attach-agent $n3 $tcp2
$ns attach-agent $n1 $sink2
$ns connect $tcp2 $sink2
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2
#$ftp2 set rate_ 1.0Mb
#$ftp2 set random_ null
#$ftp2 set interval_ 0.4
$ns at 72.2 "$ftp2 start"
$ns at 76.0 "$ftp2 stop"
set tcp3 [new Agent/TCP]
$tcp3 set class_ 2
set sink3 [new Agent/TCPSink]
$ns attach-agent $n4 $tcp3
$ns attach-agent $n1 $sink3
$ns connect $tcp3 $sink3
set ftp3 [new Application/FTP]
$ftp3 attach-agent $tcp3
#$ftp3 set rate_ 1.0Mb
#$ftp3 set random_ null
#$ftp3 set interval_ 0.4
$ns at 76.2 "$ftp3 start"
$ns at 80.0 "$ftp3 stop"
set tcp4 [new Agent/TCP]
$tcp4 set class_ 2
set sink4 [new Agent/TCPSink]
$ns attach-agent $n1 $tcp4
$ns attach-agent $n15 $sink4
$ns connect $tcp4 $sink4
set ftp4 [new Application/FTP]
$ftp4 attach-agent $tcp4
#$ftp4 set rate_ 1.0Mb
#$ftp4 set random_ null
#$ftp4 set interval_ 0.4
$ns at 80.2 "$ftp4 start"
$ns at 84.0 "$ftp4 stop"
set tcp5 [new Agent/TCP]
$tcp5 set class_ 2
set sink5 [new Agent/TCPSink]
$ns attach-agent $n5 $tcp5
$ns attach-agent $n6 $sink5
$ns connect $tcp5 $sink5
set ftp5 [new Application/FTP]
$ftp5 attach-agent $tcp5
#$ftp5 set rate_ 1.0Mb
#$ftp5 set random_ null
#$ftp5 set interval_ 0.4
$ns at 84.2 "$ftp5 start"
$ns at 88.0 "$ftp5 stop"
set tcp6 [new Agent/TCP]
$tcp6 set class_ 2
set sink6 [new Agent/TCPSink]
$ns attach-agent $n7 $tcp6
$ns attach-agent $n6 $sink6
$ns connect $tcp6 $sink6
set ftp6 [new Application/FTP]
$ftp6 attach-agent $tcp6
#$ftp6 set rate_ 1.0Mb
#$ftp6 set random_ null
#$ftp6 set interval_ 0.4
$ns at 88.2 "$ftp6 start"
$ns at 92.0 "$ftp6 stop"
set tcp7 [new Agent/TCP]
$tcp7 set class_ 2
set sink7 [new Agent/TCPSink]
$ns attach-agent $n8 $tcp7
$ns attach-agent $n6 $sink7
$ns connect $tcp7 $sink7
set ftp7 [new Application/FTP]
$ftp7 attach-agent $tcp7
#$ftp7 set rate_ 1.0Mb
#$ftp7 set random_ null
#$ftp7 set interval_ 0.4
$ns at 92.2 "$ftp7 start"
$ns at 96.0 "$ftp7 stop"
set tcp8 [new Agent/TCP]
$tcp8 set class_ 2
set sink8 [new Agent/TCPSink]
$ns attach-agent $n9 $tcp8
$ns attach-agent $n6 $sink8
$ns connect $tcp8 $sink8
set ftp8 [new Application/FTP]
$ftp8 attach-agent $tcp8
#$ftp8 set rate_ 1.0Mb
#$ftp8 set random_ null
#$ftp8 set interval_ 0.4
$ns at 96.2 "$ftp8 start"
$ns at 100.0 "$ftp8 stop"
set tcp9 [new Agent/TCP]
$tcp9 set class_ 2
set sink9 [new Agent/TCPSink]
$ns attach-agent $n6 $tcp9
$ns attach-agent $n15 $sink9
$ns connect $tcp9 $sink9
set ftp9 [new Application/FTP]
$ftp9 attach-agent $tcp9
#$ftp9 set rate_ 1.0Mb
#$ftp9 set random_ null
#$ftp9 set interval_ 0.4
$ns at 100.2 "$ftp9 start"
$ns at 104.0 "$ftp9 stop"
set tcp10 [new Agent/TCP]
$tcp10 set class_ 2
set sink10 [new Agent/TCPSink]
$ns attach-agent $n11 $tcp10
$ns attach-agent $n10 $sink10
$ns connect $tcp10 $sink10
set ftp10 [new Application/FTP]
$ftp10 attach-agent $tcp10
#$ftp10 set rate_ 1.0Mb
#$ftp10 set random_ null
#$ftp10 set interval_ 0.4
$ns at 104.2 "$ftp10 start"
$ns at 108.0 "$ftp10 stop"
set tcp11 [new Agent/TCP]
$tcp11 set class_ 2
set sink11 [new Agent/TCPSink]
$ns attach-agent $n12 $tcp11
$ns attach-agent $n10 $sink11
$ns connect $tcp11 $sink11
set ftp11 [new Application/FTP]
$ftp11 attach-agent $tcp11
#$ftp11 set rate_ 1.0Mb
#$ftp11 set random_ null
#$ftp11 set interval_ 0.4
$ns at 108.2 "$ftp11 start"
$ns at 112.0 "$ftp11 stop"
set tcp12 [new Agent/TCP]
$tcp12 set class_ 2
set sink12 [new Agent/TCPSink]
$ns attach-agent $n13 $tcp12
$ns attach-agent $n10 $sink12
$ns connect $tcp12 $sink12
set ftp12 [new Application/FTP]
$ftp12 attach-agent $tcp12
#$ftp12 set rate_ 1.0Mb
#$ftp12 set random_ null
#$ftp12 set interval_ 0.4
$ns at 112.2 "$ftp12 start"
$ns at 116.0 "$ftp12 stop"
set tcp13 [new Agent/TCP]
$tcp13 set class_ 2
set sink13 [new Agent/TCPSink]
$ns attach-agent $n14 $tcp13
$ns attach-agent $n10 $sink13
$ns connect $tcp13 $sink13
set ftp13 [new Application/FTP]
$ftp13 attach-agent $tcp13
#$ftp13 set rate_ 1.0Mb
#$ftp13 set random_ null
#$ftp13 set interval_ 0.4
$ns at 116.2 "$ftp13 start"
$ns at 120.0 "$ftp13 stop"
set tcp14 [new Agent/TCP]
$tcp14 set class_ 2
set sink14 [new Agent/TCPSink]
$ns attach-agent $n10 $tcp14
$ns attach-agent $n15 $sink14
$ns connect $tcp14 $sink14
set ftp14 [new Application/FTP]
$ftp14 attach-agent $tcp14
#$ftp14 set rate_ 1.0Mb
#$ftp14 set random_ null
#$ftp14 set interval_ 0.4
$ns at 120.2 "$ftp14 start"
$ns at 124.0 "$ftp14 stop"
set tcp15 [new Agent/TCP]
$tcp15 set class_ 2
set sink15 [new Agent/TCPSink]
$ns attach-agent $n7 $tcp15
$ns attach-agent $n6 $sink15
$ns connect $tcp15 $sink15
set ftp15 [new Application/FTP]
$ftp15 attach-agent $tcp15
#$ftp15 set rate_ 1.0Mb
#$ftp15 set random_ null
#$ftp15 set interval_ 0.4
$ns at 39.2 "$ftp15 start"
$ns at 41.0 "$ftp15 stop"
set tcp16 [new Agent/TCP]
$tcp16 set class_ 2
set sink16 [new Agent/TCPSink]
$ns attach-agent $n8 $tcp16
$ns attach-agent $n6 $sink16
$ns connect $tcp16 $sink16
set ftp16 [new Application/FTP]
$ftp16 attach-agent $tcp16
#$ftp16 set rate_ 1.0Mb
#$ftp16 set random_ null
#$ftp16 set interval_ 0.4
$ns at 41.2 "$ftp16 start"
$ns at 43.0 "$ftp16 stop"
set tcp17 [new Agent/TCP]
$tcp17 set class_ 2
set sink17 [new Agent/TCPSink]
$ns attach-agent $n9 $tcp17
$ns attach-agent $n6 $sink17
$ns connect $tcp17 $sink17
set ftp17 [new Application/FTP]
$ftp17 attach-agent $tcp17
#$ftp17 set rate_ 1.0Mb
#$ftp17 set random_ null
#$ftp17 set interval_ 0.4
$ns at 43.2 "$ftp17 start"
$ns at 45.0 "$ftp17 stop"
set tcp18 [new Agent/TCP]
$tcp18 set class_ 2
set sink18 [new Agent/TCPSink]
$ns attach-agent $n5 $tcp18
$ns attach-agent $n8 $sink18
$ns connect $tcp18 $sink18
set ftp18 [new Application/FTP]
$ftp18 attach-agent $tcp18
#$ftp18 set rate_ 1.0Mb
#$ftp18 set random_ null
#$ftp18 set interval_ 0.4
$ns at 45.2 "$ftp18 start"
$ns at 47.0 "$ftp18 stop"
set tcp19 [new Agent/TCP]
$tcp19 set class_ 2
set sink19 [new Agent/TCPSink]
$ns attach-agent $n11 $tcp19
$ns attach-agent $n10 $sink19
$ns connect $tcp19 $sink19
set ftp19 [new Application/FTP]
$ftp19 attach-agent $tcp19
#$ftp19 set rate_ 1.0Mb
#$ftp19 set random_ null
#$ftp19 set interval_ 0.4
$ns at 47.2 "$ftp19 start"
$ns at 49.0 "$ftp19 stop"
set tcp20 [new Agent/TCP]
$tcp20 set class_ 2
set sink20 [new Agent/TCPSink]
$ns attach-agent $n12 $tcp20
$ns attach-agent $n10 $sink20
$ns connect $tcp20 $sink20
set ftp20 [new Application/FTP]
$ftp20 attach-agent $tcp20
#$ftp20 set rate_ 1.0Mb
#$ftp20 set random_ null
#$ftp20 set interval_ 0.4
$ns at 50.2 "$ftp20 start"
$ns at 52.0 "$ftp20 stop"
set tcp21 [new Agent/TCP]
$tcp21 set class_ 2
set sink21 [new Agent/TCPSink]
$ns attach-agent $n13 $tcp21
$ns attach-agent $n10 $sink21
$ns connect $tcp21 $sink21
set ftp21 [new Application/FTP]
$ftp21 attach-agent $tcp21
#$ftp21 set rate_ 1.0Mb
#$ftp21 set random_ null
#$ftp21 set interval_ 0.4
$ns at 52.2 "$ftp21 start"
$ns at 54.0 "$ftp21 stop"
set tcp22 [new Agent/TCP]
$tcp22 set class_ 2
set sink22 [new Agent/TCPSink]
$ns attach-agent $n14 $tcp22
$ns attach-agent $n11 $sink22
$ns connect $tcp22 $sink22
set ftp22 [new Application/FTP]
$ftp22 attach-agent $tcp22
#$ftp22 set rate_ 1.0Mb
#$ftp22 set random_ null
#$ftp22 set interval_ 0.4
$ns at 54.2 "$ftp22 start"
$ns at 56.0 "$ftp22 stop"
set tcp23 [new Agent/TCP]
$tcp23 set class_ 2
set sink23 [new Agent/TCPSink]
$ns attach-agent $n4 $tcp23
$ns attach-agent $n1 $sink23
$ns connect $tcp23 $sink23
set ftp23 [new Application/FTP]
$ftp23 attach-agent $tcp23
#$ftp23 set rate_ 1.0Mb
#$ftp23 set random_ null
#$ftp23 set interval_ 0.4
$ns at 56.2 "$ftp23 start"
$ns at 58.0 "$ftp23 stop"
set tcp24 [new Agent/TCP]
$tcp24 set class_ 2
set sink24 [new Agent/TCPSink]
$ns attach-agent $n0 $tcp24
$ns attach-agent $n1 $sink24
$ns connect $tcp24 $sink24
set ftp24 [new Application/FTP]
$ftp24 attach-agent $tcp24
#$ftp24 set rate_ 1.0Mb
#$ftp24 set random_ null
#$ftp24 set interval_ 0.4
$ns at 59.2 "$ftp24 start"
$ns at 60.0 "$ftp24 stop"
set tcp25 [new Agent/TCP]
$tcp25 set class_ 2
set sink25 [new Agent/TCPSink]
$ns attach-agent $n2 $tcp25
$ns attach-agent $n1 $sink25
$ns connect $tcp25 $sink25
set ftp25 [new Application/FTP]
$ftp25 attach-agent $tcp25
#$ftp24 set rate_ 1.0Mb
#$ftp24 set random_ null
#$ftp24 set interval_ 0.4
$ns at 60.2 "$ftp25 start"
$ns at 62.0 "$ftp25 stop"
set tcp26 [new Agent/TCP]
$tcp26 set class_ 2
set sink26 [new Agent/TCPSink]
$ns attach-agent $n1 $tcp26
$ns attach-agent $n0 $sink26
$ns connect $tcp26 $sink26
set ftp26 [new Application/FTP]
$ftp26 attach-agent $tcp26
#$ftp24 set rate_ 1.0Mb
#$ftp24 set random_ null
#$ftp24 set interval_ 0.4
$ns at 62.2 "$ftp26 start"
$ns at 64.0 "$ftp26 stop"
#Define a 'finish' procedure
proc finish {
} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam out1.nam &
exit 0
}
for {
set i 0
} {
$i < $val(nn)
} {
incr i
} {
$ns at $val(stop) "\$n$i reset"
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run