How to pass the variable tcl to c++ using NS2?

  • The variable (total number of nodes) in tcl is passed to c++ as follows.
    TCL part :

    Example : AODV protocol
    Agent / AODV set total_nodes_ 50

  • C++ part :

     int total_nodes_ ; // in header file
    bind(“total_nodes_,&total_nodes);
    Printf(“Total number of nodes %d \n”,total_nodes_);

  • Result :

    Total number of nodes 50