First, I would like to complain: the installation of NS2. it is too troublesome, and the installation tutorials on the Internet are all like this. Various problems may occur during the installation. It took more than two days to install cygwin and NS2. I am relieved that the installation process and experience of my younger brother have been shared here, we hope to provide some help to our friends who are struggling to install NS2. Cygwin is installed online, and ns2.28 is selected for NS2.
1. cygwin must be installed first.
This is directly downloaded from the official website of cygwin. There are many online installation tutorials for cygwin. Here we will just give a brief introduction. The most important thing is to remember to remove the selection mark of the hid obsolete package in the lower left corner when selecting the installation package so that all the required packages can be found. The following packages must be selected:
Gcc
Gcc-G ++
Gnuplot
Make
Patch
Perl
Tar
X-startup-Scripts
Xorg-x11-base
Xorg-x11-bin
Xorg-x11-devel
Xorg-x11-bin-dlls
Xorg-x11-bin-lndir
Xorg-x11-etc
Xorg-x11-fenc
Xorg-x11-fnts
Xorg-x11-libs-data
Xorg-x11-xwin
Libxt-devel
Libxmu-devel
Remember not to choose the two red packages. Then, wait for cygwin installation. After the installation is complete, generate a shortcut.
2. NS2. Installation
Download NS2. when cygwin is started for the first time, a folder named after your computer username will be generated under the installed directory. For example, if cygwin is installed on drive D with the username yyx, a D will be generated: \ cygwin \ home \ yyx file. If your user name is administrator, It is D: \ cygwin \ home \ administrator.
Copy the ns2-compressed package to the Directory D: \ cygwin \ home \ yyx, run cygwin, enter the directory (which should be in this directory by default after opening), and enter TAR
Xvfz ns-allinone-2.28.tar.gz, decompress the NS2.After decompression, be sure to change the two files before installing them. Remember! Remember! :
(1) D: \ cygwin \ yyx \ ns-allinone-2.28 \ nam-1.11 \ agent.h file on the seventh line of nullchange to 0, can not generate nam.exe. In fact, this can also be modified after the installation is complete, but it is more troublesome. The method is described later.
(2) D: \ cygwin \ yyx \ ns-allinone-2.28 \ tk8.4.5 \ Generic \ tkbind. c file after adding:
# Ifdef genericevent
/* Genericevent */0,
# Endif
I did not change step 2 at the beginning. The result is that the $ Nam: [Code omitted because of length] error occurs when executing NS example2.tcl, for example, 1:
Results A search on the Internet found that it is because of the NAM call of the TK components and the xproto-7.0.13 is not compatible with the (xproto-7.0.13 added a new genericevent) Anyway, I do not understand, there is no way can only be changed and then re-installed again. So remember to change it before installing it.
After modification, CD ns-allinone-2.28 in cygwin, and then enter./install for installation. Then, wait for the installation to complete.
After the installation is complete, set the path. Many people have said this on the Internet, but the most important thing is not to copy and paste it on the Internet. the bashrc file may be copied directly because of the operating system font or because some space or line breaks are added to the copied content, therefore, you can download a ultraedit Editor, in which you can enter the following lines of content in one word. the bashrvc file is relatively secure. Here, yyx is my file name. Remember to change it to your own file name. At the beginning, I copied and pasted the file. After loading it for more than a day, no command was found whether I entered startxwin. bat or directly entered ns. When I re-installed it, I typed it in one word, and then input ns to display the "%" symbol. At that time, it was ecstatic (but I entered startxwin. bat still shows that the command cannot be found. The specific reason is described later ).
Export ns_home =/home/yyx/ns-allinone-2.28
Export Path = $ ns_home/bin: $ ns_home/tcl8.4.5/Unix: $ ns_home/tk8.4.5/Unix: $ path
Export LD_LIBRARY_PATH = $ ns_home/tcl8.4.5/Unix: $ ns_home/tk8.4.5/Unix: $ ns_home/otcl-1.9: $ ns_home/lib: LD_LIBRARY_PATH
Export tcl_library = $ ns_home/tcl8.4.5/Library
After changing the sequence, some people may say that the input startxwin does not include the following. BAT, the X Window that I dreamed of after I tried to input only startxwin finally popped up (another piece of ecstasy! At that time, I was depressed. Why didn't I mention this in all the tutorials? I thought the environment variable was set wrong again. I looked for the reason everywhere, I still don't understand why I did it.) Example 2.
If all of you have changed the settings step by step, enter
CD ns-allinone-2.28/ns-2.28/ns-tutorial/Examples
NS example2.tcl
Then you can see the result (3), which indicates that the installation is successful.
Therefore, the entire ns2-installation procedure can be simplified to: decompress, change two files, install, change environment variables, and succeed!
I was just because I didn't change the file in the first place before installation, and the result was that nsm.exe could not be found after entering NS example2.tcl. I found it online, saying it was in home/yyx/ns-allinone-2.28/workshop. Step: first go to the home/yyx/ns-allinone-2.28/nam-1.11 directory and then run the command (. /configure & make & makeinstall) will be in the home/yyx/ns-allinone-2.28/nam-1.11directory will generate a nam.exefile, but I find that after executing this command is still not using nam.exe file, and the following error figure 4 appears:
Take a closer look at this error description, and I did not copy the D: \ cygwin \ yyx \ ns-allinone-2.28 \ nam-1.11 \ hosts file to the home/Sun/ns-allinone-2.28/bin directory. Now we have Nam. In fact, you only need to change the file at the very beginning. This problem will not occur. When the installation is complete, the nam.exe file will be automatically created.
After this problem is solved, if the second file I mentioned earlier has been changed before the installation, the operation will be successful. If the file is not changed, the following error occurs:
In this case, you can only change the file and then reinstall the NS2. Therefore, everyone must follow the steps I mentioned earlier. It cannot be guaranteed that everyone will succeed, but at least I have succeeded. Haha!