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

[ns] ftp seg fault



Dear all,

Here is a snippet of my code.  I'm trying to plot TCP
throughput vs. packet error rate/probability (PER). 
For some reason, even when I set the PER=0 on both
links, I get only three spikes in my xgraph
(y-coordinate is 640*10^-6).  I expected that FTP
should be alittle more active than this - why is ftp
so inactive compared to CBR?  So I tried ftp "produce"
and "producemore" and why I am getting segmentation
faults?  Thanks a lot!

Ray

#uniform error generation
proc    build-error { n0 n1 rate} {
        global  ns

        set loss_module [new ErrorModel]
        $loss_module ranvar [new
RandomVariable/Uniform]
        $loss_module unit pkt

        # (ex) set error rate to 0.0032=0.0032/(1-0)
        #$loss_module set rate_ 0.1 -> one pkts of 10
pkts are lost
        $loss_module set rate_ $rate
        $loss_module set enable_ 1
        $loss_module drop-target [new Agent/Null]

        # Errors bet queue and delay
        $ns link-lossmodel $loss_module $n0 $n1
}

#Create 3 nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]

#Connect the nodes
$ns duplex-link $n0 $n1 1Mb 100ms DropTail
$ns duplex-link $n1 $n2 1Mb 100ms DropTail
$ns duplex-link-op $n0 $n1 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up

build-error $n0 $n1 0     
build-error $n1 $n2 0     

# TCP connections between node_(0) and node_(2)
set tcp [new Agent/TCP]

$tcp set class_ 2
#set sink0 [new Agent/TCPSink]
set sink0 [new Agent/LossMonitor]
$ns attach-agent $n0 $tcp
$ns attach-agent $n2 $sink0
$ns connect $tcp $sink0
set ftp [new Application/FTP]
$ftp set maxpkts 1000
$ftp produce 1000 
$ftp attach-agent $tcp

#Define a 'finish' procedure
proc finish {} {   
        global f0
        global ns nf
        #Close the output files
        close $f0
        $ns flush-trace
        close $nf
        exec /tmp/ns-allinone-2.1b8a/nam-1.0a10/nam
out.nam &
        #Call xgraph to display the results
        exec
/tmp/ns-allinone-2.1b8a/xgraph-12.1/xgraph out0.tr
-geometry 800x400 &
        exit 0
}

#Define a procedure which periodically records the
bandwidth received by the
#traffic sink sink0 and writes it to file f0.
proc record {} {
        global sink0 f0
        #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 [$sink0 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]"
        #Reset the bytes_ values on the traffic sinks
        $sink0 set bytes_ 0
        #Re-schedule the procedure
        $ns at [expr $now+$time] "record"
}

#Start logging the received bandwidth
$ns at 0.0 "record"
#Start the traffic sources
$ns at 10.0 "$ftp start"
#Stop the traffic sources
$ns at 50.0 "$ftp stop"
#Call the finish procedure after 60 seconds simulation
time
$ns at 60.0 "finish"

#Run the simulation
$ns run
 



__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com