[ns] Help: error when using node generated by create_topology in NS format

Filippos Kolovos f.kolovos at gmail.com
Sun Jun 10 00:05:16 PDT 2007


-
Good morning

As it looks like from your code,
you are declaring the array n($i) only inside
your proc. However, because it is a local variable
it gets erased after the proc's execution. Therefore,
in your main script, when you try to access it with
$ns monitor-queue $n(3) $n(6) "" the interpreter
complains with an error.

What I would do in order to quickly solve this situation, would
be to declare the "n array" outside the proc and then "import" it
inside the procedure with global. This way, all changes made to
the array inside the proc, will stay and after the end of the procedure,
without disrupting
the execution flow.

That is why the interpreter cannot find the array in your main script.
According
to the script: it was never created (!?).

Hope that I have helped.

Regards,

-Fk


On 6/9/07, ns-users-request at isi.edu <ns-users-request at isi.edu> wrote:
>
>
> ---------- Forwarded message ----------
> From: "khodor abboud" <kabboud at hotmail.fr>
> To: ns-users at ISI.EDU
> Date: Fri, 08 Jun 2007 17:05:10 +0200
> Subject: [ns] Help: error when using node generated by create_topology in
> NS format
>
>
> Hello evry Body,
>
> I am using the NS format generated by brite. when i try to use the node
> generated by the procedure create_topology (for monotoring per example), i
> have this error :
>
> // can't read "n(3)": no such variable
>     while executing
> "$ns monitor-queue create_topology.$n(3) $n(6) """
>     invoked from within
> "set qmon36  [$ns monitor-queue create_topology.$n(3) $n(6) ""]"
>     (file "topology.tcl" line 189)//
>
>
> the code is :
>
> // proc create_topology {} {
>         global ns
>
>         #nodes:
>         set num_node 10
>         for {set i 0} {$i < $num_node} {incr i} {
>            set n($i) [$ns mpls-node]
>         }
>
>         set node0 [$ns node]
>         set node1 [$ns node]
>
>          #links:
>         set qtype CBQ
>
>         $ns duplex-link $node0 $n(3) 10.0Mb 3ms DropTail
>         $ns duplex-link $n(0) $n(6) 10.0Mb 2.312773335190996ms $qtype
>         $ns duplex-link $n(1) $n(0) 10.0Mb 2.9694568204843463ms $qtype
>         $ns duplex-link $n(2) $n(1) 10.0Mb 1.8352240604833803ms $qtype
>         $ns duplex-link $n(3) $n(2) 10.0Mb 1.5822334297190923ms $qtype
>         $ns duplex-link $n(4) $n(0) 10.0Mb 1.4360234541568795ms $qtype
>         $ns duplex-link $n(5) $n(3) 10.0Mb 2.559521441995941ms $qtype
>         $ns duplex-link $n(6) $n(3) 10.0Mb 0.7953178172063804ms $qtype
>         $ns duplex-link $n(7) $n(4) 10.0Mb 2.7512102890042183ms $qtype
>         $ns duplex-link $n(8) $n(7) 10.0Mb 1.6254465755920127ms $qtype
>         $ns duplex-link $n(9) $n(3) 10.0Mb 0.5596028576377098ms $qtype
>         $ns duplex-link $n(7) $node1 10.0Mb 3ms DropTail
> }
>
> #end function create_topology
>
>
> set qs 100
>
>
>
> ## Queue Monitor for some links
>
> set qmon36  [$ns monitor-queue $n(3) $n(6) ""]
>
> set qmon63  [$ns monitor-queue $n(6) $n(3) ""]
>
> set sample36 [new Samples]
>
> $qmon04 set-delay-samples $sample36
>
> set sample63 [new Samples]
>
> $qmon40 set-delay-samples $sample63
>
> $ns queue-limit $n(3) $n(6) $qs //
>
> Best regards,
>
> _________________________________________________________________
> Ten :  Messenger en illimité sur votre mobile !
> http://mobile.live.fr/messenger/ten/
>
>
>
>


-- 
Filippos N Kolovos

Software Systems Analyst & Engineer
M.Sc. (Eng.) in Data Communications

Automation & Networking Department
University of Macedonia Library
Egnatia 156, P.O.Box 1591
540 06 Thessaloniki, Greece

E-Mail: f.kolovos at ieee.org,
           filippos at uom.gr
----------------------------------------------


More information about the Ns-users mailing list