## The Network Simulator: ns-2

This is a software tool that helps you perform networking experiments on your computer. Download and try it with a few simple examples, such as exercise 5 (page 196) and 6 (page 197) in the textbook.

### User Information

Main Page - Roadmap - User Information - Developer Information - Projects - Contributing - Links

Note: This page is a port of this original ISI page. All of the links should eventually migrate to become wiki pages.

### The Network Simulator - ns-2

Ns is a discrete event simulator targeted at networking research. Ns provides substantial support for simulation of TCP, routing, and multicast protocols over wired and wireless (local and satellite) networks.

Ns began as a variant of the REAL network simulator in 1989 and has evolved substantially over the past few years. In 1995 ns development was supported by DARPA through the VINT project at LBL, Xerox PARC, UCB, and USC/ISI. Currently ns development is supported through DARPA with SAMAN and through NSF with CONSER, both in collaboration with other researchers including ACIRI. Ns has always included substantal contributions from other researchers, including wireless code from the UCB Daedelus and CMU Monarch projects and Sun Microsystems. For documentation on recent changes, see the version 2 change log.

While we have considerable confidence in ns, ns is not a polished and finished product, but the result of an on-going effort of research and development. In particular, bugs in the software are still being discovered and corrected. Users of ns are responsible for verifying for themselves that their simulations are not invalidated by bugs. We are working to help the user with this by significantly expanding and automating the validation tests and demos.Similarly, users are responsible for verifying for themselves that their simulations are not invalidated because the model implemented in the simulator is not the model that they were expecting. The ongoing Ns Manual should help in this process.

### Installing ns

#### Requirements

To build ns you need a computer and a C++ compiler. We develop ns on several kinds of Unix (FreeBSD, Linux, SunOS, Solaris), so it installs smoothest there, but it should run on an Posix-like computer, possibly with some tweaking. Ns also builds and runs under Windows, see the dedicated Windows / Cygwin page. Simple scenarios should run on any reasonable machine, but very large scenarios benefit from large amounts of memory.

Ns is fairly large. The allinone package requires about 320MB of disk space to build. Building ns from pieces can save some disk space. (If multiple people want to share files in the ns build tree to save space, you may download a simple perl script, then follow the instruction in its README. There is detailed instruction from CS599b class of USC. You may also find discussions in the ns-users mailing list archive useful.)

As of November 2005, ns is available at this SourceForge location.

Ns requires a modestly up-to-date installation of Tcl/Tk (with header files), and two additional packages: tclcl and otcl. Most OS installations do not come with full Tcl/Tk installations or with these other packages, so you will most likely need to install several packages.

##### Generic Linux, BSD, OS X, and Solaris instructions

There are two typical ways to build ns: building each component individually ("from the pieces") or running a script that installs them all in one shot ("allinone"). If you just want to try it out quickly, you might try the allinone package. If you want to do C-level developement, or save download time or disk space, or have trouble with allinone, you should build it from the pieces.

• Installing the allinone package:This package has a install script that handles installation of Tcl/Tk, OTcl, tclcl, ns-2, nam-1 and other packages.
• Updating allinone: The "allinone" package is only updated for every release. If you are interested in the convenience of the allinone package for your platform, but are interested in using a fresher snapshot of the ns-2 code, this page is for you.
• Building ns from sources:Instructions

(Note: The above allinone and pieces ISI pages need wikified and updated)

Below are some instructions specific to different systems.

##### Ubuntu Installation Guide

Wouter Horré maintains a PPA for ns/nam, so you can get ready-to-use deb packages there. If looking for the build-from-sources installation instructions for some reason, check below...

ns-allinone-2.35 installs on Ubuntu (tested through Ubuntu 11.10). Make sure you have the following packages installed:

libxt-dev libx11-dev libxmu-dev

For Ubuntu 9.10 (karmic), you may encounter this error in the linking of otcl:

otcl.o: In function OTclDispatch':
/home/ns/ns-allinone-2.34/otcl/otcl.c:495: undefined reference to __stack_chk_fail_local'
otcl.o: In function Otcl_Init':
/home/ns/ns-allinone-2.34/otcl/otcl.c:2284: undefined reference to __stack_chk_fail_local'
ld: libotcl.so: hidden symbol `__stack_chk_fail_local' isn't defined
ld: final link failed: Nonrepresentable section on output
make: *** [libotcl.so] Error 1

This error is because the linker being used is "ld -shared" instead of "gcc -shared". If you edit one line in otcl-1.13/configure, and rerun install, it should work:

--- configure.orig 2009-11-02 12:14:52.556167945 -0800
+++ configure 2009-11-02 12:17:28.966706099 -0800
@@ -6301,7 +6301,7 @@
;;
Linux*)
SHLIB_CFLAGS="-fpic"
- SHLIB_LD="ld -shared"
+ SHLIB_LD="gcc -shared"
SHLIB_SUFFIX=".so"
DL_LIBS="-ldl"
SHLD_FLAGS=""

This will be fixed in future revisions of ns-2.

Other links you can check for help:

##### FreeBSD Ports collection

If you happen to be using FreeBSD, ns and nam exist in the Ports collection under net/ns and net/nam. It is good practice to always update your ports tree using any of the standard methods before installing software. To install, simply navigate to ns and nam's respective directories and issue a "make install clean" as root.

##### VMWare images

You can submit your ns2 Vmware/xen images to me for hosting if you want

send requests to ac3bf1

##### Windows-specific instructions

Ns runs on Windows platforms using Cygwin emulation. See: Running Ns and Nam Under Windows 9x/2000/XP Using Cygwin
See also: Building the Feasible Simulation Platform Supported with Multiple Versions of ns-2 (reported by Shih-Tsung Liang)

#### Validating your build

Ns has an extensive regression test suite covering a good portion of the code base, and you can check to see whether your platform is generating output consistent with other installations-- see Validation Tests and Demos.

What if you get a validation error? If you run ./validate and the script exits by complaining that some tests failed, this may not be cause for concern. Currently (June 2006) validation tests fail for some platforms, due to e.g. minor floating point variations on different platforms, or differences with new compilers such as gcc-4.0.1. If a test fails for some model that is not critical to your experiment, you may ignore the message.

Known issues:

• gcc-4.1 variants may have problems with: test-all-webcache, test-all-friendly
• x86_64 platform (Suse10) experience a number of validation errors: srm, smac-multihop, hier-routing, algo-routing, mcast, vc, session, mixmode, webcache, mcache, plm, wireless-tdma, satellite
• Cygwin (Windows XP) is failing the following tests: simultaneous, wireless-tdma, smac-multihop (reported by Michael Siu, 18 July 2006)
• A recent upgrade of Apple Xcode (2.4.1) introduced a gcc compiler version (build 5367) that is introducing the following validation errors (similar to Cygwin): ./test-all-diffusion3 ./test-all-smac ./test-all-smac-multihop ./test-all-lan ./test-all-session ./test-all-energy ./test-all-snoop

#### Troubleshooting

This has migrated to the following Troubleshooting page.

### The Network Animator - nam

Note: See nam's ISI page, which has not yet been ported to this wiki.

---

Source: ns-nam, http://nsnam.sourceforge.net/wiki/index.php/User_Information