[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Monitor-queue and satellite links
Hi all,
I have tried to use the monitor-queue command to calculate the throughput
of a satellite link.
I receive this error message:
can't read "link_(0:2)": no such variable
while executing
"$link_([$n1 id]:[$n2 id]) init-monitor $self $qtrace $sampleInterval"
(procedure "_o3" line 3)
(Simulator monitor-queue line 3)
invoked from within
"$ns monitor-queue $n1 $n3 $f2 0.5"
(file "...." line 138)
I have used also a record procedure but I'm not sure about it.
The script, you can find below, is a modified version of the script
sat-repeater.tcl that comes with NS.
Any help is appreciated, thanks in advance.
#
# Copyright (c) 1999 Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the MASH Research
# Group at the University of California Berkeley.
# 4. Neither the name of the University nor of the Research Group may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Contributed by Tom Henderson, UCB Daedalus Research Group, June 1999
#
# Simple script with a geostationary satellite and two terminals
# and an error module on the receiving terminal. The traffic consists of
# a FTP source and a CBR stream
#
global ns
set ns [new Simulator]
$ns rtproto Dummy; # Using C++ routing agents and objects
# Global configuration parameters
global opt
set opt(chan) Channel/Sat
set opt(bw_up) 2Mb; # Uplink bandwidth-- becomes downlink bw also
set opt(phy) Phy/Sat
set opt(mac) Mac/Sat
set opt(ifq) Queue/DropTail
set opt(qlim) 50
set opt(ll) LL/Sat
# XXX This tracing enabling must precede link and node creation
set f [open out.tr w]
$ns trace-all $f
#Open the output files
set f0 [open out00.tr w]
set f1 [open out01.tr w]
# Set up satellite and terrestrial nodes
# GEO satellite at 95 degrees longitude West
set n1 [$ns satnode-geo-repeater -95 $opt(chan)]
# Two terminals: one in NY and one in SF
set n2 [$ns satnode-terminal 40.9 -73.9]; # NY
set n3 [$ns satnode-terminal 37.8 -122.4]; # SF
# Add GSLs to geo satellites
$n2 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \
$opt(phy) [$n1 set downlink_] [$n1 set uplink_]
$n3 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \
$opt(phy) [$n1 set downlink_] [$n1 set uplink_]
# Add an error model to the receiving terminal node
set em_ [new ErrorModel]
$em_ unit pkt
$em_ set rate_ 0.02
$em_ ranvar [new RandomVariable/Uniform]
$n3 interface-errormodel $em_
$ns trace-all-satlinks $f
# Attach agents for CBR traffic generator
set udp0 [new Agent/UDP]
$ns attach-agent $n2 $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set interval_ 6
#Define a procedure which periodically records the bandwidth received by the
#traffic sink sink0 and queue-monitor and writes it to the two files f0/1.
proc record {} {
global sink0 f0 f1 qmon
#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_]
set bw1 [$qmon set barrivals_]
#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]"
puts $f1 "$now [expr $bw1/$time*8/1000000]"
#Reset the bytes_ values on the traffic sinks
$sink0 set bytes_ 0
$qmon set barrivals_ 0
#Re-schedule the procedure
$ns at [expr $now+$time] "record"
}
# Create 1 traffic sink and attach it to the node n3
set sink0 [new Agent/LossMonitor]
$ns attach-agent $n3 $sink0
$ns connect $udp0 $sink0
# Attach agents for FTP
set tcp1 [$ns create-connection TCP $n2 TCPSink $n3 0]
set ftp1 [$tcp1 attach-app FTP]
$ns at 7.0 "$ftp1 produce 100"
# We use centralized routing
set satrouteobject_ [new SatRouteObject]
$satrouteobject_ compute_routes
set f2 [open link.tr w]
set qmon [$ns monitor-queue $n1 $n3 $f2 0.5]
$ns at 0.0 "record"
$ns at 1.0 "$cbr0 start"
$ns at 100.0 "finish"
#Define a 'finish' procedure
proc finish {} {
global ns f f0 f1
$ns flush-trace
#Close the output files
close $f
close $f0
close $f1
#Call xgraph to display the results
exec xgraph out00.tr out01.tr -geometry 800x400 &
exit 0
}
$ns run