Exemplary implementation for CR Routing

 

(1)TCL Library Modification

Module ns-lib.tcl: invoke create-wcett-agent in function create-wireless-node as other routing protocols

Simulator instproc create-wireless-node args {

      …

       switch -exact $routingAgent_ {

                …

            WCETT {

                    set ragent [$self create-wcett-agent $node]

            }

            ….

      }

      …

}

 

Module ns-lib.tcl: add the create-wcett-agent procedure

Simulator instproc create-wcett-agent { node } {

        #  Create wcett routing agent

        set ragent [new Agent/WCETT [$node node-addr]]

        $ragent node $node

        $self at 0.0 "$ragent start"    

        $node set ragent_ $ragent

        return $ragent

}

 

(2) C++ code change

Define the interface queue and targetlist for multiple interfaces.

Module wcett: define the interface queue and targetlist for multiple interfaces

class WCETT: public Agent {

         …

Protected:

        int nIfaces; //total interfaces per node

        NsObject *targetlist[MAX_IF];

        PriQueue *ifqueuelist[MAX_IF];

        MobileNode *node_;

 

Module wcett: add the following codes in the command method

Int WCETT::command(int argc, const char*const* argv) {

    …

   Else if(argc = = 3) {

         //create pointer to mobilenode object  …

        else if(strcmp(argv[1], "node") == 0) {

             node_= (MobileNode*) TclObject::lookup(argv[2]);

             if (node_){            

                      return TCL_OK;

             }

                  return TCL_ERROR;

        }

  } else if (argc = = 4){

            //create pointer to ifqueue object

             if(strcmp(argv[1], "if-queue") == 0) {

                    ifqueue = (PriQueue*) TclObject::lookup(argv[3]);

                    int temp_=atoi(argv[2]);

                    if (temp_==nIfaces){

                            nIfaces++;

                    }

                    ifqueuelist[temp_]= ifqueue;

 

                    if (ifqueuelist[temp_]){

                           return TCL_OK;

                    }

                    return TCL_ERROR;

            }

            //create pointer to downtarget objects

            if (strcmp(argv[1],"target")==0 ){

                   int temp=atoi(argv[2]);

                   if (temp == nIfaces){

                        nIfaces++;

                   }

                   targetlist[temp]=(NsObject *) TclObject::lookup(argv[3]);

                   if(targetlist[temp]){

                          return TCL_OK;

                   }

                   return TCL_ERROR;

          }

  …

}

 

Next, when sending the packets over the specific interfaces, just using the interface number as an index to send the packet as follow.

Module wcett: example about how to use the interface

if(nIfaces) { //if multiple interfaces are defined.

        for(int i=0;i<nIfaces;i++) {

             Packet *p_copy=p->copy();

             Scheduler::instance().schedule(targetlist[i], p_copy,

                                           0.01 * Random::uniform());

       }

} else {

        //if only one interface is defined

         Scheduler::instance().schedule(target_, p,

                                           0.01 * Random::uniform());

}

 

 

Previous: Exemplary Demonstrations Overview         Next: Exemplary Demonstrations for CR MAC

Return to Main