Dear Ashraf,

Thanks for your help. Now my script is working. According to your suggestion, 
I compared the both code then run.

I was seeing 4 nodes instead of 2 nodes in NAM, because I was defining nodes 
as mobile adhoc and I was enabling the wired routing too (-wiredRouting ON). 
And thats why it was showing the warning for duplicate node declaration too.

Now it is working fine.

Best Regards,
Abdul Awal.

On Wednesday 15 March 2006 23:58, Ashraf Bourawy wrote:
> Dear Mohammed,
>
> please have a look at the following tcl script,,,,it is yours old script
> after making some changes,,,,,,,,,,,,,,it should work with you properly
> now,,,,,,,try to find differences between this script and the original
> script you submitted,,,,,,,,,,As for traffic visualization in nam it is not
> supported yet,,,,,,,,
> In addition, please look at Marc Greis' tutorial at
> http://www.isi.edu/nsnam/ns/tutorial/  it is very useful though,,,,,,,,
>
> Best regard,
> Ashraf.
>
>
>
> # mohammed.tcl
> # this is a simple wireless scenario
> # =====================================
>
> set ns_ [new Simulator]
>
> #
> ==========================================================================
> # 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
> packets in ifq
> set val(nn)            2                                           ;#
> number of mobiles
> set val(rp)            DSDV                                    ;# routing
> protocol
> set val(x)             700                                        ;# X
> dimension of topology
> set val(y)             700                                        ;# Y
> dimension of topology
>
> #
> ===========================================================================
>
> $ns_ use-newtrace
> set tf [open unicast.tr w]
> $ns_ trace-all $tf
>
> set nf [open unicast.nam w]
> $ns_ namtrace-all-wireless $nf $val(x) $val(y)
>
> # set up topology
> # =======================================
> #
> set topo [new Topography]
> $topo load_flatgrid $val(x) $val(y)
>
> # Create god
> # =======================================
> #
> create-god $val(nn)
>
> # create a new channel
> set chan1_ [new $val(chan)]
>
> # =================================================
> # Configure 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) \
>            -channel $chan1_ \
>            -topoInstance $topo \
>            -agentTrace ON \
>            -routerTrace OFF \
>            -macTrace OFF \
>            -movementTrace OFF
>
> # =====================================================
> # Create nodes
> # =====================================================
>
> for {set i 0} {$i < $val(nn) } {incr i} {
>     set node_($i) [$ns_ node]
>     $node_($i) random-motion 0            ;# disable random motion
> }
>
> # =====================================================
> # Provide nodes with initial co-ord
> # =====================================================
>
> $node_(0) set X_ 100.0
> $node_(0) set Y_ 50.0
> $node_(0) set Z_ 0.0
>
> $node_(1) set X_ 300.0
> $node_(1) set Y_ 50.0
> $node_(1) set Z_ 0.0
>
>
> # ======================================================
> # define mobiles initial position for nam
> # ======================================================
> for {set i 0} {$i < $val(nn)} {incr i} {
>
>     $ns_ initial_node_pos $node_($i) 20
> }
>
> # ======================================================
> # define simple movement for nodes
> # ======================================================
> # nodes move away from each other
> #
> $ns_ at 10.0 "$node_(0) setdest 30.0 50.0 10.0"
> $ns_ at 11.0 "$node_(1) setdest 400.0 50.0 15.0"
>
> #
> # nodes move towards each other
> #
> $ns_ at 60.0 "$node_(0) setdest 120.0 50.0 10.0"
> $ns_ at 61.0 "$node_(1) setdest 300.0 50.0 15.0"
>
>
> # =====================================================
> # set up traffic flow between nodes
> # =====================================================
>
> set sender [new Agent/TCP]
> $sender set class_ 1
> set rcver [new Agent/TCPSink]
>
> $ns_ attach-agent $node_(0) $sender
> $ns_ attach-agent $node_(1) $rcver
>
> set ftp [new Application/FTP]
> $ftp attach-agent $sender
>
> $ns_ connect $sender $rcver
> $ns_ at 1.0 "$ftp start"
>
> # ====================================================
> # tell nodes when simulation ends
> # ====================================================
>
> for {set i 0} {$i < $val(nn) } {incr i} {
>     $ns_ at 100.0001 "$node_($i) reset"
> }
>
> # ====================================================
> # Stop Traffic
> # ====================================================
> $ns_ at 100.0002 "$ftp stop"
>
>
> $ns_ at 100.0005 "puts \"NS EXITING...\" ; $ns_ halt"
>
> $ns_ at 100.0004 "stop"
>
> proc stop { } {
>    global ns_ tf nf
>    $ns_ flush-trace
>    close $tf
>    close $nf
> }
>
> # ====================================================
> # Run simulation
> # ====================================================
> puts "Starting Simulation..."
> $ns_ run

Reply via email to