50% found this document useful (2 votes)
2K views

ns2 Programming Languages

The document discusses the use of two languages, C++ and OTcl, in the ns-2 network simulator. It explains that ns-2 uses both languages because it needs to efficiently simulate protocols (C++) and quickly configure simulation scenarios (OTcl). C++ allows for fast runtimes but slower development, making it suitable for protocol implementations. OTcl allows for faster development at the cost of runtime speed, making it ideal for configuring simulations. The document provides guidance on when each language should be used.

Uploaded by

samasimo5
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
2K views

ns2 Programming Languages

The document discusses the use of two languages, C++ and OTcl, in the ns-2 network simulator. It explains that ns-2 uses both languages because it needs to efficiently simulate protocols (C++) and quickly configure simulation scenarios (OTcl). C++ allows for fast runtimes but slower development, making it suitable for protocol implementations. OTcl allows for faster development at the cost of runtime speed, making it ideal for configuring simulations. The document provides guidance on when each language should be used.

Uploaded by

samasimo5
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Otcl/C++ in ns-2:

Why two languages?


ns uses two languages because simulator has two different kinds of things it needs to do. 1. Detailed simulations of protocols requires a systems programming language which can efficiently manipulate bytes, packet headers, and implement algorithms that run over large data sets. For these tasks run-time speed is important and turn-around time (run simulation, find bug, fix bug, recompile, re-run) is less important. 2. A large part of network research involves slightly varying parameters or configurations, or quickly exploring a number of scenarios. In these cases, iteration time (change the model and re-run) is more important. Since configuration runs once (at the beginning of the simulation), run-time of this part of the task is less important. How?

ns meets both of these needs with two languages, C++ and Otcl (Object oriented Tool Command Langauge) 1. C++ is fast to run but slower to change, making it suitable for detailed protocol implementation. 2. OTcl runs much slower but can be changed very quickly (and interactively), making it ideal for simulation configuration. 3. ns (via tclcl) provides glue to make objects and variables appear on both langauges. When to use each langauge?

Otcl: Simulation scenario configurations and one time stuff. If it is something that can be done without modifying existing Tcl module. C++: If you are doing anything that requires processing each packet of a flow.
1

Need to change behavior of existing module.


Summary: If your simulation scenario uses only predefined ns objects, then all you have to do is to write the tcl script. You don't need any C++ programming unless you want to add new functionality to ns. For further readings: Otcl tutorial: ftp://ftp.tns.lcs.mit.edu/pub/otcl/doc/tutorial.html Tcl/Tk Book: ftp://ftp.scriptics.com/pub/welch TclTutor: http://www.msen.com/~clif/TclTutor.html

You might also like