NS 2におけるコンテンツ配信システム(CDN)シミュレーション
16588 ワード
詳細については、次の項目を参照してください.http://sourceforge.net/projects/cdnsimulator/files/このサイトにはns-2.33バージョンのCDNシミュレーションモジュールが表示されており、インストールも便利です.
まず、ダウンロードしたインストールパッケージを解凍し、下図に示す赤いボックスマークのファイルをns-allinone-2.33/ディレクトリにコピーします.
次に、コマンド:patch-p 1最後に、再コンパイル:./configure; make clean; make
10ノードのシミュレーションスクリプト
シミュレーション結果は処理されず,正常に動作していることがわかり,具体的なデータ解析はまだ検証されていない.
まず、ダウンロードしたインストールパッケージを解凍し、下図に示す赤いボックスマークのファイルをns-allinone-2.33/ディレクトリにコピーします.
次に、コマンド:patch-p 1
10ノードのシミュレーションスクリプト
set ns [new Simulator]
proc finish {} {
# exec gnuplot 0_plot10nodi.gp
# exec gnuplot 0_oh_plot10nodi.gp
# exec gnuplot 0_inst_oh_plot10nodi.gp
exit 0
}
############################## GLOBAL SETTINGS ################################
# #
# CDN ALGORITHM ("algo"): # OVERLAY TOPOLOGY ("topology"):
# #
# LL // Lowest Load: 0 # full mesh: 0
# RR // Round Robin: 1 # squares: 1
# RAND // Random: 2 # mista: 2
# R2C // Two Random Choise: 3 #
# SWL // Statistic Weighted Load: 4 #
# FSOB // Fictitius Starred: 5 #
set topology 0
set algo 2
set algo_rate 2
set totaltime 500
set initial_peak 75
set final_peak 450
#######################################################################################
set multiredirect 1
if {$algo==1} {set multiredirect 0}
if {$algo==2} {set multiredirect 0}
if {$algo==3} {set multiredirect 0}
#Server node creation ##############################################
set s0 [$ns node]
$s0 color green
$s0 label server_add:[$s0 id]
set s1 [$ns node]
$s1 color green
$s1 label server_add:[$s1 id]
set s2 [$ns node]
$s2 color green
$s2 label server_add:[$s2 id]
set s3 [$ns node]
$s3 color green
$s3 label server_add:[$s3 id]
set s4 [$ns node]
$s4 color green
$s4 label server_add:[$s4 id]
set s5 [$ns node]
$s5 color green
$s5 label server_add:[$s5 id]
set s6 [$ns node]
$s6 color green
$s6 label server_add:[$s6 id]
set s7 [$ns node]
$s7 color green
$s7 label server_add:[$s7 id]
set s8 [$ns node]
$s8 color green
$s8 label server_add:[$s8 id]
set s9 [$ns node]
$s9 color green
$s9 label server_add:[$s9 id]
#Links
$ns duplex-link $s0 $s1 1Mb 100ms DropTail
$ns duplex-link $s1 $s2 1Mb 100ms DropTail
$ns duplex-link $s2 $s3 1Mb 100ms DropTail
$ns duplex-link $s5 $s6 1Mb 100ms DropTail
$ns duplex-link $s2 $s6 1Mb 100ms DropTail
$ns duplex-link $s1 $s7 1Mb 100ms DropTail
$ns duplex-link $s7 $s8 1Mb 100ms DropTail
$ns duplex-link $s2 $s8 1Mb 100ms DropTail
$ns duplex-link $s4 $s8 1Mb 100ms DropTail
$ns duplex-link $s3 $s9 1Mb 100ms DropTail
$ns duplex-link $s4 $s9 1Mb 100ms DropTail
#Servers' agents
set S0 [new Agent/CdnAgent]
$s0 attach $S0 80
set S1 [new Agent/CdnAgent]
$s1 attach $S1 80
set S2 [new Agent/CdnAgent]
$s2 attach $S2 80
set S3 [new Agent/CdnAgent]
$s3 attach $S3 80
set S4 [new Agent/CdnAgent]
$s4 attach $S4 80
set S5 [new Agent/CdnAgent]
$s5 attach $S5 80
set S6 [new Agent/CdnAgent]
$s6 attach $S6 80
set S7 [new Agent/CdnAgent]
$s7 attach $S7 80
set S8 [new Agent/CdnAgent]
$s8 attach $S8 80
set S9 [new Agent/CdnAgent]
$s9 attach $S9 80
#Servers' applications and settings
set cs0 [new Application/CdnServer $S0]
set cs1 [new Application/CdnServer $S1]
set cs2 [new Application/CdnServer $S2]
set cs3 [new Application/CdnServer $S3]
set cs4 [new Application/CdnServer $S4]
set cs5 [new Application/CdnServer $S5]
set cs6 [new Application/CdnServer $S6]
set cs7 [new Application/CdnServer $S7]
set cs8 [new Application/CdnServer $S8]
set cs9 [new Application/CdnServer $S9]
$cs0 set scan-rate 0.0001
$cs1 set scan-rate 0.0001
$cs2 set scan-rate 0.0001
$cs3 set scan-rate 0.0001
$cs4 set scan-rate 0.0001
$cs5 set scan-rate 0.0001
$cs6 set scan-rate 0.0001
$cs7 set scan-rate 0.0001
$cs8 set scan-rate 0.0001
$cs9 set scan-rate 0.0001
#Clients settings
#client
set c0 [$ns node]
$c0 color red
$c0 label client_add:[$c0 id]
#link
$ns duplex-link $c0 $s0 1Mb 100ms DropTail
#agent
set C0 [new Agent/CdnAgent]
$c0 attach $C0 80
#application
set cc0 [new Application/CdnClient $C0 ]
#application settings
$cc0 wait-mode off
#client
set c1 [$ns node]
$c1 color red
$c1 label client_add:[$c1 id]
$ns duplex-link $c1 $s1 1Mb 100ms DropTail
set C1 [new Agent/CdnAgent]
$c1 attach $C1 80
set cc1 [new Application/CdnClient $C1 ]
$cc1 wait-mode off
#client
set c2 [$ns node]
$c2 color red
$c2 label client_add:[$c2 id]
$ns duplex-link $c2 $s2 1Mb 100ms DropTail
set C2 [new Agent/CdnAgent]
$c2 attach $C2 80
set cc2 [new Application/CdnClient $C2 ]
$cc2 wait-mode off
#client
set c3 [$ns node]
$c3 color red
$c3 label client_add:[$c3 id]
#link
$ns duplex-link $c3 $s3 1Mb 100ms DropTail
#agent
set C3 [new Agent/CdnAgent]
$c3 attach $C3 80
#application
set cc3 [new Application/CdnClient $C3 ]
#application settings
$cc3 wait-mode off
#client
set c4 [$ns node]
$c4 color red
$c4 label client_add:[$c4 id]
$ns duplex-link $c4 $s4 1Mb 100ms DropTail
set C4 [new Agent/CdnAgent]
$c4 attach $C4 80
set cc4 [new Application/CdnClient $C4 ]
$cc4 wait-mode off
#client
set c5 [$ns node]
$c5 color red
$c5 label client_add:[$c5 id]
$ns duplex-link $c5 $s5 1Mb 100ms DropTail
set C5 [new Agent/CdnAgent]
$c5 attach $C5 80
set cc5 [new Application/CdnClient $C5 ]
$cc5 wait-mode off
#client
set c6 [$ns node]
$c6 color red
$c6 label client_add:[$c6 id]
$ns duplex-link $c6 $s6 1Mb 100ms DropTail
set C6 [new Agent/CdnAgent]
$c6 attach $C6 80
set cc6 [new Application/CdnClient $C6 ]
$cc6 wait-mode off
#client
set c7 [$ns node]
$c7 color red
$c7 label client_add:[$c7 id]
$ns duplex-link $c7 $s7 1Mb 100ms DropTail
set C7 [new Agent/CdnAgent]
$c7 attach $C7 80
set cc7 [new Application/CdnClient $C7 ]
$cc7 wait-mode off
#client
set c8 [$ns node]
$c8 color red
$c8 label client_add:[$c8 id]
$ns duplex-link $c8 $s8 1Mb 100ms DropTail
set C8 [new Agent/CdnAgent]
$c8 attach $C8 80
set cc8 [new Application/CdnClient $C8 ]
$cc8 wait-mode off
#client
set c9 [$ns node]
$c9 color red
$c9 label client_add:[$c9 id]
$ns duplex-link $c9 $s9 1Mb 100ms DropTail
set C9 [new Agent/CdnAgent]
$c9 attach $C9 80
set cc9 [new Application/CdnClient $C9 ]
$cc9 wait-mode off
#Topology & Balancig ############################################################
switch $topology {
0 {$cs0 peers [$s1 id] [$s2 id] [$s3 id] [$s4 id] [$s5 id] [$s6 id] [$s7 id] [$s8 id] [$s9 id]
$cs1 peers [$s0 id] [$s2 id] [$s3 id] [$s4 id] [$s5 id] [$s6 id] [$s7 id] [$s8 id] [$s9 id]
$cs2 peers [$s1 id] [$s0 id] [$s3 id] [$s4 id] [$s5 id] [$s6 id] [$s7 id] [$s8 id] [$s9 id]
$cs3 peers [$s1 id] [$s2 id] [$s0 id] [$s4 id] [$s5 id] [$s6 id] [$s7 id] [$s8 id] [$s9 id]
$cs4 peers [$s1 id] [$s2 id] [$s3 id] [$s0 id] [$s5 id] [$s6 id] [$s7 id] [$s8 id] [$s9 id]
$cs5 peers [$s1 id] [$s2 id] [$s3 id] [$s4 id] [$s0 id] [$s6 id] [$s7 id] [$s8 id] [$s9 id]
$cs6 peers [$s1 id] [$s2 id] [$s3 id] [$s4 id] [$s5 id] [$s0 id] [$s7 id] [$s8 id] [$s9 id]
$cs7 peers [$s1 id] [$s2 id] [$s3 id] [$s4 id] [$s5 id] [$s6 id] [$s0 id] [$s8 id] [$s9 id]
$cs8 peers [$s1 id] [$s2 id] [$s3 id] [$s4 id] [$s5 id] [$s6 id] [$s7 id] [$s0 id] [$s9 id]
$cs9 peers [$s1 id] [$s2 id] [$s3 id] [$s4 id] [$s5 id] [$s6 id] [$s7 id] [$s8 id] [$s0 id]
}
1 { $cs0 peers [$s1 id] [$s5 id]
$cs1 peers [$s0 id] [$s2 id] [$s6 id]
$cs2 peers [$s3 id] [$s1 id] [$s7 id]
$cs3 peers [$s2 id] [$s4 id] [$s8 id]
$cs4 peers [$s3 id] [$s9 id]
$cs5 peers [$s6 id] [$s0 id]
$cs6 peers [$s5 id] [$s1 id] [$s7 id]
$cs7 peers [$s8 id] [$s6 id] [$s2 id]
$cs8 peers [$s9 id] [$s7 id] [$s3 id]
$cs9 peers [$s4 id] [$s8 id]
}
2 { $cs0 peers [$s1 id] [$s3 id]
$cs1 peers [$s0 id] [$s2 id] [$s4 id]
$cs2 peers [$s5 id] [$s1 id] [$s6 id]
$cs3 peers [$s0 id] [$s4 id] [$s9 id]
$cs4 peers [$s3 id] [$s1 id] [$s5 id]
$cs5 peers [$s2 id] [$s4 id]
$cs6 peers [$s2 id] [$s7 id]
$cs7 peers [$s6 id]
$cs8 peers [$s9 id]
$cs9 peers [$s3 id] [$s8 id]
}
default {puts "Topology-error!!!"}
}
#Load Balancing algorithm choice
$cs0 algorithm $algo
$cs1 algorithm $algo
$cs2 algorithm $algo
$cs3 algorithm $algo
$cs4 algorithm $algo
$cs5 algorithm $algo
$cs6 algorithm $algo
$cs7 algorithm $algo
$cs8 algorithm $algo
$cs9 algorithm $algo
#Algorate peering interval settings
$cs0 set algo-rate $algo_rate
$cs1 set algo-rate $algo_rate
$cs2 set algo-rate $algo_rate
$cs3 set algo-rate $algo_rate
$cs4 set algo-rate $algo_rate
$cs5 set algo-rate $algo_rate
$cs6 set algo-rate $algo_rate
$cs7 set algo-rate $algo_rate
$cs8 set algo-rate $algo_rate
$cs9 set algo-rate $algo_rate
#Multiple redirect settings
$cs0 set multiple-redirect $multiredirect
$cs1 set multiple-redirect $multiredirect
$cs2 set multiple-redirect $multiredirect
$cs3 set multiple-redirect $multiredirect
$cs4 set multiple-redirect $multiredirect
$cs5 set multiple-redirect $multiredirect
$cs6 set multiple-redirect $multiredirect
$cs7 set multiple-redirect $multiredirect
$cs8 set multiple-redirect $multiredirect
$cs9 set multiple-redirect $multiredirect
# TRAFFIC SETTINGS ##############################################################
#Initial condition creation with a first load on servers
$ns at 0.0 "$cc0 set get-rate 0.1"
$ns at 0.0 "$cc1 set get-rate 0.1"
$ns at 0.0 "$cc2 set get-rate 0.1"
$ns at 0.0 "$cc3 set get-rate 0.1"
$ns at 0.0 "$cc4 set get-rate 0.1"
$ns at 0.0 "$cc5 set get-rate 0.1"
$ns at 0.0 "$cc6 set get-rate 0.1"
$ns at 0.0 "$cc7 set get-rate 0.1"
$ns at 0.0 "$cc8 set get-rate 0.1"
$ns at 0.0 "$cc9 set get-rate 0.1"
$ns at 0.0 "$cc0 load-a-server [$s0 id] 1 20"
$ns at 0.0 "$cc1 load-a-server [$s1 id] 1 10"
$ns at 0.0 "$cc2 load-a-server [$s2 id] 1 5"
$ns at 0.0 "$cc3 load-a-server [$s3 id] 1 25"
$ns at 0.0 "$cc4 load-a-server [$s4 id] 1 20"
$ns at 0.0 "$cc5 load-a-server [$s5 id] 1 10"
$ns at 0.0 "$cc6 load-a-server [$s6 id] 1 5"
$ns at 0.0 "$cc7 load-a-server [$s7 id] 1 25"
$ns at 0.0 "$cc8 load-a-server [$s8 id] 1 10"
$ns at 0.0 "$cc9 load-a-server [$s9 id] 1 20"
$cs0 exp-serv
$cs1 exp-serv
$cs2 exp-serv
$cs3 exp-serv
$cs4 exp-serv
$cs5 exp-serv
$cs6 exp-serv
$cs7 exp-serv
$cs8 exp-serv
$cs9 exp-serv
$cs0 set exp-avg 0.085
$cs1 set exp-avg 0.10
$cs2 set exp-avg 0.15
$cs3 set exp-avg 0.105
$cs4 set exp-avg 0.075
$cs5 set exp-avg 0.095
$cs6 set exp-avg 0.09
$cs7 set exp-avg 0.07
$cs8 set exp-avg 0.06
$cs9 set exp-avg 0.08
$cc0 set exp-avg 0.08
$cc1 set exp-avg 0.075
$cc2 set exp-avg 0.07
$cc3 set exp-avg 0.06
$cc4 set exp-avg 0.10
$cc5 set exp-avg 0.09
$cc6 set exp-avg 0.095
$cc7 set exp-avg 0.15
$cc8 set exp-avg 0.105
$cc9 set exp-avg 0.085
#Flash Crowd
#ns at 200.0 "$cc0 set exp-avg 0.04"
#ns at 250.0 "$cc0 set exp-avg 0.1"
#New infinite loading process at get-rate seconds
$ns at 50.0 "$cc0 load-a-server [$s0 id] 1 -2"
$ns at 50.0 "$cc1 load-a-server [$s1 id] 1 -2"
$ns at 50.0 "$cc2 load-a-server [$s2 id] 1 -2"
$ns at 50.0 "$cc3 load-a-server [$s3 id] 1 -2"
$ns at 50.0 "$cc4 load-a-server [$s4 id] 1 -2"
$ns at 50.0 "$cc5 load-a-server [$s5 id] 1 -2"
$ns at 50.0 "$cc6 load-a-server [$s6 id] 1 -2"
$ns at 50.0 "$cc7 load-a-server [$s7 id] 1 -2"
$ns at 50.0 "$cc8 load-a-server [$s8 id] 1 -2"
$ns at 50.0 "$cc9 load-a-server [$s9 id] 1 -2"
####################################################################################
#Start...
#Servers' start
$ns at 50.0 "$cs0 start"
$ns at 50.0 "$cs1 start"
$ns at 50.0 "$cs2 start"
$ns at 50.0 "$cs3 start"
$ns at 50.0 "$cs4 start"
$ns at 50.0 "$cs5 start"
$ns at 50.0 "$cs6 start"
$ns at 50.0 "$cs7 start"
$ns at 50.0 "$cs8 start"
$ns at 50.0 "$cs9 start"
#Start the sampler
set samplingtime 5
#Start the sampler on SERVER
$ns at 50.0 "$cs0 start-sampler $samplingtime"
$ns at 50.0 "$cs1 start-sampler $samplingtime"
$ns at 50.0 "$cs2 start-sampler $samplingtime"
$ns at 50.0 "$cs3 start-sampler $samplingtime"
$ns at 50.0 "$cs4 start-sampler $samplingtime"
$ns at 50.0 "$cs5 start-sampler $samplingtime"
$ns at 50.0 "$cs6 start-sampler $samplingtime"
$ns at 50.0 "$cs7 start-sampler $samplingtime"
$ns at 50.0 "$cs8 start-sampler $samplingtime"
$ns at 50.0 "$cs9 start-sampler $samplingtime"
#Start the sampler on CLIENT
#$ns at 50.0 "$cc0 start-sampler $samplingtime"
#$ns at 50.0 "$cc1 start-sampler $samplingtime"
#$ns at 50.0 "$cc2 start-sampler $samplingtime"
#$ns at 50.0 "$cc3 start-sampler $samplingtime"
#Start the sampler on CLIENT
$ns at 50.0 "$cc0 start-sampler 20"
$ns at 50.0 "$cc1 start-sampler 20"
$ns at 50.0 "$cc2 start-sampler 20"
$ns at 50.0 "$cc3 start-sampler 20"
$ns at 50.0 "$cc4 start-sampler 20"
$ns at 50.0 "$cc5 start-sampler 20"
$ns at 50.0 "$cc6 start-sampler 20"
$ns at 50.0 "$cc7 start-sampler 20"
$ns at 50.0 "$cc8 start-sampler 20"
$ns at 50.0 "$cc9 start-sampler 20"
#Finishing... ########################################################################
proc pre_finish {algor client1 client2 client3 client4 client5 client6
client7 client8 client9 client10 } {
$client1 "show-overhead"
$client2 "show-overhead"
$client3 "show-overhead"
$client4 "show-overhead"
$client5 "show-overhead"
$client6 "show-overhead"
$client7 "show-overhead"
$client8 "show-overhead"
$client9 "show-overhead"
$client10 "show-overhead"
$client1 "rtt-avg-value"
$client2 "rtt-avg-value"
$client3 "rtt-avg-value"
$client4 "rtt-avg-value"
$client5 "rtt-avg-value"
$client6 "rtt-avg-value"
$client7 "rtt-avg-value"
$client8 "rtt-avg-value"
$client9 "rtt-avg-value"
$client10 "rtt-avg-value"
$client1 "rtt-std-dev"
$client2 "rtt-std-dev"
$client3 "rtt-std-dev"
$client4 "rtt-std-dev"
$client5 "rtt-std-dev"
$client6 "rtt-std-dev"
$client7 "rtt-std-dev"
$client8 "rtt-std-dev"
$client9 "rtt-std-dev"
$client10 "rtt-std-dev"
}
$ns at $totaltime "$cc0 rtt-peak $initial_peak $final_peak"
$ns at $totaltime "$cc1 rtt-peak $initial_peak $final_peak"
$ns at $totaltime "$cc2 rtt-peak $initial_peak $final_peak"
$ns at $totaltime "$cc3 rtt-peak $initial_peak $final_peak"
$ns at $totaltime "$cc4 rtt-peak $initial_peak $final_peak"
$ns at $totaltime "$cc5 rtt-peak $initial_peak $final_peak"
$ns at $totaltime "$cc6 rtt-peak $initial_peak $final_peak"
$ns at $totaltime "$cc7 rtt-peak $initial_peak $final_peak"
$ns at $totaltime "$cc8 rtt-peak $initial_peak $final_peak"
$ns at $totaltime "$cc9 rtt-peak $initial_peak $final_peak"
$ns at $totaltime "pre_finish $algo $cc0 $cc1 $cc2 $cc3 $cc4 $cc5 $cc6 $cc7 $cc8 $cc9"
$ns at $totaltime "$cc0 show-avarage 10"
#$ns at [expr $totaltime - 1] "$cc0 rtt-peak $initial_peak $final_peak"
#$ns at [expr $totaltime - 1] "$cc1 rtt-peak $initial_peak $final_peak"
#$ns at [expr $totaltime - 1] "$cc2 rtt-peak $initial_peak $final_peak"
#$ns at [expr $totaltime - 1] "$cc3 rtt-peak $initial_peak $final_peak"
#$ns at [expr $totaltime - 1] "pre_finish $algo $cc0 $cc1 $cc2 $cc3"
#$ns at [expr $totaltime - 1] "$cc0 show-avarage 4"
$ns at $totaltime "finish"
$ns run
シミュレーション結果は処理されず,正常に動作していることがわかり,具体的なデータ解析はまだ検証されていない.