Preparation: ubuntu12.10has been successfully installed. The installation package contains the ns2installation file. Here I am using ns-allinone-2.33.tar and preparing two other patches:Tk-8.4-lastevent.patchAndTk-8.4.18-tkBind.patch
Step 1:Copy the ns2compressed package ns-allinone-2.33.tar.gz to the desktop, right-click and decompress it to the desktop, and copy the decompressed folder to the ready installation location,
For example, in my folder home/WL (WL is the login user name), create a new folder program and paste the folder of NS2.
Step 2:In the root user name or admin user, download and install the system package required for the ns-2.33 installation, the details are as follows:
First, enter apt-Get install build-essential in the terminal to download and install it. This step is for GCC and some essential installation;
Then, enter apt-Get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-Dev in the terminal to download and install tcl and TK;
Finally, enter apt-Get install libxmu-Dev in the terminal to download and install it. This step is for the installation of NAM.
Step 3: Check the GCC version. The version automatically installed by the system is generally higher than 4.0, but it is still necessary to check before installation. The terminal command is as follows:
Run ls/usr/bin/GCC-l or GCC -- rsion or GCC-V on the terminal. Mine is gcc4.7.2.
Because GCC 4.0 used LD-share to generate a shared library, but later than version 4.0, this command was changed to GCC-share.
Therefore, if the version is higher than gcc4.0, you need to make the following changes:
CD/home/Liu/Program/ns-allinone-2.33 // otcl-1.13
Do gedit Configure. In
Save the 77 rows and change shlib_ld = "LD-shared" to shlib_ld = "gcc-shared", and exit
Modify the configure 5,518th line shlib_ld = "LD-shared" to shlib_ld = "gcc-shared" and save and exit.
The above modification is in the form of terminal commands and can be opened directly in the view, provided that the "read and write" permission of the file is opened.
Step 4:Because I installed ns2.33, it is said that there are some problems, so I tested and installed the patch in advance. The specific steps are as follows:
(1) run the built-in instance for testing:/ns-allinone-2.33/ns-2.33/Tcl/EX/simple. TCL
Possible problems:
The system prompts the following,
[Code omitted because of length]
: No event type or button # Or keysym
While executing
"Bind ListBox <mousewheel> {
% W yview scroll [expr {-(% d/120) * 4}] Units
}"
Invoked from
"If {[TK windowingsystem] EQ" classic "| [TK windowingsystem] EQ" Aqua "}{
Bind ListBox <mousewheel> {
% W yview scroll [expr {-(% d)}] Units
}
Bind li ..."
Cause: It is said that ns2.33, which is caused by the incompatibility of the TK component called by NAM and the xproto-7.0.13 (the xproto-7.0.13 has added genericevent), So patch the ns2.33 before installing it. If no patch is installed, an error will be reported when NAM is called later.
Solution:
(1) prepared patch tk-8.4-lastevent.patch
Move this file to tk8.4.18 In the NS directory.
$ CD/home/Liu/Program/ns-allinone-2.33/tk8.4.18
$ Patch-P1 <tk-8.4-lastevent.patch
(2) Prepare the patch tk-8.4.18-tkBind.patch
Move the file tk-8.4.18-tkBind.patch to the ns-allinone-2.33 directory and run the following command:
$ Patch-P0 <tk-8.4.18-tkBind.patch
Step 5:Start to install and install NS2. The command is as follows:
Move CD/home/Liu/Program/ns-allinone-2.33/Under the NS2/
Install./install
PS: I thought the next step was several minutes of tumbling, and the installation was successful. However, we had to solve the following problems one by one:
1. after entering the installation command, the system prompts "Permission denied". Even though I am already a root user, the system still prompts "Permission denied". The solution is to modify the install permission, this is done in the view, as shown in
And then reinstall it.
The installation was finally started, but the following problems occurred:
1. Error 1: the following error occurs during ns2.34 installation:
Tools/ranvar. CC: In member function 'virtual double gammarandomvariable: Value ()':
Tools/ranvar. CC: 219: 70: Error: cannot call constructor 'gammarandomvariable: gammarandomvariable' directly
Tools/ranvar. CC: 219: 70: Error: for a function-style cast, remove the redundant ': gammarandomvariable'
Make: *** [tools/ranvar. O] Error 1
NS make failed!
See http://www.isi.edu/nsnam/ns/ns-problems.html for Problems
This is because the GCC version is not compatible with the simplified calling of internal functions of the class after it is upgraded. The solution is as follows:
Under the ns-allinone-2.34/ns-2.34/Tools Folder, locate the ranvar. CC file in the error prompt, open and find the corresponding row 219 Delete: gaammarandomvariable, save,
That is, return gammarandomvariable: gammarandomvariable (219 + Alpha _, beta _). Value () * POW (u, 1.0/Alpha _);
Change to: Return gammarandomvariable (1.0 + Alpha _, beta _). Value () * POW (u, 1.0/Alpha _);
Save and exit, and reinstall NS2.
2. Error 2: Re-type $./install in the NS directory,
Mobile/nakagami. CC: In member function 'virtual double nakagami: Pr (packetstamp *, packetstamp *, wirelessphy *)':
Mobile/nakagami. CC: 183: 73: Error: cannot call constructor 'erlangrandomvariable: erlangrandomvariable 'directly
Mobile/nakagami. CC: 183: 73: Error: for a function-style cast, remove the redundant ': erlangrandomvariable'
Mobile/nakagami. CC: 185: 67: Error: cannot call constructor 'gammarandomvariable: gammarandomvariable' directly
Mobile/nakagami. CC: 185: 67: Error: for a function-style cast, remove the redundant ': gammarandomvariable'
Make: *** [MOBILE/nakagami. O] Error 1
NS make failed!
See http://www.isi.edu/nsnam/ns/ns-problems.html for Problems
Solution:
In the ns-allinone-2.34/ns-2.34/mobile folder, locate the nakagami. CC file in the error prompt, open and find the corresponding row 183 Delete: erlangrandomvariable, save,
That is, convert the resultpower = erlangrandomvariable: erlangrandomvariable (Pr/m, int_m). Value () of the 183 rows ();
Changed to: resultpower = erlangrandomvariable (Pr/m, int_m). Value ();
In the ns-allinone-2.34/ns-2.34/mobile folder, locate the nakagami. CC file in the error prompt, open and find the corresponding row 185 Delete: gammarandomvariable, save,
That is, convert the resultpower = gammarandomvariable: gammarandomvariable (M, Pr/m). Value () of the 185 rows ();
Changed to: resultpower = gammarandomvariable (M, Pr/m). Value ();
Re-type $./install in the NS directory to install the SDK. If a similar problem occurs again, find the corresponding file and number of lines, and modify it. Until the installation is successful.
3.
In File sorted ded from MAC/mac-802_11Ext.cc: 66: 0:
MAC/mac-802_11Ext.h: In member function 'U _ int32_t phy_mibext: gethdrlen11 ()':
MAC/mac-802_11Ext.h: 175: 19: Error: expected primary-expression before 'struct'
MAC/mac-802_11Ext.h: 175: 41: Error: 'dh _ body' was not declared in this scope
MAC/mac-802_11Ext.h: 175: 51: Error: 'offsetof 'was not declared in this scope
MAC/mac-802_11Ext.h: 177: 3: Warning: control reaches end of non-void function [-wreturn-type]
Make: *** [MAC/mac-802_11Ext.o] Error 1
NS make failed!
Solutions to this problem:
If you get error like:
MAC/mac-802_11Ext.h: In member function 'U _ int32_t phy_mibext: gethdrlen11 ()':
MAC/mac-802_11Ext.h: 176: 19: Error: expected primary-expression before 'struct'
MAC/mac-802_11Ext.h: 176: 41: Error: 'dh _ body' was not declared in this scope
MAC/mac-802_11Ext.h: 176: 51: Error: 'offsetof 'was not declared in this scope
Open that file and add
# Include <cstddef>
To the header files.
Add # include <cstddef> In the ns-allinone-2.34 \ ns-2.34 \ Mac \ mac-802_11Ext.h File
Then reinstall.
4.
In File sorted ded from linkstate/LS. CC: 67: 0:
Linkstate/LS. h: in instantiation of 'void lsmap: eraseall () [with key = int; t = lsidseq] ':
Linkstate/LS. CC: 396: 28: required from here
Linkstate/LS. h: 137: 20: Error: 'erase' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of Instantiation [-fpermissive]
Linkstate/LS. h: 137: 20: Note: declarations in dependent base 'std: map, STD: Allocator> 'are not found by unqualified Lookup
Linkstate/LS. h: 137: 20: Note: Use 'this-> erase' instead
Make: *** [linkstate/LS. O] Error 1
NS make failed!
Modify the LS file: ns-2.35/linkstate/LS. h
137th rows
Void eraseall () {erase (basemap: Begin (), basemap: end ());}
Change to: void eraseall () {This-> erase (basemap: Begin (), basemap: end ());}
Then run./install again. After a while, the following prompt is displayed:
Installation is complete!
Step 6:As the prompt says, some configuration is required:
Return to the upper-level directory of the ns-allinone-2.33 and enter: sudo gedit. bashrc
Edit the following information at the end of the file and save it:
Path = "$ path:/home/WL/Program/ns-allinone-2.33/bin:/home/WL/Program/ns-allinone-2.33/tcl8.4.18/Unix: /home/WL/Program/ns-allinone-2.33/tk8.4.18/Unix"
LD_LIBRARY_PATH = "/home/WL/Program/ns-allinone-2.33/otcl-1.13:/home/WL/Program/ns-allinone-2.33/lib"
Tcl_library = "$ tcl_library:/home/WL/ns-allinone-2.33/tcl8.4.18/library"
PS: replace WL in the path with your own path
However, an error is displayed as follows:
The problem I encountered here is that it is not still opened in the program directory. bashrc, opened. bashrc is actually empty. It is wrong to directly edit the above content, that is, no environment variable is set.
Therefore, follow these steps:
Exit the original terminal, create a new terminal, and directly type the command: gedit.After bashrc press enter, the following correct non-empty. bashrc appears, and modify the content in the red line box of the edit command, for example:
Step 7:Verify whether the installation is successful: open another terminal, enter ns, and check whether the installation is successful. If the installation is successful, run the self-contained instance for testing: /ns-allinone-2.33/ns-2.33/Tcl/EX/simple. TCL.
Next, I entered ns on the terminal, but still got an error message indicating no installation. So I closed all open windows and re-typed the command: NS finally showed %, then, type NAM and the following dialog box is displayed:
At this point, the installation is successful, and it is really a wave of twists and turns!
Step 8:Install xgraph:
Run sudo apt-Get install xgraph and press enter to install xgraph. The installation is successful:
Finally, the verification example is completed,
First enter the directory/home/WL/Program/ns-allinone-2.33/ns-2.33/Tcl/ex, then type the command NS simple. TCL, and press Enter ,:
The above network simulation animation is displayed. So far, NS has been installed.