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

Re: [ns] What's the format of TrafficTrace file



Yeah, you are right. After I used a binary tracefile,  the bad file size error
disappeared.
But another error like following exits. 

ns mpgwfq1.tcl
ns: _o28 start:
    (_o28 cmd line 1)
    invoked from within
"_o28 cmd start"
    invoked from within
"catch "$self cmd $args" ret"
    (procedure "_o28" line 2)
    (SplitObject unknown line 2)
    invoked from within
"_o28 start" 

This code can run ok before modification to traffictrace.
I attach my tcl file here, i hope those guru can help me check it.
I am a newbee here, and Yu help me a lot. Thank you.

Regards,

 On Tue, 29 Feb 2000, Haobo Yu wrote:
> I thought the tracefile should be binary? If you look what that piece of
> code is doing, it's checking if the file size is multiples of tracerec,
> which are 2 integers. Perhaps you want to write raw binary data to your
> trace file instead of ascii
set ns [new Simulator]

set n0 [$ns node]
set n1 [$ns node]


set f0 [open out0.tr w]
set f1 [open out1.tr w]
# $ns trace-all $f


# install a duplex link with WFQ queues at both ends
$ns duplex-link $n0 $n1 1Mb 2ms WFQ

# create an instance of the classifier suited for flow aggregation
set cl [new WFQAggregClassifier]

# install the classifier on the WFQ server at node $n0 heading at nt $n1
$ns wfqclassifier-install $n0 $n1 $cl 

set tfile [new Tracefile]
$tfile filename out.dat 

set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
$udp0 set fid_ 0; # this is the info used by WFQ classifier
set t0 [new Application/Traffic/Trace]
$t0 attach-tracefile $tfile
$t0 attach-agent $udp0

#set traffic [new Traffic/Expoo]
#$traffic set packet-size 200
#$traffic set burst-time 2s
#$traffic set idle-time 1s
#$traffic set rate 500k
#$cbr0 attach-traffic $traffic

set udp1 [new Agent/UDP]
$ns attach-agent $n1 $udp1
$udp1 set fid_ 2; # this is the info used by WFQ classifier
set t1 [new Application/Traffic/Trace]
$t1 attach-tracefile $tfile
$t1 attach-agent $udp1

#set traffic [new Traffic/Expoo]
#$traffic set packet-size 200
#$traffic set burst-time 2s
#$traffic set idle-time 1s
#$traffic set rate 1M
#$cbr1 attach-traffic $traffic

# in this example we have a flow for each queue but
# more than one flow can be assigned to the same WFQ server queue(PGPS session)
$cl setqueue 0 3; # fid 0 -> WFQ server queue 3
$cl setqueue 1 4; # fid 1 -> WFQ server queue 4

#we set WFQ server queue weights
$cl setweight 3 .5; # WFQ server queue 3 has weight .5
$cl setweight 4 .2; # WFQ server queue 4 has weight .2

set null0 [new Agent/LossMonitor]
$ns attach-agent $n0 $null0

set null1 [new Agent/LossMonitor]
$ns attach-agent $n1 $null1

$ns connect $udp0 $null0
$ns connect $udp1 $null1

#Define a procedure which periodically records the bandwidth received by the
#traffic sink1 and writes it to the files f1.
proc record {} {
        global null0 null1 f0 f1
	#Get an instance of the simulator
	set ns [Simulator instance]
	#Set the time after which the procedure should be called again
        set time 0.5
	#How many bytes have been received by the traffic sinks?
        set bw0 [$null0 set bytes_]
	set bw1 [$null1 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]"
        
	#Reset the bytes_ values on the traffic sinks
        $null0 set bytes_ 0
	$null1 set bytes_ 0
        #Re-schedule the procedure
        $ns at [expr $now+$time] "record"
}

#Start logging the received bandwidth
$ns at 0.0 "record"

$ns at 1.0 "$udp0 start"
$ns at 1.1 "$udp1 start"


$ns at 10.0 "finish"

proc finish {} {
	global ns f0 f1	
	close $f0 
	close $f1
	#Call xgraph to display the results
	exec xgraph out0.tr out1.tr -geometry 800x400 &
        exit 0
}

$ns run