How to Install ns-2 on Mac OS X 10.7 LION

Installing ns-2 on a mac is a pain!

It was easy enough on the windows 7, but it was very tough on a mac.

Steps to install ns-2.34 –

1. Make sure you have the latest Xcode.

2. Download ns-allinone-2.34 from here.

3. Extract the downloaded tar package in it to the /Users/username/ path of your mac.   (You can get to know your username by executing “who” on your terminal )

4. Now go to the ns-allinone-2.34 folder and open the “install” file using a text editor.

5. Delete its contents and copy paste the file present in this link

6. Now open a terminal and run “./install”

7. I have encountered a lot of errors here, but finally it installed successfully.(If you get stuck, leave a comment)

8. After you get “ns-allinone package has been installed successfully.” on your terminal, execute this command in the same folder

echo “PATH=/Users/username/ns-allinone-2.34/bin:$PATH” > .bashrc

9. Next goto your home directory or just execute ‘cd’ on your terminal.

10. Present here is a hidden file called ‘.profile’. Open the file “.profile” using a text editor and add these lines –

export PATH=$PATH:/Users/username/ns-allinone-2.34/bin:/Users/username/ns-allinone-2.34/tcl8.4.18/unix:/Users/username/ns-allinone-2.34/tk8.4.18/unix

export LD_LIBRARY_PATH=/Users/username/ns-allinone-2.34/otcl-1.13:/Users/username/ns-allinone-2.34/lib

export TCL_LIBRARY=/Users/username/ns-allinone-2.34/tcl8.4.18/library

11. Run “source ~/.profile” in the terminal to refresh the terminal with the added comments in the .profile file.

12. To test if its working, download example file from here.

To know the working of the code you can go here.

13.The tcl file can be run by executing “ns example1b.tcl” on your terminal.

Source –



How to Install ns-2 on Mac OS X 10.7 LION

22 thoughts on “How to Install ns-2 on Mac OS X 10.7 LION

  1. Hello,

    Thanks a lot for this! I followed your instructions and I successfuly installed ns2 .but as I did not find ‘.profile’ on my home directory (or /Users/username/ ) I creted this file in /Users/username/ and wrote the lines that you propsed on it. after I execute ./validate and these tests fail:

    validate overall report: some portable tests failed:
    ./test-all-newreno ./test-all-sack ./test-all-tcpOptions ./test-all-tcpLinux ./test-all-tcpHighspeed ./test-all-red ./test-all-cbq ./test-all-webtraf
    some non-portable tests also failed:
    ./test-all-srm ./test-all-smac-multihop ./test-all-hier-routing ./test-all-algo-routing ./test-all-mcast ./test-all-vc ./test-all-session ./test-all-mixmode ./test-all-webcache ./test-all-mcache ./test-all-plm ./test-all-wireless-tdma
    to re-run a specific test, cd tcl/test; ./test-all-TEST-NAME

    Do you know what should I do?
    Thanks in advance for your reply.

    1. I am sorry but I have no idea why it is failing. I am pretty sure that .profile file is created by default on mac. I Will check on that and let you know.

      1. Thanks for your reply, I read in the official Nsnam Troubleshooting page that “ns-2 is known to have problems with some validation tests on certain platforms due to 64-bit problems”, I have a 64-bit processor (Core i7) maybe that’s the reason why these tests fail. About ‘.profile’, I actually looked among all hidden files in home directory and even other directories but couldn’t find it, that is why I created it.

    1. You probably have a space character anywhere in your directory (check it via the ‘pwd’ command in the directory of the ‘install’). Probably you just need to place your file in a map so there is nowhere a space character in the directory name of ‘install’

  2. Samudra says:

    Hey Ashwin,

    Thanks for all this guide. I have one additional step to include to these.
    This step is missing from your instructions and has to deal with the .profile file that we create and modify.
    This step has to be executed after Step 10 and before Step 11 in your instructions.
    I am calling this step 10.1.

    10.1 Type source .profile in your terminal.

    On performing this step, one will then be able to run the example.



  3. Gh Gh says:

    Hi Ashwin,

    Thanks a lot for your post, At step 6 (./install) I get the following error, it would be great if you can help me to fix it. Thanks a lot

    * Build tcl8.4.18
    ./install: line 437: autoconf: command not found
    loading cache ./config.cache
    checking whether to use symlinks for manpages… no
    checking whether to compress the manpages… no
    checking whether to add a package name suffix for the manpages… no
    checking for gcc… no
    checking for cc… no
    configure: error: no acceptable cc found in $PATH
    tcl8.4.18 configuration failed! Exiting …
    Tcl is not part of the ns project. Please see
    to see if they have a fix for your platform.

    1. Sawsan Alkhdair says:

      As the error says : Tcl is not part of the ns project. This is because you replaced the content of “install” file by the content provided in the link as mentioned in this blog and the new content has tcl8.4.18 but the folder of ns-allinone-2.34 that extracted has a tcl file with name tcl8.5.10 so what you need to do is keep the original content of the “install” file or only keep the part of tcl only 🙂 good luck

  4. Asad says:

    During installation this error occurred:

    ist -o wish
    ld: library not found for -lX11
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [wish] Error 1
    tk8.4.18 make failed! Exiting …
    For problems with Tcl/Tk see

    I’d be grateful if you could help

  5. Farhan says:

    when I install it on my Mac then this error is coming. kindly help me in this regard.

    /Users/farhanmasud/ns-allinone-2.34/tk8.4.18/unix/../generic/tk.h:81:11: fatal error:
    ‘X11/Xlib.h’ file not found
    # include
    1 error generated.
    make: *** [tk3d.o] Error 1
    tk8.4.18 make failed! Exiting …
    For problems with Tcl/Tk see

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s