LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Problem with Simple NS2 Simulation (https://www.linuxquestions.org/questions/linux-networking-3/problem-with-simple-ns2-simulation-4175555471/)

Niggly91 10-06-2015 05:03 PM

Problem with Simple NS2 Simulation
 
Hello,

I have to do an assignment of my university. I have to simulate a very simple network consisting of only 2 nodes.

When I run my tcl-file in the terminal only errors follow and I don't know why.

Here is my simple code:

set ns [new Simulator]

set tracefile [open out.tr w]
$ns trace-all $tracefile

set cwndfile [open outcwnd.tr w]

set node1 [$ns node]
set node2 [$ns node]

$ns duplex-link $node1 $node2 1Mb 4ms DropTail

set queue 18
$ns queue-limit $node1 $node2 $queue

set tcp1 [new Agent/TCP]
$ns attach-agent $node1 $tcp1

set ftp [new Application/FTP]
$ftp attach-agent $tcp1

set tcpsink [new Agent/TCPSink]
$ns attach-agent $node2 $tcpsink

$ns connect $tcp1 $tcpsink

proc record {} {
global ns tcp1 cwndfile
set now [$ns now]
puts $cwndfile $now [$tcp1 set cwnd_]
$ns at [expr $now+0.01] record
}

proc finish {} {
global ns tracefile cwndfile

$ns flush-trace
close $tracefile
close $cwndfile

puts Simulation Complete!
$ns halt
}

$ns at 0.0 record
$ns at 0.0 $ftp start
$ns at 10 finish
puts Simulation Running
$ns run





When I run this, than I got this message:

(_o5 cmd line 1)
invoked from within
"_o5 cmd at 0.0 _o38 start"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o5" line 2)
(SplitObject unknown line 2)
invoked from within
"_o5 at 0.0 _o38 start"
("eval" body line 1)
invoked from within
"eval $scheduler_ at $args"
(procedure "_o3" line 3)
(Simulator at line 3)
invoked from within
"$ns at 0.0 $ftp start"
(file "tcpTahoe.tcl" line 46)


I would be so glad, if you could help me. By the way, the script is from my teacher.

Thanks a lot!

knudfl 10-07-2015 10:44 AM

Welcome to LQ.

You have missing quotes in line 46, $ns at 0.0 $ftp start
and line 48, puts Simulation Running
... Must be
$ns at 0.0 "$ftp start"
$ns at 10 finish
puts "Simulation Running"

And there might also be quotes to add in line 45, $ns at 0.0 record
... To
$ns at 0.0 "record"

Solutions can be found by comparing with the 2,000 other simulation examples.
All examples : all_tcl-examples-2.tar.gz (41.8MB)
https://drive.google.com/file/d/0B7S...ew?usp=sharing

** There are still some issues in your file : With the "record" entries.
Example search command, All-examples/ : $ grep -n record *
>>> Example file with "record" : wireless-tcp.tcl


-


All times are GMT -5. The time now is 10:58 PM.