Vous êtes sur la page 1sur 9

Virginia Tech n ECE 5984: Network Performance, Design, and Management n Spring 2002

Beginners Guide to ns2 Installation and Basic Usage


(Updated 1/28/2002)

Introduction

The Network Simulator (ns2) [1] network simulation package will be the supported tool for this class. You may run ns2 using the ECE Graduate Workstation Laboratory or you can install it on your own Linux or Microsoft Windows computer. This document provides instructions for installing and running ns2 on Windows, based on [3] and [4]. Installing and running ns2 in Linux is not covered in this document; further information is provided by [2]. You will need to install the following packages. Tcl Tk Otcl Tclcl Ns2 Nam Tracegraph (for Windows), or Xgraph (for Unix)

Tcl, Tk, Otcl, and Tclcl are support programs that are used by ns2, which is the simulation program. Nam is the network simulator which provides visual views of the network simulation. Tracegraph is used to obtain statistics and produce graphical results under the Windows platform. Alternatively, if you are installing under Unix, Xgraph is used for the same purpose. This installation tutorial covers only the installation steps required for Windows. For instructions on Unix installation, see [1]. The zip file available in the course website contains only the precompiled version of ns2 and nam for Windows. If you want to install the full sources of ns2 and nam, you can download the sources from [1]. For the purpose of the class, a precompiled version of ns2 and nam are sufficient and can save some space. Questions about ns2 should be posted to the ns2 forum at your class web site. Corrections and updates should be sent to Raymond Law (rlaw@vt.edu). 2 References Here are some

Additional information about installing ns2 is available on the web. helpful sites. [1] The Network Simulator - ns-2, http://www.isi.edu/nsnam/ns/

[2] The Network Simulator: Building Ns, http://www.isi.edu/nsnam/ns/ns-build.html [3] How to Compile Ns2 on Windows Platform, http://www.isi.edu/nsnam/ns/ns-win32build.html [4] Installing ns on Windows ME/2000, http://www.public.iastate.edu/~magico/nsFiles/InstallNS1.html [5] Ns Manual, http://www.isi.edu/nsnam/ns/ns-documentation.html

[6] Tutorial for the Network Simulator ns, http://www.isi.edu/nsnam/ns/tutorial/index.html [7] Tracegraph Program Download Page, http://www.geocities.com/tracegraph/ 3 3.1 Preliminaries System Requirements

To successfully install ns2, you system must meet the following requirements. 3.2 Windows 2000 Microsoft Visual C++ 6.0 or above Approximately 70 MB of space for precompiled ns2 binary, or 145+50 (nam) MB of space for full ns2 and nam source Making a Network Simulator Directory

First, you have to decide on a directory to place the ns2 code and its associated components. This installation tutorial will assume the C:\NetSim directory. Throughout the installation, a MS-DOS command prompt is needed to compile and install the different components. In Windows 2000, make sure you use the full functional command prompt by going to Start Menu, Run, and then type cmd (i.e. do not type command). cmd.exe has full functionalities while command.com does not. For Windows 95/98, there is not cmd, so command is fine. To create the ns2 directory in MS-DOS prompt, type the following: D:\>C: C:\>mkdir NetSim C:\>cd NetSim 3.3 Setting up Microsoft Visual C++ Environment Variables

Microsoft Visual C++ needs to be set up to use the command line compiler and linker in a MS-DOS prompt. Type the following in MS-DOS prompt: C:\>cd C:\NetSim C:\>vcvars32.bat 3.4 Downloading the Sources

To make the download process easier, a single zipped file containing all necessary files is available. You can download this file, ns2.zip, from the class web site. Otherwise, you can download the following components separately from [2]. tcl-8.3.2 tk-8.3.2 otcl-1.0a7 tclcl-1.0b11

ns-2.1b8a-win use either the precompiled binary or the full source, see section 4.5 nam-1.0a10 use either the precompiled binary or the full source, see section 4.6 trgraph120beng and mglinstaller (for Windows, covered here), or xgraph-12.1 (for Unix, not covered here) for obtaining statistics and plotting graphs

No matter whichever download method you choose, the compressed files are in .zip or .tar.gz format and WinZip can be used to unzip the files. 3.5 Decompressing the Source Files

Use WinZip to unzip the downloaded files into their respective directories. The simple and easy way to do this is to place the download files in the directory C:\NetSim, and double click the files in the order given above. This action will create the directories for each necessary component. Make sure you do not change the directory names after decompression because the makefiles decompressed are dynamically generated and are based on this directory structures. Decompress the files tcl-8.3.2.tar.gz, tk-8.3.2.tar.gz, otcl1.0a7.tar.gz, and tclcl-1.0b11.tar.gz. Decompress also ns-2.1b8awin.tar.gz and nam-1.0a10.tar.gz if installing the full sources. You should see a directory structure similar to the following: C: 9 NetSim 9 9 9 9 9 9 tcl8.3.2 tk8.3.2 otcl-1.0a7 tclcl-1.0b11 ns-2.1b8a-win nam-1.0a10

Tracegraph is installed after ns2 installation is completed, and thus its files are not uncompressed yet. 4 Installation

The ns2 installation consists of several installs of the necessary components. These components must be installed in the following order: tcl-8.3.2 tk-8.3.2 otcl-1.0a7 tclcl-1.0b11 ns-2.1b8a-win

nam-1.0a10 trgraph120beng

Each of the following subsection contains instructions for installing each of these components in the above order. Many of these installations require changes to the makefiles. If you use Notepad to modify these files, make sure the extension is still .vc when you save. This can be done by putting double quotes around the filename in Save As (i.e. makefile.vc will save as makefile.vc, but makefile.vc will save as makefile.vc.txt). 4.1 4.1.1 Installing Tcl Modifying the Makefiles

In the file C:\NetSim\tcl8.3.2\win\makefile.vc, change the following lines: Before: After: INSTALLDIR = c:\Progra~1\Tcl INSTALLDIR = c:\NetSim\tcl8.3.2

Make sure the paths to MSVC are correct. Depending on the version of MSVC you have, one of the following should apply. Due to the limitation of DOS filenames, your system may have micro~2, or micro~3, etc. Microsoft Visual C++ is assumed for the rest of the tutorial. IMPORTANT: If you have Microsoft Visual Studio, you need to make the necessary changes in the batch files. Visual Studio: Visual C++: Visual Studio: Visual C++: 4.1.2 TOOLS32 = c:\Progra~1\devstudio\vc TOOLS32 = c:\Progra~1\micros~4\vc98 TOOLS32_rc = c:\Progra~1\devstudio\sharedide TOOLS32_rc = c:\Progra~1\micros~4\common\msdev98

Compiling and Installing the Sources

Nmake is the Microsoft Visual C++ command line compiler and is used to compile the sources for ns2. Open up a MS-DOS prompt and change to the appropriate directory. Then use nmake to compile the source. The option /f means using the following argument as the file to be compiled. I would recommend putting the following lines in a batch file (.bat) and just run the batch file. A set of batch files are pre-written for this purpose and is available at in the ns2.zip file. The batch file to use for installing Tcl is named install_tcl.bat. cd C:\NetSim\tcl8.3.2\win c:\progra~1\micros~4\vc98\bin\nmake /f makefile.vc c:\progra~1\micros~4\vc98\bin\nmake /f makefile.vc install 4.2 4.2.1 Installing Tk Modifying the Makefiles

In the file C:\NetSim\tk8.3.2\win\makefile.vc, change the following lines: Before: TCLDIR = ..\..\tcl8.3

After: Before: After:

TCLDIR = ..\..\tcl8.3.2 INSTALLDIR = c:\progra~1\tcl INSTALLDIR = c:\NetSim\tcl8.3.2

Visual Studio: Visual C++: Visual Studio: Visual C++: 4.2.2

TOOLS32 = c:\Progra~1\devstudio\vc TOOLS32 = c:\Progra~1\micros~4\vc98 TOOLS32_rc = c:\Progra~1\devstudio\sharedide TOOLS32_rc = c:\Progra~1\micros~4\common\msdev98

Compiling and Installing the Sources

Run the following commands in MS-DOS prompt, or use the batch file named install_tk.bat. cd C:\NetSim\tk8.3.2\win c:\progra~1\micros~4\vc98\bin\nmake /f makefile.vc c:\progra~1\micros~4\vc98\bin\nmake /f makefile.vc install 4.2.3 Setting up the Tcl/Tk Path

Several paths need to be added to the search path of the current MS-DOS prompt in order for ns2 to find Tcl. These paths can be added to the autoexec.bat or autoexec.nt so that the paths are properly added every time you start a MS-DOS prompt. However, you dont always start a MS-DOS prompt to run ns2. If the paths of all programs you use are added to the autoexec.bat, it only delays the time to find the right executable to run. Therefore, it is recommended that when you want to run ns2, you start a MS-DOS prompt and run the batch file before using ns2. Run the following commands in MS-DOS prompt, or use the batch file named set_path.bat to set up the paths for running ns2. PATH %PATH%;C:\NetSim\tcl8.3.2\bin;C:\NetSim\ns-2.1b8awin;C:\NetSim\nam-1.0a10-win32;C:\NetSim 4.3 4.3.1 Installing Otcl Modifying the Makefiles

In the file C:\NetSim\otcl-1.0a7\makefile.vc, change the following lines: Visual Studio: Visual C++: Before: After: Before: After: TOOLS32 = c:\Progra~1\devstudio\vc TOOLS32 = c:\progra~1\micros~4\VC98

OTCL_DIR = ..\otcl OTCL_DIR = ..\otcl-1.0a7 STATIC_TCLTK = 1 # STATIC_TCLTK = 1

4.3.2

Compiling the Sources

Run the following commands in MS-DOS prompt, or use the batch file named install_otcl.bat. cd C:\NetSim\otcl-1.0a7 c:\progra~1\micros~4\vc98\bin\nmake /f makefile.vc 4.4 4.4.1 Installing Tclcl Modifying the Makefiles

In the file C:\NetSim\tclcl-1.0b11\conf\makefile.win, change the following lines: Visual Studio: Visual C++: Before: After: TOOLS32 = c:\Progra~1\devstudio\vc MSVCDIR = c:\progra~1\micros~4\VC98

LOCAL_SRC = c:\research\vint\ns-allinone-2.1b7 LOCAL_SRC = c:\NetSim

Make sure the version numbers for tcl and tk are correct. TCL_SUFFIX = 8.3.2 TK_SUFFIX = 8.3.2 Before: After: Before: After: 4.4.2 OTCL_DIR = $(LOCAL_SRC)\otcl-1.0a6 OTCL_DIR = $(LOCAL_SRC)\otcl-1.0a7 TCLCL_DIR = $(LOCAL_SRC)\tclcl-1.0b10 TCLCL_DIR = $(LOCAL_SRC)\tclcl-1.0b11

Compiling the Sources

The /I option is used to suppress the error that an existing executable c:\NetSim\tclcl1.0b11\tcl2c++.exe cannot be found. Of course it cannot be found since it hasnt been previously installed. This error comes up when I ran the installation. Note that the /I option is not recommended for usual compilation. Run the following commands in MS-DOS prompt, or use the batch file named install_tclcl.bat. cd C:\NetSim\tclcl-1.0b11 c:\progra~1\micros~4\vc98\bin\nmake /I /f makefile.vc 4.5 Installing Ns-2

You can download a precompiled version of ns2 (ns-2.1b8a-win32.exe) from [1], also available from the zip file we provide. This is a quick and easy way to install ns2. In this class, you will be given code for the model or you will write your own model. Therefore, you do not need to modify the existing ns2 code. For the purpose of this class, this type of installation will suffice.

However, if you already have experience with ns2 or plan to use ns2 for further research, a more complicated installation is recommended. This method requires installing the full source of ns2 (~75 MB) and takes a longer time. The steps involved are very similar to those for installing Tclcl. If you choose to install the precompiled version, copy the file ns-2.1b8a.exe to the C:\NetSim directory and rename it as ns. You can type ns in MS-DOS prompt to invoke ns2. If you choose to install the full source, download and decompress the file ns-src2.1b8a-win.tar.gz from [1] and read the Appendix. Now ns2 has been installed in your computer. To invoke ns2, open an MS-DOS prompt, run the batch file set_path.bat, and type ns. 4.6 Installing nam

IMPORTANT: It seems there are some inconsistencies between Unix and Windows that the makefiles fail to account for. The precompiled binary is recommended since you wont be modifying nam source in this class. Nam is the network simulation animator that animates the network simulation done by ns2. It provides a visual view of the network simulation. Although nam is optional but it is recommended that you install it so that you can see what is going on during the simulation. Similarly, you can choose to install nam as a precompiled binary. Or you can choose to install the full nam source. If you choose to install the precompiled version, copy the file nam-1.0a10-win32.exe to the C:\NetSim directory and rename it as nam. You can type nam in MS-DOS prompt to invoke nam. Skip sections 4.6.1 and 4.6.2. If you choose to install the full source, download and decompress the file nam-src1.0a10.tar.gz from [1] and read sections 4.6.1 and 4.6.2. However, instructions are not available. You can try asking in the ns mailing list for some help. 4.7 Installing Tracegraph

Xgraph is the program to plot graphs for nam. However, it can only work in Unix. In order to obtain graphical results from ns2 simulation in Windows, tracegraph must be installed. In addition, the Matlab Graphics Run Time Libraries must also be installed. You can download both Mglinstaller.zip and trgraph120beng.zip from Jaroslaw Maleks website [7]. To install these two programs, follow the steps below: Unzip the file Mglinstaller.zip to extract the file mglinstaller.exe. Double click the file mglinstaller.exe. When prompted, enter C:\NetSim\mgl as the install path, and press Enter. Now the Matlab Graphics Run Time Libraries has been installed. Unzip the file trgraph120beng.zip into C:\NetSim\mgl\bin\win32. Add C:\NetSim\mgl\bin\win32 to the system path. The file set_path.bat should take care of this.

Ns2 Basics

The official ns2 documentation is the Ns Manual [5], which is quite difficult to read if you are new to ns2. The Tutorial for the Network Simulator ns [6] provides an easy to read introduction and basic usage to ns2. It is a very good tutorial for a ns2 beginner. Moreover, a set of Powerpoint slides, which covers some basic usages and examples, will be posted to the course website.

Appendix This appendix contains the instructions for installing the source of ns2. A.1 Modifying the Makefiles In the file C:\NetSim\ns-2.1b8a-win\conf\makefile.win, change the following lines: Visual Studio: Visual C++: Before: After: MSVCDIR = c:\Progra~1\devstudio\vc MSVCDIR = c:\progra~1\micros~4\VC98

LOCAL_SRC = c:\research\vint\ns-allinone-2.1b7 LOCAL_SRC = c:\NetSim

Make sure the version numbers for tcl and tk are correct. TCL_SUFFIX = 8.3.2 TK_SUFFIX = 8.3.2 Before: After: Before: After: A.2 OTCL_DIR = $(LOCAL_SRC)\otcl-1.0a7 OTCL_DIR = $(LOCAL_SRC)\otcl-1.0a7 TCLCL_DIR = $(LOCAL_SRC)\tclcl-1.0b11 TCLCL_DIR = $(LOCAL_SRC)\tclcl-1.0b11

Installing the Sources

This is a fairly long process. Depending on the speed of your computer, it may take from 10 to 30 minutes. cd C:\NetSim\ns-2.1b8a-win c:\progra~1\micros~4\vc98\bin\nmake /f makefile.vc

Vous aimerez peut-être aussi