Many thanks for the previous reply and solution. i have changed it to ns [new
Simulator] "S" instead of "s"
again, i got an error when i run it after did some change.i'm very new and
need any help in this forum discussion..
this is the whole program:
1 # myfirst_ns.tcl
2 # create a simulator
3 set ns [new Simulator]
4 create a trace file
5 set mytrace [open out.tr w]
6 $ns trace-all $mytrace
7 create a NAM trace file
8 set myNAM [open out.nam w]
9 $ns namtrace-all $myNAM
10 define a procedure finish
11 proc finish {} {
12 global ns mytrace myNAM
13 $ns flush-trace
14 close $mytrace
15 close $myNAM
16 exec nam out.nam &
17 exit 0
18 }
19 create nodes
20 set n0 [$ns node]
21 set n1 [$ns node]
22 set n2 [$ns node]
23 set n3 [$ns node]
24 set n4 [$ns node]
25 connect nodes with links
26 $ns duplex-link $n0 $n2 100Mb 5ms DropTail
27 $ns duplex-link $n1 $n2 100Mb 5ms DropTail
28 $ns duplex-link $n2 $n4 54Mb 10ms DropTail
29 $ns duplex-link $n2 $n3 54Mb 10ms DropTail
30 $ns duplex-link $n3 $n4 10Mb 15ms DropTail
31 $ns queue-limit $n2 n3 40
32 create a UDP agent
33 set udp [new Agent/UDP]
34 $ns attach-agent $n0 $udp
35 set null [new Agent/Null]
36 $ns attach-agent $n3 $null
37 $ns connect $udp $null
38 $udp set fid_1
39 create a CBR traffic source
40 set cbr [new Application/Traffic/CBR]
41 $cbr attach-agent $udp
42 $cbr set packetSize_1000
43 $cbr set rate_2Mb
44 create a TCP agent
45 set tcp [new Agent/TCP]
46 $ns attach-agent $n1 $tcp
47 set sink [new Agent/TCPSink]
48 $ns attach-agent $n4 $sink
49 $ns connect $tcp $sink
50 $tcp set fid_2
51 create an FTP session
52 set ftp [new Application/FTP]
53 $ftp attach-agent $tcp
54 schedule events
55 ns at 0.05 "$ftp start"
56 ns at 0.1 "$cbr start"
57 ns at 60.0 "$ftp stop"
58 ns at 60.5 "$cbr stop"
59 ns at 61 "finish"
60 }
61 # Start the simulation
62 $ns run
ON THE CYGWIN I RUN THE FILE
$ ns myfirst_ns.tcl
can't read "fid_1": no such variable
while executing
"subst $[subst $var]"
<procedure "_o125" line 5>
<object next line 5>
invoked from within
"_o125 next fid_1"
<"eval" body line 1>
invoked from within
"eval $self next $args"
<procedure "_o125" line 18>
<agent set line 18>
invoked from within
$udp set fid_1 <file "myfirst_ns.tcl" line 44>