LAMPIRAN
SCRIPT PROGRAM SINGLE SERVER
1. Single Server Server
#Pembuatan jaringan CDN
set ns [new Simulator]
$ns color 0 blue $ns color 1 red $ns color 2 green $ns color 3 yellow $ns color 4 brown $ns color 5 purple $ns color 6 black $ns color 7 grey $ns color 8 maroon
set f [open out.tr w] $ns trace-all $f
set nf [open out.nam w] $ns namtrace-all $nf
$ns duplex-link $n0 $n3 5Mb 2ms DropTail $ns duplex-link $n1 $n3 5Mb 2ms DropTail $ns duplex-link $n2 $n3 5Mb 2ms DropTail $ns duplex-link $n10 $n3 1.5Mb 10ms DropTail $ns duplex-link $n9 $n10 1.5Mb 10ms DropTail $ns duplex-link $n10 $n16 1.5Mb 10ms DropTail $ns duplex-link $n10 $n11 1.5Mb 10ms DropTail $ns duplex-link $n10 $n17 1.5Mb 10ms DropTail $ns duplex-link $n3 $n4 1.5Mb 10ms DropTail $ns duplex-link $n4 $n5 1.5Mb 10ms DropTail $ns duplex-link $n4 $n11 1.5Mb 10ms DropTail $ns duplex-link $n5 $n6 1.5Mb 10ms DropTail $ns duplex-link $n6 $n7 1.5Mb 10ms DropTail $ns duplex-link $n6 $n8 1.5Mb 10ms DropTail $ns duplex-link $n11 $n12 1.5Mb 10ms DropTail $ns duplex-link $n12 $n13 1.5Mb 10ms DropTail $ns duplex-link $n12 $n14 1.5Mb 10ms DropTail $ns duplex-link $n12 $n15 1.5Mb 10ms DropTail $ns duplex-link $n11 $n18 1.5Mb 10ms DropTail $ns duplex-link $n18 $n19 1.5Mb 10ms DropTail $ns duplex-link $n18 $n20 1.5Mb 10ms DropTail $ns duplex-link $n5 $n21 1.5Mb 10ms DropTail $ns duplex-link $n5 $n22 1.5Mb 10ms DropTail
$ns duplex-link-op $n0 $n3 orient right-up $ns duplex-link-op $n1 $n3 orient right-down $ns duplex-link-op $n2 $n3 orient down $ns duplex-link-op $n10 $n3 orient up $ns duplex-link-op $n9 $n10 orient right-up $ns duplex-link-op $n10 $n11 orient right $ns duplex-link-op $n10 $n16 orient down $ns duplex-link-op $n10 $n17 orient right-down $ns duplex-link-op $n3 $n4 orient right
$ns duplex-link-op $n6 $n7 orient right-up $ns duplex-link-op $n6 $n8 orient right $ns duplex-link-op $n11 $n12 orient right $ns duplex-link-op $n12 $n13 orient right-up $ns duplex-link-op $n12 $n14 orient right $ns duplex-link-op $n12 $n15 orient right-down $ns duplex-link-op $n11 $n18 orient right-down $ns duplex-link-op $n18 $n19 orient left-down $ns duplex-link-op $n18 $n20 orient right-down $ns duplex-link-op $n5 $n21 orient right-up $ns duplex-link-op $n5 $n22 orient left-up
$ns duplex-link-op $n2 $n3 queuePos 0.5
#Penambahan Background Traffic
set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0
set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0
set udp1 [new Agent/UDP] $ns attach-agent $n3 $udp1 $udp1 set class_ 1
set cbr1 [new Application/Traffic/CBR] $cbr1 attach-agent $udp1
set udp2 [new Agent/UDP] $ns attach-agent $n9 $udp2 $udp2 set class_ 2
set cbr2 [new Application/Traffic/CBR] $cbr2 attach-agent $udp2
set udp3 [new Agent/UDP] $ns attach-agent $n16 $udp3 $udp3 set class_ 3
set cbr3 [new Application/Traffic/CBR] $cbr3 attach-agent $udp3
set cbr4 [new Application/Traffic/CBR] $cbr4 attach-agent $udp4
set udp5 [new Agent/UDP] $ns attach-agent $n7 $udp5 $udp5 set class_ 5
set cbr5 [new Application/Traffic/CBR] $cbr5 attach-agent $udp5
set udp6 [new Agent/UDP] $ns attach-agent $n14 $udp6 $udp6 set class_ 6
set cbr6 [new Application/Traffic/CBR] $cbr6 attach-agent $udp6
set udp7 [new Agent/UDP] $ns attach-agent $n13 $udp7 $udp7 set class_ 7
set cbr7 [new Application/Traffic/CBR] $cbr7 attach-agent $udp7
set udp8 [new Agent/UDP] $ns attach-agent $n1 $udp8 $udp8 set class_ 8
set cbr8 [new Application/Traffic/CBR] $cbr8 attach-agent $udp8
set null0 [new Agent/Null] $ns attach-agent $n14 $null0
set null1 [new Agent/Null] $ns attach-agent $n13 $null1
set null2 [new Agent/Null] $ns attach-agent $n8 $null2
set null3 [new Agent/Null] $ns attach-agent $n20 $null3
set null5 [new Agent/Null] $ns attach-agent $n20 $null5
set null6 [new Agent/Null] $ns attach-agent $n21 $null6
set null7 [new Agent/Null] $ns attach-agent $n22 $null7
set null8 [new Agent/Null] $ns attach-agent $n17 $null8
$ns connect $udp0 $null0 $ns connect $udp1 $null1 $ns connect $udp2 $null2 $ns connect $udp3 $null3 $ns connect $udp4 $null4 $ns connect $udp5 $null5 $ns connect $udp6 $null6 $ns connect $udp7 $null7 $ns connect $udp8 $null8
#Penambahan Traffic Video
# creation trace traffic
set max_fragmented_size 1024
#add udp header(8 bytes) and IP header (20bytes) set packetSize 1052
set original_file_name trafik set trace_file_name video1.dat
set original_file_id [open $original_file_name r] set trace_file_id [open $trace_file_name w] set pre_time 0
while {[eof $original_file_id] == 0} { gets $original_file_id current_line
scan $current_line "%d%s%d%d%f" no_ frametype_ length_ tmp1_ tmp2_ set time [expr int(($tmp2_ - $pre_time)*1000000.0)]
if { $frametype_ == "I" } { set type_v 1
set prio_p 0 }
set type_v 2 set prio_p 0 }
if { $frametype_ == "B" } { set type_v 3
set prio_p 0 }
if { $frametype_ == "H" } { set type_v 1
set prio_p 0 }
puts $trace_file_id "$time $length_ $type_v $prio_p $max_fragmented_size" set pre_time $tmp2_
}
close $original_file_id close $trace_file_id set end_sim_time $tmp2_ puts "$end_sim_time"
set trace_file [new Tracefile]
$trace_file filename $trace_file_name
#Sistem Load Balancer
#Attach video to server #create source traffic
#Create a UDP agent and attach it to node n0 set udp_0 [new Agent/myUDP]
$udp_0 set_filename udpSend0 $udp_0 set packetSize_ 1052
$ns attach-agent $n2 $udp_0 ;#Server 2
set udp_1 [new Agent/myUDP] $udp_1 set_filename udpSend1 $udp_1 set packetSize_ 1052
$ns attach-agent $n2 $udp_1 ;#Server 2
set udp_7 [new Agent/myUDP] $udp_7 set_filename udpSend7 $udp_7 set packetSize_ 1052
set udp_8 [new Agent/myUDP] $udp_8 set_filename udpSend8 $udp_8 set packetSize_ 1052
$ns attach-agent $n2 $udp_8 ;#Server 2
set udp_9 [new Agent/myUDP] $udp_9 set_filename udpSend9 $udp_9 set packetSize_ 1052
$ns attach-agent $n2 $udp_9 ;#Server 2
set udp_14 [new Agent/myUDP] $udp_14 set_filename udpSend14 $udp_14 set packetSize_ 1052
$ns attach-agent $n2 $udp_14 ;#Server 2
set udp_15 [new Agent/myUDP] $udp_15 set_filename udpSend15 $udp_15 set packetSize_ 1052
$ns attach-agent $n2 $udp_15 ;#Server 2
set udp_16 [new Agent/myUDP] $udp_16 set_filename udpSend16 $udp_16 set packetSize_ 1052
$ns attach-agent $n2 $udp_16 ;#Server 2
set udp_19 [new Agent/myUDP] $udp_19 set_filename udpSend19 $udp_19 set packetSize_ 1052
$ns attach-agent $n2 $udp_19 ;#Server 2
set udp_21 [new Agent/myUDP] $udp_21 set_filename udpSend21 $udp_21 set packetSize_ 1052
$ns attach-agent $n2 $udp_21 ;#Server 2
# Attach video traffic source
set video0 [new Application/Traffic/myEvalvid] $video0 attach-tracefile $trace_file
$video0 attach-agent $udp_0
$video1 attach-tracefile $trace_file $video1 attach-agent $udp_1
set video2 [new Application/Traffic/myEvalvid] $video2 attach-tracefile $trace_file
$video2 attach-agent $udp_7
set video3 [new Application/Traffic/myEvalvid] $video3 attach-tracefile $trace_file
$video3 attach-agent $udp_8
set video4 [new Application/Traffic/myEvalvid] $video4 attach-tracefile $trace_file
$video4 attach-agent $udp_9
set video5 [new Application/Traffic/myEvalvid] $video5 attach-tracefile $trace_file
$video5 attach-agent $udp_14
set video6 [new Application/Traffic/myEvalvid] $video6 attach-tracefile $trace_file
$video6 attach-agent $udp_15
set video7 [new Application/Traffic/myEvalvid] $video7 attach-tracefile $trace_file
$video7 attach-agent $udp_16
set video8 [new Application/Traffic/myEvalvid] $video8 attach-tracefile $trace_file
$video8 attach-agent $udp_19
set video9 [new Application/Traffic/myEvalvid] $video9 attach-tracefile $trace_file
$video9 attach-agent $udp_21
# Create the Null agent to sink traffic set null_0 [new Agent/myEvalvid_Sink] $null_0 set_filename udpRec0
$ns attach-agent $n0 $null_0
$ns attach-agent $n1 $null_1
set null_7 [new Agent/myEvalvid_Sink] $null_7 set_filename udpRec7
$ns attach-agent $n7 $null_7
set null_8 [new Agent/myEvalvid_Sink] $null_8 set_filename udpRec8
$ns attach-agent $n8 $null_8
set null_9 [new Agent/myEvalvid_Sink] $null_9 set_filename udpRec9
$ns attach-agent $n9 $null_9
set null_14 [new Agent/myEvalvid_Sink] $null_14 set_filename udpRec14
$ns attach-agent $n14 $null_14
set null_15 [new Agent/myEvalvid_Sink] $null_15 set_filename udpRec15
$ns attach-agent $n15 $null_15
set null_16 [new Agent/myEvalvid_Sink] $null_16 set_filename udpRec16
$ns attach-agent $n16 $null_16
set null_19 [new Agent/myEvalvid_Sink] $null_19 set_filename udpRec19
$ns attach-agent $n19 $null_19
set null_21 [new Agent/myEvalvid_Sink] $null_21 set_filename udpRec21
$ns attach-agent $n21 $null_21
# Attach the 2 agents
$ns connect $udp_16 $null_16 $ns connect $udp_19 $null_19 $ns connect $udp_21 $null_21
$ns at 1.0 "$cbr0 start" $ns at 6.1 "$cbr1 start" $ns at 1.3 "$cbr2 start" $ns at 2.6 "$cbr3 start" $ns at 1.8 "$cbr4 start" $ns at 3.0 "$cbr5 start" $ns at 2.1 "$cbr6 start" $ns at 5.2 "$cbr7 start" $ns at 7.3 "$cbr8 start"
$ns at 4.0 "$cbr5 stop" $ns at 5.1 "$cbr6 stop" $ns at 5.8 "$cbr7 stop"
#Evaluated traffics $ns at 2.0 "$video0 start" $ns at 2.5 "$video1 start" $ns at 3.0 "$video2 start" $ns at 3.5 "$video3 start" $ns at 4.0 "$video4 start" $ns at 4.5 "$video5 start" $ns at 5.0 "$video6 start" $ns at 5.5 "$video7 start" $ns at 6.0 "$video8 start" $ns at 6.5 "$video9 start"
set tcp [new Agent/TCP] $tcp set class_ 2
set sink [new Agent/TCPSink] $ns attach-agent $n0 $tcp $ns attach-agent $n3 $sink $ns connect $tcp $sink
set ftp [new Application/FTP] $ftp attach-agent $tcp
$ns at 1.2 "$ftp start"
puts [$cbr0 set packetSize_] puts [$cbr0 set interval_]
$ns at 500.0 "finish"
proc finish {} { global ns f nf $ns flush-trace close $f close $nf
puts "running nam..." exec nam out.nam & exit 0
}
LAMPIRAN
SCRIPT PROGRAM LEAST CONNECTION
set ns [new Simulator]
$ns color 0 pink $ns color 1 red $ns color 2 green $ns color 3 yellow $ns color 4 brown $ns color 5 purple $ns color 6 black $ns color 7 grey $ns color 8 maroon
set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] set n6 [$ns node] set n7 [$ns node] set n8 [$ns node] set n9 [$ns node] set n10 [$ns node] set n11 [$ns node] set n12 [$ns node] set n13 [$ns node] set n14 [$ns node] set n15 [$ns node] set n16 [$ns node] set n17 [$ns node] set n18 [$ns node] set n19 [$ns node] set n20 [$ns node] set n21 [$ns node] set n22 [$ns node]
set f [open out.tr w] $ns trace-all $f
set nf [open out.nam w] $ns namtrace-all $nf
$ns duplex-link $n1 $n3 5Mb 2ms DropTail $ns duplex-link $n2 $n3 5Mb 2ms DropTail $ns duplex-link $n10 $n3 1.5Mb 10ms DropTail $ns duplex-link $n9 $n10 1.5Mb 10ms DropTail $ns duplex-link $n10 $n16 1.5Mb 10ms DropTail $ns duplex-link $n10 $n11 1.5Mb 10ms DropTail $ns duplex-link $n10 $n17 1.5Mb 10ms DropTail $ns duplex-link $n3 $n4 1.5Mb 10ms DropTail $ns duplex-link $n4 $n5 1.5Mb 10ms DropTail $ns duplex-link $n4 $n11 1.5Mb 10ms DropTail $ns duplex-link $n5 $n6 1.5Mb 10ms DropTail $ns duplex-link $n6 $n7 1.5Mb 10ms DropTail $ns duplex-link $n6 $n8 1.5Mb 10ms DropTail $ns duplex-link $n11 $n12 1.5Mb 10ms DropTail $ns duplex-link $n12 $n13 1.5Mb 10ms DropTail $ns duplex-link $n12 $n14 1.5Mb 10ms DropTail $ns duplex-link $n12 $n15 1.5Mb 10ms DropTail $ns duplex-link $n11 $n18 1.5Mb 10ms DropTail $ns duplex-link $n18 $n19 1.5Mb 10ms DropTail $ns duplex-link $n18 $n20 1.5Mb 10ms DropTail $ns duplex-link $n5 $n21 1.5Mb 10ms DropTail $ns duplex-link $n5 $n22 1.5Mb 10ms DropTail
$ns duplex-link-op $n0 $n3 orient right-up $ns duplex-link-op $n1 $n3 orient right-down $ns duplex-link-op $n2 $n3 orient down $ns duplex-link-op $n10 $n3 orient up $ns duplex-link-op $n9 $n10 orient right-up $ns duplex-link-op $n10 $n11 orient right $ns duplex-link-op $n10 $n16 orient down $ns duplex-link-op $n10 $n17 orient right-down $ns duplex-link-op $n3 $n4 orient right
$ns duplex-link-op $n4 $n5 orient right-up $ns duplex-link-op $n4 $n11 orient down $ns duplex-link-op $n5 $n6 orient right $ns duplex-link-op $n6 $n7 orient right-up $ns duplex-link-op $n6 $n8 orient right $ns duplex-link-op $n11 $n12 orient right $ns duplex-link-op $n12 $n13 orient right-up $ns duplex-link-op $n12 $n14 orient right $ns duplex-link-op $n12 $n15 orient right-down $ns duplex-link-op $n11 $n18 orient right-down $ns duplex-link-op $n18 $n19 orient left-down $ns duplex-link-op $n18 $n20 orient right-down $ns duplex-link-op $n5 $n21 orient right-up $ns duplex-link-op $n5 $n22 orient left-up
set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0
set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0
set udp1 [new Agent/UDP] $ns attach-agent $n3 $udp1 $udp1 set class_ 1
set cbr1 [new Application/Traffic/CBR] $cbr1 attach-agent $udp1
set udp2 [new Agent/UDP] $ns attach-agent $n9 $udp2 $udp2 set class_ 2
set cbr2 [new Application/Traffic/CBR] $cbr2 attach-agent $udp2
set udp3 [new Agent/UDP] $ns attach-agent $n16 $udp3 $udp3 set class_ 3
set cbr3 [new Application/Traffic/CBR] $cbr3 attach-agent $udp3
set udp4 [new Agent/UDP] $ns attach-agent $n19 $udp4 $udp4 set class_ 4
set cbr4 [new Application/Traffic/CBR] $cbr4 attach-agent $udp4
set udp5 [new Agent/UDP] $ns attach-agent $n7 $udp5 $udp5 set class_ 5
set cbr5 [new Application/Traffic/CBR] $cbr5 attach-agent $udp5
set udp6 [new Agent/UDP] $ns attach-agent $n14 $udp6 $udp6 set class_ 6
set cbr6 [new Application/Traffic/CBR] $cbr6 attach-agent $udp6
set udp7 [new Agent/UDP] $ns attach-agent $n13 $udp7 $udp7 set class_ 7
set udp8 [new Agent/UDP] $ns attach-agent $n1 $udp8 $udp8 set class_ 8
set cbr8 [new Application/Traffic/CBR] $cbr8 attach-agent $udp8
set null0 [new Agent/Null] $ns attach-agent $n14 $null0
set null1 [new Agent/Null] $ns attach-agent $n13 $null1
set null2 [new Agent/Null] $ns attach-agent $n8 $null2
set null3 [new Agent/Null] $ns attach-agent $n20 $null3
set null4 [new Agent/Null] $ns attach-agent $n14 $null4
set null5 [new Agent/Null] $ns attach-agent $n20 $null5
set null6 [new Agent/Null] $ns attach-agent $n21 $null6
set null7 [new Agent/Null] $ns attach-agent $n22 $null7
set null8 [new Agent/Null] $ns attach-agent $n17 $null8
$ns connect $udp0 $null0 $ns connect $udp1 $null1 $ns connect $udp2 $null2 $ns connect $udp3 $null3 $ns connect $udp4 $null4 $ns connect $udp5 $null5 $ns connect $udp6 $null6 $ns connect $udp7 $null7 $ns connect $udp8 $null8
# creation trace traffic
set max_fragmented_size 1024
#add udp header(8 bytes) and IP header (20bytes) set packetSize 1052
set trace_file_name video1.dat
set original_file_id [open $original_file_name r] set trace_file_id [open $trace_file_name w] set pre_time 0
while {[eof $original_file_id] == 0} { gets $original_file_id current_line
scan $current_line "%d%s%d%d%f" no_ frametype_ length_ tmp1_ tmp2_ set time [expr int(($tmp2_ - $pre_time)*1000000.0)]
if { $frametype_ == "I" } { set type_v 1
set prio_p 0 }
if { $frametype_ == "P" } { set type_v 2
set prio_p 0 }
if { $frametype_ == "B" } { set type_v 3
set prio_p 0 }
if { $frametype_ == "H" } { set type_v 1
set prio_p 0 }
puts $trace_file_id "$time $length_ $type_v $prio_p $max_fragmented_size" set pre_time $tmp2_
}
close $original_file_id close $trace_file_id set end_sim_time $tmp2_ puts "$end_sim_time"
set trace_file [new Tracefile]
$trace_file filename $trace_file_name
#Attach video to server #create source traffic
#Create a UDP agent and attach it to node n0 set udp_0 [new Agent/myUDP]
$udp_0 set_filename udpSend0 $udp_0 set packetSize_ 1052
$ns attach-agent $n2 $udp_0 ;#Server 2
set udp_1 [new Agent/myUDP] $udp_1 set_filename udpSend1 $udp_1 set packetSize_ 1052
set udp_4 [new Agent/myUDP] $udp_4 set_filename udpSend7 $udp_4 set packetSize_ 1052
$ns attach-agent $n2 $udp_4 ;#Server 2
set udp_7 [new Agent/myUDP] $udp_7 set_filename udpSend8 $udp_7 set packetSize_ 1052
$ns attach-agent $n2 $udp_7 ;#Server 2
set udp_2 [new Agent/myUDP] $udp_2 set_filename udpSend9 $udp_2 set packetSize_ 1052
$ns attach-agent $n20 $udp_2 ;#Server 20
set udp_5 [new Agent/myUDP] $udp_5 set_filename udpSend14 $udp_5 set packetSize_ 1052
$ns attach-agent $n20 $udp_5 ;#Server 20
set udp_8 [new Agent/myUDP] $udp_8 set_filename udpSend15 $udp_8 set packetSize_ 1052
$ns attach-agent $n20 $udp_8 ;#Server 20
set udp_3 [new Agent/myUDP] $udp_3 set_filename udpSend16 $udp_3 set packetSize_ 1052
$ns attach-agent $n22 $udp_3 ;#Server 22
set udp_6 [new Agent/myUDP] $udp_6 set_filename udpSend19 $udp_6 set packetSize_ 1052
$ns attach-agent $n22 $udp_6 ;#Server 22
set udp_9 [new Agent/myUDP] $udp_9 set_filename udpSend21 $udp_9 set packetSize_ 1052
$ns attach-agent $n22 $udp_9 ;#Server 22
# Attach video traffic source
set video0 [new Application/Traffic/myEvalvid] $video0 attach-tracefile $trace_file
$video0 attach-agent $udp_0
set video1 [new Application/Traffic/myEvalvid] $video1 attach-tracefile $trace_file
set video2 [new Application/Traffic/myEvalvid] $video2 attach-tracefile $trace_file
$video2 attach-agent $udp_2
set video3 [new Application/Traffic/myEvalvid] $video3 attach-tracefile $trace_file
$video3 attach-agent $udp_3
set video4 [new Application/Traffic/myEvalvid] $video4 attach-tracefile $trace_file
$video4 attach-agent $udp_4
set video5 [new Application/Traffic/myEvalvid] $video5 attach-tracefile $trace_file
$video5 attach-agent $udp_5
set video6 [new Application/Traffic/myEvalvid] $video6 attach-tracefile $trace_file
$video6 attach-agent $udp_6
set video7 [new Application/Traffic/myEvalvid] $video7 attach-tracefile $trace_file
$video7 attach-agent $udp_7
set video8 [new Application/Traffic/myEvalvid] $video8 attach-tracefile $trace_file
$video8 attach-agent $udp_8
set video9 [new Application/Traffic/myEvalvid] $video9 attach-tracefile $trace_file
$video9 attach-agent $udp_9
# Create the Null agent to sink traffic set null_0 [new Agent/myEvalvid_Sink] $null_0 set_filename udpRec0
$ns attach-agent $n0 $null_0
set null_1 [new Agent/myEvalvid_Sink] $null_1 set_filename udpRec1
$ns attach-agent $n1 $null_1
set null_7 [new Agent/myEvalvid_Sink] $null_7 set_filename udpRec7
$ns attach-agent $n7 $null_7
$ns attach-agent $n8 $null_8
set null_9 [new Agent/myEvalvid_Sink] $null_9 set_filename udpRec9
$ns attach-agent $n9 $null_9
set null_14 [new Agent/myEvalvid_Sink] $null_14 set_filename udpRec14
$ns attach-agent $n14 $null_14
set null_15 [new Agent/myEvalvid_Sink] $null_15 set_filename udpRec15
$ns attach-agent $n19 $null_15
set null_16 [new Agent/myEvalvid_Sink] $null_16 set_filename udpRec16
$ns attach-agent $n19 $null_16
set null_19 [new Agent/myEvalvid_Sink] $null_19 set_filename udpRec19
$ns attach-agent $n19 $null_19
set null_21 [new Agent/myEvalvid_Sink] $null_21 set_filename udpRec21
$ns attach-agent $n21 $null_21
# Attach the 2 agents
$ns connect $udp_0 $null_0 $ns connect $udp_1 $null_1 $ns connect $udp_2 $null_7 $ns connect $udp_3 $null_8 $ns connect $udp_4 $null_9 $ns connect $udp_5 $null_14 $ns connect $udp_6 $null_15 $ns connect $udp_7 $null_16 $ns connect $udp_8 $null_19 $ns connect $udp_9 $null_21
$ns at 4.0 "$cbr5 stop" $ns at 5.1 "$cbr6 stop" $ns at 5.8 "$cbr7 stop"
#Evaluated traffics $ns at 2.0 "$video0 start" $ns at 2.5 "$video1 start" $ns at 3.0 "$video2 start" $ns at 3.4 "$video3 start" $ns at 3.8 "$video4 start" $ns at 4.0 "$video5 start" $ns at 4.5 "$video6 start" $ns at 5.0 "$video7 start" $ns at 5.5 "$video8 start" $ns at 6.0 "$video9 start"
set tcp [new Agent/TCP] $tcp set class_ 2
set sink [new Agent/TCPSink] $ns attach-agent $n0 $tcp $ns attach-agent $n3 $sink $ns connect $tcp $sink
set ftp [new Application/FTP] $ftp attach-agent $tcp
$ns at 1.2 "$ftp start"
$ns at 1.35 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink"
puts [$cbr0 set packetSize_] puts [$cbr0 set interval_]
$ns at 500.0 "finish"
proc finish {} { global ns f nf $ns flush-trace close $f close $nf
puts "running nam..." exec nam out.nam & exit 0
}
LAMPIRAN
SCRIPT PROGRAM ROUND ROBIN
set ns [new Simulator]
$ns color 0 pink $ns color 1 red $ns color 2 green $ns color 3 yellow $ns color 4 brown $ns color 5 purple $ns color 6 black $ns color 7 grey $ns color 8 maroon
set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] set n6 [$ns node] set n7 [$ns node] set n8 [$ns node] set n9 [$ns node] set n10 [$ns node] set n11 [$ns node] set n12 [$ns node] set n13 [$ns node] set n14 [$ns node] set n15 [$ns node] set n16 [$ns node] set n17 [$ns node] set n18 [$ns node] set n19 [$ns node] set n20 [$ns node] set n21 [$ns node] set n22 [$ns node]
set f [open out.tr w] $ns trace-all $f
set nf [open out.nam w] $ns namtrace-all $nf
$ns duplex-link $n1 $n3 5Mb 2ms DropTail $ns duplex-link $n2 $n3 5Mb 2ms DropTail $ns duplex-link $n10 $n3 1.5Mb 10ms DropTail $ns duplex-link $n9 $n10 1.5Mb 10ms DropTail $ns duplex-link $n10 $n16 1.5Mb 10ms DropTail $ns duplex-link $n10 $n11 1.5Mb 10ms DropTail $ns duplex-link $n10 $n17 1.5Mb 10ms DropTail $ns duplex-link $n3 $n4 1.5Mb 10ms DropTail $ns duplex-link $n4 $n5 1.5Mb 10ms DropTail $ns duplex-link $n4 $n11 1.5Mb 10ms DropTail $ns duplex-link $n5 $n6 1.5Mb 10ms DropTail $ns duplex-link $n6 $n7 1.5Mb 10ms DropTail $ns duplex-link $n6 $n8 1.5Mb 10ms DropTail $ns duplex-link $n11 $n12 1.5Mb 10ms DropTail $ns duplex-link $n12 $n13 1.5Mb 10ms DropTail $ns duplex-link $n12 $n14 1.5Mb 10ms DropTail $ns duplex-link $n12 $n15 1.5Mb 10ms DropTail $ns duplex-link $n11 $n18 1.5Mb 10ms DropTail $ns duplex-link $n18 $n19 1.5Mb 10ms DropTail $ns duplex-link $n18 $n20 1.5Mb 10ms DropTail $ns duplex-link $n5 $n21 1.5Mb 10ms DropTail $ns duplex-link $n5 $n22 1.5Mb 10ms DropTail
$ns duplex-link-op $n0 $n3 orient right-up $ns duplex-link-op $n1 $n3 orient right-down $ns duplex-link-op $n2 $n3 orient down $ns duplex-link-op $n10 $n3 orient up $ns duplex-link-op $n9 $n10 orient right-up $ns duplex-link-op $n10 $n11 orient right $ns duplex-link-op $n10 $n16 orient down $ns duplex-link-op $n10 $n17 orient right-down $ns duplex-link-op $n3 $n4 orient right
$ns duplex-link-op $n4 $n5 orient right-up $ns duplex-link-op $n4 $n11 orient down $ns duplex-link-op $n5 $n6 orient right $ns duplex-link-op $n6 $n7 orient right-up $ns duplex-link-op $n6 $n8 orient right $ns duplex-link-op $n11 $n12 orient right $ns duplex-link-op $n12 $n13 orient right-up $ns duplex-link-op $n12 $n14 orient right $ns duplex-link-op $n12 $n15 orient right-down $ns duplex-link-op $n11 $n18 orient right-down $ns duplex-link-op $n18 $n19 orient left-down $ns duplex-link-op $n18 $n20 orient right-down $ns duplex-link-op $n5 $n21 orient right-up $ns duplex-link-op $n5 $n22 orient left-up
set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0
set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0
set udp1 [new Agent/UDP] $ns attach-agent $n3 $udp1 $udp1 set class_ 1
set cbr1 [new Application/Traffic/CBR] $cbr1 attach-agent $udp1
set udp2 [new Agent/UDP] $ns attach-agent $n9 $udp2 $udp2 set class_ 2
set cbr2 [new Application/Traffic/CBR] $cbr2 attach-agent $udp2
set udp3 [new Agent/UDP] $ns attach-agent $n16 $udp3 $udp3 set class_ 3
set cbr3 [new Application/Traffic/CBR] $cbr3 attach-agent $udp3
set udp4 [new Agent/UDP] $ns attach-agent $n19 $udp4 $udp4 set class_ 4
set cbr4 [new Application/Traffic/CBR] $cbr4 attach-agent $udp4
set udp5 [new Agent/UDP] $ns attach-agent $n7 $udp5 $udp5 set class_ 5
set cbr5 [new Application/Traffic/CBR] $cbr5 attach-agent $udp5
set udp6 [new Agent/UDP] $ns attach-agent $n14 $udp6 $udp6 set class_ 6
set cbr6 [new Application/Traffic/CBR] $cbr6 attach-agent $udp6
set udp7 [new Agent/UDP] $ns attach-agent $n13 $udp7 $udp7 set class_ 7
set udp8 [new Agent/UDP] $ns attach-agent $n1 $udp8 $udp8 set class_ 8
set cbr8 [new Application/Traffic/CBR] $cbr8 attach-agent $udp8
set null0 [new Agent/Null] $ns attach-agent $n14 $null0
set null1 [new Agent/Null] $ns attach-agent $n13 $null1
set null2 [new Agent/Null] $ns attach-agent $n8 $null2
set null3 [new Agent/Null] $ns attach-agent $n20 $null3
set null4 [new Agent/Null] $ns attach-agent $n14 $null4
set null5 [new Agent/Null] $ns attach-agent $n20 $null5
set null6 [new Agent/Null] $ns attach-agent $n21 $null6
set null7 [new Agent/Null] $ns attach-agent $n22 $null7
set null8 [new Agent/Null] $ns attach-agent $n17 $null8
$ns connect $udp0 $null0 $ns connect $udp1 $null1 $ns connect $udp2 $null2 $ns connect $udp3 $null3 $ns connect $udp4 $null4 $ns connect $udp5 $null5 $ns connect $udp6 $null6 $ns connect $udp7 $null7 $ns connect $udp8 $null8
# creation trace traffic
set max_fragmented_size 1024
#add udp header(8 bytes) and IP header (20bytes) set packetSize 1052
set trace_file_name video1.dat
set original_file_id [open $original_file_name r] set trace_file_id [open $trace_file_name w] set pre_time 0
while {[eof $original_file_id] == 0} { gets $original_file_id current_line
scan $current_line "%d%s%d%d%f" no_ frametype_ length_ tmp1_ tmp2_ set time [expr int(($tmp2_ - $pre_time)*1000000.0)]
if { $frametype_ == "I" } { set type_v 1
set prio_p 0 }
if { $frametype_ == "P" } { set type_v 2
set prio_p 0 }
if { $frametype_ == "B" } { set type_v 3
set prio_p 0 }
if { $frametype_ == "H" } { set type_v 1
set prio_p 0 }
puts $trace_file_id "$time $length_ $type_v $prio_p $max_fragmented_size" set pre_time $tmp2_
}
close $original_file_id close $trace_file_id set end_sim_time $tmp2_ puts "$end_sim_time"
set trace_file [new Tracefile]
$trace_file filename $trace_file_name
#Attach video to server #create source traffic
#Create a UDP agent and attach it to node n0 set udp_0 [new Agent/myUDP]
$udp_0 set_filename udpSend0 $udp_0 set packetSize_ 1052
$ns attach-agent $n2 $udp_0 ;#Server 2
set udp_3 [new Agent/myUDP] $udp_3 set_filename udpSend1 $udp_3 set packetSize_ 1052
set udp_6 [new Agent/myUDP] $udp_6 set_filename udpSend7 $udp_6 set packetSize_ 1052
$ns attach-agent $n2 $udp_6 ;#Server 2
set udp_9 [new Agent/myUDP] $udp_9 set_filename udpSend8 $udp_9 set packetSize_ 1052
$ns attach-agent $n2 $udp_9 ;#Server 2
set udp_1 [new Agent/myUDP] $udp_1 set_filename udpSend9 $udp_1 set packetSize_ 1052
$ns attach-agent $n20 $udp_1 ;#Server 20
set udp_4 [new Agent/myUDP] $udp_4 set_filename udpSend14 $udp_4 set packetSize_ 1052
$ns attach-agent $n20 $udp_4 ;#Server 20
set udp_7 [new Agent/myUDP] $udp_7 set_filename udpSend15 $udp_7 set packetSize_ 1052
$ns attach-agent $n20 $udp_7 ;#Server 20
set udp_2 [new Agent/myUDP] $udp_2 set_filename udpSend16 $udp_2 set packetSize_ 1052
$ns attach-agent $n22 $udp_2 ;#Server 22
set udp_5 [new Agent/myUDP] $udp_5 set_filename udpSend19 $udp_5 set packetSize_ 1052
$ns attach-agent $n22 $udp_5 ;#Server 22
set udp_8 [new Agent/myUDP] $udp_8 set_filename udpSend21 $udp_8 set packetSize_ 1052
$ns attach-agent $n22 $udp_8 ;#Server 22
# Attach video traffic source
set video0 [new Application/Traffic/myEvalvid] $video0 attach-tracefile $trace_file
$video0 attach-agent $udp_0
$video1 attach-agent $udp_1
set video2 [new Application/Traffic/myEvalvid] $video2 attach-tracefile $trace_file
$video2 attach-agent $udp_2
set video3 [new Application/Traffic/myEvalvid] $video3 attach-tracefile $trace_file
$video3 attach-agent $udp_3
set video4 [new Application/Traffic/myEvalvid] $video4 attach-tracefile $trace_file
$video4 attach-agent $udp_4
set video5 [new Application/Traffic/myEvalvid] $video5 attach-tracefile $trace_file
$video5 attach-agent $udp_5
set video6 [new Application/Traffic/myEvalvid] $video6 attach-tracefile $trace_file
$video6 attach-agent $udp_6
set video7 [new Application/Traffic/myEvalvid] $video7 attach-tracefile $trace_file
$video7 attach-agent $udp_7
set video8 [new Application/Traffic/myEvalvid] $video8 attach-tracefile $trace_file
$video8 attach-agent $udp_8
set video9 [new Application/Traffic/myEvalvid] $video9 attach-tracefile $trace_file
$video9 attach-agent $udp_9
# Create the Null agent to sink traffic set null_0 [new Agent/myEvalvid_Sink] $null_0 set_filename udpRec0
$ns attach-agent $n0 $null_0
set null_1 [new Agent/myEvalvid_Sink] $null_1 set_filename udpRec1
$ns attach-agent $n1 $null_1
set null_7 [new Agent/myEvalvid_Sink] $null_7 set_filename udpRec7
set null_8 [new Agent/myEvalvid_Sink] $null_8 set_filename udpRec8
$ns attach-agent $n8 $null_8
set null_9 [new Agent/myEvalvid_Sink] $null_9 set_filename udpRec9
$ns attach-agent $n9 $null_9
set null_14 [new Agent/myEvalvid_Sink] $null_14 set_filename udpRec14
$ns attach-agent $n14 $null_14
set null_15 [new Agent/myEvalvid_Sink] $null_15 set_filename udpRec15
$ns attach-agent $n19 $null_15
set null_16 [new Agent/myEvalvid_Sink] $null_16 set_filename udpRec16
$ns attach-agent $n19 $null_16
set null_19 [new Agent/myEvalvid_Sink] $null_19 set_filename udpRec19
$ns attach-agent $n19 $null_19
set null_21 [new Agent/myEvalvid_Sink] $null_21 set_filename udpRec21
$ns attach-agent $n21 $null_21
# Attach the 2 agents
$ns connect $udp_0 $null_0 $ns connect $udp_1 $null_1 $ns connect $udp_2 $null_7 $ns connect $udp_3 $null_8 $ns connect $udp_4 $null_9 $ns connect $udp_5 $null_14 $ns connect $udp_6 $null_15 $ns connect $udp_7 $null_16 $ns connect $udp_8 $null_19 $ns connect $udp_9 $null_21
$ns at 7.3 "$cbr8 start"
$ns at 4.0 "$cbr5 stop" $ns at 5.1 "$cbr6 stop" $ns at 5.8 "$cbr7 stop"
#Evaluated traffics $ns at 2.0 "$video0 start" $ns at 2.5 "$video1 start" $ns at 3.0 "$video2 start" $ns at 3.4 "$video3 start" $ns at 3.8 "$video4 start" $ns at 4.0 "$video5 start" $ns at 4.5 "$video6 start" $ns at 5.0 "$video7 start" $ns at 5.5 "$video8 start" $ns at 6.0 "$video9 start"
set tcp [new Agent/TCP] $tcp set class_ 2
set sink [new Agent/TCPSink] $ns attach-agent $n0 $tcp $ns attach-agent $n3 $sink $ns connect $tcp $sink
set ftp [new Application/FTP] $ftp attach-agent $tcp
$ns at 1.2 "$ftp start"
$ns at 1.35 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink"
puts [$cbr0 set packetSize_] puts [$cbr0 set interval_]
$ns at 500.0 "finish"
proc finish {} { global ns f nf $ns flush-trace close $f close $nf
puts "running nam..." exec nam out.nam & exit 0
}
LAMPIRAN
SCRIPT PROGRAM WEIGHTED ROUND ROBIN
set ns [new Simulator]
$ns color 0 pink $ns color 1 red $ns color 2 green $ns color 3 yellow $ns color 4 brown $ns color 5 purple $ns color 6 black $ns color 7 grey $ns color 8 maroon
set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] set n6 [$ns node] set n7 [$ns node] set n8 [$ns node] set n9 [$ns node] set n10 [$ns node] set n11 [$ns node] set n12 [$ns node] set n13 [$ns node] set n14 [$ns node] set n15 [$ns node] set n16 [$ns node] set n17 [$ns node] set n18 [$ns node] set n19 [$ns node] set n20 [$ns node] set n21 [$ns node] set n22 [$ns node]
set f [open out.tr w] $ns trace-all $f
set nf [open out.nam w] $ns namtrace-all $nf
$ns duplex-link $n2 $n3 5Mb 2ms DropTail $ns duplex-link $n10 $n3 1.5Mb 10ms DropTail $ns duplex-link $n9 $n10 1.5Mb 10ms DropTail $ns duplex-link $n10 $n16 1.5Mb 10ms DropTail $ns duplex-link $n10 $n11 1.5Mb 10ms DropTail $ns duplex-link $n10 $n17 1.5Mb 10ms DropTail $ns duplex-link $n3 $n4 1.5Mb 10ms DropTail $ns duplex-link $n4 $n5 1.5Mb 10ms DropTail $ns duplex-link $n4 $n11 1.5Mb 10ms DropTail $ns duplex-link $n5 $n6 1.5Mb 10ms DropTail $ns duplex-link $n6 $n7 1.5Mb 10ms DropTail $ns duplex-link $n6 $n8 1.5Mb 10ms DropTail $ns duplex-link $n11 $n12 1.5Mb 10ms DropTail $ns duplex-link $n12 $n13 1.5Mb 10ms DropTail $ns duplex-link $n12 $n14 1.5Mb 10ms DropTail $ns duplex-link $n12 $n15 1.5Mb 10ms DropTail $ns duplex-link $n11 $n18 1.5Mb 10ms DropTail $ns duplex-link $n18 $n19 1.5Mb 10ms DropTail $ns duplex-link $n18 $n20 1.5Mb 10ms DropTail $ns duplex-link $n5 $n21 1.5Mb 10ms DropTail $ns duplex-link $n5 $n22 1.5Mb 10ms DropTail
$ns duplex-link-op $n0 $n3 orient right-up $ns duplex-link-op $n1 $n3 orient right-down $ns duplex-link-op $n2 $n3 orient down $ns duplex-link-op $n10 $n3 orient up $ns duplex-link-op $n9 $n10 orient right-up $ns duplex-link-op $n10 $n11 orient right $ns duplex-link-op $n10 $n16 orient down $ns duplex-link-op $n10 $n17 orient right-down $ns duplex-link-op $n3 $n4 orient right
$ns duplex-link-op $n4 $n5 orient right-up $ns duplex-link-op $n4 $n11 orient down $ns duplex-link-op $n5 $n6 orient right $ns duplex-link-op $n6 $n7 orient right-up $ns duplex-link-op $n6 $n8 orient right $ns duplex-link-op $n11 $n12 orient right $ns duplex-link-op $n12 $n13 orient right-up $ns duplex-link-op $n12 $n14 orient right $ns duplex-link-op $n12 $n15 orient right-down $ns duplex-link-op $n11 $n18 orient right-down $ns duplex-link-op $n18 $n19 orient left-down $ns duplex-link-op $n18 $n20 orient right-down $ns duplex-link-op $n5 $n21 orient right-up $ns duplex-link-op $n5 $n22 orient left-up
set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0
set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0
set udp1 [new Agent/UDP] $ns attach-agent $n3 $udp1 $udp1 set class_ 1
set cbr1 [new Application/Traffic/CBR] $cbr1 attach-agent $udp1
set udp2 [new Agent/UDP] $ns attach-agent $n9 $udp2 $udp2 set class_ 2
set cbr2 [new Application/Traffic/CBR] $cbr2 attach-agent $udp2
set udp3 [new Agent/UDP] $ns attach-agent $n16 $udp3 $udp3 set class_ 3
set cbr3 [new Application/Traffic/CBR] $cbr3 attach-agent $udp3
set udp4 [new Agent/UDP] $ns attach-agent $n19 $udp4 $udp4 set class_ 4
set cbr4 [new Application/Traffic/CBR] $cbr4 attach-agent $udp4
set udp5 [new Agent/UDP] $ns attach-agent $n7 $udp5 $udp5 set class_ 5
set cbr5 [new Application/Traffic/CBR] $cbr5 attach-agent $udp5
set udp6 [new Agent/UDP] $ns attach-agent $n14 $udp6 $udp6 set class_ 6
set cbr6 [new Application/Traffic/CBR] $cbr6 attach-agent $udp6
set udp7 [new Agent/UDP] $ns attach-agent $n13 $udp7 $udp7 set class_ 7
set cbr7 [new Application/Traffic/CBR] $cbr7 attach-agent $udp7
$ns attach-agent $n1 $udp8 $udp8 set class_ 8
set cbr8 [new Application/Traffic/CBR] $cbr8 attach-agent $udp8
set null0 [new Agent/Null] $ns attach-agent $n14 $null0
set null1 [new Agent/Null] $ns attach-agent $n13 $null1
set null2 [new Agent/Null] $ns attach-agent $n8 $null2
set null3 [new Agent/Null] $ns attach-agent $n20 $null3
set null4 [new Agent/Null] $ns attach-agent $n14 $null4
set null5 [new Agent/Null] $ns attach-agent $n20 $null5
set null6 [new Agent/Null] $ns attach-agent $n21 $null6
set null7 [new Agent/Null] $ns attach-agent $n22 $null7
set null8 [new Agent/Null] $ns attach-agent $n17 $null8
$ns connect $udp0 $null0 $ns connect $udp1 $null1 $ns connect $udp2 $null2 $ns connect $udp3 $null3 $ns connect $udp4 $null4 $ns connect $udp5 $null5 $ns connect $udp6 $null6 $ns connect $udp7 $null7 $ns connect $udp8 $null8
# creation trace traffic
set max_fragmented_size 1024
#add udp header(8 bytes) and IP header (20bytes) set packetSize 1052
set original_file_id [open $original_file_name r] set trace_file_id [open $trace_file_name w] set pre_time 0
while {[eof $original_file_id] == 0} { gets $original_file_id current_line
scan $current_line "%d%s%d%d%f" no_ frametype_ length_ tmp1_ tmp2_ set time [expr int(($tmp2_ - $pre_time)*1000000.0)]
if { $frametype_ == "I" } { set type_v 1
set prio_p 0 }
if { $frametype_ == "P" } { set type_v 2
set prio_p 0 }
if { $frametype_ == "B" } { set type_v 3
set prio_p 0 }
if { $frametype_ == "H" } { set type_v 1
set prio_p 0 }
puts $trace_file_id "$time $length_ $type_v $prio_p $max_fragmented_size" set pre_time $tmp2_
}
close $original_file_id close $trace_file_id set end_sim_time $tmp2_ puts "$end_sim_time"
set trace_file [new Tracefile]
$trace_file filename $trace_file_name
#Attach video to server #create source traffic
#Create a UDP agent and attach it to node n0 set udp_0 [new Agent/myUDP]
$udp_0 set_filename udpSend0 $udp_0 set packetSize_ 1052
$ns attach-agent $n2 $udp_0 ;#Server 2
set udp_1 [new Agent/myUDP] $udp_1 set_filename udpSend1 $udp_1 set packetSize_ 1052
set udp_4 [new Agent/myUDP] $udp_4 set_filename udpSend7 $udp_4 set packetSize_ 1052
$ns attach-agent $n2 $udp_4 ;#Server 2
set udp_5 [new Agent/myUDP] $udp_5 set_filename udpSend8 $udp_5 set packetSize_ 1052
$ns attach-agent $n2 $udp_5 ;#Server 2
set udp_8 [new Agent/myUDP] $udp_8 set_filename udpSend9 $udp_8 set packetSize_ 1052
$ns attach-agent $n2 $udp_8 ;#Server 2
set udp_9 [new Agent/myUDP] $udp_9 set_filename udpSend14 $udp_9 set packetSize_ 1052
$ns attach-agent $n2 $udp_9 ;#Server 2
set udp_2 [new Agent/myUDP] $udp_2 set_filename udpSend15 $udp_2 set packetSize_ 1052
$ns attach-agent $n20 $udp_2 ;#Server 20
set udp_6 [new Agent/myUDP] $udp_6 set_filename udpSend16 $udp_6 set packetSize_ 1052
$ns attach-agent $n20 $udp_6 ;#Server 20
set udp_3 [new Agent/myUDP] $udp_3 set_filename udpSend19 $udp_3 set packetSize_ 1052
$ns attach-agent $n22 $udp_3 ;#Server 22
set udp_7 [new Agent/myUDP] $udp_7 set_filename udpSend21 $udp_7 set packetSize_ 1052
$ns attach-agent $n22 $udp_7 ;#Server 22
# Attach video traffic source
set video0 [new Application/Traffic/myEvalvid] $video0 attach-tracefile $trace_file
$video0 attach-agent $udp_0
set video1 [new Application/Traffic/myEvalvid] $video1 attach-tracefile $trace_file
set video2 [new Application/Traffic/myEvalvid] $video2 attach-tracefile $trace_file
$video2 attach-agent $udp_2
set video3 [new Application/Traffic/myEvalvid] $video3 attach-tracefile $trace_file
$video3 attach-agent $udp_3
set video4 [new Application/Traffic/myEvalvid] $video4 attach-tracefile $trace_file
$video4 attach-agent $udp_4
set video5 [new Application/Traffic/myEvalvid] $video5 attach-tracefile $trace_file
$video5 attach-agent $udp_5
set video6 [new Application/Traffic/myEvalvid] $video6 attach-tracefile $trace_file
$video6 attach-agent $udp_6
set video7 [new Application/Traffic/myEvalvid] $video7 attach-tracefile $trace_file
$video7 attach-agent $udp_7
set video8 [new Application/Traffic/myEvalvid] $video8 attach-tracefile $trace_file
$video8 attach-agent $udp_8
set video9 [new Application/Traffic/myEvalvid] $video9 attach-tracefile $trace_file
$video9 attach-agent $udp_9
# Create the Null agent to sink traffic set null_0 [new Agent/myEvalvid_Sink] $null_0 set_filename udpRec0
$ns attach-agent $n0 $null_0
set null_1 [new Agent/myEvalvid_Sink] $null_1 set_filename udpRec1
$ns attach-agent $n1 $null_1
set null_7 [new Agent/myEvalvid_Sink] $null_7 set_filename udpRec7
$ns attach-agent $n7 $null_7
$null_8 set_filename udpRec8 $ns attach-agent $n8 $null_8
set null_9 [new Agent/myEvalvid_Sink] $null_9 set_filename udpRec9
$ns attach-agent $n9 $null_9
set null_14 [new Agent/myEvalvid_Sink] $null_14 set_filename udpRec14
$ns attach-agent $n14 $null_14
set null_15 [new Agent/myEvalvid_Sink] $null_15 set_filename udpRec15
$ns attach-agent $n19 $null_15
set null_16 [new Agent/myEvalvid_Sink] $null_16 set_filename udpRec16
$ns attach-agent $n19 $null_16
set null_19 [new Agent/myEvalvid_Sink] $null_19 set_filename udpRec19
$ns attach-agent $n19 $null_19
set null_21 [new Agent/myEvalvid_Sink] $null_21 set_filename udpRec21
$ns attach-agent $n21 $null_21
# Attach the 2 agents
$ns connect $udp_0 $null_0 $ns connect $udp_1 $null_1 $ns connect $udp_2 $null_7 $ns connect $udp_3 $null_8 $ns connect $udp_4 $null_9 $ns connect $udp_5 $null_14 $ns connect $udp_6 $null_15 $ns connect $udp_7 $null_16 $ns connect $udp_8 $null_19 $ns connect $udp_9 $null_21
$ns at 4.0 "$cbr5 stop" $ns at 5.1 "$cbr6 stop" $ns at 5.8 "$cbr7 stop"
#Evaluated traffics $ns at 2.0 "$video0 start" $ns at 2.5 "$video1 start" $ns at 3.0 "$video2 start" $ns at 3.4 "$video3 start" $ns at 3.8 "$video4 start" $ns at 4.0 "$video5 start" $ns at 4.5 "$video6 start" $ns at 5.0 "$video7 start" $ns at 5.5 "$video8 start" $ns at 6.0 "$video9 start"
set tcp [new Agent/TCP] $tcp set class_ 2
set sink [new Agent/TCPSink] $ns attach-agent $n0 $tcp $ns attach-agent $n3 $sink $ns connect $tcp $sink
set ftp [new Application/FTP] $ftp attach-agent $tcp
$ns at 1.2 "$ftp start"
$ns at 1.35 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink"
puts [$cbr0 set packetSize_] puts [$cbr0 set interval_]
$ns at 20.0 "finish"
proc finish {} { global ns f nf $ns flush-trace close $f close $nf
puts "running nam..." exec nam out.nam & exit 0
}