[ns] How to select the Exponential (Only) in TCL
Mahmood Qureshi
comsians_bce at yahoo.com
Wed Mar 19 09:18:17 PDT 2008
Hi everyone
I want to implement the Finite Queuing in NS-2
according to the formula the Throughput can be calculated as
Throughput = lambda(1-Pk) // k is the queue length
and Pk = (e^k)*Po
and P0 = (1-e)/(1-e^(k+1))
which i have implemented in this code
if queue size is 2 then
throughput = 0.010144
Is it possible I can get the nearest of this value without using Random Variable ?
What Should I do ?
How to cancel the effect of random variable in the following code
Kindly Help me .............. It shall be greatly appreciated .............
In the given below i have provided the code .........
set ns [new Simulator]
set tf [open out.tr w]
$ns trace-all $tf
set lambda 30.0
set mu 33.0
set qsize 2
set duration 200
set n1 [$ns node]
set n2 [$ns node]
set link [$ns simplex-link $n1 $n2 100kb 0ms DropTail]
$ns queue-limit $n1 $n2 $qsize
# generate random interarrival times and packet sizes
set InterArrivalTime [new RandomVariable/Exponential]
$InterArrivalTime set avg_ [expr 1/$lambda]
#line edited below one
#set pktSize 100
set pktSize [new RandomVariable/Exponential]
$pktSize set avg_ [expr 100000.0/(8*$mu)]
set src [new Agent/UDP]
$src set packetSize_ 100000
$ns attach-agent $n1 $src
# queue monitoring
set qmon [$ns monitor-queue $n1 $n2 [open qm.out w] 0.1]
$link queue-sample-timeout
proc finish {} {
global ns tf
$ns flush-trace
close $tf
exit 0
}
proc th_put {} {
global qsize InterArrivalTime
set eps 2.718281828
set qsize1 [expr $qsize +1]
set eps_qsize1 [expr pow($eps,$qsize1)]
set eps_qsize [expr pow($eps, $qsize)]
set p0_1 [expr 1-$eps]
set p0_2 [expr 1-$eps_qsize1]
set p0 [expr $p0_1/$p0_2]
set pk [expr $eps_qsize*$p0]
for {set i 1} {$i<= 10} {incr i} {
set iat [$InterArrivalTime value]
puts " ====== IATe --> $iat ======= "
# Throughput
set t_put [expr [expr 1 - $pk]* $iat]
puts "Throughput = $t_put"
# Response Time
set res_time [expr $qsize1 / $t_put]
puts "Response Time = $res_time"
}
}
proc sendpacket {} {
global ns src InterArrivalTime pktSize
set time [$ns now]
$ns at [expr $time + [$InterArrivalTime value]] "sendpacket"
#edited line below one
#set bytes $pktSize
set bytes [expr round ([$pktSize value])]
$src send $bytes
}
set sink [new Agent/Null]
$ns attach-agent $n2 $sink
$ns connect $src $sink
$ns at 0.0001 "sendpacket"
$ns at 190 "th_put"
$ns at $duration "finish"
############################################################################
puts ""
puts "===========================Testing===================================="
puts "Processing ... "
$ns run
Engr. Mahmood Qureshi
HEC Scholar
Graduate Student: Computer Engineering
Myongji University, South-Korea
San 38-2
Nam-Dong
Yong-in
Gyunggi-Do (449-728)
South Korea
Mobile No. : +82-10-2891-7096
---------------------------------
Looking for last minute shopping deals? Find them fast with Yahoo! Search.
More information about the Ns-users
mailing list