try this command...
first as first remark 
its preferable to work under this directory : /ns-allinone-2.33/bin and put
in it the trace file , the nam file and obviously the Tcl file..ok
second 
i will suppose that you have done this.so to run the nam file :

exec ./nam /home/faraz/Desktop/ns-allinone-2.33/bin/attachment &



i hope that it will work

  




Syed Faraz Hasan wrote:
> 
> 
> Hello ALL,
> 
> I am trying to visualize the entire simulation using NAM. I open the .nam
> file in the finish procedure. I have associated CBR source with one of the
> nodes to make it send packets to another node. NAM executes properly at
> the beginning (but does not show nodes at all), as soon as the scheduled
> time of sending packets arrive NAM exits. Although it generates the trace
> file.
> 
> Please write back soon
> 
> Heres the code...
> 
> # ======================================================================
> 
> # 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)             3                          ;# number of
> mobilenodes
> 
> set val(rp)             AODV                       ;# routing protocol
> 
> set val(x)              880                       ;# x-axis of grid
> set val(y)              880                       ;# y-axis of grid
> set opt(energymodel)    EnergyModel     ;
> set opt(radiomodel)     RadioModel     ;
> set opt(initialenergy)  1000            ;# Initial energy in Joules
> set num_ms_nodes        10;
> set opt(nn)             2;
> 
> # ======================================================================
> 
> # Main Program
> 
> # ======================================================================
> 
> 
> 
> 
> 
> #
> 
> # Initialize Global Variables
> 
> #
> 
> 
> 
> #start the simulator
> set ns [new Simulator]
> 
> #open the trace file
> set tracefile1 [open a.tr w]
> $ns trace-all $tracefile1
> 
> #Open NAM file
> set nf [open attachment.nam w]
> $ns namtrace-all $nf
> 
> 
> #define the procedure finish
> #proc finish {} {
> #global ns tracefile1
> #$ns flush-trace
> #close $tracefile1
> #exit 0
> #}
> 
> proc finish {} {
>         global ns nf
>         $ns flush-trace
>         close $nf
>         exec /home/faraz/Desktop/ns-allinone-2.33/nam-1.13/nam
> attachment.nam &
>         exit 0
>         }
> 
> 
> # set up topography object
> 
> set topo       [new Topography]
> 
> 
> $topo load_flatgrid $val(x) $val(y)
> 
> 
> 
> # Create God General Operations Director
> 
> 
> 
> create-god [expr $opt(nn) + $num_ms_nodes]
> 
> # Create channel #1 and #2
> set chan_1_ [new $val(chan)]
> 
> 
> 
> #
> 
> #  Create the specified number of mobilenodes [$val(nn)] and "attach" them
> 
> #  to the channel.
> 
> #  Here two nodes are created : node(0) and node(1)
> 
> 
> 
> # configure node
> 
> 
> 
>         $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) \
> 
>                          -topoInstance $topo \
> 
>                          -agentTrace OFF \
> 
>                          -routerTrace ON \
> 
>                          -macTrace OFF \
> 
>                          -movementTrace OFF\
>                          -channel $chan_1_
> 
> 
>                          #-energyModel $opt(energymodel) \
>                          -idlePower 1.0 \
>                          -rxPower 1.0 \
>                          -txPower 1.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]
>        $node_($i) random-motion 0   ;# disable random motion
>        }
> 
> 
> set udp0 [new Agent/UDP]
> $ns attach-agent $node_(0) $udp0
> 
> set cbr0 [new Application/Traffic/CBR]
> $cbr0 set packetSize_ 1000
> $cbr0 set interval_ 0.005
> $cbr0 attach-agent $udp0
> 
> set null0 [new Agent/Null]
> $ns attach-agent $node_(1) $null0
> 
> $ns connect $udp0 $null0
> 
> $ns at 1 "$cbr0 start"
> $ns at 4 "$cbr0 stop"
> $ns at 4.1 "finish"
> 
> puts "Starting Simulation..."
> $ns run
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/NAM-does-not-run-wireless-simulation-over-ns-2-tp21352896p21369180.html
Sent from the ns-users mailing list archive at Nabble.com.

Reply via email to