0
我編寫了一個ns2腳本來運行來自80個節點中的40個節點的併發HTTP請求。Ns2節點不會發出併發http請求
但是,仿真顯示一個節點而不是40個節點向HTTP服務器發出請求。
有人可以請澄清什麼可能是錯誤的代碼?
該代碼在下面提供
謝謝你的時間,每個人。
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"