Hi

Here's what i think you need to do:

You need to have a reference to the IFQ, and once you have a reference to
the IFQ you can easily access the variable bytes_ associated with that IFQ

Insert the red code into the files node.cc and ns-lib.tcl (shown below).
These will make sure that any node has a reference to the ll-queue
associated with that node.  Then, from any point in the code where you have
access to a node object (in dsdv for instance... there is a object called
node_) you can access the queue with this

node_->ll_queue->bytes_

I think that should work.  Its basically using the TCL code to link the C++
objects together and making them accessible from different different objects
in the code.  I found that access to the ll_queue was supposed to be in
ns2.33, but it didn't work and needed these small adjustments to work

Good luck

Ariel

node.cc

int
Node::command(int argc, const char*const* argv)
{
    Tcl& tcl = Tcl::instance();
    if (argc == 2) {
#ifdef HAVE_STL
        // Mods for Nix-Vector Routing
        if(strcmp(argv[1], "populate-objects") == 0) {
            if (nixnode_) {
                nixnode_->PopulateObjects();
            }
            return TCL_OK;
        }
        // End mods for Nix-Vector routing
#endif // HAVE_STL
        if(strcmp(argv[1], "address?") == 0) {
            tcl.resultf("%d", address_);
             return TCL_OK;
        }
        //Ariel
        else if (strcasecmp (argv[1], "ll-queue") == 0){
        if (!(ll_queue = (PriQueue *) TclObject::lookup (argv[2])))
            {
              fprintf (stderr, "Node: ll-queue lookup of %s failed\n",
argv[2]);
              return TCL_ERROR;
            }
        ll_queue = (PriQueue *) TclObject::lookup (argv[2]);
        printf("The ll_queue has been set in node instance");
        return TCL_OK;
        }


    } else if (argc == 3) {
#ifdef HAVE_STL
        // Mods for Nix-Vector Routing
        if (strcmp(argv[1], "get-nix-vector") == 0) {
            if (nixnode_) {
                nixnode_->GetNixVector(atol(argv[2]));
            }
            return TCL_OK;
        }
#endif //HAVE_STL
        if (strcmp(argv[1], "set-neighbor") == 0) {
#ifdef HAVE_STL
            if (nixnode_) {
                nixnode_->AddAdj(atol(argv[2]));
            }
#endif //HAVE_STL
            return(TCL_OK);
        }
        if (strcmp(argv[1], "addr") == 0) {
            address_ = Address::instance().str2addr(argv[2]);
#ifdef HAVE_STL
            if (nixnode_) {
                nixnode_->Id(address_);
            }
#endif //HAVE_STL
            return TCL_OK;
        // End mods for Nix-Vector routing
        } else if (strcmp(argv[1], "nodeid") == 0) {
            nodeid_ = atoi(argv[2]);
            return TCL_OK;
        } else if(strcmp(argv[1], "addlinkhead") == 0) {
            LinkHead* slhp = (LinkHead*)TclObject::lookup(argv[2]);
            if (slhp == 0)
                return TCL_ERROR;
            slhp->insertlink(&linklisthead_);
            return TCL_OK;
        } else if (strcmp(argv[1], "addenergymodel") == 0) {
            energy_model_=(EnergyModel*)TclObject::lookup(argv[2]);
            if(!energy_model_)
                return TCL_ERROR;
            return TCL_OK;
        } else if (strcmp(argv[1], "namattach") == 0) {
                        int mode;
                        namChan_ = Tcl_GetChannel(tcl.interp(),
(char*)argv[2],
                                                  &mode);
                        if (namChan_ == 0) {
                                tcl.resultf("node: can't attach %s",
argv[2]);
                                return (TCL_ERROR);
                        }
                        return (TCL_OK);
        } else if (strcmp(argv[1], "add-neighbor") == 0) {
            Node * node = (Node *)TclObject::lookup(argv[2]);
             if (node == 0) {
                 tcl.resultf("Invalid node %s", argv[2]);
                                 return (TCL_ERROR);
            }
            addNeighbor(node);
            return TCL_OK;
        }
        else if (strcasecmp (argv[1], "ll-queue") == 0){
            if (!(ll_queue = (PriQueue *) TclObject::lookup (argv[2]))){
                fprintf (stderr, "DSDV_Agent: ll-queue lookup of %s
failed\n", argv[2]);
                return TCL_ERROR;
            }
            //Ariel
            ll_queue = (PriQueue *) TclObject::lookup (argv[2]);
            printf("The ll-queue has been set in the node\n");
            return TCL_OK;
        }
    }
    return ParentNode::command(argc,argv);
}

/tcl/lib/ns-lib.tcl

# XXX This should be moved into the node initialization procedure instead
# of standing here in ns-lib.tcl.
Simulator instproc create-wireless-node args {
        #Ariel
        puts "create-wireless-node"
        $self instvar routingAgent_ wiredRouting_ propInstance_ llType_ \
        macType_ ifqType_ ifqlen_ phyType_ chan antType_ \
        energyModel_ initialEnergy_ txPower_ rxPower_ \
        idlePower_ sleepPower_ sleepTime_ transitionPower_ transitionTime_ \
        topoInstance_ level1_ level2_ inerrProc_ outerrProc_ FECProc_
rtAgentFunction_

    Simulator set IMEPFlag_ OFF

        # create node instance
        set node [eval $self create-node-instance $args]

        # basestation address setting
        if { [info exist wiredRouting_] && $wiredRouting_ == "ON" } {
        $node base-station [AddrParams addr2id [$node node-addr]]
        }
        if {$rtAgentFunction_ != ""} {
        set ragent [$self $rtAgentFunction_ $node]
    } else {
        switch -exact $routingAgent_ {
            DSDV {
                set ragent [$self create-dsdv-agent $node]
            }
            DSR {
                $self at 0.0 "$node start-dsr"
            }
            AODV {
                set ragent [$self create-aodv-agent $node]
            }
            TORA {
                Simulator set IMEPFlag_ ON
                set ragent [$self create-tora-agent $node]
            }
            DIFFUSION/RATE {
                eval $node addr $args
                set ragent [$self create-diffusion-rate-agent $node]
            }
            DIFFUSION/PROB {
                eval $node addr $args
                set ragent [$self create-diffusion-probability-agent $node]
            }
            Directed_Diffusion {
                eval $node addr $args
                set ragent [$self create-core-diffusion-rtg-agent $node]
            }
            FLOODING {
                eval $node addr $args
                set ragent [$self create-flooding-agent $node]
            }
            OMNIMCAST {
                eval $node addr $args
                set ragent [$self create-omnimcast-agent $node]
            }
            DumbAgent {
                set ragent [$self create-dumb-agent $node]
            }
            ManualRtg {
                set ragent [$self create-manual-rtg-agent $node]
            }
            default {
                eval $node addr $args
                puts "Wrong node routing agent!"
                exit
            }
        }
    }

    # errProc_ and FECProc_ are an option unlike other
        # parameters for node interface
    if ![info exist inerrProc_] {
        set inerrProc_ ""
    }
    if ![info exist outerrProc_] {
        set outerrProc_ ""
    }
    if ![info exist FECProc_] {
        set FECProc_ ""
    }



    # Add main node interface
    $node add-interface $chan $propInstance_ $llType_ $macType_ \
        $ifqType_ $ifqlen_ $phyType_ $antType_ $topoInstance_ \
            $inerrProc_ $outerrProc_ $FECProc_
    # Attach agent
    if {$routingAgent_ != "DSR"} {
        $node attach $ragent [Node set rtagent_port_]

                #Ariel
        puts "adding the ll-queue"
        set ifq_ariel_ [new Queue/DropTail/PriQueue]
        set ifq_ariel_ [$node get-queue]
        puts "node $node ragent $ragent ifq_ariel_ $ifq_ariel_"
           $ragent ll-queue $ifq_ariel_    ;# ugly filter-queue hack
           $node ll-queue $ifq_ariel_

    }
    if {$routingAgent_ == "DIFFUSION/RATE" ||
            $routingAgent_ == "DIFFUSION/PROB" ||
            $routingAgent_ == "FLOODING" ||
            $routingAgent_ == "OMNIMCAST" ||
        $routingAgent_ == "Directed_Diffusion" } {
        $ragent port-dmux [$node demux]
        $node instvar ll_
        $ragent add-ll $ll_(0)
    }
    if { $routingAgent_ == "DumbAgent" } {
        $ragent port-dmux [$node demux]
    }


    # Bind routing agent and mip agent if existing basestation
    # address setting
        if { [info exist wiredRouting_] && $wiredRouting_ == "ON" } {
        if { $routingAgent_ != "DSR" } {
            $node mip-call $ragent
        }
    }
    #
        # This Trace Target is used to log changes in direction
        # and velocity for the mobile node.
        #
    set tracefd [$self get-ns-traceall]
        if {$tracefd != "" } {
        $node nodetrace $tracefd
        $node agenttrace $tracefd
    }
    set namtracefd [$self get-nam-traceall]
    if {$namtracefd != "" } {
        $node namattach $namtracefd
    }
    if [info exists energyModel_] {
        if  [info exists level1_] {
            set l1 $level1_
        } else {
            set l1 0.5
        }
        if  [info exists level2_] {
            set l2 $level2_
        } else {
            set l2 0.2
        }
        $node addenergymodel [new $energyModel_ $node \
                $initialEnergy_ $l1 $l2]
        }
        if [info exists txPower_] {
        $node setPt $txPower_
        }
        if [info exists rxPower_] {
        $node setPr $rxPower_
        }
        if [info exists idlePower_] {
        $node setPidle $idlePower_
        }
#
    if [info exists sleepPower_] {
        $node setPsleep $sleepPower_
        }
    if [info exists sleepTime_] {
        $node setTSleep $sleepTime_
        }
    if [info exists transitionPower_] {
        $node setPtransition $transitionPower_
        }
    if [info exists transitionTime_] {
        $node setTtransition $transitionTime_
        }
#
    $node topography $topoInstance_

    return $node
}

On Fri, Mar 12, 2010 at 2:33 PM, waqar haq <warin...@gmail.com> wrote:

>
> hi to all
>
> plz do reply, i m in die hard need
>
> i was trying to get nos of bytes currently contain in a que
>
> after searching i have found that queue class contain a packetqueue object
> that hav a protected variable "bytes_"
>
> i have done this to get a queue handle
>
> set queu [[[$ns link $node $nbr ] set queue_] set limit_]
>
> it gives me max nos of packet queue can contain
>
> but i want to communicate queue c++ class ,but finds out that queue doesnt
> have any command funtion
>
>
> then i turn back to droptail queue classs and find out that it contain a
> command function and also contain queue::command();
>
> but i havent found any implementation of queue::command()
>
>
> further more when i try to write my own command funtion in existing queue
> base class it gives an errror of unknown split object
>
>
> can any any one tell me whats really hapning and it there any thing i can
> do
> to get bytes_ value in my program
>
>
> thnks alot
>
>
> and plz do reply
>



-- 
Kind Regards

Ariel Goldberg

Mobile: +27 82 998 7122
Phone: +27 21 940 9757
Mail: ariel.goldbe...@gmail.com

Reply via email to