[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] Tutorial example modification



Hi, all.

I tried to simulate a Marc Greis' example (Network Dynamics) in a slightly
diferent way. I changed the CBR source with a FTP source. The problem is no
data is exchanged, only routing packets are sent all the time. Oddly enough,
the simulation never stops. It just goes on even after the defined end time.
The modified tcl script is also included. Thanks for any help!!

--Lipas


##########################################

#Create a simulator object
set ns [new Simulator]
#Tell the simulator to use dynamic routing
$ns rtproto DV
#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf

#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Execute nam on the trace file
exec nam out.nam &
exit 0
}
#Create seven nodes
for {set i 0} {$i < 7} {incr i} {
set n($i) [$ns node]
}

#Create links between the nodes
for {set i 0} {$i < 7} {incr i} {
$ns duplex-link $n($i) $n([expr ($i+1)%7]) 1Mb 10ms DropTail
}

#Create a CBR agent and attach it to node n(0)
set tcp [new Agent/TCP]
$ns attach-agent $n(0) $tcp
$tcp set window_ 5
#Create a TCPSink agent and attach it to node n(3)
set sink [new Agent/TCPSink]
$ns attach-agent $n(3) $sink
#Connect the traffic source with the traffic sink
$ns connect $tcp $sink
#Create and connect FTP Agent
set ftp [new Application/FTP]
$ftp attach-agent $tcp
#Run the simulation
$ns run
#Schedule events for the FTP agent and the network dynamics
$ns at 0.5 "$ftp start"
$ns rtmodel-at 1.0 down $n(1) $n(2)
$ns rtmodel-at 2.0 up $n(1) $n(2)
$ns at 4.5 "$ftp stop"
#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"
#Run the simulation
$ns run

##########################################