📄 nsbasic.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0049)http://www.isi.edu/nsnam/ns/tutorial/nsbasic.html -->
<HTML><HEAD><TITLE>Marc Greis' Tutorial for the UCB/LBNL/VINT Network Simulator "ns"</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.3199" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff>
<H1 align=center>III. The Basics</H1>
<P>[<A href="http://www.isi.edu/nsnam/ns/tutorial/nsdoc.html">Previous
section</A>] [<A href="http://www.isi.edu/nsnam/ns/tutorial/nsscript1.html">Next
section</A>] [<A href="http://www.isi.edu/nsnam/ns/tutorial/nsindex.html">Back
to the index</A>] </P>
<HR>
<A name=inst>
<P><STRONG>III.1. Downloading/Installing ns&nam</STRONG><BR>You can build ns
either from the the various packages (Tcl/Tk, otcl, etc.), or you can download
an 'all-in-one' package. I would recommend that you start with the all-in-one
package, especially if you're not entirely sure which packages are installed on
your system, and where exactly they are installed. The disadvantage of the
all-in-one distribution is the size, since it contains some components that you
don't need anymore after you compiled ns and nam. It's still good for first
tests, and you can always switch to the single-package distribution later. </P>
<P>Note: The all-in-one package only works on Unix systems. </P>
<P>You can download the package from the <A
href="http://www.isi.edu/nsnam/ns/ns-build.html">ns download page</A> at UCB. If
you have any problems with your installation, take a look at the <A
href="http://www.isi.edu/nsnam/ns/ns-problems.html">installation problems
page</A> on their server. If that also doesn't solve your problem, you might
want to ask the <A href="http://www.isi.edu/nsnam/ns/ns-lists.html">ns-users
mailing list</A>. </P>
<P>After the installation is complete, you should make sure that your path
points to the 'ns-allinone/bin' directory (if you installed the ns-allinone
package) where links to the ns and nam executables in the 'ns-2' and 'nam-1'
directories can be found or (if you built ns and nam from the pieces) let your
path point directly to the directories with the ns and nam executables. </P>
<P>On some systems you will also have to make sure that ns can find the library
'libotcl.so'. If you installed the ns-allinone package, it should be in
'ns-allinone/otcl/'. On Solaris systems you would have to add this path to the
'LD_LIBRARY_PATH' environment variable. For help with other systems, consult the
<A href="http://www.isi.edu/nsnam/ns/ns-problems.html">installation problem
page</A>, the <A href="http://www.isi.edu/nsnam/ns/ns-lists.html">ns-users
mailing list</A> or your local Unix gurus. </P>
<P>A note concerning the ns-allinone version 2.1b3: There is a bug in it which
causes some problems on Solaris systems when nam trace generation is turned on.
You can either download <A
href="http://www.isi.edu/nsnam/dist/vint/ns-allinone-2.1b2.tar.gz">ns-allinone
version 2.1b2</A> instead or go to the <A
href="http://www.isi.edu/nsnam/ns/index.html">ns web page</A> to download a
current snapshot of ns. If you do that, you have to unzip and untar the file in
your allinone directory. Then you change into the new directory and run
'./configure', then 'make'. </P>
<HR>
<A name=ns><STRONG>III.2. Starting ns</STRONG>
<P>You start ns with the command 'ns <tclscript>' (assuming that you are
in the directory with the ns executable, or that your path points to that
directory), where '<tclscript>' is the name of a Tcl script file which
defines the simulation scenario (i.e. the topology and the events). You could
also just start ns without any arguments and enter the Tcl commands in the Tcl
shell, but that is definitely less comfortable. For information on how to write
your own Tcl scripts for ns, see <A
href="http://www.isi.edu/nsnam/ns/tutorial/nsscript1.html">section IV</A>. </P>
<P>Everything else depends on the Tcl script. The script might create some
output on stdout, it might write a trace file or it might start nam to visualize
the simulation. Or all of the above. These possibilities will all be discussed
in later sections. </P>
<HR>
<A name=nam><STRONG>III.3. Starting nam</STRONG>
<P>You can either start nam with the command 'nam <nam-file>' where
'<nam-file>' is the name of a nam trace file that was generated by ns, or
you can execute it directly out of the Tcl simulation script for the simulation
which you want to visualize. The latter possibility will be described in <A
href="http://www.isi.edu/nsnam/ns/tutorial/nsscript1.html">Section IV</A>. For
additional parameters to nam, see the <A
href="http://www.isi.edu/nsnam/ns/tutorial/nam.txt">nam manual page</A>. Below
you can see a screenshot of a nam window where the most important functions are
being explained. </P>
<P><IMG src="nsbasic.files/namss1.gif"> </P>
<HR>
<P>[<A href="http://www.isi.edu/nsnam/ns/tutorial/nsdoc.html">Previous
section</A>] [<A href="http://www.isi.edu/nsnam/ns/tutorial/nsscript1.html">Next
section</A>] [<A href="http://www.isi.edu/nsnam/ns/tutorial/nsindex.html">Back
to the index</A>] </P>ns-users <BR>
<ADDRESS><A
href="mailto:ns-users@isi.edu">ns-users@isi.edu</A></ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -