I wrote an ns2 script to run concurrent HTTP requests from 40 nodes out of 80 nodes.
However, the simulation showed one node, rather than 40 nodes, make requests to the HTTP server.
Could someone please clarify what might be wrong with the code?
The code is provided below
Thank you for your time, everyone.
set ns [new Simulator]
set clswitch [$ns node] # the access layer switch
set distrswitch [$ns node] # the distribution switch
set cch [$ns node] # the cache
set websrv [$ns node] # the web server
set traceFile [open Asim.tr w]
set namTraceFile [open Asim.nam w]
$ns namtrace-all $namTraceFile
$ns trace-all $traceFile
proc finish {} {
global ns traceFile namTraceFile
$ns flush-trace-all
puts "Simulation completed."
flush $traceFile
flush $namTraceFile
close $traceFile
close $namTraceFile
exit 0
}
for {set i 0} {$i < 80} {incr i} {
if {$i % 2 == 0} {
set cl ($i) [$ns node]
$ns duplex-link $cl($i) $clswitch 100Mb 10ms DropTail
set tcpAgent [new Agent/TCP]
$ns attach-agent $cl($i) $tcpAgent
set tcpSink [new Agent/TCPSink]
$ns attach-agent $clswitch $tcpSink
$ns connect $tcpAgent $tcpSink
set client [new Http/Client $ns $cl($i)]
proc start-connection {} {
global ns client cache server
$client connect $cache
$cache connect $server
$client start-session $cache $server
}
$ns at 0.5 "start-connection"
}
}
$ns duplex-link $clswitch $distrswitch 100Mb 10ms DropTail
set tcpAgent [new Agent/TCP]
$ns attach-agent $clswitch $tcpAgent
set tcpSink [new Agent/TCPSink]
$ns attach-agent $distrswitch $tcpSink
$ns connect $tcpAgent $tcpSink
$ns duplex-link $distrswitch $cch 100Mb 10ms DropTail
set tcpAgent [new Agent/TCP]
$ns attach-agent $distrswitch $tcpAgent
set tcpSink [new Agent/TCPSink]
$ns attach-agent $cch $tcpSink
$ns connect $tcpAgent $tcpSink
$ns duplex-link $cch $websrv 100Mb 10ms DropTail
set tcpAgent [new Agent/TCP]
$ns attach-agent $cch $tcpAgent
set tcpSink [new Agent/TCPSink]
$ns attach-agent $websrv $tcpSink
$ns connect $tcpAgent $tcpSink
set server [new Http/Server $ns $websrv]
set cache [new Http/Cache $ns $cch]
set pgp [new PagePool/Math]
set tmp [new RandomVariable/Constant]
$tmp set val_ 4096
$pgp ranvar-size $tmp
set tmp [new RandomVariable/Exponential]
$tmp set avg_ 6
$pgp ranvar-age $tmp
$server set-page-generator $pgp
set tmp [new RandomVariable/Exponential]
$tmp set avg_ 0.5
$client set-interval-generator $tmp
$client set-page-generator $pgp
$ns at 6.0 "finish"
Aucun commentaire:
Enregistrer un commentaire