1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
\chapter{Asim: approximate analytical simulation}
\label{chap:asim}
\begin{figure}
% \hrule
\vspace{1em}
\centerline{\includegraphics[angle=0,width=5in]{struct.eps}}
\vspace{1em}
% \hrule
\caption{The structure of Asim}
\label{fig:struct}
\end{figure}
This chapter describes a fast approximate network simulator, Asim.
Asim solves the steady state of the network using
approximate fixed points. The overall structure is shown in
Figure \ref{fig:struct}.
The user feeds a regular ns script
and turns on the asim flag.
Asim would do a fast approximate simulation of the
network scenario and would present to the user the drop probabilities
of the routers,
the delays and the approximate aggregate throughput
of the links and the flows.
In particular, we the following links/traffic are supported:
\begin{itemize}
\item Drop Tail Queues
\item RED Queues
\item Bulk TCP flows with FTP traffic
\item Short lived TCP flows
\end{itemize}
The data structures of Asim
are populated by a module within the Tcl space of ns from the
user supplied script. Upon executing Asim, the results can
be accessed using Tcl routines.
To use the Asim within a script the user has to use
\noindent Simulator set useasim\_ 1
\noindent By default, this flag is set to 0
A simple script is given below
\begin{verbatim}
proc addsrc { s } {
global ns
set t [$ns set src_]
lappend t $s
$ns set src_ $t
}
proc adddst { src } {
global ns
set t [$ns set dst_]
lappend t $src
$ns set dst_ $t
}
proc finish {} {
global ns fmon
set drops [$fmon set pdrops_]
set pkts [$fmon set parrivals_]
set notDroped [$fmon set pdepartures_]
set overflow_prob [expr 1.0 * $drops / $pkts]
puts [format "tdrops $drops tpkts $pkts o_prob. %7.4f" $overflow_prob]
exit 0
}
set N_ 100000
set arrival 0
set available $N_
set endTime_ 200
set ns [new Simulator]
$ns set useasim_ 1
$ns at $endTime_ "finish"
set src_ ""
set dst_ ""
$ns set src_ $src_
$ns set dst_ $dst_
set n(0) [$ns node]
set n(1) [$ns node]
set link(0:1) [$ns duplex-link $n(0) $n(1) 1Mbps 50ms RED]
for {set i 0} { $i < 4} {incr i} {
set ltcp($i) [new Agent/TCP]
set ltcpsink($i) [new Agent/TCPSink]
$ns attach-agent $n(0) $ltcp($i)
$ns attach-agent $n(1) $ltcpsink($i)
$ns connect $ltcp($i) $ltcpsink($i)
set lftp($i) [new Application/FTP]
$lftp($i) attach-agent $ltcp($i)
$ns at 0 "$lftp($i) start"
}
# Short term flows
addsrc 1
adddst 0
set pool [new PagePool/WebTraf]
# Set up server and client nodes
$pool set-num-client [llength [$ns set src_]]
$pool set-num-server [llength [$ns set dst_]]
global n
set i 0
foreach s [$ns set src_] {
$pool set-client $i $n($s)
incr i
}
set i 0
foreach s [$ns set dst_] {
$pool set-server $i $n($s)
incr i
}
# Number of Pages per Session
set numPage 100000
$pool set-num-session 1
set interPage [new RandomVariable/Exponential]
$interPage set avg_ 0.5
set pageSize [new RandomVariable/Constant]
$pageSize set val_ 1
set interObj [new RandomVariable/Exponential]
$interObj set avg_ 1
set objSize [new RandomVariable/Constant]
$objSize set val_ 20
# This is needed
$pool use-asim
$pool create-session 0 $numPage 0 $interPage $pageSize $interObj $objSize
# Dumps internal data structures to this dumpfile
$ns asim-dump dumpfile
# Calls asim-run
$ns asim-run
# Access asim statistics
set l [$ns link $n(0) $n(1)]
puts "after asim run, link bw = [$ns asim-getLinkTput $l] packets"
puts "after asim run, flow bw = [$ns asim-getFlowTput $ltcp(0)] packets"
\end{verbatim}
|