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

Re: [ns] MM1 queue and statistics: anyone has an example orimplementation?



Hi,
Here is sample script which might help you...But it require Akaroa
simulator with it  which is available at
http://www.cosc.canterbury.ac.nz/research/RG/net_sim/simulation_group.html.
I think that you can skip akaroa portion if you like it so ...
otherwise you need to install akaroa as well....?
Hope that it will help you..
Bye,
Aun.
*********************************
set ns [new Simulator]
#set nf [open out.nam w] 
#set tr [open out.tr w] 
set ak [new Akaroa]
#$ns namtrace-all $nf 
set expo1 [new RandomVariable/Exponential]
$expo1 set avg_ 1
set expo2 [new RandomVariable/Exponential]
$expo2 set avg_ 98
set node1 [$ns node]
set node2 [$ns node]
set link [$ns simplex-link $node1 $node2 1kb 0ms DropTail]
set qu  [$link queue]
$qu set limit_ 10000000 
$ns simplex-link-op $node1 $node2 queuePos 0.5
#$link trace $ns $tr 
set src [new Agent/UDP]
$ns attach-agent $node1 $src
set qmon [$ns monitor-queue $node1 $node2 ""]
set number 0
$ak AkDeclareParameters 2

proc finish {} {
    global ns number nf tr
    $ns flush-trace 
    puts "[expr $number/[$ns now]]"
    close $nf
    close $tr
    exit 0 
} 

proc sendpacket {} {
    global ns ak number src expo1 expo2 
    set then [$ns now]
    $ns at [expr $then + [$expo1 value]] "sendpacket"
    set bytes [expr round ([$expo2 value])]
    $ak AkObservation 1 $bytes
    #puts "$bytes"
    set number [expr $number + $bytes]
    $src send $bytes
    #puts "[expr $number/[$ns now]]"
}

proc observe {} {
    global ns qmon ak link
    #puts "[$link sample-queue-size]"
    set now [$ns now]
    set pkt [$qmon set pkts_]
    #puts "$now $pkt"
    $ns at [expr $now + 1] "observe"
    $ak AkObservation 2 $pkt
}

set sink [new Agent/Null]
$ns attach-agent $node2 $sink
$ns connect $src $sink
$ns at 0.00001 "sendpacket"
$ns at 0.00001 "observe"
$ns at 1000000000.0 "finish"

$ns run
******************************************************************************