⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 marc greis' tutorial for the ucb-lbnl-vint network simulator ns.mht

📁 ns2方面比较初级的教程
💻 MHT
📖 第 1 页 / 共 2 页
字号:
<P>Random traffic connections of TCP and CBR can be setup between =
mobilenodes=20
using a traffic-scenario generator script. This traffic generator script =
is=20
available under ~ns/indep-utils/cmu-scen-gen and is called cbrgen.tcl. =
It can be=20
used to create CBR and TCP traffics connections between wireless =
mobilenodes. In=20
order to create a traffic-connection file, we need to define the type of =
traffic=20
connection (CBR or TCP), the number of nodes and maximum number of =
connections=20
to be setup between them, a random seed and incase of CBR connections, a =
rate=20
whose inverse value is used to compute the interval time between the CBR =
pkts.=20
So the command line looks like the following:=20
<TABLE cellPadding=3D5 bgColor=3D#eeeeee>
  <TBODY>
  <TR>
    <TD><CODE><PRE>ns cbrgen.tcl [-type cbr|tcp] [-nn nodes] [-seed =
seed] [-mc connections]
[-rate rate]
</PRE></CODE></TD></TR></TBODY></TABLE></P>
<P>The start times for the TCP/CBR connections are randomly generated =
with a=20
maximum value set at 180.0s. Go through the tcl script cbrgen.tcl for =
the=20
details of the traffic-generator implementation. </P>
<P>For example, let us try to create a CBR connection file between 10 =
nodes,=20
having maximum of 8 connections, with a seed value of 1.0 and a rate of =
4.0. So=20
at the prompt type:=20
<TABLE cellPadding=3D5 bgColor=3D#eeeeee>
  <TBODY>
  <TR>
    <TD><CODE><PRE>ns cbrgen.tcl -type cbr -nn 10 -seed 1.0 -mc 8 -rate =
4.0 &gt; cbr-10-test
</PRE></CODE></TD></TR></TBODY></TABLE></P>
<P>From cbr-10-test file (into which the output of the generator is =
redirected)=20
thus created, one of the cbr connections looks like the following:=20
<TABLE cellPadding=3D5 bgColor=3D#eeeeee>
  <TBODY>
  <TR>
    <TD><CODE><PRE>#
# 2 connecting to 3 at time 82.557023746220864
#
set udp_(0) [new Agent/UDP]
$ns_ attach-agent $node_(2) $udp_(0)
set null_(0) [new Agent/Null]
$ns_ attach-agent $node_(3) $null_(0)
set cbr_(0) [new Application/Traffic/CBR]
$cbr_(0) set packetSize_ 512
$cbr_(0) set interval_ 0.25
$cbr_(0) set random_ 1
$cbr_(0) set maxpkts_ 10000
$cbr_(0) attach-agent $udp_(0)
$ns_ connect $udp_(0) $null_(0)
$ns_ at 82.557023746220864 "$cbr_(0) start"
</PRE></CODE></TD></TR></TBODY></TABLE>Thus a UDP connection is setup =
between=20
node 2 and 3. Total UDP sources (chosen between nodes 0-10) and total =
number of=20
connections setup is indicated as 5 and 8 respectively, at the end of =
the file=20
cbr-10-test. </P>
<P>Similarly TCP connection files can be created using "type" as tcp. An =
example=20
would be:=20
<TABLE cellPadding=3D5 bgColor=3D#eeeeee>
  <TBODY>
  <TR>
    <TD><CODE><PRE>ns cbrgen.tcl -type tcp -nn 25 -seed 0.0 -mc 8 &gt; =
tcp-25-test
</PRE></CODE></TD></TR></TBODY></TABLE>A typical connection from =
tcp-25-test=20
looks like the following:=20
<TABLE cellPadding=3D5 bgColor=3D#eeeeee>
  <TBODY>
  <TR>
    <TD><CODE><PRE>#
# 5 connecting to 7 at time 163.0399642433226
#
set tcp_(1) [$ns_ create-connection  TCP $node_(5) TCPSink $node_(7) 0]
$tcp_(1) set window_ 32
$tcp_(1) set packetSize_ 512
set ftp_(1) [$tcp_(1) attach-source FTP]
$ns_ at 163.0399642433226 "$ftp_(1) start"
</PRE></CODE></TD></TR></TBODY></TABLE></P><A name=3Dsecond></A>
<P><STRONG>XI.2. Creating node-movements for wireless scenarios.=20
</STRONG><BR></P>
<P>The node-movement generator is available under=20
~ns/indep-utils/cmu-scen-gen/setdest directory and consists of =
setdest{.cc,.h}=20
and Makefile. CMU's version of setdest used system dependent /dev/random =
and=20
made calls to library functions initstate() for generating random =
numbers. That=20
was replaced with a more portable random number generator (class RNG) =
available=20
in ns. In order to compile the revised setdest.cc do the following: =
<BR>1. Go to=20
ns directory and run "configure" (you probably have done that already =
while=20
building ns). This creates a makefile for setdest. <BR>2.Go to=20
indep-utils/cmu-scen-gen/setdest. Run "make" , which first creates a =
stand-alone=20
object file for ~ns/rng.cc (the stand-alone version doesnot use Tclcl =
libs) and=20
then creates the executable setdest. <BR>3. Run setdest with arguments =
as shown=20
below:=20
<TABLE cellPadding=3D5 bgColor=3D#eeeeee>
  <TBODY>
  <TR>
    <TD><CODE><PRE>./setdest [-n num_of_nodes] [-p pausetime] [-s =
maxspeed] [-t simtime] \
      [-x maxx] [-y maxy] &gt; [outdir/movement-file]
</PRE></CODE></TD></TR></TBODY></TABLE></P>
<P>Lets say we want to create a node-movement scenario consisting of 20 =
nodes=20
moving with maximum speed of 10.0m/s with an average pause between =
movement=20
being 2s. We want the simulation to stop after 200s and the topology =
boundary is=20
defined as 500 X 500. So our command line will look like:=20
<TABLE cellPadding=3D5 bgColor=3D#eeeeee>
  <TBODY>
  <TR>
    <TD><CODE><PRE>./setdest -n 20 -p 2.0 -s 10.0 -t 200 -x 500 -y 500 =
&gt; scen-20-test
</PRE></CODE></TD></TR></TBODY></TABLE></P>
<P>The output is written to stdout by default. We redirect the output to =
file=20
scen-20-test. The file begins with the initial position of the nodes and =
goes on=20
to define the node movements.=20
<TABLE cellPadding=3D5 bgColor=3D#eeeeee>
  <TBODY>
  <TR>
    <TD><CODE><PRE>$ns_ at 2.000000000000 "$node_(0) setdest =
90.441179033457 44.896095544010
1.373556960010"
</PRE></CODE></TD></TR></TBODY></TABLE>This line from scen-20-test =
defines that=20
node_(0) at time 2.0s starts to move toward destination (90.44, 44.89) =
at a=20
speed of 1.37m/s. These command lines can be used to change direction =
and speed=20
of movement of mobilenodes. </P>
<P>Directives for GOD are present as well in node-movement file. The =
General=20
Operations Director (GOD) object is used to store global information =
about the=20
state of the environment, network, or nodes that an omniscent observer =
would=20
have, but that should not be made known to any participant in the =
simulation.=20
</P>
<P>Currently, the god object is used only to store an array of the =
shortest=20
number of hops required to reach from one node to an other. The god =
object does=20
not calculate this on the fly during simulation runs, since it can be =
quite time=20
consuming. The information is loaded into the god object from the =
movement=20
pattern file where lines of the form=20
<TABLE cellPadding=3D5 bgColor=3D#eeeeee>
  <TBODY>
  <TR>
    <TD><CODE><PRE>$ns_ at 899.642 "$god_ set-dist 23 46 2"
</PRE></CODE></TD></TR></TBODY></TABLE>are used to load the god object =
with the=20
knowledge that the shortest path between node 23 and node 46 changed to =
2 hops=20
at time 899.642. </P>
<P>The setdest program generates node-movement files using the random =
waypoint=20
algorithm. These files already include the lines to load the god object =
with the=20
appropriate information at the appropriate time. </P>
<P>Another program calcdest (also available in=20
~ns/indep-utils/cmu-scen-gen/setdest) can be used to annotate movement =
pattern=20
files generated by other means with the lines of god information. =
calcdest makes=20
several assumptions about the format of the lines in the input movement =
pattern=20
file which will cause it to fail if the file is not formatted properly. =
If=20
calcdest rejects a movement pattern file you have created, the easiest =
way to=20
format it properly is often to load it into ad-hockey and then save it =
out=20
again. If ad-hockey can read your input correctly, its output will be =
properly=20
formatted for calcdest. </P>
<P>Both calcdest and setdest calculate the shortest number of hops =
between nodes=20
based on the nominal radio range, ignoring any effects that might be =
introduced=20
by the propagation model in an actual simulation. The nominal range is =
either=20
provided as an argument to the programs, or extracted from the header on =
the=20
movement pattern file. </P>
<P>The path length information was used by the Monarch Project to =
analyze the=20
path length optimality of ad hoc network routing protocols, and so was =
printed=20
out as part of the CMUTrace output for each packet. </P>
<P>Other uses that CMU found for the information:=20
<LI>Characterizing the rate of topology change in a movement pattern.=20
<LI>Identifying the frequency and size of partitions.=20
<LI>Experimenting with the behavior of the routing protocols if the god=20
information is used to provide them with ``perfect'' neighbor =
information at=20
zero cost.=20
<P></P>
<P>Thus at the end of the node-movement file are listed information like =
number=20
of destination unreachable, total number of route and connectivity =
changes for=20
mobilenodes and the same info for each mobilenode. </P>
<P>The revised (more portable) version of setdest ( files revised are:=20
setdest{.cc,.h}, ~ns/rng{.cc,.h}, ~ns/Makefile.in ) should be available =
from the=20
latest ns distribution. If not, you could download the daily snapshot =
version of=20
ns from <A href=3D"http://www.isi.edu/nsnam/ns/ns-build.html">ns-build =
page</A>.=20
<HR>

<P>[<A =
href=3D"http://www.isi.edu/nsnam/ns/tutorial/nsscript6.html">Previous=20
section</A>] [<A =
href=3D"http://www.isi.edu/nsnam/ns/tutorial/nsindex.html">Back=20
to the index</A>] </P>
<P>VINT <BR>
<ADDRESS><A =
href=3D"mailto:ns-users@isi.edu">ns-users@isi.edu</A></ADDRESS>
<P></P></LI></BODY></HTML>

------=_NextPart_000_0000_01C82DEE.F32C9230--

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -