How to Run TCL File in Ns2

If you guys are looking for technical explanations about TCL files based different approaches in Ns2, then no doubt you are the right place. Shall we start this article with the short note about the TCL in the following? Let’s go ahead…

What is TCL?

Tool command language is abbreviated as the TCL, it is the script language that is used to create the performance of network simulation process and the scripts based on TCL is deployed to simulate various parameters and configurations and it is used to avoid the drawbacks of C++.

Ns2 Shell Executable Command

The TCL scripts are functioning in command to prompt Ns2 and we have explained the processes that are required to implement the TCL files based on Ns2.

  • Install Ns2 and to set the path
  • Ns2 is installed then the $prompt is reached to run the file name as ns tcp.tcl
  • The users can view the demo in GUI and to function the nam tcp.nam
  • One window will be opened and the user have to click the run button
  • .tr file is considered as the supportive file to view the performance factors such as packet drop, throughput and etc. The users are capable to parse the .tr file with the utilization of software like tracegraph202 and Xgraph

The code appeared in the last line of tcp.tcl and at the end it is starting the simulation through using this command “$ns run”. The users are to save the file at this movement and try to run along with the “ns tcp.tcl” to acquire the simulation window.

Below, our research professionals who have years of experience in this field have enlisted the functions of Tcl code using two nodes and one link.

Tcl Code for Two Nodes and One Link

This section is about the depiction of simple topology through the utilization of two nodes and that are connected using one link. The two significant lines about the process are defining the two nodes such as.

set n0 [$ns node]

set n1 [$ns node]

The novel node object is generated along with the command named as “$ns node” and the above mentioned code is to create the two nodes and that is capable to assign the process to handle both the “n0” and “n1”. The below mentioned command is deployed to connect the two nodes.

$ns duplex-link $n0 $n1 1Mb 10ms DropTail

Consequently, the users have to save the file to start the simulation process again and while clicking the play button which is located in the nam window. Then the users can see the process after 0.5 simulation seconds, the node 0 is started to send the data packets towards the node 1.

In addition, our technical professionals have years of experience in dealing with the research and development based on TCL file in Ns2. So, we have complete awareness in all required research processes that are essential to reply the question “how to run TCL file in Ns2”. In addition, we have listed down few important mobility models based on the TCL file utilization in Ns2.

Mobility Models in TCL

The process includes four mobility models based on TCL script generator and our research professionals have enlisted the list of models in the following for your reference.

  • Random waypoint model
  • Manhattan model
  • Gauss Markov mobility model
  • Reference point group mobility model

Above, we have discussed about the notable mobile models based on the TCL files. In addition, if you are in search to get to know about how to run the TCL file in Ns2, then contact us. Our research experts assist you to found the required and simple process to run the TCL file in Ns2. At this moment, let us discuss about some of the significant characteristics in the mobility models based on TCL.

Random Waypoint Model

The random waypoint mode is denoted as the applied mobility model based on wireless networks particularly in the mobile ad hoc network. It is used to create several realistic mobility models in various node moves towards the random point within the particular network area and the remaining position of specific period is considered as the pause time and it is to move the random next random point and etc.

For your reference, our research professionals have enlisted the sample code that is offer the methods for generating this mobility model.

#******************Defining Mobility ************************#

# For mobility 300= movement x value, 100=movement y value, 50=speed in m/s

$ns at 2.0 “$node_(2) setdest 300 100 50”

#*****************Defining Random Mobility *******************#

#Random mobility for all the nodes

for { set i 1} {$i < 3} {incr i} {

set xr [expr rand()*$val(x)]

set yr [expr rand()*$val(y)]

$ns at 2.0 “$node_($i) setdest $xr $yr 50”


Manhattan Model

It is considered as the significant type of urban mobility model based on the vehicular ad hoc network (VANET). The grid road topology is particularly used in this Manhattan mobility model. In addition, this mobility model includes the mobility nodes to move into the vertical or horizontal direction based urban map. The functions of this Manhattan mobility model includes the probabilistic approach to select the movements based on nodes and all the intersections selects the vehicles to keep on moving towards the same direction. Consequently, we have highlighted the significant features of Manhattan mobility model in the following.

  • Similar to freeway model, the relationship among both the inter node and intra node based on Manhattan mobility model is providing the difference above the expectation
  • Mobile nodes are permitting to move along with the grid based on vertical and horizontal streets in the map
  • The interaction based on horizontal and vertical streets provide the process of probability to mobile nodes with the direction guidelines

Gauss Markov Mobility Model

The gauss Markov mobility model is abbreviated as GMM and it is applying some alterations to the alpha, parameters and to adopt various levels of random. All the mobile nodes are assigned towards the initial speed and direction so the limited time interval for the new value speed and direction is calculated for all the mobile nodes through value that is calculated already. It is frequently functions during the time of simulation.

Reference Point Group Mobility Model

It is about the depiction of group simulation in which all the nodes are based on the group where the nodes are following the logical center for the determination of the characteristics based on group motion. The nodes in the group are functional to the random distribution to the reference point and various nodes are deployed with their own mobility model and that is added with the reference point to drive the direction of group.

The aforementioned are major and notable mobility models with its characteristics and advantages that are essential to outline the effective process of TCL file in Ns2. So far, we have discussed about the significance about the functions of TCL file in Ns2. We hope that you guys would have grabbed some consequence about this installation and functions. Do you interested to explore more about the process of TCL file? Then contact our research professionals without any hesitation we are ready to support you at any time.

Opening Time


Lunch Time


Break Time


Closing Time


  • award1
  • award2