when i am  trying to generate  nam  file  it
  gives  error :   "Flow 1 starts at time 0.000000
                        Segmentation fault (core dumped)"


plz give me solution how to solve this  problem


--------------------------------mkc.tcl---------------------------------------------------

# create scheduler
set ns [new Simulator]


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

#set stat [open stat.txt w]

#create topology

#set number of flows
set N 2

#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 f nf
        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 f nf

        $ns flush-trace
        close $f
        close $nf

        puts "running nam...."
        exec nam out.nam &

        #exec xgraph out0.tr out1.tr out2.tr -geometry 800x400 &
        exit 0
}

$ns run





thank you

Reply via email to