How to Run a TCL File

              Tool command language is denoted as TCL and it is the shell application which is capable to read the TCL command from the standard input and over the file that provides the anticipated results. We can describe TCL as procedural and string based scripting language. In addition, the program based on TCL includes the .tcl extension. The following is based on the characteristics of TCL.

Features of TCL

  • It is an open source and free language
  • It is deployed in commercial applications
  • It includes the powerful set of networking functions
  • Consisting Java, C++, C in TCL and extending the existing applications are considered as the easy process
  • It is functioning in reduced development of time

Applications of TCL

Consequently, TCL is considered as the general purpose of language and the users are capable to recognize TCL all around and the applications based on TCL are listed in the following.

  • Embedded applications
  • Desktop GUI applications
  • Web servers with high performance using TclHttpd
  • Scalable websites with the support of databases
  • TCL with CGI based websites

TCL Script to Simulate Link State Routing in Ns2

         For your reference, we have highlighted the implementation of TCL script to simulate link state routing in Ns2. This process includes several steps for the simulation of link state routing and it includes the various lines of codes too and they are highlighted in the following.

Step-1: Initializing the Network

           Firstly, we have to initialize the network simulator along with the creation of network simulator object and the routing protocol (rtproto) to link state (LS) is initialized through the below mentioned commands.

set ns [new Simulator]
$ns rtproto LS

Step-2: Creating Number of Nodes

              Following that initialization, random numbers of nodes are created and the node instance is utilized for the creation of nodes such as,

set node1 [$ns node]
set node2 [$ns node]
set node3 [$ns node]

Step-3: Creating Trace File

          The next step is to create the trace file and nam file. Here, the nam file is deployed to view the simulator output in which the trace file is tracing all the routing information based on the process. Then, the nam file and trace file is created and it is opens the files with the write mode. The trace-all instance is deployed to trace the routing data into the trace file and in the same way namtrace-all the nam files.

set tf [open out.tr w]
$ns trace-all $tf
set nf [open out.nam w]
$ns namtrace-all $nf

Step-4: Labeling the Nodes

           Preceding the trace file creation, we have to label the nodes and the labels are customized through assigning various colors.

$node1 label "node 1"
$node2 label "node 2"
$node3 label "node 3"
$node1 label-color blue
$node2 label-color red
$node3 label-color red

Step-5: Creating Duplex Links

        It is about the creation of duplex links among the node creation and it is acquired through the utilization of duplex link instance with the specification of three significant parameters.

$ns duplex-link $node1 $node2 1.5Mb 10ms DropTail
$ns duplex-link $node2 $node3 1.5Mb 10ms DropTail
$ns duplex-link $node3 $node1 1.5Mb 10ms DropTail

Step-6: Orient the Links among Nodes

          The link orientation is required among the nodes to acquire the appropriate alignment and the duplex-link-op is deployed.  

$ns duplex-link-op $node1 $node2 orient left-down
$ns duplex-link-op $node2 $node3 orient left-down
$ns duplex-link-op $node1 $node1 orient left-up

Step-7: Attach TCP Agents

      TCP agents are attached with two nodes and they include node 1 and node 3 to create the source and sink objects to connect the instance.

set tcp2 [new Agent/TCP]
$ns attach-agent $node1 $tcp2
set sink2 [new Agent/TCPSink]
$ns attach-agent $node3 $sink2
$ns connect $tcp2 $sink2

Step-8: Create FTP Traffic

        It is about the creation of FTP traffic and attach to TCP source and the traffic is the flow over node 1 and node 3.

set traffic_ftp2 [new Application/FTP]
$traffic_ftp2 attach-agent $tcp2

Step-9: Add Finish Procedure

      It is to add the finish procedure to flush all the data in trace file and to run the nam file.

proc finish{} {
global ns nf
$ns flush-trace
close $nf
exec nam out.nam &
exit 0

Step-10: Scheduling FTP

        It is about scheduling FTP traffic with the essential time intervals and we are capable to disable the link among various pair of nodes with the timestamp along with the utilization of rtmodel-at.

$ns at 0.5 "traffic_ftp2 start"
$ns rtmodel-at 1.0 down $node2 $node3
$ns rtmodel-at 2.0 up $node2 $node3
$ns at 3.0 "traffic_ftp2 start"
$ns at 4.0 "traffic_ftp2 stop"
$ns at 5.0 "finish"
$ns run

Step-11: Execute TCL Program

        When the above mentioned code is completed, save the file as First.tcl and it is implemented through the command such as,

“tclsh First.tcl” or “./ns First.tcl”

                Through this article we have given you a very broad picture about the running process of TCL file, where you can find complete information regarding the processes and functions. In addition, reach us to fulfill all your research requirements with the best innovations and novel executions along with the support of our research experts.