CÁC BẠN xem, mình viết code thuật toán FFUC đúng không các bạn.
có gì nhờ tư vấn thêm
code.
#Cac thong so ban dau
#10 node bien, 10 node loi
#20 Gbit/s channels
#4 DCs; 2 CCs
StatCollector set debug_ 0
Classifier/BaseClassifier/EdgeClassifier set type_ 0
Classifier/BaseClassifier/CoreClassifier set type_ 1
# Thoi gian xu ly goi dieu khien 1 micro-second
source ../lib/ns-obs-lib.tcl
source ../lib/ns-obs-defaults.tcl
source ../lib/ns-optic-link.tcl
set ns [new Simulator]
set nf [open basic01.nam w]
set sc [new StatCollector]
set tf [open trace01.tr w]
set ndf [open ndtrace01.tr w]
set old_data 0
# Xuat ra file nam
$ns namtrace-all $nf
$ns trace-all $tf
$ns nodetrace-all $ndf
#====================================================================#
# Cac thong so trong mang
#v6 uses 1 - 70 mu s FOR offset time
BurstManager offsettime 0.00002
#v6 uses 10000 - 70000 bytes
BurstManager maxburstsize 60000
#Thoi gian thiet lap burst
BurstManager bursttimeout 0.0003
# Xu ly goi tin dieu khien 1 microsecond
Classifier/BaseClassifier/CoreClassifier set bhpProcTime 0.000001
Classifier/BaseClassifier/EdgeClassifier set bhpProcTime 0.0000015
#Gia su co 1 kenh FDL tren 1 kenh buoc song dau ra
Classifier/BaseClassifier set nfdl 10
#v6 fdl prop delay not known; 100 mu s is of order of trans delay
Classifier/BaseClassifier set fdldelay 0.0001
Classifier/BaseClassifier set option 0
#v6 uses up to 10 FDL delays per node
Classifier/BaseClassifier set maxfdls 8
Classifier/BaseClassifier set ebufoption 0
#Thoi gian tre co dinh tai moi node
OBSFiberDelayLink set FDLdelay 0.0001
#Tong so node bien
set edge_count 10
# tong so node loi
set core_count 10
# total bandwidth/channel (1mb = 1000000)
set bwpc 10000000000
#set bwpc
# Tre tinh bang milliseconds
set delay 0.1ms
# So kenh tren duong kink
set maxch 6
#So kenh dieu khien tren duong link
set ncc 2
#So kenh du kieu tren duong link
set ndc 4
#====================================================================#
# Cac qua trinh ho tro
# finish procedure
proc finish {} {
global ns nf sc tf ndf old_data
$ns flush-trace
$ns flush-nodetrace
close $nf
close $tf
close $ndf
$sc display-sim-list
#Thuc hien file nam
#exec nam basic01.nam &
exec awk {
{
if ( $1=="r") {
old_data = old_data + $5 }
print $2, old_data*1.0
}
} ndtrace01.tr > lauc.data
exec xgraph ffuc.data &
puts "Qua trinh mo phong hoan tat";
exit 0
}
#print $2, old_data*8.0/$2/10000000000
#Tao topology bien_loi_bien
Simulator instproc create_topology { } {
$self instvar Node_
global E C
global edge_count core_count
global bwpc maxch ncc ndc delay
set i 0
# Thiet lap node bien
WHILE { $i < $edge_count } {
set E($i) [$self create-edge-node $edge_count]
set nid [$E($i) id]
set string1 "E($i) node id: $nid"
puts $string1
incr i
}
set i 0
# Thiet lap node loi
WHILE { $i < $core_count } {
set C($i) [$self create-core-node $core_count]
set nid [$C($i) id]
set string1 "C($i) node id: $nid"
puts $string1
incr i
}
$self createDuplexFiberLink $E(0) $C(0) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $E(1) $C(1) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $E(2) $C(2) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $E(3) $C(3) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $E(4) $C(4) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $E(5) $C(5) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $E(6) $C(6) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $E(7) $C(7) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $E(8) $C(8) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $E(9) $C(9) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $C(0) $C(1) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $C(1) $C(2) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $C(2) $C(3) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $C(3) $C(4) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $C(4) $C(5) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $C(5) $C(6) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $C(6) $C(0) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $C(7) $C(0) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $C(8) $C(0) $bwpc $delay $ncc $ndc $maxch
$self createDuplexFiberLink $C(9) $C(0) $bwpc $delay $ncc $ndc $maxch
$self build-routing-table
}
#Tao dong luu luong chinh a UDP agent
Simulator instproc create_selfsim_connection { selfsim udp null src dest start0 stop0 } {
upvar 1 $udp udpr
upvar 1 $selfsim selfsimr
upvar 1 $null nullr
upvar 1 $src srcr
upvar 1 $dest destr
set udpr [ new Agent/UDP]
$self attach-agent $srcr $udpr
set selfsimr [ new Application/Traffic/SelfSimilar ]
$selfsimr set starttime $start0
$selfsimr set stoptime $stop0
$selfsimr attach-agent $udpr
set nullr [ new Agent/Null ]
$self attach-agent $destr $nullr
$self connect $udpr $nullr
$self at $start0 "$selfsimr start"
$self at $stop0 "$selfsimr stop"
puts "traffic stream between $src = $srcr and $dest = $destr created"
}
$ns create_topology
Agent/UDP set packetSize_ 1500
Application/Traffic/SelfSimilar set batchsize 4500
Application/Traffic/SelfSimilar set sb 0
Application/Traffic/SelfSimilar set Hb -0.5
Application/Traffic/SelfSimilar set rate 5000.0
Application/Traffic/SelfSimilar set std_dev_inter_batch_time 1.0e-5
Application/Traffic/SelfSimilar set Ht 0.5
#Them dong luu luong giua cac cap node bien
set i 0
WHILE {$i < $edge_count} {
set j 0
WHILE {$j < $edge_count} {
if {$i != $j} {
$ns create_selfsim_connection selfsim($i:$j) udp($i:$j) null($i:$j) E($i) E($j) 1.0 1.1
}
incr j
}
incr i
}
$ns at 5.1 "finish"
$ns run