Hello
   
  I m working with a network scenario ....where link BW is 1.5Mbps and is 
shared by both TCP and UDP flows. I used FTP over TCP and UDP based CBR 
background load with the same packet size 512 bytes. ..................
   
  Simulation Time: is 30sec. I have to maintain CBR rate to 
   
  At   0-5  sec :   1Mbps
  At 5-10  sec:    1.5 Mbps
  At 10-15 sec:  .8Mbps
  At 15-20 sec:  .1.3Mbps
  At 20-25 sec:  1.5Mbps
  At 20-25 sec:  .4Mbps
   
  But i dont know how to control cbr rate in TCL script. My outputs are always 
close to link BW .....they are not close available BW.
   
  Here is my TCL Script : 
   
  set ns [new Simulator]
  #Open the Trace files
set file1 [open out.txt w]
set f0 [open output1.txt w]
   
  $ns trace-all $file1
  #Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
   
  $ns color 1 Blue
$ns color 2 Red
   
  #Define a 'finish' procedure
proc finish {} {
      global f0 ns nf
        $ns flush-trace
 #Close the trace file
        close $nf
 #Execute nam on the trace file
        exec nam out.nam &
 close $f0
          exit 0
}
  set n0 [$ns node]
set n1 [$ns node]
  $ns duplex-link $n0 $n1 1.5Mb 10ms DropTail
  proc record {} {
        global sink0 f0
        set ns [Simulator instance]
   #Set the time after which the procedure should be called again
        set time 0.1 
        #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"
}
  set u_src [new Agent/UDP]
$ns attach-agent $n0 $u_src
set u_dst [new Agent/Null]
$ns attach-agent $n1 $u_dst
$ns connect $u_src $u_dst
$u_src set fid_ 1
   
  set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 512
#$cbr set interval_ 0.250
$cbr attach-agent $u_src
   
   
  set t_src [new Agent/TCP/Newreno]
$t_src set packetSize_ 512
set sink0 [new Agent/TCPSink]
$ns attach-agent $n0 $t_src
$ns attach-agent $n1 $sink0
$ns connect $t_src $sink0
$t_src set fid_ 2
   
  set ftp [new Application/FTP]
$ftp attach-agent $t_src
$ns at 0.0 "record" 
   
  $ns at 0.1 "$cbr start"
$cbr set rate_ 1
$ns at 5.0 "$cbr stop"
   
  $ns at 5.1 "$cbr start"
$cbr set rate_ 1.5
$ns at 10.0 "$cbr stop"
   
  $ns at 10.1 "$cbr start"
$cbr set rate_ .8
$ns at 15.0 "$cbr stop"
   
  $ns at 15.1 "$cbr start"
$cbr set rate_ 1.3
$ns at 20.0 "$cbr stop"
   
  $ns at 20.1 "$cbr start"
$cbr set rate_ 1.5
$ns at 25.0 "$cbr stop"
   
  $ns at 25.1 "$cbr start"
$cbr set rate_ .4
$ns at 30.0 "$cbr stop"
  
$ns at 1.0 "$ftp start"
$ns at 29.0 "$ftp stop"
  $ns at 30.1 "finish"
#Run the simulation
$ns run
   
  If anyone understand my problem ..i will very much appreitate his reply. 
Thanks.
   

       
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.

Reply via email to