[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] asking for solution, please!!!!
Just a Guess:
Everytime you call "record" you are repetitively getting/creating a new
instance of ns (the simulator itself) via:
set ns [Simulator instance]
Take it out of procedures, make it global. Also to track what's happening
print out the time:
set nowtime [expr $now+$time]
puts "$nowtime"
Ismail
See if it increments by 0.5
>
>
> proc record {} {
> global ns f0 f1 f2 traceapp0 traceapp1
> traceapp2
> set ns [Simulator instance]
> set time 0.5
>
> #How many bytes have been received by the
> traffic sinks?
> set bw0 [$traceapp0 set bytes_]
> set bw1 [$traceapp1 set bytes_]
> set bw2 [$traceapp2 set bytes_]
>
> #Get the current time
> set now [$ns now]
> #Calculate the bandwidth (in MBit/s) and write
> it to the files
> puts $f0 "$now [expr $bw0/$time*8/1000000]"
> puts $f1 "$now [expr $bw1/$time*8/1000000]"
> puts $f2 "$now [expr $bw2/$time*8/1000000]"
>
>
>
> #Reset the bytes_ values on the traffic tracer
> $traceapp0 set bytes_ 0
> $traceapp1 set bytes_ 0
> $traceapp2 set bytes_ 0
>
> # $ns trace-all $f
> #Re-schedule the procedure
> $ns at [expr $now+$time] "record"
> }
>
>
> proc finish {} {
> global ns traceapp0 traceapp1 traceapp2 tcpsrc0
> tcpsrc1 tcpsrc2 f0 f1 f2
> close $f0
> close $f1
> close $f2
>
> #Call xgraph to display the results
> exec xgraph out0.tr out1.tr out2.tr -geometry 450x250
> &
> #exec xgraph BW.tr Window.tr bad.tr -bb -bg white -t
> results -x "time" -geometry 800x400 &
> #exec xgraph BW.tr Window.tr RTT.tr bad.tr -bb -t
> results -x "time" -geometry 800x400 &
> # exec xgraph Bandwidth.tr cwnd.tr RTT.tr -bb
> -bg white -t results -x "Time" -geometry 450x250 &
> exit 0
> }
>
>
>
> ### This simulation is an example of combination of
> wired and wireless
> ### topologies.
>
>
> # 0 o W1(0.0.0)
> WIRED NODES
> # |
> # 1 o W2 (0.1.0)
> # |
> # 2 o W3 (0.2.0)
> # |
> # |
> #--*--*--*--*--*-- 3 o base-stn nodes
> --*-*-*-*-*-*-*-
> # (1.0.0) BS
> # o 5
> # 4 o WL2 (1.0.2)
> # (1.0.1) WL1
> # o 6 (1.0.3) WIRELESS
> NODES
> # WL3
> #
> #
> #===============================================================
> #options
>
> set opt(chan) Channel/WirelessChannel
> set opt(prop) Propagation/TwoRayGround
> set opt(netif) Phy/WirelessPhy
> set opt(mac) Mac/802_11
> set opt(ifq) Queue/DropTail/PriQueue
> set opt(ll1) LL
> set opt(ll2) LL/LLSnoop
> set opt(ant) Antenna/OmniAntenna
> set opt(x) 670 ;# X & Y dimension of the topography
> set opt(y) 670 ;# hard wired for now...
> set opt(rp) dsdv ;# available routing
> proto:dsdv/dsr
> set opt(ifqlen) 50 ;# max packet in ifq
> set opt(tr) wired-wireless-out.tr
>
> # Default settings
> set num_wired_nodes 3
> set num_bs_nodes 1
> set num_wireless_nodes 3
> set opt(nn) 4 ;# total number of
> wireless nodes
>
> # Other class settings
> set AgentTrace ON
> set RouterTrace ON
> set MacTrace OFF
>
>
> Queue/DropTail/PriQueue set Prefer_Routing_Protocols
> 1
>
> # unity gain, omni-directional antennas
> # set up the antennas to be centered in the node and
> 1.5 meters above it
> Antenna/OmniAntenna set X_ 0
> Antenna/OmniAntenna set Y_ 0
> Antenna/OmniAntenna set Z_ 1.5
> Antenna/OmniAntenna set Gt_ 1.0
> Antenna/OmniAntenna set Gr_ 1.0
>
> # Initialize the SharedMedia interface with parameters
> to make
> # it work like the 914MHz Lucent WaveLAN DSSS radio
> interface
> Phy/WirelessPhy set CPThresh_ 10.0
> Phy/WirelessPhy set CSThresh_ 1.559e-11
> Phy/WirelessPhy set RXThresh_ 3.652e-10
> Phy/WirelessPhy set Rb_ 2*1e6
> Phy/WirelessPhy set Pt_ 0.2818
> Phy/WirelessPhy set freq_ 914e+6
> Phy/WirelessPhy set L_ 1.0
>
>
> # intial setup - set addressing to hierarchical
>
> set ns [new Simulator]
> $ns set-address-format hierarchical
>
> #set namtrace [open wired-wireless-out.nam w]
> #$ns namtrace-all $namtrace
> #set trace [open wired-wireless-out.tr w]
> #$ns trace-all $trace
>
> AddrParams set domain_num_ 3
> lappend cluster_num 3 1 1
> AddrParams set cluster_num_ $cluster_num
> lappend eilastlevel 1 1 1 4 1
> AddrParams set nodes_num_ $eilastlevel
>
> # setup the wired nodes
> set temp {0.0.0 0.1.0 0.2.0}
> for {set i 0} {$i < $num_wired_nodes} {incr i} {
> set W($i) [$ns node [lindex $temp $i]]
> }
>
> ### setup base stations & wireless nodes
>
> if { $opt(x) == 0 || $opt(y) == 0 } {
> puts "No X-Y boundary values given for wireless
> topology\n"
> }
> set chan [new $opt(chan)]
> set prop [new $opt(prop)]
> set topo [new Topography]
> set tracefd [open $opt(tr) w]
>
> #setup snoop in basestation
> #set ll [new LL/LLSnoop]
> #$ns node-config -llType $ll
>
> #setup topography and propagation model
> $topo load_flatgrid $opt(x) $opt(y)
> $prop topography $topo
>
> # Create God
> create-god $opt(nn)
>
>
> # create base stations
>
> set temp {1.0.0 1.0.1 1.0.2 1.0.3}
> set BS(0) [create-base-station-node [lindex $temp 0]]
>
> #provide some co-ord (fixed) to base stations
> $BS(0) set X_ 1.0
> $BS(0) set Y_ 2.0
> $BS(0) set Z_ 0.0
>
> #configure for mobilenodes
> $ns node-config -wiredRouting OFF
> #$ns node-config -llType $opt(ll)
>
>
> #create some mobilenodes in the same domain as BS_0
> for {set j 0} {$j < $num_wireless_nodes} {incr j} {
> set node_($j) [ dsdv-create-mobile-node $j [lindex
> $temp \
> [expr $j+1]] ]
>
> $node_($j) base-station [AddrParams addr2id
> [$BS(0) node-addr]]
> }
>
> if { $opt(x) == 0 || $opt(y) == 0 } {
> usage $argv0
> exit 1
> }
>
> #create links between wired and BS nodes
>
> $ns duplex-link $W(0) $BS(0) 5Mb 2ms DropTail
> $ns duplex-link $W(1) $BS(0) 5Mb 2ms DropTail
> $ns duplex-link $W(2) $BS(0) 5Mb 2ms DropTail
>
> #$ns duplex-link-op $W(0) $W(1) orient down
> #$ns duplex-link-op $W(1) $W(2) orient down
> #$ns duplex-link-op $W(2) $BS(0) orient down
>
>
>
> # setup TCP connections
> set tcpsrc0 [new Agent/TCP]
> set tcpsrc1 [new Agent/TCP]
> set tcpsrc2 [new Agent/TCP]
>
>
> $ns attach-agent $W(0) $tcpsrc0
> $ns attach-agent $W(1) $tcpsrc1
> $ns attach-agent $W(2) $tcpsrc2
>
> # setup tcp sink (destination)
> set sink0 [new Agent/TCPSink]
> set sink1 [new Agent/TCPSink]
> set sink2 [new Agent/TCPSink]
>
> $ns attach-agent $BS(0) $sink0
> $ns attach-agent $BS(0) $sink1
> $ns attach-agent $BS(0) $sink2
>
>
> # tracing application
> set traceapp0 [new TraceApp]
> set traceapp1 [new TraceApp]
> set traceapp2 [new TraceApp]
>
> $traceapp0 attach-agent $sink0
> $traceapp1 attach-agent $sink1
> $traceapp2 attach-agent $sink2
>
> # make connection between tcp source and tcp sink
> $ns connect $tcpsrc0 $sink0
>
> # create traffic data FTP
> set ftp0 [$tcpsrc0 attach-source FTP]
>
> #open output files
> set f0 [open out0.tr w]
> set f1 [open out1.tr w]
> set f2 [open out2.tr w]
>
> # start up the source
> $ns at 0.0 "record"
> $ns at 0.0 "$ftp0 start"
>
> $ns at 0.0 "$traceapp0 start"
>
> $ns at 40.0 "$ftp0 stop"
>
> $ns at 40.0 "$traceapp0 stop"
>
> $ns at 50.0 "finish"
>
> #running simulation
> $ns run
>
>
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Find a job, post your resume.
> http://careers.yahoo.com
>