Dear All

I need to know how can i measure the utilization of access point transmission 
buffer ,as i am simulating voip in wireless lan 802.11 and i need to measure 
the utilization of the access point transmission buffer and included in the 
mail the tcl script i use it.

# vim: syntax=tcl

#

 

##############################################################################

#                       CONFIGURATION OF PARAMETERS                          #

##############################################################################

 

#

# Simulation environment

#

set opt(run)        0         ;# replic ID

set opt(duration)   100.0     ;# run duration, in seconds

set opt(warm)       0       ;# run duration, in seconds

set opt(out)        "out"     ;# statistics output file

set opt(debug)      ""        ;# debug configuration file, "" = no debug

set opt(startdebug) 100.0     ;# start time of debug output

 

# VoIP modules parameters

 

set opt(aggregate) 1

set opt(tagrand)   "uniform"

set opt(tagmean)    0.130

set opt(tagvar)     0.01

set opt(tagper)     0

set opt(decoder)   "optimal"

#set opt(codec)    "GSM.AMR" ;# G.711, G.723.1, G.729A, GSM.EFR, GSM.AMR, 

set opt(codec)     "G.711" ;# G.711, G.723.1, G.729A, GSM.EFR, GSM.AMR, 

 

# static decoder parameters

set opt(static-buffer)  20

set opt(static-delay)   0.08

global opt

 

set opt(chan)       Channel/WirelessChannel

set opt(prop)       Propagation/TwoRayGround

set opt(netif)      Phy/WirelessPhy

set opt(mac)        Mac/802_11

set opt(ifq)        Queue/DropTail/PriQueue

set opt(ll)         LL

set opt(ant)        Antenna/OmniAntenna

set opt(x)             670   

set opt(y)              670   

set opt(ifqlen)         50  

set opt(tr)          wired-and-wireless2.tr

set opt(namtr)       wired-and-wireless2.nam

set opt(nn)             120                       

set opt(rp)            DSDV                     

set opt(cp)             ""                        

set opt(sc)             "../mobility/scene/scen-3-test"   

set opt(stop)           120                          

set num_bs_nodes         1

 

 

##############################################################################

#                       DEFINITION OF PROCEDURES                             #

##############################################################################

 

#

# parse command-line options_ and store values into the $opt(.) hash

#

proc getopt {argc argv} {

        global opt

 

        for {set i 0} {$i < $argc} {incr i} {

                set arg [lindex $argv $i]

                if {[string range $arg 0 0] != "-"} continue

 

                set name [string range $arg 1 end]

                set opt($name) [lindex $argv [expr $i+1]]

        }

}

 

#

# print out options

#

proc printopt { } {

        global opt

 

        foreach x [lsort [array names opt]] {

                puts "$x = $opt($x)"

        }

}

 

#

# die function

#

proc die { x } {

        puts $x

        exit 1

}

 

#

# alive function

#

proc alive { } {

        global ns_ opt

 

        if { [$ns_ now] != 0 } {

                puts -nonewline \

                 [format "elapsed %.0f s (remaining %.0f s) completed %.f%%" \

                 [$ns_ now] \

                 [expr $opt(duration) - [$ns_ now]] \

                 [expr 100 * [$ns_ now] / $opt(duration)]]

                if { [$ns_ now] >= $opt(warm) } {

                        puts " stat collection ON"

                } else {

                        puts ""

                }

        }

        $ns_ at [expr [$ns_ now] + $opt(duration) / 10.0] "alive"

}

 

#

# collect statistics at the end of the simulation

#

proc finish {} {

        global ns_ simtime

 

        # print statistics to output file

        $ns_ stat print

 

        # print out the simulation time

        set simtime [expr [clock seconds] - $simtime]

        puts "run duration: $simtime s"

 

        exit 0

}

 

#

# initialize simulation

#

proc init {} {

        global opt defaultRNG ns_ simtime

set t 1

set f [expr $opt(nn) + $t]              

set ns_   [new Simulator]

# set up for hierarchical routing

 $ns_ node-config -addressType hierarchical

 AddrParams set domain_num_ 1          

 lappend cluster_num 1                

 AddrParams set cluster_num_ $cluster_num

 lappend eilastlevel $f

 AddrParams set nodes_num_ $eilastlevel 

#  set tracefd  [open $opt(tr) w]

#  $ns_ trace-all $tracefd

  set namtracefd [open $opt(namtr) w]

  $ns_ namtrace-all $namtracefd

set num_bs_nodes         1

 

 

 

  set topo   [new Topography]

  $topo load_flatgrid $opt(x) $opt(y)

  # god needs to know the number of all wireless interfaces

  create-god [expr $opt(nn) + $num_bs_nodes]

 

  

  $ns_ node-config -adhocRouting $opt(rp) \

                 -llType $opt(ll) \

                 -macType $opt(mac) \

                 -ifqType $opt(ifq) \

                 -ifqLen $opt(ifqlen) \

                 -antType $opt(ant) \

                 -propInstance [new $opt(prop)] \

                 -phyType $opt(netif) \

                 -channel [new $opt(chan)] \

                 -topoInstance $topo \

                 -wiredRouting ON \

                 -agentTrace ON \

                 -routerTrace OFF \

                 -macTrace OFF

 

 

  

        # create the simulator instance

   

        $defaultRNG seed 1

 

        # initialize statistics collection

        $ns_ run-identifier $opt(run)

        $ns_ stat file "$opt(out)"

        $ns_ at $opt(warm) "$ns_ stat on"

        $ns_ at $opt(duration) "finish"

 

        # add default probes

        $ns_ stat add e2e_owd_a    avg discrete

        $ns_ stat add e2e_tpt      avg rate

        $ns_ stat add e2e_owpl     avg rate

        $ns_ stat add ifq     avg continuous 

 

        #$ns_ stat add tcp_cwnd_a   avg continuous

        #$ns_ stat add tcp_dupacks  avg continuous

        #$ns_ stat add tcp_ssthresh avg continuous

        #$ns_ stat add tcp_rtt      avg continuous

        #$ns_ stat add tcp_srtt     avg continuous

 

        #$ns_ stat add tcp_cwnd_d   dst continuous 0 128 128

        $ns_ stat add e2e_owd_d    dst discrete 0.0 1.0 1000

        #$ns_ stat add e2e_ipdv_d   dst discrete 0.0 5.0 100 

 

        $ns_ stat add voip_frame_delay avg discrete

        $ns_ stat add voip_frame_sent avg counter

        $ns_ stat add voip_frame_rcvd avg counter

        $ns_ stat add voip_mos_talkspurt avg discrete

        $ns_ stat add voip_none_frame_sent avg counter

        $ns_ stat add voip_none_frame_rcvd avg counter

        $ns_ stat add voip_none_mos_talkspurt avg discrete

        $ns_ stat add voip_end_mos avg discrete

        $ns_ stat add voip_end_per avg discrete

        $ns_ stat add voip_end_cell_outage avg discrete

           $ns_ stat add voip_buffer_overflow_drop avg counter

              $ns_ stat add voip_buffer_out_of_time_drop avg counter

              $ns_ stat add voip_%_of_bad_talkspurts avg discrete

$ns_ stat trace ifq 0 ifq.tr 

$ns_ stat trace e2e_owd_a 0 average-end-to-end-one-way-delay-s.tr

$ns_ stat trace e2e_tpt 0 average-end-to-endthroughput-bytes-s.tr

$ns_ stat trace e2e_owpl 0 avg-e2e-one-waypacketloss-pkts-s.tr    

$ns_ stat trace e2e_owd_d 0 dist-e2e-one-waydelay-0sto5s-step-50ms.tr        

        $ns_ stat trace voip_frame_delay 0 voip_frame_delay.tr 

        $ns_ stat trace voip_frame_sent 0 voip_frame_sent.tr

        $ns_ stat trace voip_frame_rcvd 0 voip_frame_rcvd.tr

        $ns_ stat trace voip_mos_talkspurt 0 voip_mos_talkspurt.tr 

        $ns_ stat trace voip_none_frame_sent 0 voip_none_frame_sent.tr 

        $ns_ stat trace voip_none_frame_rcvd 0 voip_none_frame_rcvd.tr

     $ns_ stat trace voip_none_mos_talkspurt 0 voip_none_mos_talkspurt.tr 

        $ns_ stat trace voip_end_mos 0 voip_end_mos.tr

        $ns_ stat trace voip_end_per 0 voip_end_per.tr 

     $ns_ stat trace voip_end_cell_outage 0 voip_outage.tr  

$ns_ stat trace voip_buffer_overflow_drop 0 voip_buffer_overflow_drop.tr  

$ns_ stat trace voip_buffer_out_of_time_drop 0 voip_buferoutoftimedrop.tr

$ns_ stat trace voip_%_of_bad_talkspurts 0 voip_%_of_bad_talkspurts.tr 

       

 # open trace files

        set opt(trace) [open "WVOIP2.tr" w]

        set simtime [clock seconds]

 

        $ns_ trace-all $opt(trace)

 

}

 

##############################################################################

#                       SCENARIO CONFIGURATION                               #

##############################################################################

 

proc scenario {} {

        global ns_ opt

        global opt

 

set temp 1.0.0

puts "coordinate of bs=$temp"

 # set BS(0) [$ns_ node 1.0.0] 

 set BS(0) [$ns_ node [lindex $temp]]

  $BS(0) random-motion 0 

 

  $BS(0) set X_ 1.0

  $BS(0) set Y_ 2.0

  $BS(0) set Z_ 0.0

  

 

  

  #configure for mobilenodes

  $ns_ node-config -wiredRouting OFF

 

  for {set j 0} {$j < $opt(nn)} {incr j} {

set h [expr $j + 1] 

set temp 1.0.$h

puts "coordinate=1.0.$h"

 

    set node_($j) [ $ns_ node [lindex $temp]]

    $node_($j) base-station [AddrParams addr2id [$BS(0) node-addr]]

  }        

        

 

            

      

set Tp 58

set Ravg 11.000

set Tsifs 16

set Tdifs 34

set Tack 18.7

set RTP [expr 12 * 8 / $Ravg]

set UDP [expr 8 * 8 /$Ravg]

set IP [expr 20 * 8 /$Ravg]

set MAC [expr 34 * 8/$Ravg]

set PHY 32.000

set Tlayers [expr $RTP + $UDP + $IP +$MAC +$PHY]

set vv [expr $Tp + $Tlayers + $Tsifs + $Tdifs +$Tack]

set Tdcf [expr 43.085 + 0.064 * $vv]

set uu [expr $Tp * $Ravg*1e6]

set dd [expr 128000 * ($Tp + $Tlayers +$Tsifs + $Tdifs +$Tack + $Tdcf + $Tdcf)]

set Nmax [expr $uu/$dd]

puts "Maximum no. of voip connections=$Nmax"

set y 2

set z [expr $opt(nn) / $y]

puts "max. no. of senders=$Nmax"

set t 0

set g 100 

set i 0

set u 0

for { set j 0 } { $j < $z } { incr j } {

 

if { $j < 6 } {

puts "sender=$j"

puts “t=$t”

 

              set source($i) [new VoipSource]

                    #$source($i) model exponential 1 1

                    $source($i) model one-to-one

                    $ns_ at $t "$source($i) start"

                    $ns_ at $g "$source($i) stop"

incr t

 

                    set encoder($i) [new Application/VoipEncoder]

                    $encoder($i) codec $opt(codec)

 

                    $source($i) encoder $encoder($i)

 

                    if { $opt(decoder) == "optimal" } {

                   set decoder($i) [new Application/VoipDecoderOptimal]

                    } elseif { $opt(decoder) == "static" } {

              set decoder($i) [new Application/VoipDecoderStatic]

                          $decoder($i) buffer-size   $opt(static-buffer)

                          $decoder($i) initial-delay $opt(static-delay)

                    } else {

                          puts "Unknown decoder type '$opt(decoder)'"

                          exit 0

                    }

 

        $decoder($i) id $i

                    $decoder($i) cell-id 0

                    $decoder($i) emodel $opt(codec)

 

                    set agtsrc($i) [new Agent/UDP]

                    set agtdst($i) [new Agent/UDP]

                    $agtsrc($i) set fid_ 1

set w 1

set l [expr $j + $w]

puts "reciever=$l"

                    $ns_ attach-agent $node_($j) $agtsrc($i)

                    $ns_ attach-agent $node_($l) $agtdst($i)

                    $ns_ connect $agtsrc($i) $agtdst($i)

                    $encoder($i) attach-agent $agtsrc($i)

                    $decoder($i) attach-agent $agtdst($i)

 

                    set aggregate($i) [new Application/VoipAggregate]

                    #$aggregate($i) size 200

                    $aggregate($i) nframes $opt(aggregate)

                    $aggregate($i) attach-agent $agtsrc($i)

                    $encoder($i) aggregate $aggregate($i)

 

                    $ns_ at $opt(startdebug) "$source($i) debug"

                    $ns_ at $opt(startdebug) "$encoder($i) debug"

                    $ns_ at $opt(startdebug) "$decoder($i) debug"

                    $ns_ at $opt(startdebug) "$aggregate($i) debug"

 

                    # end-to-end modules statistics collection

                    set tag [new e2et]

                    set mon [new e2em]

 

                    if { $opt(tagrand) == "uniform" } {

                          set tag_ranvar [new RandomVariable/Uniform]

                          $tag_ranvar set min_ 0

                          $tag_ranvar set max_ [expr $opt(tagmean) / 2]

                    } elseif { $opt(tagrand) == "exponential" } {

                          set tag_ranvar [new RandomVariable/Exponential]

                          $tag_ranvar set avg_ $opt(tagmean)

                    } elseif { $opt(tagrand) == "normal" } {

                          set tag_ranvar [new RandomVariable/Normal]

                          $tag_ranvar set avg_ $opt(tagmean)

                          $tag_ranvar set std_ [expr $opt(tagvar) / 2]

                    } elseif { $opt(tagrand) == "weibull" } {

                          set tag_ranvar [new RandomVariable/Weibull]

                          $tag_ranvar set shape_ 2

                    $tag_ranvar set scale_ [expr $opt(tagmean) / 0.88623]

                    } elseif { $opt(tagrand) == "constant" } {

                        set tag_ranvar [new RandomVariable/Constant]

                          $tag_ranvar set val_ $opt(tagmean)

                    } else {

                          puts "Unknown distribution '%s'"

                          exit 0

                    }

 

                    if { $opt(tagrand) != "none" } {

                          $tag ranvar $tag_ranvar

                    }

 

                    $tag per $opt(tagper)

                    $agtsrc($i) attach-e2et $tag

                    $agtdst($i) attach-e2em $mon

                    $mon index $i

                    $mon start-log

 

                    #$ns_ stat trace voip_frame_delay $i delay.$i

} else {

incr u

puts "Number of blocked voip connections=$u"

 

}

 

              }

 

 

  

              #set bidirectional [new VoipBidirectional]

              #$bidirectional source $source(0)

              #$bidirectional source $source(1)

              #$source(0) bidirectional $bidirectional

              #$source(1) bidirectional $bidirectional

              #$ns_ at $opt(startdebug) "$bidirectional debug"

}

 

##############################################################################

#                            MAIN BODY                                       #

##############################################################################

getopt $argc $argv

init

scenario

if { $opt(debug) != "" } {

        printopt

}

alive

 

$ns_ run

 



BR

Reply via email to