how to generate nam file and xgraph

alok kumar <[email protected]>
Newsgroups gmane.network.simulator.isi
Message-ID <CACHMSCVT0Vb4Q6nQw296kiyAg741oZJv6_tisrm-X2F3cPK+xg@mail.gmail.com>
sir,
   I am not understand  how to generate nam file and xgraph for below
.tcl file.Plz send me solution  according to below  .tcl file.

-------------------------------------------------------mkc-T1-heterogeneous.tcl------------------------------------------

# create scheduler
set ns [new Simulator]

# turn tracing on
set ns_f [open HeteroFlow.tr w]
$ns trace-all $ns_f
$ns namtrace-all [open out.nam w]

#set stat [open stat.txt w]

#create topology

#set number of flows
set N 5

#set the output file
for {set i 1} {$i<=$N} {incr i} {
	set out_($i) [open out$i.txt w]
}

#source
for {set i 1} {$i<=$N} {incr i} {
	set R_($i) [$ns node]
}

#bottleneck
set R_([expr $N + 1]) [$ns node]

#sink
set R_([expr $N + 2]) [$ns node]

#create the link connecting the source and sink
for {set i 1} {$i<=$N} {incr i} {
		$ns duplex-link $R_($i) $R_([expr $N + 1]) 500Mb [expr 100 + [expr
$i - 1] * 900]ms MKCQueue
}

$ns duplex-link $R_([expr $N + 1]) $R_([expr $N + 2]) 10Mb 10ms MKCQueue

for {set i 1} {$i<=$N} {incr i} {
		set mkcq_($i) [[$ns link $R_($i) $R_([expr $N + 1])] queue]
}

set mkcq_([expr $N + 1]) [[$ns link $R_([expr $N + 1]) $R_([expr $N +
2])] queue]

# link capacity
for {set i 1} {$i<=$N} {incr i} {
		$mkcq_($i) set C 500000000
		# the router sampling interval
		#$mkcq_($i) set T 0.1
		$mkcq_($i) set T [expr 0.1 * [expr $i - 1]]
		$mkcq_($i) set rid $i
}

# the bottleneck link capacity
$mkcq_([expr $N + 1]) set C 10000000
# the router sampling interval
$mkcq_([expr $N + 1]) set T 0.1
$mkcq_([expr $N + 1]) set rid [expr $N + 1]


#create and attach MKC agent

for {set i 1} {$i<=$N} {incr i} {
	# create a new MKC sender
 	set Src_($i) [new Agent/MKC]
	
 	# attach the sender at the source node
	$ns attach-agent $R_($i) $Src_($i)

 	$Src_($i) set alpha_ 1000000
	$Src_($i) set beta_ 0.5
	$Src_($i) set fid_ $i

	# set the initial rate
	$Src_($i) set init_rate_ 100000
	
	# set the data packet size
	$Src_($i) set packetSize_ 200
}

#create and attach MKCSink agents

for {set i 1} {$i<=$N} {incr i} {
	set Snk_($i) [new Agent/MKCSink]

	# set ACK packet size
	$Snk_($i) set packetSize_ 40

	# attach the receiver at the sink node
	$ns attach-agent $R_([expr $N + 2]) $Snk_($i)
}


# connect each pair of sender and receiver

for {set i 1} {$i<=$N} {incr i} {
	$ns connect $Src_($i) $Snk_($i)
}

# schedule the events

$ns at 0 "$Src_(1) start"
$ns at 5 "$Src_(2) start"

for {set i 1} {$i<=$N} {incr i} {
	$ns at 0 "record $Src_($i) $out_($i)"
}


for {set i 1} {$i<=$N} {incr i} {
	$ns at 100.0 "$Src_($i) stop"
}

$ns at 100.0 "finish"

proc record {mkcsrc file} {
global ns
	set step 0.1
    	set now [$ns now]
	set rate_ [$mkcsrc set rate_]
    	set pkt_loss_ [$mkcsrc set pkt_loss_]
    	puts $file "$now $rate_ $pkt_loss_"
    	$ns at [expr $now+$step] "record $mkcsrc $file"
}

proc finish {} {
        global ns ns_f  mkcq
        $ns flush-trace
        close $mkcq
        puts "running nam..."
        exec nam out.nam &
	exit 0
}

$ns run
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.