Where to Find What?



Before going into a discussion of how to extend NS, let's briefly examine what information is stored in which directory or file. Figure 17 shows a part of the directory structure of the simulator if you installed it using the ns-allinone-2.1b package.



Figure 17. NS Directory Structure

Among the sub-directories of ns-allinone-2.1b, ns-2 is the place that has all of the simulator implementations (either in C++ or in OTcl), validation test OTcl scripts and example OTcl scripts. Within this directory, all OTcl codes and test/example scripts are located under a sub-directory called tcl, and most of C++ code, which implements event scheduler and basic network component object classes, except the WWW related ones, are located in the main level. For example, if you want to see the implementation of the UDP agent, you should go to "ns-allinone-2.1b/ns-2" directory, and open up "udp.h", "udp.cc" and the files that contain the implementation of ancestor classes of UDP as needed. For the class hierarchy of network components, refer to Figure 6 in the "Network Components" section. From now on, it is assumed that you are already in "ns-allinone-2.1b" directory.

The tcl directory has sub-directories, among which the lib directory that contains OTcl source codes for the most basic and essential parts of the NS implementation (agent, node, link, packet, address, routing, and etc.) is the place one as a user or as a developer will visit the most. Note that the OTcl source codes for LAN, Web, and Multicast implementations are located in separate subdirectories of tcl. Following is a partial list of files in "ns-2/tcl/lib" directory.

Two sub-directories of tcl that might be interesting for a user who wants to know how to design a specific simulation are ex and test. The former directory contains various example simulation scripts and the latter contains simulation scripts that validate the NS installed in your machine by running various simulations and comparing the results with the expected results.