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

[ns] can someone help me? error.jpg



dear all,

i have this script that i have written and i am
getting this error.jpg. i don't really understand what
it could have meant.

thanks in advance.

ta

_____________________________________________________________________________
http://messenger.yahoo.com.au - Yahoo! Messenger
- Voice chat, mail alerts, stock quotes and favourite news and lots more!

error.jpg

image/pjpeg

# ======================================================================
# Define options
# ======================================================================
set opt(nn)		10	;# number of nodes
set opt(seed)		0.0
set opt(stop)		20	;# simulation time
set opt(k)		10.0

# exponential traffic generator
set opt(pktsize)    500
set opt(burst)		500ms
set opt(idle)		500ms
set opt(rate)		100k

#Create a simulator object
set ns [new Simulator]

#Open the output files
set nsf [open out.nam w]; $ns namtrace-all $nsf

# Open Trace file for post processing
set namf [open out.tr w]; $ns trace-all $namf

#set up the random number generator
#this will allow for rng to work properly
set rng [new RNG]
$rng seed 0 


# setup initial values
Application/Traffic/Exponential set PacketSize_ $opt(pktsize)
Application/Traffic/Exponential set burst_time_ $opt(burst)
Application/Traffic/Exponential set idle_time_ $opt(idle)
Application/Traffic/Exponential set rate_ $opt(rate)

#create finish procedure
proc finish {} {
	global ns nsf namf
	$ns flush-trace
	close $nsf
	close $namf
	exec nam out.nam &
	exit 0
}



#################   Topology        ##################

########### for {set i 0} {$i < $opt(nn)} {incr i} { set n($i) [$ns node] }

puts "Create nodes..."
for {set count 0} {$count <= 9} {incr count} { set n($count) [$ns node] }

puts "create links..."
for {set count 0} {$count <= 9} {incr count} {
  $ns simplex-link $n($count) $n([expr ($count+1)%10]) 4Mb 1ms DropTail }

puts "tcp sinks created ..."
for {set count 0} {$count <= 9} {incr count} { set sink($count) [new Agent/LossMonitor] }

puts "attach sinks..."
for {set count 0} {$count <= 9} {incr count} { $ns attach-agent $n($count) $sink($count) }



#Define a procedure that attaches a UDP agent to a previously created node
#'node' and attaches an Expoo traffic generator to the agent with the
#characteristic values 'size' for packet size 'burst' for burst time,
#'idle' for idle time and 'rate' for burst peak rate. The procedure connects
#the source with the previously defined traffic sink 'sink' and returns the
#source object.

proc exp { node sink size burst idle rate } {
	puts "Get an instance of the simulator"
	set ns [Simulator instance]

	puts "Create a UDP agent and attach it to the node"
	set source [new Agent/UDP] ;#### [new Agent/CBR/UDP]

        puts "attach source to node..."
	$ns attach-agent $node $source
	
	puts "Create an Expoo traffic agent and set its configuration parameters"
	set traffic [new Application/Traffic/Exponential]
	
        puts "set traffic details..."
	$traffic set packet-size $size
	$traffic set burst-time $burst
	$traffic set idle-time $idle
	$traffic set rate $rate
	
	puts "attach the traffic agent to the traffic source"
	$traffic attach-agent $source

	puts "Connect the source and the sink"
	$ns connect $source $sink

	return $source
}


#  =======================  Randomised activities =========================
# Create links and connections to the src and sinks for each random
# data being sent from any source and sink other than itself



for {set i 0} {$i < $opt(nn)} {incr i} {
	puts "*** randomized activitity for $i..."
	set u [$rng integer 10]
	if {$u != $i} {
	set now [$ns now]
	#Set the time after which the procedure should be stopped
	
	set source($i) [exp $n(0) $sink($u) 200 2s 1s 100k]
	#set source1 [exp $n(1) $sink($u) 200 2s 1s 200k]
	#set source2 [exp $n(2) $sink($u) 200 2s 1s 300k]
		       
	set time 1.0
        $ns at $now "$source(0) start"
	
}
}

#Define a procedure which periodically records the bandwidth received by the
#three traffic sinks sink0/1/2 and writes it to the three files f0/1/2.
proc record {} {
        global sink0 sink1 sink2 f0 f1 f2

	puts "Get an instance of the simulator"
	set ns [Simulator instance]

	puts "Set the time after which the procedure should be called again"
        set time 0.5

	puts "How many bytes have been received by the traffic sinks?"
        set bw0 [$sink0 set bytes_]
        set bw1 [$sink1 set bytes_]
        set bw2 [$sink2 set bytes_]
        
	puts "Get the current time"
        set now [$ns now]

	puts "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]"

	puts "Reset the bytes_ values on the traffic sinks"
        $sink0 set bytes_ 0
        $sink1 set bytes_ 0
        $sink2 set bytes_ 0

	puts "Re-schedule the procedure"
        $ns at [expr $now+$time] "record"
}

###### END OF Create source of Traffic #######


puts "Call the finish procedure after X seconds simulation time"
$ns at 100.0 "finish"

puts "Run the simulation"
$ns run