i have installed ns-2.34 using ns-allinone-package . i have problem
simulating energy model in existing code.
have attached the code :
# A 10-node example for ad-hoc simulation with DSDV
# Define options
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation
model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 10 ;# number of mobilenodes
set val(rp) DSDV ;# routing protocol
set val(x) 500 ;# X dimension of topography
set val(y) 400 ;# Y dimension of topography
set val(stop) 150 ;# time of simulation end
set opt(energymodel) EnergyModel ;
set opt(radiomodel) RadioModel ;
set opt(initialenergy) 1000 ;# Initial energy in
Joules
set ns [new Simulator]
set tracefd [open milind.tr w]
set windowVsTime2 [open win.tr w]
set namtrace [open milind.nam w]
$ns trace-all $tracefd
#$ns use-newtrace
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
#
# Create nn mobilenodes [$val(nn)] and attach them to the channel.
#
# configure the nodes
$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON
-energyModel $opt(energymodel) \
-idlePower 1.0 \
-rxPower 1.0 \
-txPower 2.0 \
-sleepPower 0.001 \
-transitionPower 0.2 \
-transitionTime 0.005 \
-initialEnergy $opt(initialenergy)
for {set i 0} {$i < $val(nn) } { incr i } {
set node_($i) [$ns node]
}
# Provide initial location of mobilenodes
$node_(0) set X_ 5.0
$node_(0) set Y_ 5.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 50.0
$node_(1) set Y_ 200.0
$node_(1) set Z_ 0.0
$node_(2) set X_ 150.0
$node_(2) set Y_ 200.0
$node_(2) set Z_ 0.0
$node_(3) set X_ 300.0
$node_(3) set Y_ 150.0
$node_(3) set Z_ 0.0
$node_(4) set X_ 30.0
$node_(4) set Y_ 100.0
$node_(4) set Z_ 0.0
$node_(5) set X_ 400.0
$node_(5) set Y_ 150.0
$node_(5) set Z_ 0.0
$node_(6) set X_ 400.0
$node_(6) set Y_ 200.0
$node_(6) set Z_ 0.0
$node_(7) set X_ 250.0
$node_(7) set Y_ 200.0
$node_(7) set Z_ 0.0
$node_(8) set X_ 300.0
$node_(8) set Y_ 240.0
$node_(8) set Z_ 0.0
$node_(9) set X_ 250.0
$node_(9) set Y_ 350.0
$node_(9) set Z_ 0.0
# Generation of movements
$ns at 10.0 "$node_(0) setdest 480.0 50.0 10.0"
$ns at 30.0 "$node_(0) setdest 230.0 55.0 5.0"
$ns at 70.0 "$node_(0) setdest 480.0 300.0 5.0"
# Set a TCP connection between node_(0) and node_(1)
set tcp [new Agent/TCP/Newreno]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node_(0) $tcp
$ns attach-agent $node_(1) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 10.0 "$ftp start"
# Printing the window size
proc plotWindow {tcpSource file} {
global ns
set time 0.01
set now [$ns now]
set cwnd [$tcpSource set cwnd_]
puts $file "$now $cwnd"
$ns at [expr $now+$time] "plotWindow $tcpSource $file" }
$ns at 10.1 "plotWindow $tcp $windowVsTime2"
# Define node initial position in nam
for {set i 0} {$i < $val(nn)} { incr i } {
# 30 defines the node size for nam
$ns initial_node_pos $node_($i) 30
}
# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "$node_($i) reset";
}
# ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 150.01 "puts \"end simulation\" ; $ns halt"
proc stop {} {
global ns tracefd namtrace
$ns flush-trace
close $tracefd
close $namtrace
}
$ns run
but there is error while running ..
invalid command name "-energyModel"
while executing
"-energyModel $opt(energymodel) \
-idlePower 1.0 \
-rxPower 1.0 \
-txPower 2.0 \
-sleepPower 0.001 \
-transitionP..."
(file "milindenergy.tcl" line 57)
On Tue, May 18, 2010 at 11:46 AM, <[email protected]> wrote:
>
> Welcome to posting to the ns-users mailing list!
>
> We automatically send this message to every new person who sends mail
> to the list. You should only receive it once. My apologies if the
> program contacts you twice, perhaps because you have multiple e-mail
> addresses or send mail from multiple machines.
>
> If you are an experienced ns-user who simply has not posted since we
> started using this responder, our apologies for inconveniencing you
> with this message. This message is intended to help inform users and
> cut down on redundant posts, which benefits everyone.
>
> Please look at the attached list of ns Frequently Asked Questions.
> If it answers your question, great! You're done.
> If not, please RE-SEND your original message to [email protected].
> A copy of your original message is included below for reference.
>
> You will NOT have to do re-send your message every time you post, only
> the FIRST time you send from a new account. The goal is to quickly
> help new users find the FAQ (hopefully answering their question).
>
> Thanks,
> -the ns development team
>
>
> ----------------------------------------
>
>
> The Network Simulator ns-2: Frequently Asked Questions
>
> (This FAQ is also on the web at
> http://www.isi.edu/nsnam/ns/ns-faq.html.)
>
> * _Where do I get ns?_
>
> From the ns web site at http://www.isi.edu/nsnam/ns/ns.html and
> the download page http://www.isi.edu/nsnam/ns/ns-tests.html.
>
> * _What platforms does ns run on and what kind of hardware do I
> need?_
>
> Please see "where to start" on the building ns web page:
> http://www.isi.edu/nsnam/ns/ns-build.html#start.
>
> * _What should I do if I have trouble downloading/extracting ns?_
>
> This question is answered in detail at
> http://www.isi.edu/nsnam/ns/ns-problems.html#downloading.
>
> * _What should I do if I encounter problems building ns?_
>
> Check:
> 1. the README that comes in the distribution (very brief),
> 2. the "installation problems, bug fixes and help" web page
> http://www.isi.edu/nsnam/ns/ns-problems.html,
> 3. the archives of the ns-users mailing list
> http://www.isi.edu/nsnam/ns/ns-lists.html,
> 4. post a bug report (see below)
> http://www.isi.edu/cgi-bin/nsnam/reportbug.cgi.
>
> * _What do I do after I successfully build ns?_
>
> + Put the path to your ns executable into your PATH environment
> + Put the path to your otcl into your LD_LIBRARY_PATH
> environment
> + Put the path to your tcl library into your TCL_LIBRARY
> environment
>
> * _Where can I find documentation for ns?_
>
> All documentation is linked from the main ns web page
> http://www.isi.edu/nsnam/ns/. Documentation includes a tutorial
> (originally from Marc Greis) and a reference manual (ns notes and
> documentation).
>
> * _Words, words, words... that documentation is nice, but where are
> some sample scripts I can start from?_
>
> Many sample scripts can be found in the ns distribution in
> ~ns-2/tcl/ex and ~ns-2/tcl/test.
>
> * _What protocols does ns support?_
>
> A lot! Almost all variants of TCP, several forms of multicast,
> wired networking, several ad hoc routing protocols and propagation
> models (but not cellular phones), data diffusion, satellite, and
> other stuff. See the documentation (described above) for details,
> or download ns and look.
>
> * _How do I know that ns correctly implements these protocols?_
>
> Ns has validation tests that cover many protocols, see
> http://www.isi.edu/nsnam/ns/ns-tests.html. However, ultimately
> users are responsible for verifying that ns is accurate for their
> purposes---since we cannot foresee all the ways ns may be used, we
> cannot test all cases with all inputs.
>
> * _Are there any contributed/additional protocols not in the main
> distribution?_
>
> Yes, please see the contributed code web page
> http://www.isi.edu/nsnam/ns/ns-contributed.html. The mailing list
> archives can also be helpful (see below).
>
> * _How should I get started doing something (like implementing a new
> protocol or trying an experiment)?_
>
> We recommend that you look through the tutorial (see
> documentation, above), then start with an example program that is
> most similar to yours (in the tutorial, or in tcl/ex or tcl/test
> in the distribution), and then start changing things.
>
> * _What should I do to compile ns to reflect my changes if I've
> modified some .cc or .h files?_
>
> go to ns directory and run "make" or "make depend; make"
>
> * _How do I subscribe to the ns-users mailing list? How do I search
> old list archives? I can't take any more---how do I get off this
> list?_
>
> To subscribe or unsubscribe, see
> http://www.isi.edu/nsnam/ns/ns-lists.html. The list archive is at
> http://www.isi.edu/nsnam/ns/ns-lists.html.
>
> * _What if I have a question that's not answered here?_
>
> If you've checked the installation problems and bug fixes web page
> (http://www.isi.edu/nsnam/ns/ns-problems.html) and there's no
> answer to your question, you may want to file a bug report or post
> a question to the ns-user's mailing list.
>
> First, you should check the archive of the list at
> http://www.isi.edu/nsnam/ns/ns-lists.html. Your question may
> already be answered there.
>
> If not, you can post a bug report using the web form at
> http://www.isi.edu/cgi-bin/nsnam/reportbug.cgi.
>
> If your question is NOT about ns implementation bugs, you may wish
> to post to the list. First you should subscribe. Subscription
> instructions are at http://www.isi.edu/nsnam/ns/ns-lists.html.
>
> _Please note that mail sent to the list is publicly distributed
> and archived. _If you have concerns about your message being made
> public (spam harvesting of your address), please consider that
> _before_ posting. We cannot remove messages from reciepient's
> mailboxes or the public archive after they're posted.
>
> When posting bug reports, please _always_ include information
> including at least (the bug report form includes spaces for
> these):
> + what version of ns you're using,
> + what operating system you're running on (not just Linux or
> Solaris, but RedHat version 7.0 or Solaris 2.4---send us the
> output of "uname -a"),
> + what specific behavior you see (if ns doesn't compile, what's
> the specific error; if TCP does something strange, what
> exactly did it do [send a pointer to a packet trace]),
> + what behavior you expected to see (if ns doesn't compile this
> is obvious, but if TCP does something strange, why is it
> strange, where is the TCP spec violated?),
> + pointers to your script detailed output files,
> + a statement that "yes, I've read the FAQ, ns-problems page,
> and manual and I couldn't find the answer there" (or a
> statement about why you didn't do that yet :-)
>
> A reminder about mailing list etiquette:
> + Please check the web pages and list archives before posting
> your question.
> + Please keep the body of your post to simple ASCII, not HTML.
> + Please do _not_ send large attachments (if what you have is
> bigger than a few kilobytes, put it on a web page and send a
> URL)
> + Before posting a question like "did people see my post" or
> "the list seems down", please check the archives (you can
> answer this question more accurately by checking yourself
> rather than asking).
> + Please don't post subscribe/unsubscribe requests directly to
> the list, use the lists' information page. (see the web page
> mentioned above for details).
> _________________________________________________________________
>
>
> ----------------------------------------
>
> From [email protected] Mon May 17 23:16:03 2010
> Received: from vapor.isi.edu (vapor.isi.edu [128.9.64.64])
> by gamma.isi.edu (8.13.8/8.13.8) with ESMTP id o4I6FUTE007237
> (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
> for <[email protected]>; Mon, 17 May 2010 23:15:39 -0700
> (PDT)
> Received: from mail-iw0-f174.google.com
> (mail-iw0-f174.google.com[209.85.214.174])
> by vapor.isi.edu (8.13.8/8.13.8) with ESMTP id o4I6F4OD005984
> for <[email protected]>; Mon, 17 May 2010 23:15:14 -0700 (PDT)
> Received: by iwn6 with SMTP id 6so1232271iwn.33
> for <[email protected]>; Mon, 17 May 2010 23:15:04 -0700 (PDT)
> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
> d=gmail.com; s=gamma;
> h=domainkey-signature:mime-version:received:received:date:message-id
> :subject:from:to:content-type;
> bh=G+t4mwbZrZe7ymfI22fvp8zUbPjH6rON5DP3sPnSuk0=;
> b=WryCYKnpWwfB/xvndnNdBdHx2m+0ralDtXOqDwxFDa9uQGgP2aN21yMb83HQw0E1cv
>
> 2nsCI4SfJwO5+tQIODeOc/Cv9f2bQkNF8R9Xfn8T9/9pC5rMJoFsJ+gnOGK+WByIMKMR
> xkvsO9FqOUilpAo8FEf/YXpOoYfnNQonS8BXQ=
> DomainKey-Signature: a=rsa-sha1; c=nofws;
> d=gmail.com; s=gamma;
> h=mime-version:date:message-id:subject:from:to:content-type;
> b=LMJ9JpJ7T7lCQcxQy/QGF2Qqn+f/+kD+u6czCuBlScAqlhhnZsO2KFbAxtwPN1X6MP
>
> Cq6n6oHwpw+sCL3z03mz1CEVEMIZ4ywLVoB0J26q+S7oamXK+tx8KXoPnKYeIBHGIsvR
> dvtPxAVqWAe4VVrmKeiQr1DvwMh8IpOKZCtQw=
> MIME-Version: 1.0
> Received: by 10.231.120.69 with SMTP id c5mr1042987ibr.79.1274163304297;
> Mon,
> 17 May 2010 23:15:04 -0700 (PDT)
> Received: by 10.231.150.134 with HTTP; Mon, 17 May 2010 23:15:04 -0700
> (PDT)
> Date: Tue, 18 May 2010 11:45:04 +0530
> Message-ID: <[email protected]>
> Subject: energy model in ns-2.34
> From: Milind Gunjan <[email protected]>
> To: [email protected]
> Content-Type: multipart/alternative; boundary=0016e64712262374550486d84334
> X-ISI-4-43-8-MailScanner: Found to be clean, Found to be clean
> X-MailScanner-From: [email protected]
>
> --0016e64712262374550486d84334
> Content-Type: text/plain; charset=ISO-8859-1
>
> i have installed ns-2.34 using ns-allinone-package . i have problem
> simulating energy model in existing code.
> have attached the code :
> # A 10-node example for ad-hoc simulation with DSDV
>
> # Define options
> set val(chan) Channel/WirelessChannel ;# channel type
> set val(prop) Propagation/TwoRayGround ;# radio-propagation
> model
> set val(netif) Phy/WirelessPhy ;# network interface
> type
>
> set val(mac) Mac/802_11 ;# MAC type
> set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
> set val(ll) LL ;# link layer type
> set val(ant) Antenna/OmniAntenna ;# antenna model
> set val(ifqlen) 50 ;# max packet in ifq
> set val(nn) 10 ;# number of mobilenodes
> set val(rp) DSDV ;# routing protocol
> set val(x) 500 ;# X dimension of topography
> set val(y) 400 ;# Y dimension of topography
> set val(stop) 150 ;# time of simulation end
> set opt(energymodel) EnergyModel ;
> set opt(radiomodel) RadioModel ;
> set opt(initialenergy) 1000 ;# Initial energy in
> Joules
>
>
> set ns [new Simulator]
> set tracefd [open milind.tr w]
> set windowVsTime2 [open win.tr w]
> set namtrace [open milind.nam w]
>
> $ns trace-all $tracefd
> #$ns use-newtrace
> $ns namtrace-all-wireless $namtrace $val(x) $val(y)
>
> # set up topography object
> set topo [new Topography]
>
> $topo load_flatgrid $val(x) $val(y)
>
> create-god $val(nn)
>
> #
> # Create nn mobilenodes [$val(nn)] and attach them to the channel.
> #
>
> # configure the nodes
> $ns node-config -adhocRouting $val(rp) \
> -llType $val(ll) \
> -macType $val(mac) \
> -ifqType $val(ifq) \
> -ifqLen $val(ifqlen) \
> -antType $val(ant) \
> -propType $val(prop) \
> -phyType $val(netif) \
> -channelType $val(chan) \
> -topoInstance $topo \
> -agentTrace ON \
> -routerTrace ON \
> -macTrace OFF \
> -movementTrace ON
> -energyModel $opt(energymodel) \
> -idlePower 1.0 \
> -rxPower 1.0 \
> -txPower 2.0 \
> -sleepPower 0.001 \
> -transitionPower 0.2 \
> -transitionTime 0.005 \
> -initialEnergy $opt(initialenergy)
>
>
>
> for {set i 0} {$i < $val(nn) } { incr i } {
> set node_($i) [$ns node]
> }
>
> # Provide initial location of mobilenodes
> $node_(0) set X_ 5.0
> $node_(0) set Y_ 5.0
> $node_(0) set Z_ 0.0
>
> $node_(1) set X_ 50.0
> $node_(1) set Y_ 200.0
> $node_(1) set Z_ 0.0
>
> $node_(2) set X_ 150.0
> $node_(2) set Y_ 200.0
> $node_(2) set Z_ 0.0
>
>
> $node_(3) set X_ 300.0
> $node_(3) set Y_ 150.0
> $node_(3) set Z_ 0.0
>
> $node_(4) set X_ 30.0
> $node_(4) set Y_ 100.0
> $node_(4) set Z_ 0.0
>
> $node_(5) set X_ 400.0
> $node_(5) set Y_ 150.0
> $node_(5) set Z_ 0.0
>
> $node_(6) set X_ 400.0
> $node_(6) set Y_ 200.0
> $node_(6) set Z_ 0.0
>
> $node_(7) set X_ 250.0
> $node_(7) set Y_ 200.0
> $node_(7) set Z_ 0.0
>
> $node_(8) set X_ 300.0
> $node_(8) set Y_ 240.0
> $node_(8) set Z_ 0.0
>
> $node_(9) set X_ 250.0
> $node_(9) set Y_ 350.0
> $node_(9) set Z_ 0.0
>
>
>
> # Generation of movements
> $ns at 10.0 "$node_(0) setdest 480.0 50.0 10.0"
> $ns at 30.0 "$node_(0) setdest 230.0 55.0 5.0"
> $ns at 70.0 "$node_(0) setdest 480.0 300.0 5.0"
>
>
>
> # Set a TCP connection between node_(0) and node_(1)
> set tcp [new Agent/TCP/Newreno]
> $tcp set class_ 2
> set sink [new Agent/TCPSink]
> $ns attach-agent $node_(0) $tcp
> $ns attach-agent $node_(1) $sink
> $ns connect $tcp $sink
> set ftp [new Application/FTP]
> $ftp attach-agent $tcp
> $ns at 10.0 "$ftp start"
>
> # Printing the window size
> proc plotWindow {tcpSource file} {
> global ns
> set time 0.01
> set now [$ns now]
> set cwnd [$tcpSource set cwnd_]
> puts $file "$now $cwnd"
> $ns at [expr $now+$time] "plotWindow $tcpSource $file" }
> $ns at 10.1 "plotWindow $tcp $windowVsTime2"
>
> # Define node initial position in nam
> for {set i 0} {$i < $val(nn)} { incr i } {
> # 30 defines the node size for nam
> $ns initial_node_pos $node_($i) 30
> }
>
> # Telling nodes when the simulation ends
> for {set i 0} {$i < $val(nn) } { incr i } {
> $ns at $val(stop) "$node_($i) reset";
> }
>
> # ending nam and the simulation
> $ns at $val(stop) "$ns nam-end-wireless $val(stop)"
> $ns at $val(stop) "stop"
> $ns at 150.01 "puts \"end simulation\" ; $ns halt"
> proc stop {} {
> global ns tracefd namtrace
> $ns flush-trace
> close $tracefd
> close $namtrace
> }
>
> $ns run
>
> but there is error while running ..
> invalid command name "-energyModel"
> while executing
> "-energyModel $opt(energymodel) \
> -idlePower 1.0 \
> -rxPower 1.0 \
> -txPower 2.0 \
> -sleepPower 0.001 \
> -transitionP..."
> (file "milindenergy.tcl" line 57)
>
> --0016e64712262374550486d84334
> Content-Type: text/html; charset=ISO-8859-1
> Content-Transfer-Encoding: quoted-printable
>
> i have installed ns-2.34 using ns-allinone-package . i have problem
> simulat=
> ing energy model in existing code.<br>have attached the code :<br># A
> 10-no=
> de example for ad-hoc simulation with DSDV
> <br>=A0<br># Define options
> <br>set val(chan)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Channel/WirelessChannel=A0=
> =A0=A0 ;# channel type
> <br>set val(prop)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
> Propagation/TwoRayGround=A0=
> =A0 ;# radio-propagation model
> <br>set val(netif)=A0=A0=A0=A0=A0=A0=A0=A0=A0 Phy/WirelessPhy=A0=A0=A0=A0=
> =A0=A0=A0=A0=A0=A0=A0 ;# network interface type
> <br>set val(mac)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
> Mac/802_11=A0=A0=A0=A0=A0=
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ;# MAC type
> <br>set val(ifq)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Queue/DropTail/PriQueue=
> =A0=A0=A0 ;# interface queue type
> <br>set val(ll)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
> LL=A0=A0=A0=A0=A0=A0=A0=
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ;# link layer type
> <br>set val(ant)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
> Antenna/OmniAntenna=A0=A0=
> =A0=A0=A0=A0=A0 ;# antenna model
> <br>set val(ifqlen)=A0=A0=A0=A0=A0=A0=A0=A0 50=A0=A0=A0=A0=A0=A0=A0=A0=A0=
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ;# max packet in ifq
> <br>set val(nn)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
> 10=A0=A0=A0=A0=A0=A0=A0=
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ;# number of
> mobilenode=
> s
> <br>set val(rp)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 DSDV=A0=A0=A0=A0=A0=A0=
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ;# routing protocol
> <br>set val(x)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 500=A0=A0 =A0=A0 =A0=
> =A0=A0 =A0=A0=A0 =A0=A0=A0 ;# X dimension of topography <br>set val(y)=A0=
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 400=A0=A0 =A0=A0 =A0=A0=A0 =A0=A0=A0 =
> =A0=A0=A0 ;# Y dimension of topography=A0 =A0<br>set val(stop)=A0=A0
> =A0=A0=
> =A0 =A0150=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 ;# time of simulation end
> <b=
> r>
> set opt(energymodel)=A0=A0=A0 EnergyModel=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
> =A0=A0=A0=A0 ;<br>set opt(radiomodel)=A0=A0=A0 =A0=A0 =A0RadioModel=A0=A0=
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ;<br>set opt(initialenergy)=A0
> 1=
> 000=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ;#
> In=
> itial energy in Joules<br><br>=A0=A0=A0
> <br>set ns=A0=A0 =A0=A0=A0 =A0=A0 [new Simulator] <br>set tracefd=A0=A0=A0=
> =A0=A0=A0 [open <a href=3D"http://milind.tr">milind.tr</a> w]
> <br>set windowVsTime2 [open <a href=3D"http://win.tr">win.tr</a> w]=A0
> <br>set namtrace=A0=A0=A0=A0=A0 [open milind.nam w]=A0=A0=A0=A0
> <br>=A0<br>$ns trace-all $tracefd
> <br>#$ns use-newtrace=A0
> <br>$ns namtrace-all-wireless $namtrace $val(x) $val(y)
> <br>=A0<br># set up topography object
> <br>set topo=A0=A0=A0=A0=A0=A0 [new Topography]
> <br>=A0<br>$topo load_flatgrid $val(x) $val(y)
> <br>=A0<br>create-god $val(nn)
> <br>=A0<br>#
> <br>#=A0 Create nn mobilenodes [$val(nn)] and attach them to the channel.=
> =A0
> <br>#
> <br>=A0<br># configure the nodes
> <br>=A0=A0=A0=A0=A0=A0=A0 $ns node-config -adhocRouting $val(rp) \
> <br>=A0=A0=A0 =A0=A0 =A0=A0=A0 =A0 -llType $val(ll) \ <br>=A0=A0=A0 =A0=A0
> =
> =A0=A0=A0 =A0 -macType $val(mac) \ <br>=A0=A0=A0 =A0=A0 =A0=A0=A0 =A0
> -ifqT=
> ype $val(ifq) \ <br>=A0=A0=A0 =A0=A0 =A0=A0=A0 =A0 -ifqLen $val(ifqlen) \
> <=
> br>=A0=A0=A0 =A0=A0 =A0=A0=A0 =A0 -antType $val(ant) \ <br>=A0=A0=A0
> =A0=A0=
> =A0=A0=A0 =A0 -propType $val(prop) \ <br>
> =A0=A0=A0 =A0=A0 =A0=A0=A0 =A0 -phyType $val(netif) \ <br>=A0=A0=A0 =A0=A0
> =
> =A0=A0=A0 =A0 -channelType $val(chan) \ <br>=A0=A0=A0 =A0=A0 =A0=A0=A0 =A0
> =
> -topoInstance $topo \ <br>=A0=A0=A0 =A0=A0 =A0=A0=A0 =A0 -agentTrace ON \
> <=
> br>=A0=A0=A0 =A0=A0 =A0=A0=A0 =A0 -routerTrace ON \ <br>=A0=A0=A0 =A0=A0 =
> =A0=A0=A0 =A0 -macTrace OFF \ <br>
> =A0=A0=A0 =A0=A0 =A0=A0=A0 =A0 -movementTrace ON<br>=A0=A0=A0 =A0=A0
> =A0=A0=
> =A0 =A0 -energyModel $opt(energymodel) \<br>=A0=A0=A0 =A0=A0 =A0=A0=A0 =A0
> =
> -idlePower 1.0 \<br>=A0=A0=A0 =A0=A0 =A0=A0=A0 =A0 -rxPower 1.0
> \<br>=A0=A0=
> =A0 =A0=A0 =A0=A0=A0 =A0 -txPower 2.0 \<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=
> =A0 =A0=A0=A0 =A0 -sleepPower 0.001 \<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0
> =A0=A0=
> =A0=A0=A0 =A0 -transitionPower 0.2 \<br>
> =A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0 =A0=A0=A0 =A0 -transitionTime 0.005
> \<br=
> >=A0=A0=A0 =A0=A0 =A0=A0=A0 =A0 -initialEnergy $opt(initialenergy)<br><br>=
> =A0<br>=A0=A0=A0 =A0=A0 =A0=A0=A0 =A0 =A0<br>=A0=A0=A0 for {set i 0} {$i
> &l=
> t; $val(nn) } { incr i } { <br>=A0=A0=A0 =A0=A0 =A0set node_($i) [$ns
> node]=
> =A0=A0 =A0 <br>=A0=A0=A0 } <br>
> =A0<br># Provide initial location of mobilenodes
> <br>$node_(0) set X_ 5.0
> <br>$node_(0) set Y_ 5.0
> <br>$node_(0) set Z_ 0.0
> <br>=A0<br>$node_(1) set X_ 50.0
> <br>$node_(1) set Y_ 200.0
> <br>$node_(1) set Z_ 0.0
> <br>=A0<br>$node_(2) set X_ 150.0
> <br>$node_(2) set Y_ 200.0
> <br>$node_(2) set Z_ 0.0
> <br><br><br>$node_(3) set X_ 300.0
> <br>$node_(3) set Y_ 150.0
> <br>$node_(3) set Z_ 0.0<br><br>$node_(4) set X_ 30.0
> <br>$node_(4) set Y_ 100.0
> <br>$node_(4) set Z_ 0.0<br><br>$node_(5) set X_ 400.0
> <br>$node_(5) set Y_ 150.0
> <br>$node_(5) set Z_ 0.0<br><br>$node_(6) set X_ 400.0
> <br>$node_(6) set Y_ 200.0
> <br>$node_(6) set Z_ 0.0<br><br>$node_(7) set X_ 250.0
> <br>$node_(7) set Y_ 200.0
> <br>$node_(7) set Z_ 0.0<br><br>$node_(8) set X_ 300.0
> <br>$node_(8) set Y_ 240.0
> <br>$node_(8) set Z_ 0.0<br><br>$node_(9) set X_ 250.0
> <br>$node_(9) set Y_ 350.0
> <br>$node_(9) set Z_ 0.0<br><br><br>=A0<br># Generation of movements
> <br>$ns at 10.0 "$node_(0) setdest 480.0 50.0 10.0"
> <br>$ns at 30.0 "$node_(0) setdest 230.0 55.0 5.0"<br>$ns at
> 70.0=
> "$node_(0) setdest 480.0 300.0 5.0" <br>=A0<br><br>=A0<br># Set
> =
> a TCP connection between node_(0) and node_(1)
> <br>set tcp [new Agent/TCP/Newreno]
> <br>$tcp set class_ 2
> <br>set sink [new Agent/TCPSink]
> <br>$ns attach-agent $node_(0) $tcp
> <br>$ns attach-agent $node_(1) $sink
> <br>$ns connect $tcp $sink
> <br>set ftp [new Application/FTP]
> <br>$ftp attach-agent $tcp
> <br>$ns at 10.0 "$ftp start"=A0
> <br>=A0<br># Printing the window size
> <br>proc plotWindow {tcpSource file} {
> <br>global ns
> <br>set time 0.01
> <br>set now [$ns now]
> <br>set cwnd [$tcpSource set cwnd_]
> <br>puts $file "$now $cwnd"
> <br>$ns at [expr $now+$time] "plotWindow $tcpSource $file" }
> <br>$ns at 10.1 "plotWindow $tcp $windowVsTime2"=A0=A0
> <br>=A0<br># Define node initial position in nam
> <br>for {set i 0} {$i < $val(nn)} { incr i } {
> <br># 30 defines the node size for nam
> <br>$ns initial_node_pos $node_($i) 30
> <br>}
> <br>=A0<br># Telling nodes when the simulation ends
> <br>for {set i 0} {$i < $val(nn) } { incr i } {
> <br>=A0=A0=A0 $ns at $val(stop) "$node_($i) reset";
> <br>}
> <br>=A0<br># ending nam and the simulation=A0
> <br>$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
> <br>$ns at $val(stop) "stop"
> <br>$ns at 150.01 "puts \"end simulation\" ; $ns halt"
> <br>proc stop {} {
> <br>=A0=A0=A0 global ns tracefd namtrace
> <br>=A0=A0=A0 $ns flush-trace
> <br>=A0=A0=A0 close $tracefd
> <br>=A0=A0=A0 close $namtrace
> <br>}
> <br>=A0<br>$ns run
> <br>=A0 <br>but there is error while running ..<br>=A0invalid command name
> =
> "-energyModel"<br>=A0=A0=A0 while
> executing<br>"-energyModel=
> $opt(energymodel) \<br>=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0-idlePower 1.0
> \<b=
> r>=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0-rxPower 1.0 \<br>
> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0-txPower 2.0
> \<br>=A0=A0=A0=A0=A0=A0=A0=A0=
> =A0 =A0=A0=A0 =A0=A0=A0 =A0-sleepPower 0.001 \<br>=A0=A0=A0=A0=A0=A0=A0=A0=
> =A0 =A0=A0=A0 =A0=A0=A0 =A0-transitionP..."<br>=A0=A0=A0 (file
> "m=
> ilindenergy.tcl" line 57)<br><br>
>
> --0016e64712262374550486d84334--
>
>