[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] queue-tracing



hi all
in my simulations i would like to know what happens in the queues.
i read in the ns manual about "monitor-queue" and similar things
but i don't know what commands i have to add to my script, to get a 
"trace-file of the queue"...can someone help me?
thanks very much
lorenz

here is the simulation script:

# ======================================================================
# Define options
# ======================================================================

set val(chan)       Channel/WirelessChannel
set val(prop)       Propagation/TwoRayGround
set val(netif)      Phy/WirelessPhy
set val(mac)        Mac/802_11
set val(ifq)        Queue/DropTail/PriQueue
set val(ll)         LL
set val(ant)        Antenna/OmniAntenna
set val(x)              200  ;# X dimension of the topography
set val(y)              200   ;# Y dimension of the topography
set val(ifqlen)         50            ;# max packet in ifq
set val(seed)           0.0
set val(adhocRouting)   DSR
set val(nn)             5            ;# how many nodes are simulated
set val(stop)           20        ;# simulation time

# =====================================================================
# Main Program
# ======================================================================

#
# Initialize Global Variables
#

# create simulator instance

set ns		[new Simulator]

# setup topography object

set topo	[new Topography]

# create trace object for ns and nam

set tracefd	[open 5tr.tr w]
set namtrace    [open 5nam.nam w]
for {set i 0} {$i < $val(nn)} {incr i} {
    set f($i)  [open out($i).tr w]
    }
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

#Define a 'finish' procedure
proc finish {} {
        global ns tracefd f
        $ns flush-trace
	#Close the trace file
        close $tracefd
	#Execute nam on the trace file
        exec nam 5nam.nam &
        exit 0
}

# define topology
$topo load_flatgrid $val(x) $val(y)

#
# Create God
#
set god [create-god $val(nn)]

#
# define how node should be created
#
# Create channel
set chan_0_ [new $val(chan)]
#global node setting

$ns node-config -adhocRouting $val(adhocRouting) \
                 -llType $val(ll) \
                 -macType $val(mac) \
                 -ifqType $val(ifq) \
                 -ifqLen $val(ifqlen) \
                 -antType $val(ant) \
                 -propType $val(prop) \
                 -phyType $val(netif) \
		 -topoInstance $topo \
		 -agentTrace ON \
                 -routerTrace OFF \
                 -macTrace OFF \
		 -channel $chan_0_

#
#  Create the specified number of nodes [$val(nn)] and "attach" them
#  to the channel.

for {set i 0} {$i < $val(nn) } {incr i} {
	set node_($i) [$ns node]
	$node_($i) random-motion 0		;# disable random motion

}
#
# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes
for {set i 0} {$i < $val(nn) } {incr i} {
    $node_($i) set X_ [expr 80*cos((6.282/($val(nn))*($i+1)))]
    $node_($i) set Y_ [expr 80*sin((6.282/($val(nn))*($i+1)))]

    $node_($i) set Z_ 0.0
}

#


#
for {set i 0} {$i < $val(nn) } {incr i} {
    set tcp($i) [new Agent/TCP]
    $ns attach-agent $node_([expr ($val(nn)-1)]) $tcp($i)
}

for {set i 0} {$i < $val(nn) } {incr i } {
    set null($i) [new Agent/LossMonitor]
    $ns attach-agent $node_($i) $null($i)
}

for {set i 0} {$i <  $val(nn)-1 } {incr i} {


	$ns connect $tcp($i) $null($i)
	}

for {set i 0} {$i < ($val(nn)-1) } {incr i} {
    set exp($i) [new Application/Traffic/Exponential]
    $exp($i) set packetSize_ 210
    $exp($i) set burst_time_ 3
    $exp($i) set idle_time_ 1
    $exp($i) set rate_ 64000
    $exp($i) attach-agent $tcp($i)}


for {set i 0} {$i < ($val(nn)-1) } {incr i} {
    $ns at 5.0 "$exp($i) start" }



# Define node initial position in nam

for {set i 0} {$i < $val(nn)} {incr i} {

    # 20 defines the node size in nam, must adjust it according to your 
scenario
    # The function must be called after mobility model is defined

    $ns initial_node_pos $node_($i) 20
}

proc record {} {
	global  null f
	set ns [Simulator instance]
	set time 0.001
	for {set i 0} {$i < 5} {incr i} {
	    set bw($i) [$null($i) set bytes_]
	    }
	set now [$ns now]
	for {set i 0} {$i < 5} {incr i} {
	    puts $f($i) "$now [expr $bw($i)]"
	    $null($i) set bytes_ 0
	    }
	$ns at [expr $now+$time] "record"
}

$ns at 0.0 "record"

#Call the finish procedure after 5 seconds of simulation time
$ns at 20 "finish"

#
# Tell nodes when the simulation ends
#
for {set i 0} {$i < $val(nn) } {incr i} {
    $ns at $val(stop).0 "$node_($i) reset";
}

$ns at  $val(stop).0002 "puts \"NS EXITING...\" ; $ns halt"


puts "Starting Simulation..."
$ns run






_________________________________________________________________
Downloaden Sie MSN Explorer kostenlos unter http://explorer.msn.de/intl.asp