How do I Create an Ns2 File

Let’s discuss about the process that are required to create a source files based on network simulator 2.

Programming Languages in Ns2

As first, we have highlighted the list of programming languages that are supportive for network simulator 2.

  • C++
  • It is deployed to create the source code packages for the proposed methods and algorithms
  • TCL
  • It is the script language which is used to configure the network and nodes based on the Ns2 package which is already built

Creation of Ns2 Source File

Following that, we have to create the Ns2 source code program file in the xns-allinone-2.35\ns-2.35 location with the file extension .cc. In addition, we have highlighted the sample ns2 source code for packet scheduler configuration.

Scheduler& s = Scheduler::instance();

            double txt = txtime(p);

            downtarget_->recv(p, this);


                        s.schedule(&hRes_, &intr_, txt);

Ns2 Tcl Script File

Finally, we have to create the Ns2 network configuration script file in the project workspace location with the file extension of .tcl and the sample Ns2 Tcl script code for node position and configuration is highlighted below.

for {set i 0} {$i < $val(nn)} { incr i } {

$ns initial_node_pos $node_($i) 30


The research scholars can reach us at time to clarify your difficulties based on the creation of source files in Ns2.