Hi,
I am a new ns user (version 2.29 under Windows - cygwin). I have to
simulate a behaviour of some network with 22 nodes, so I would like to
connect them together: I mean that the packets will be send from node 0
to all nodes in the network, from node 1 to all nodes in the
network....etc. On the bottom of this mail you can see my script
simulating this network. It's working, but the results are wrong. The
simulation last from 0.1 to 5.0 seconds, but after a few decimals of
second the packets are only sending from node 20 to node 21 and
inversly. Could somebody have a look at my script and say what I'm doing
wrong?
Bartek Nawrocki
set ns [new Simulator]
$ns color 1 Blue
$ns color 2 Red
set nf [open out.nam w]
#set winfile [open WinFile w]
#set winfile1 [open WinFile1 w]
$ns namtrace-all $nf
set tf [open out.tr w]
$ns trace-all $tf
##########################PROCEDURES################################
proc make_topology {} {
global ns n
#stworzenie wezlow
for {set i 0} {$i < 22} {incr i} {
set n($i) [$ns node]
}
#polaczenia miedzy wezlami
$ns duplex-link $n(0) $n(1) 20Gb 10ms SFQ
$ns duplex-link $n(0) $n(7) 20Gb 10ms SFQ
$ns duplex-link $n(1) $n(2) 20Gb 10ms SFQ
$ns duplex-link $n(2) $n(3) 1Gb 10ms SFQ
$ns duplex-link $n(2) $n(5) 20Gb 10ms SFQ
$ns duplex-link $n(3) $n(4) 1Gb 10ms SFQ
$ns duplex-link $n(4) $n(8) 20Gb 10ms SFQ
$ns duplex-link $n(5) $n(6) 20Gb 10ms SFQ
$ns duplex-link $n(6) $n(7) 20Gb 10ms SFQ
$ns duplex-link $n(7) $n(8) 20Gb 10ms SFQ
$ns duplex-link $n(7) $n(9) 20Gb 10ms SFQ
$ns duplex-link $n(7) $n(10) 20Gb 10ms SFQ
$ns duplex-link $n(8) $n(10) 20Gb 10ms SFQ
$ns duplex-link $n(8) $n(11) 20Gb 10ms SFQ
$ns duplex-link $n(9) $n(21) 20Gb 10ms SFQ
$ns duplex-link $n(10) $n(19) 20Gb 10ms SFQ
$ns duplex-link $n(11) $n(12) 20Gb 10ms SFQ
$ns duplex-link $n(11) $n(14) 20Gb 10ms SFQ
$ns duplex-link $n(12) $n(13) 20Gb 10ms SFQ
$ns duplex-link $n(13) $n(15) 1Gb 10ms SFQ
$ns duplex-link $n(14) $n(16) 20Gb 10ms SFQ
$ns duplex-link $n(15) $n(16) 1Gb 10ms SFQ
$ns duplex-link $n(16) $n(17) 20Gb 10ms SFQ
$ns duplex-link $n(17) $n(18) 20Gb 10ms SFQ
$ns duplex-link $n(18) $n(19) 20Gb 10ms SFQ
$ns duplex-link $n(18) $n(20) 20Gb 10ms SFQ
$ns duplex-link $n(20) $n(21) 20Gb 10ms SFQ
#polozenie wezlow w nam
$ns duplex-link-op $n(0) $n(1) orient right-up
$ns duplex-link-op $n(0) $n(7) orient right-down
$ns duplex-link-op $n(1) $n(2) orient right
$ns duplex-link-op $n(2) $n(3) orient right-down
$ns duplex-link-op $n(2) $n(5) orient down
$ns duplex-link-op $n(3) $n(4) orient right-down
$ns duplex-link-op $n(4) $n(8) orient left-down
$ns duplex-link-op $n(5) $n(6) orient right-down
$ns duplex-link-op $n(6) $n(7) orient left-down
$ns duplex-link-op $n(7) $n(8) orient right
$ns duplex-link-op $n(7) $n(9) orient left-down
$ns duplex-link-op $n(7) $n(10) orient right-down
$ns duplex-link-op $n(8) $n(10) orient left-down
$ns duplex-link-op $n(8) $n(11) orient down
$ns duplex-link-op $n(9) $n(21) orient down
$ns duplex-link-op $n(10) $n(19) orient down
$ns duplex-link-op $n(11) $n(12) orient right
$ns duplex-link-op $n(11) $n(14) orient down
$ns duplex-link-op $n(12) $n(13) orient right-down
$ns duplex-link-op $n(13) $n(15) orient left-down
$ns duplex-link-op $n(14) $n(16) orient down
$ns duplex-link-op $n(15) $n(16) orient left-down
$ns duplex-link-op $n(16) $n(17) orient right
$ns duplex-link-op $n(17) $n(18) orient up
$ns duplex-link-op $n(18) $n(19) orient up
$ns duplex-link-op $n(18) $n(20) orient right
$ns duplex-link-op $n(20) $n(21) orient up
}
#-----------------------------------------------------------------
proc make_sinks {} {
global ns sink n
for {set i 0} {$i < 22} {incr i} {
set sink($i) [new Agent/TCPSink]
$ns attach-agent $n($i) $sink($i)
}
}
#-----------------------------------------------------------------
proc attach_FTP_for_TCP {} {
global ftp tcp
for {set i 0} {$i < 22} {incr i} {
set ftp($i) [new Application/FTP]
$ftp($i) attach-agent $tcp($i)
$ftp($i) set type_ FTP
}
}
#-----------------------------------------------------------------
proc make_TCPSources {} {
global ns sink n tcp
for {set i 0} {$i < 22} {incr i} {
set tcp($i) [new Agent/TCP]
$tcp($i) set packetSize_ 500
$tcp($i) set fid_ 1
$ns attach-agent $n($i) $tcp($i)
}
for {set i 0} {$i < 22} {incr i} {
for {set j 0} {$j < 22} {incr j} {
if {$i != $j} {
$ns connect $tcp($i) $sink($j)
}
}
}
attach_FTP_for_TCP
}
#-----------------------------------------------------------------
proc run_sim {} {
global ns ftp start_time stop_time
for {set i 0} {$i < 22} {incr i} {
$ns at $start_time "$ftp($i) start"
$ns at $stop_time "$ftp($i) stop"
}
}
#-----------------------------------------------------------------
proc finish {} {
global ns nf tf
$ns flush-trace
close $nf
close $tf
exec nam out.nam &
exit 0
}
#-----------------------------------------------------------------
#########################MAIN PROGRAM############################
make_topology
make_sinks
make_TCPSources
set start_time 0.1
set stop_time 5.0
run_sim
$ns at 5.25 "finish"
$ns run
----------------------------------------------------------------------
Sprawdz gdzie lezy snieg, czy dzialaja armatki
i jak przygotowane sa stoki >>> http://link.interia.pl/f1cfc