Hi all,

I'm running ns-2.27 under windows using cygwin but I have a problem when I try 
and run a script. The scripts code is as follows:

#Create a simulator object
set ns [new Simulator]

#Open trace files
set f [open droptail-queue-out.tr w]
$ns trace-all $f

#Open the nam trace file
set nf [open droptail-queue-out.nam w]
$ns namtrace-all $nf

#s1, s2 and s3 act as sources.
set s1 [$ns node]
set s2 [$ns node]
set s3 [$ns node]

#G acts as a gateway.
set G [$ns node]

#r acts as a receiver.
set r [$ns node]

#Define different colors for dats flows
$ns color 1 red ;# the color of packets from s1
$ns color 2 SeaGreen ;# the color of packets from s2
$ns color 3 blue ;# the color of packets from s3

#Create links between the nodes
$ns duplex-link $s1 $G 6Mb 1ms DropTail
$ns duplex-link $s2 $G 6Mb 1ms DropTail
$ns duplex-link $s3 $G 6Mb 1ms DropTail
$ns duplex-link $G $r 3Mb 1ms DropTail

#Define the queue size for the link between node G and r
$ns queue-limit $G $r 5

#Define the layout of the topology
$ns duplex-link-op $s1 $G orient right-up
$ns duplex-link-op $s2 $G orient right
$ns duplex-link-op $s3 $G orient right-down
$ns duplex-link-op $G $r orient right

#Monitor the queues for links
$ns duplex-link-op $s1 $G queuePos 0.5
$ns duplex-link-op $s2 $G queuePos 0.5
$ns duplex-link-op $s3 $G queuePos 0.5
$ns duplex-link-op $G $r queuePos 0.5

#Create a TCP agent and attach it to node s1
set tcp1 [new Agent/TCP/Reno]
$ns attach-agent $s1 $tcp1
$tcp1 set window_ 8
$tcp1 set fid_ 1

#Create a TCP agent and attach it to node s2
set tcp2 [new Agent/TCP/Reno]
$ns attach-agent $s2 $tcp2
$tcp2 set window_ 8
$tcp2 set fid_ 2

#Create a TCP agent and attach it to node s3
set tcp3 [new Agent/TCP/Reno]
$ns attach-agent $s3 $tcp3
$tcp3 set window_ 4
$tcp3 set fid_ 3

#Create TCP sink agents and attach them to node r
set sink1 [new Agent/TCPSink]
set sink2 [new Agent/TCPSink]
set sink3 [new Agent/TCPSink]
$ns attach-agent $r $sink1
$ns attach-agent $r $sink2
$ns attach-agent $r $sink3

#Connect the traffic sources with the traffic sinks
$ns connect $tcp1 $sink1
$ns connect $tcp2 $sink2
$ns connect $tcp3 $sink3

#Create FTP applications and attach them to agents
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1

set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2

set ftp3 [new Application/FTP]
$ftp3 attach-agent $tcp3

#Define a 'finish' procedure
proc finish {} {
    global ns nf
    $ns flush-trace
    puts "running nam..."
    #close trace file
    close $nf
    #execute nam on the trace file 
    exec nam –a droptail-queue-out.nam &
    exit 0
}

$ns at 0.0 "$s1 label Sender1"
$ns at 0.0 "$s2 label Sender2"
$ns at 0.0 "$s3 label Sender3"
$ns at 0.0 "$G label Gateway"
$ns at 0.0 "$r label Receiver"
$ns at 0.1 "$ftp1 start"
$ns at 0.1 "$ftp2 start"
$ns at 0.1 "$ftp3 start"
$ns at 5.0 "$ftp1 stop"
$ns at 5.0 "$ftp2 stop"
$ns at 5.0 "$ftp3 stop"
$ns at 5.25 "finish"

$ns run

it runs the finish procedure up to "running nam..." but then produces the error 
message 

"cannot connect to existing nam instance. Startin a new one....

nam: unable to open the file "a.nam""

I think there may be a problem with this line "exec nam –a 
droptail-queue-out.nam &" but the nam file does exist and can run in other 
scripts.

Any help would be much appreciated.








The all-new Yahoo! Mail goes wherever you go - free your email address from 
your Internet provider.



All New Yahoo! Mail – Tired of unwanted email come-ons? Let our SpamGuard 
protect you.


                
___________________________________________________________ 
Copy addresses and emails from any email account to Yahoo! Mail - quick, easy 
and free. http://uk.docs.yahoo.com/trueswitch2.html

Reply via email to