[ns] Web traffic simulator
yaya
lyningg at sina.com
Wed Sep 13 00:49:42 PDT 2006
HI, ns-users
my web simulator as following. I want get a process of getting only one page and finish. and I will analyse the latency of getting a web, the throughput, loss, and so on. but the operation of getting web page run from the beginning to the end. How can I do. thanks !
# Initial setup
source /home/ns2/ns-allinone-2.28/ns-2.28/tcl/http/http-mod.tcl
#Create a simulator object
set ns [new Simulator]
$ns color 0 blue ;# Set colors to display packets
$ns color 1 red
#Open the trace file
set p2p_tracefd [open http.tr w]
$ns trace-all $p2p_tracefd
#Open the nam trace file
set p2p_namfd [open http.nam w]
$ns namtrace-all $p2p_namfd
######################################################
#set the default parameter
######################################################
set m 1; ##set the number m of short-lived web
set u 10Mb; ##set the capacity of the bottleneck link
set Ltn 10ms; ##set the link RTT of long-lived tcp
set Ltm 20ms; ##set the link RTT of short-lived tcp
######################################################
#Create the nodes and links
#####################################################
set N0 [$ns node]
set r [$ns node]
$N0 label "N0"
$r label "route"
for {set j 1} {$j<=$m} {incr j} {
set Nt($j) [$ns node]
$Nt($j) label "Nt$j"
}
#Create a duplex link between the nodes
$ns duplex-link $N0 $r $u 1ms RED
$ns duplex-link-op $N0 $r color pink
for {set l 1} {$l<=$m} {incr l} {
$ns duplex-link $r $Nt($l) $u $Ltm RED
$ns duplex-link-op $r $Nt($l) color green
}
##########################################################
#set the short-lived web flow
#########################################################
$ns set src_ [list 2]
$ns set dst_ [list 0]
## Number of Pages per Session
set numPage 1
set httpSession1 [new HttpSession $ns $numPage [$ns picksrc]]
set httpSession2 [new HttpSession $ns $numPage [$ns picksrc]]
$httpSession1 setDistribution interPage_ Exponential 30 ;#in sec
$httpSession1 setDistribution pageSize_ Constant 1 ;# number of objects/page
$httpSession1 createPage
$httpSession1 setDistribution interObject_ Exponential 0.01 ;# in sec
$httpSession1 setDistribution objectSize_ ParetoII 10 1.2 ;# number of packets
# uses default
$httpSession2 createPage
$ns at 2.1 "$httpSession1 start" ;# in sec as well
$ns at 2.2 "$httpSession2 start"
###################################################################
# set the start and stop of the produce
##################################################################
$ns at 15 "finish"
#Define a 'finish' procedure of p2p nam
proc finish {} {
global ns p2p_tracefd p2p_namfd
$ns flush-trace
close $p2p_tracefd
close $p2p_namfd ;
exec nam http.nam &;
puts "finishing the ns"
exit 0
}
#Run the simulation
$ns run
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡yaya
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡lyningg at sina.com
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡2006-09-13
More information about the Ns-users
mailing list