[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Bidirectional CBQ ??
Dear ns-users,
few weeks ago, you gave me a solution for my problem with CBQ and TCP. At this
time, I had traffic in only one direction, so that I configured CBQ in one
direction and SFQ in the other and it worked (in the other direction, I had only
ack packets). Now, I want to create traffic on the both sides of my network and
I can't configure properly the CBQ in the two directions. The results I get are
wrong (see below and nam). Could someone have a look at my file and say to me
what I'm doing wrong??? Or if you don't feel like reading my file, can you send
me a tcl-script where it works??
Thanks a lot,
Regards,
Gerald
Link statistics 5-8 :
parrivals_=168, pdrops_=0,pdepartures_=168
Link statistics 0-1 :
parrivals_=84, pdrops_=0,pdepartures_=84
Link statistics 4-2 :
parrivals_=84, pdrops_=0,pdepartures_=84
Link statistics 2-1 :
parrivals_=84, pdrops_=0,pdepartures_=84
Link statistics 1-3 :
parrivals_=168, pdrops_=174,pdepartures_=5388
Link statistics 3-5 :
parrivals_=168, pdrops_=0,pdepartures_=168
Link statistics 8-5 :
parrivals_=174, pdrops_=0,pdepartures_=174
Link statistics 1-0 :
parrivals_=0, pdrops_=0,pdepartures_=0
Link statistics 2-4 :
parrivals_=0, pdrops_=0,pdepartures_=0
Link statistics 1-2 :
parrivals_=0, pdrops_=0,pdepartures_=0
Link statistics 3-1 :
parrivals_=5220, pdrops_=0,pdepartures_=0
Link statistics 5-3 :
parrivals_=174, pdrops_=0,pdepartures_=174
simulation complete
# Creation of a simulator object
set ns [new Simulator]
# Colors!
$ns color 1 Blue
$ns color 2 Red
# Opening of a file
#set tf [open ../../../../../home_holmes/angerman/simu/outtestbis.tr w]
#$ns trace-all $tf
set nf [open ../../../../../home_holmes/angerman/simu/testduplexCBQ_link_procedure_out.nam w]
$ns namtrace-all $nf
#########################################################################
# Procedures
#------------------------------------------------------------------------
proc make_topology {} {
global ns n qmon1 qmon2 qmon3 qmon4 qmon5 qmon6 qmon7 qmon8 qmon9 qmon10 qmon11 qmon12 cbqlink1 cbqlink2
for {set i 0} {$i < 9} {incr i} {
set n($i) [$ns node]
}
$ns duplex-link $n(0) $n(1) 1Mb 10ms SFQ
$ns duplex-link $n(2) $n(1) 1Mb 10ms SFQ
$ns duplex-link $n(2) $n(4) 1Mb 10ms SFQ
$ns duplex-link $n(1) $n(3) 1Mb 10ms CBQ
$ns duplex-link $n(3) $n(5) 1Mb 10ms SFQ
$ns duplex-link $n(3) $n(6) 1Mb 10ms SFQ
$ns duplex-link $n(7) $n(5) 1Mb 10ms SFQ
$ns duplex-link $n(5) $n(8) 1Mb 10ms SFQ
set cbqlink1 [$ns link $n(3) $n(1)]
set cbqlink2 [$ns link $n(1) $n(3)]
set qmon1 [$ns monitor-queue $n(5) $n(8) stdout]
set qmon2 [$ns monitor-queue $n(0) $n(1) stdout]
set qmon3 [$ns monitor-queue $n(4) $n(2) stdout]
set qmon4 [$ns monitor-queue $n(2) $n(1) stdout]
set qmon5 [$ns monitor-queue $n(1) $n(3) stdout]
set qmon6 [$ns monitor-queue $n(3) $n(5) stdout]
set qmon7 [$ns monitor-queue $n(8) $n(5) stdout]
set qmon8 [$ns monitor-queue $n(1) $n(0) stdout]
set qmon9 [$ns monitor-queue $n(2) $n(4) stdout]
set qmon10 [$ns monitor-queue $n(1) $n(2) stdout]
set qmon11 [$ns monitor-queue $n(3) $n(1) stdout]
set qmon12 [$ns monitor-queue $n(5) $n(3) stdout]
}
#------------------------------------------------------------------------
proc make_hierarchy {} {
global rootClass voice data
set rootClass [new CBQClass]
set voice [new CBQClass]
set data [new CBQClass]
$rootClass setparams none 0 0.80 auto 0 2 0
$voice setparams $rootClass true 0.35 auto 1 1 0ms
$data setparams $rootClass true 0.35 auto 2 1 0ms
set q1 [new Queue/SFQ]
$q1 set limit_ 20
set q2 [new Queue/SFQ]
$q2 set limit_ 30
$voice install-queue $q1
$data install-queue $q2
}
#------------------------------------------------------------------------
proc make_cbqlink { link } {
global rootClass voice data
$link insert $rootClass
$link insert $voice
$link insert $data
$link bind $voice 1
$link bind $data 2
}
#------------------------------------------------------------------------
proc make_all_sinks {} {
global ns sink n
set sink(0) [new Agent/LossMonitor]
$ns attach-agent $n(8) $sink(0)
for {set i 1} {$i < 3} {incr i} {
set sink($i) [new Agent/TCPSink]
$ns attach-agent $n(8) $sink($i)
}
set sink(3) [new Agent/LossMonitor]
$ns attach-agent $n(0) $sink(3)
set sink(4) [new Agent/TCPSink]
$ns attach-agent $n(0) $sink(4)
set sink(5) [new Agent/TCPSink]
$ns attach-agent $n(4) $sink(5)
set sink(6) [new Agent/LossMonitor]
$ns attach-agent $n(4) $sink(6)
}
#------------------------------------------------------------------------
proc parameter_CBRApplication_for_voice { cbrvoice } {
$cbrvoice set packetSize_ 50
$cbrvoice set interval_ 0.05
}
#------------------------------------------------------------------------
proc attach_CBRApplications_for_UDP {} {
global cbrvoice udp
for {set i 0} {$i < 4} {incr i} {
set cbrvoice($i) [new Application/Traffic/CBR]
parameter_CBRApplication_for_voice $cbrvoice($i)
$cbrvoice($i) attach-agent $udp($i)
}
}
#------------------------------------------------------------------------
proc make_all_UDPSources {} {
global ns n sink udp
set udp(0) [new Agent/UDP]
$udp(0) set fid_ 1
$ns attach-agent $n(0) $udp(0)
$ns connect $udp(0) $sink(0)
set udp(1) [new Agent/UDP]
$udp(1) set fid_ 1
$ns attach-agent $n(4) $udp(1)
$ns connect $udp(1) $sink(0)
set udp(2) [new Agent/UDP]
$udp(2) set fid_ 1
$ns attach-agent $n(8) $udp(2)
$ns connect $udp(2) $sink(3)
set udp(3) [new Agent/UDP]
$udp(3) set fid_ 1
$ns attach-agent $n(8) $udp(3)
$ns connect $udp(3) $sink(6)
attach_CBRApplications_for_UDP
}
#------------------------------------------------------------------------
proc parameter_CBRApplication_for_data { cbrdata } {
$cbrdata set packetSize_ 500
$cbrdata set interval_ 0.005
}
#------------------------------------------------------------------------
proc attach_CBRApplications_for_TCP {} {
global cbrdata tcp
for {set i 0} {$i < 4} {incr i} {
set cbrdata($i) [new Application/Traffic/CBR]
parameter_CBRApplication_for_data $cbrdata($i)
$cbrdata($i) attach-agent $tcp($i)
}
}
#------------------------------------------------------------------------
proc make_all_TCPSources {} {
global ns n sink tcp
set tcp(0) [new Agent/TCP]
$tcp(0) set packetSize_ 500
$tcp(0) set fid_ 2
$ns attach-agent $n(0) $tcp(0)
$ns connect $tcp(0) $sink(1)
set tcp(1) [new Agent/TCP]
$tcp(1) set packetSize_ 500
$tcp(1) set fid_ 2
$ns attach-agent $n(4) $tcp(1)
$ns connect $tcp(1) $sink(2)
set tcp(2) [new Agent/TCP]
$tcp(2) set packetSize_ 500
$tcp(2) set fid_ 2
$ns attach-agent $n(8) $tcp(2)
$ns connect $tcp(2) $sink(4)
set tcp(3) [new Agent/TCP]
$tcp(3) set packetSize_ 500
$tcp(3) set fid_ 2
$ns attach-agent $n(8) $tcp(3)
$ns connect $tcp(3) $sink(5)
attach_CBRApplications_for_TCP
}
#------------------------------------------------------------------------
proc run_sim {} {
global ns cbrvoice cbrdata start_time stop_time
for {set i 0} {$i < 4} {incr i} {
$ns at $start_time "$cbrvoice($i) start"
$ns at $stop_time "$cbrvoice($i) stop"
}
for {set i 0} {$i < 4} {incr i} {
$ns at $start_time "$cbrdata($i) start"
$ns at $stop_time "$cbrdata($i) stop"
}
}
#------------------------------------------------------------------------
proc open_trace-files {} {
global ns tf1 tf2 tf3 tf4 n
set tf1 [open ../../../../../home_holmes/angerman/simu/outtestduplexCBQ_link_procedure_0_1.tr w]
$ns trace-queue $n(0) $n(1) $tf1
set tf2 [open ../../../../../home_holmes/angerman/simu/outtestduplexCBQ_link_procedure_5_8.tr w]
$ns trace-queue $n(5) $n(8) $tf2
set tf3 [open ../../../../../home_holmes/angerman/simu/outtestduplexCBQ_link_procedure_4_2.tr w]
$ns trace-queue $n(4) $n(2) $tf3
set tf4 [open ../../../../../home_holmes/angerman/simu/outtestduplexCBQ_link_procedure_2_4.tr w]
$ns trace-queue $n(2) $n(4) $tf4
}
#------------------------------------------------------------------------
proc output_link-statistics { qmon link } {
puts "Link statistics $link :"
puts "parrivals_=[$qmon set parrivals_], pdrops_=[$qmon set pdrops_],pdepartures_=[$qmon set pdepartures_]"
}
#------------------------------------------------------------------------
proc finish {} {
global ns nf sink tf1 tf2 tf3 tf4 qmon1 qmon2 qmon3 qmon4 qmon5 qmon6 qmon7 qmon8 qmon9 qmon10 qmon11 qmon12
output_link-statistics $qmon1 5-8
output_link-statistics $qmon2 0-1
output_link-statistics $qmon3 4-2
output_link-statistics $qmon4 2-1
output_link-statistics $qmon5 1-3
output_link-statistics $qmon6 3-5
output_link-statistics $qmon7 8-5
output_link-statistics $qmon8 1-0
output_link-statistics $qmon9 2-4
output_link-statistics $qmon10 1-2
output_link-statistics $qmon11 3-1
output_link-statistics $qmon12 5-3
puts "simulation complete"
$ns flush-trace
close $tf1
close $tf2
close $tf3
close $tf4
close $nf
exec nam ../../../../../home_holmes/angerman/simu/testduplexCBQ_link_procedure_out.nam &
exit 0
}
#------------------------------------------------------------------------
#########################################################################
## Main program
# Topology
make_topology
# Set two leaf classes: voice and data
make_hierarchy
# Insertion of the classes in the links
make_cbqlink $cbqlink1
make_cbqlink $cbqlink2
# Sinks
make_all_sinks
# UDP Sources
make_all_UDPSources
# TCP Sources
make_all_TCPSources
# Run the simulation
set start_time 0.5
set stop_time 4.5
run_sim
# Open of trace-files
open_trace-files
$ns at 30.0 "finish"
# Starting of the simulation
$ns run