[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Problem - Throughput greater than link bandwith
Hi NS users,
I have modified the script sat_repeater.tcl that comes with NS.
The script takes 2 argument:
first argument in the error rate in % (0 <--> 100) of the error model
second argument is:
the number of TCP Agents and FTP traffic sources
the number uf UDP Agents and CBR traffic sources
the bandwith of the link in Mb/s
(You can find the complete script below my signature)
With a simple awk script, I sum the size (in bytes) of all the packets
received by node2 (node2 in the trace file), I convert it to Mb and then
divide it by the length of the data transfer.
Now I try to explain my problem with an example:
ns script_name.tcl 0 2
so the error rate is 0.0 and I have 2 TCP agents and so on ... and a
bandwith of 2 Mb/s (or at least I think) .
The awk script gives me a value of about 3.5 (Mb/s I think). How is it
possible?
Could someone tell me where is my error?
Thanks in advance,
Giuseppe Tringali
#
# 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
#
# Modified by Giuseppe Tringali, 03-09-2001
# The script takes 2 argument:
# first argument in the error rate in % (0 <--> 100) of the error model
# second argument is:
# the number of TCP Agents and FTP traffic sources
# the number uf UDP Agents and CBR traffic sources
# the bandwith of the link in Mb/s
if {$argc != 2} {
puts "ERROR! ns called with wrong number of arguments!($argc)"
exit 1
} else {
set arg [lindex $argv 0]
set NN [lindex $argv 1]
set bw [expr $NN*1e6]
set max 100.0
set rate [expr $arg/$max]
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) bw; # Uplink bandwidth-- becomes downlink bw also
set opt(phy) Phy/Sat
set opt(mac) Mac/Sat
set opt(ifq) Queue/DropTail
set opt(qlim) 1000
set opt(ll) LL/Sat
# XXX This tracing enabling must precede link and node creation
set f [open out_p($arg)_n($NN).tr w]
$ns trace-all $f
# 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
# and sets its packet error rate to $rate
set em_ [new ErrorModel]
$em_ unit pkt
$em_ set rate_ $rate
$em_ ranvar [new RandomVariable/Uniform]
$n3 interface-errormodel $em_
$ns trace-all-satlinks $f
for {set counter 1} {$counter <= $NN} {incr counter} {
global ns n2 n3
# Attach agents for FTP
set tcp($counter) [$ns create-connection TCP/Newreno $n2 TCPSink $n3 $counter]
# set windows size to 100 packets
$tcp($counter) set window_ 100
# set packet size to 500 bytes
$tcp($counter) set packetSize_ 500
set ftp($counter) [$tcp($counter) attach-app FTP]
$ns at 1.0 "$ftp($counter) start"
# Attach agents for CBR traffic generator
set udp($counter) [new Agent/UDP]
$ns attach-agent $n2 $udp($counter)
set cbr($counter) [new Application/Traffic/CBR]
$cbr($counter) attach-agent $udp($counter)
# set packet size to 500 bytes
$udp($counter) set packetSize_ 500
# set flow id to counter
$udp($counter) set fid_ $counter
# set rate to 1 Mbps
$cbr($counter) set rate_ 1Mb
set sink($counter) [new Agent/LossMonitor]
$ns attach-agent $n3 $sink($counter)
$ns connect $udp($counter) $sink($counter)
$ns at 1.0 "$cbr($counter) start"
}
# We use centralized routing
set satrouteobject_ [new SatRouteObject]
$satrouteobject_ compute_routes
$ns at 100.0 "finish"
proc finish {} {
global ns f f0 f1
$ns flush-trace
close $f
exit 0
}
$ns run
}
}