For most users of NS2, it would be easier if they can use a popular IDE to work with the files.
Here are the step by step instructions I followed to set up NS-2.34 with Eclipse 3.5 in Ubuntu Linux.
In older versions of Eclipse, the settings might be slightly different.
I have compiled the following steps after running into various problems and errors with the setup, and solving them all. So I hope the setup will be smooth for you.
Setting up Eclipse:
- Download Eclipse SDK
- Extract the SDK to a folder
- Open Eclipse
- Go to Help -> Install New Software. In the Work With bar type this:
- Choose CDT Main Features and CDT Optional Features. Install them.
CDT stands for “C/C++ Development Tooling”
- If you do not have a working internet connection in the system you have installed Eclipse, instead of steps 4 and 5, download the CDT from the above mentioned site. Then move to Install New Software (see step 4) -> Add and add the archive downloaded.
- Download NS-2
- Extract NS-2 to a folder, i.e. /home/username/ns-allinone-2.34
- Edit Makefile:
- Open “…/ns-allinone-2.34/ns-2.34/Makefile.in”and
- Add these lines anywhere near the top of the file:
CCOPT = -g
DEFINE = -DNDEBUG
DEFINE = -DDEBUG
- Navigate to …/ns-allinone-2.34/ns-2.34 and run “./configure”
- Navigate to the NS-2 folder using terminal and type ./install
- Also, follow the instructions are displayed at the end of a successful installation. These instructions are to modify the PATH variable and other environment variables as needed.
Adding NS-2 as a Project in Eclipse
- Open Eclipse
- Set the workspace as the ns installation path( /home/username/ns-allinone-2.34 ) by selecting File -> Switch Workspace
- Choose File -> New -> Project -> C++ Project
- Select Project Type as Makefile Project -> Empty C++ Project.
Toolchains: Linux GCC
- Enter Project Name as ns-2.34
- Uncheck “Use default location” then browse to the directory NS-2 source directory ( …/ns-allione-2.34/ns-2.34 )
- Select “Next” and “Finish.
- From the workspace, Selecting the NS-2 Project and choosing Project -> Build All should not give Error.
- Running the project must open the console with the NS-2 prompt, %
Setting Debug Configuration:
- Select Run -> Debug Configurations
- Choose C/C++ Application. Type in any name.
- Under the Main tab, Choose the following:
Project as ns-2.34.
C/C++ Application as ns. (Search Project and Choose this)
- Under the Debugger tab, choose GDB Debugger. Uncheck the “Stop on startup at” option.
- Apply and Debug.
Update from Readers: Changes to be made in Makefile.in file:
Add -g to the line
CCOPT = @V_CCOPT@
CCOPT = @V_CCOPT@ -g
-DNDEBUG -DDEBUG to the end of the following line:
DEFINE = -DTCP_DELAY_BIND_ALL -DNO_TK @V_DEFINE@ @V_DEFINES@ @DEFS@-DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=@CPP_NAMESPACE@-DUSE_SINGLE_ADDRESS_SPACE -Drng_test -DNDEBUG -DDEBUG
Special thanks to Ella Taha for notifying me about the correction!
I wrote this post many years ago, and I have since then moved away from using NS-2.
Here is a relatively recent post by Erlend that might be of help: Using ns-2 with Eclipse