Make your own free website on
Building ns-2 on Cygwin

I got the inspiration for writing this document after feeling the need for ns-2, network simulator. NS-2 is an excellent tool for simulating wired or wireless network on your PC and doing the required analysis. Since I was looking for some good tool for simulating network, I came across ns-2. But ns-2 only works on UNIX and not on Ms Windows.

So, the work around is install CYGWIN, which emulated the UNIX environment on top of Windows OS. So, the very first think that you need is cygwin-1.3.12 or later. Cygwin can be obtained from After downloading Cygwin, just install it on your PC. The next thing you require is network simulator itself i.e. ns-allinone-2.27, available at This network simulator contains lot of interesting stuff, like C, UNIX editors and lots of other thing. Things of our interest are NAM (Network Animator) and GraphX (For viewing the analysis) that are installed automatically once you install ns-allonone-2.27.

Next install the downloaded ns-allinone-2.27.tar.gz. But before installing, just confirm whether you have installed Cygwin with the UNIX text type. Infact during the second step of installation of Cygwin, you get two options, DOS text type or UNIX text type. Just select the radio button with UNIX text type.

Always remember that install CYGWIN in c:\cygwin directory, which is asked during the steps of installation of CYGWIN, also there should be no space in directory name. Then create a home directory i.e. c:\cygwin\home. Then create another directory by your name, which will be like c:\cgywin\home\harshit\.

Step1: Then copy the installed ns-allinone-2.27 in your home directory i.e. c:\cgywin\home\harshit. Home directory is an acronym in UNIX; it does not mean the directory with the name home, but the directory for user.

Step2: Launch Cygwin, and start the XFree86 server by double clicking the MS-DOS batch file startxwin, which is present in C:\cygwin\usr\X11R6\bin\. Execution of this batch file will result in a UNIX window and a UNIX prompt called here as Cygwin (bash) prompt.

Step3: From your Cygwin (bash) prompt, go to your home directory by typing cd ~. run the following commands

gzip -d -c ns-allinone-2.27.tar.gz | tar xvf –

Basically you are unzipping the tar file.

Step4: After unzipping the tar file which will take considerable amount Of time depending upon your system configuration, type the following command

cd ns-allinone-2.27

Step 5: Now you are in the directory c:\cygwin\home\harshit\ns-allinone-2.27. You can then install everything by just typing


Step 6: Using emacs (editor), create a file emacs ‘.bashrc’, In UNIX, file names that start with ‘.’ are hidden files. This file is executed every time you start Cygwin on your system.

export NS_HOME=/home/XXX/ns-allinone-2.1b9a/

export PATH=$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix:$NS_HOME/bin:$PATH

export LD_LIBRARY_PATH=$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix: $NS_HOME/otcl-1.0a8:$NS_HOME/lib:$LD_LIBRARY_PATH

export TCL_LIBRARY=$NS_HOME/tcl8.3.2/library

where XXX is harshit in my case.

The job is finished, you have successfully installed the CYGWIN and ns-allin-one2.27 Just close the Cygwin server and restart it again.