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

[ns] Problems creating tcl object from within c++ class



Hi Folks,
 

        I've created a new ping agent (Agent/TEPing) and I needed to access it from inside a c++ class (a new classifier that I created).

        I was trying to put this agent inside a node by creating a new ping_variable and then attaching it to the node. I really don't know whether this is the best way to do things, because I am getting all sorts of error messages.

        So my question is: is there a way to access a tcl object from within a c++ class?
        I a using ns v2.1.b7.
 

        Thanks!
        Tulius Lima

* tcl code ---------------------------
RtModule/MPLS/TE/MATE instproc register { node } {
    $self instvar classifier_
    $self attach-node $node
    $node route-notify $self
    $node port-notify $self
    set classifier_ [new Classifier/Addr/MPLS/TE/MATE]
    $classifier_ set-node $node $self
    $node install-entry $self $classifier_ 0

    $self instvar ping_
    set ping_ [new Agent/TEPing]

    $node attach $ping_
}

# Measuremnt Functions (ping related)

RtModule/MPLS/TE/MATE instproc send-probe-pkts-to {fec lspid fecV lspidV} {
    $self instvar ping_
    $ping_ sendto $fec $lspid $fecV $lspidV
}

RtModule/MPLS/TE/MATE instproc get-ping-agent {} {
    $self instvar ping_
    return $ping_
}

RtModule/MPLS/TE/MATE instproc setup-ping { node } {
    # creating simulator instance
    set ns [Simulator instance]
    $self instvar ping_

    # attaching ping agent to this node
    #$ns attach-agent $node $ping_

    #$self attach $ping_
    #puts "  %self  attach  %ping_"

}

RtModule/MPLS/TE/MATE instproc te-attach-egress {egress} {
    set ns [Simulator instance]
    $self instvar ping_

    set pong_ [new Agent/TEPing]
    $pong_ [$egress get-ping-agent]

    $ns connect $ping_ $pong_
}
 

--------------------------- tcl code *

--------------------------------------

* error message ----------------------
ns: _o23 send-probe-pkts-to 14 3000 0 4000:
    (_o23 cmd line 1)
    invoked from within
"_o23 cmd send-probe-pkts-to 14 3000 0 4000"
    invoked from within
"catch "$self cmd $args" ret"
    (procedure "_o23" line 2)
    (SplitObject unknown line 2)
    invoked from within
"_o23 send-probe-pkts-to 14 3000 0 4000"
---------------------- error message *