TCL in Ns2

           The tool command language is considered as the script programming language. On the other hand, the Ns2 is utilizing object oriented extension of Tcl and it is written through C++. The system configuration based on OTcl is implemented through the C++.

Ns2 Workbench to Design Networks and Generate TCL Scripts

           The process of analysis and development in Ns2 simulation is functioning easier and faster with the functions of expressiveness and flexibility over the script that is written. In addition, it includes some characteristics such as,

  • Routing protocols
  • Loss models
  • Link monitors
  • Scenario generator
  • Services
  • Application
  • TCP sink
  • Agents
  • Nodes

          In general, the process of TCL in Ns2 is functioning for various process and we have highlighted the procedure about error reporting and exit through the utilization of Tcl.

Error Reporting and Exist Using Tcl

[const char* ] tcl.error../Tcl/Tcl.ccTcl::error performs the following functions:
write to stdout; write tcl_-result to stdout; exit with error code 1.
{\bfseries{}tcl.resultf}("cmd = %s", cmd);
{\bfseries{}tcl.error}("invalid command specified");

      It is considered as the provision of uniform techniques about to report the errors that are compiled code. The process of node includes some slight variations through the differences in TCL_ERROR return.

Example Configuration of Tcl Object

set srm [new Agent/SRM/Adaptive]
\$srm set packetSize_ 1024
\$srm traffic-source \$s0

         The abovementioned code is the depiction of configuration of SRM agent and that is written in (Agent/SRM/Adaptive../ns-2/srm-adaptive.tcl). In addition, we have highlighted the process about the creation of Tcl objects in Tcl.

Creating Tcl Objects in Tcl

Agent/SRM/Adaptive instproc init args {
eval \$self next \$args
\$self array set closest_ "requestor 0 repairor 0"
\$self set eps_ [\$class set eps_]

        The utilization of []new is assistive to create an interpreted Tcl object and it is the implementation of constructor over the object.

Deletion of Tcl Objects

Simulator instproc use-scheduler type {
$self instvar scheduler_
delete scheduler_ # first delete the existing list scheduler;
set scheduler_ [new Scheduler/$type]

       It is about the process of deleting the interpreted object along with the shadow functioning. For instance, [scheduler]use-scheduler../ns-2/ns-lib.tcl Simulator::use-scheduler is deployed to delete the procedure to remove the default list scheduler.

        To this end, we hope that we have provided the appropriate research guidance based on Tcl in Ns2. The research scholars can contact us to aid more from our research experts.