BabyPinky8888
Programmer
Hi:
I have a code with which I want to be able to draw graphs for the congestion window and the throughput.. Can you please take a look at it.. and tell me where I am going wrong ? The simulation has been programmed to run for 500s but it does not run for even 5 secs.. I am pasting my TCL code here.. the cwnd_ is for the congestion window at the sender and bytes_ at the receiver for recording throughput.. they both existing in the corresponding .cc files and have a variable which can be used in the tcl script of mine.
I want the myconnection () to return 2 values.. but it does not!
source /home/kbhaskaran/ns2/ns-allinone-2.33/ns-2.33/obs-0.9a/tcl/lib/ns-obs-lib.tcl
source /home/kbhaskaran/ns2/ns-allinone-2.33/ns-2.33/obs-0.9a/tcl/lib/ns-obs-defaults.tcl
source /home/kbhaskaran/ns2/ns-allinone-2.33/ns-2.33/obs-0.9a/tcl/lib/ns-optic-link.tcl
StatCollector set debug_ 1
Classifier/BaseClassifier/EdgeClassifier set type_ 0
Classifier/BaseClassifier/CoreClassifier set type_ 1
Classifier/BaseClassifier set nfdl 16
Classifier/BaseClassifier set fdldelay 0.000
Classifier/BaseClassifier set maxfdls 5
Classifier/BaseClassifier set ebufoption 0
#no FDLs:
Classifier/BaseClassifier set option 0
OBSFiberDelayLink set FDLdelay 0.0
#bandwidth (bps) that EACH channel gets
set bwpc 1000000000
set delay .5ms
#number of control channels
set ncc 4
#number of data channels
set ndc 4
#burst assembly time (s)
BurstManager bursttimeout 0.01
#burst size threshold (bytes)
#1000000 (1MB)
BurstManager maxburstsize 1000000
#.000001 (1us)
BurstManager offsettime 0.00004
Classifier/BaseClassifier/CoreClassifier set bhpProcTime .000001
Classifier/BaseClassifier/EdgeClassifier set bhpProcTime .000001
Agent/TCP set packetSize_ 1000
Agent/TCP set window_ 10000
Agent/TCP set max_ssthresh_ 512
#simulator object
set ns [new Simulator]
#stat collector
set sc [new StatCollector]
#Kavitha
set trace [open trace1a.tr w]
set cwnd [open cwnd1b.tr w]
set cwnd1 [open cwnd1c.tr w]
set bytes [open bytes.tr w]
set bytes1 [open bytes1.tr w]
$ns trace-all $trace
#called when the simulation is complete
proc finish {} {
global ns sc bytes
#display the stats
$sc display-sim-list
puts "done"
exit 0
}
#add method create topology to simulator object
proc create_topology { } {
global E C ns tcpSrc cwnd bytes
global bwpc ncc ndc delay
set edge_count 6
set core_count 2
for { set i 0 } { $i < $edge_count } { incr i } {
set E($i) [$ns create-edge-node $edge_count]
}
for { set i 0 } { $i < $core_count } { incr i } {
set C($i) [$ns create-core-node $core_count]
}
set maxch [expr $ncc + $ndc]
$ns createDuplexFiberLink $E(0) $C(0) $bwpc 1ms $ncc $ndc $maxch
$ns createDuplexFiberLink $C(0) $E(1) $bwpc 1ms $ncc $ndc $maxch
$ns createDuplexFiberLink $E(2) $C(0) $bwpc 1ms $ncc $ndc $maxch
$ns createDuplexFiberLink $C(0) $C(1) $bwpc 5ms $ncc $ndc $maxch
$ns createDuplexFiberLink $C(1) $E(3) $bwpc 1ms $ncc $ndc $maxch
$ns createDuplexFiberLink $C(1) $E(4) $bwpc 1ms $ncc $ndc $maxch
$ns createDuplexFiberLink $C(1) $E(5) $bwpc 1ms $ncc $ndc $maxch
$ns build-routing-table
}
#writes all the data to the trace files
proc record {} {
global ns tcpSrc tcpSrc1 cwnd cwnd1 bytes bytes1
$ns at [expr [$ns now] +0.5] "record"
puts $cwnd "[$ns now] [$tcpSrc set bytes_]"
#Today
puts $cwnd1 "[$ns now] [$tcpSrc1 set bytes_]"
puts $bytes "[ns now] [$tcpSrc set bytes_]"
puts $bytes1 "[ns now] [$tcpSrc1 set bytes_]"
}
proc setup-flows {} {
global E
global ns
global tcpSrc tcpSrc1 ns bytes
#global flowsPerNode udpFlowsPerNode
#global ns pkts
set tcpSrc [myconnection TCP/Sack1 $E(0) TCPSink/Sack1 $E(2) 0]
set tcpSrc1 [myconnection TCP/Sack1 $E(0) TCPSink/Sack1 $E(2) 0]
set ftp [new Application/FTP]
set ftp1 [new Application/FTP]
$ftp attach-agent $tcpSrc
$ftp1 attach-agent $tcpSrc1
$tcpSrc set windowOption_ 8
$tcpSrc1 set windowOption_ 8
$ns at 0.0 "$ftp start"
$ns at 0.0 "$ftp1 start"
}
proc myconnection {s_type source d_type dest pktClass} {
global s_agent d_agent bytes
global ns
set s_agent [new Agent/$s_type]
set d_agent [new Agent/$d_type]
$s_agent set fid_ $pktClass
$d_agent set fid_ $pktClass
$ns attach-agent $source $s_agent
$ns attach-agent $dest $d_agent
$ns connect $s_agent $d_agent
return $d_agent
return $s_agent
}
create_topology
setup-flows
$ns at 0.0 "record"
$ns at 500 "finish"
$ns run
I have a code with which I want to be able to draw graphs for the congestion window and the throughput.. Can you please take a look at it.. and tell me where I am going wrong ? The simulation has been programmed to run for 500s but it does not run for even 5 secs.. I am pasting my TCL code here.. the cwnd_ is for the congestion window at the sender and bytes_ at the receiver for recording throughput.. they both existing in the corresponding .cc files and have a variable which can be used in the tcl script of mine.
I want the myconnection () to return 2 values.. but it does not!
source /home/kbhaskaran/ns2/ns-allinone-2.33/ns-2.33/obs-0.9a/tcl/lib/ns-obs-lib.tcl
source /home/kbhaskaran/ns2/ns-allinone-2.33/ns-2.33/obs-0.9a/tcl/lib/ns-obs-defaults.tcl
source /home/kbhaskaran/ns2/ns-allinone-2.33/ns-2.33/obs-0.9a/tcl/lib/ns-optic-link.tcl
StatCollector set debug_ 1
Classifier/BaseClassifier/EdgeClassifier set type_ 0
Classifier/BaseClassifier/CoreClassifier set type_ 1
Classifier/BaseClassifier set nfdl 16
Classifier/BaseClassifier set fdldelay 0.000
Classifier/BaseClassifier set maxfdls 5
Classifier/BaseClassifier set ebufoption 0
#no FDLs:
Classifier/BaseClassifier set option 0
OBSFiberDelayLink set FDLdelay 0.0
#bandwidth (bps) that EACH channel gets
set bwpc 1000000000
set delay .5ms
#number of control channels
set ncc 4
#number of data channels
set ndc 4
#burst assembly time (s)
BurstManager bursttimeout 0.01
#burst size threshold (bytes)
#1000000 (1MB)
BurstManager maxburstsize 1000000
#.000001 (1us)
BurstManager offsettime 0.00004
Classifier/BaseClassifier/CoreClassifier set bhpProcTime .000001
Classifier/BaseClassifier/EdgeClassifier set bhpProcTime .000001
Agent/TCP set packetSize_ 1000
Agent/TCP set window_ 10000
Agent/TCP set max_ssthresh_ 512
#simulator object
set ns [new Simulator]
#stat collector
set sc [new StatCollector]
#Kavitha
set trace [open trace1a.tr w]
set cwnd [open cwnd1b.tr w]
set cwnd1 [open cwnd1c.tr w]
set bytes [open bytes.tr w]
set bytes1 [open bytes1.tr w]
$ns trace-all $trace
#called when the simulation is complete
proc finish {} {
global ns sc bytes
#display the stats
$sc display-sim-list
puts "done"
exit 0
}
#add method create topology to simulator object
proc create_topology { } {
global E C ns tcpSrc cwnd bytes
global bwpc ncc ndc delay
set edge_count 6
set core_count 2
for { set i 0 } { $i < $edge_count } { incr i } {
set E($i) [$ns create-edge-node $edge_count]
}
for { set i 0 } { $i < $core_count } { incr i } {
set C($i) [$ns create-core-node $core_count]
}
set maxch [expr $ncc + $ndc]
$ns createDuplexFiberLink $E(0) $C(0) $bwpc 1ms $ncc $ndc $maxch
$ns createDuplexFiberLink $C(0) $E(1) $bwpc 1ms $ncc $ndc $maxch
$ns createDuplexFiberLink $E(2) $C(0) $bwpc 1ms $ncc $ndc $maxch
$ns createDuplexFiberLink $C(0) $C(1) $bwpc 5ms $ncc $ndc $maxch
$ns createDuplexFiberLink $C(1) $E(3) $bwpc 1ms $ncc $ndc $maxch
$ns createDuplexFiberLink $C(1) $E(4) $bwpc 1ms $ncc $ndc $maxch
$ns createDuplexFiberLink $C(1) $E(5) $bwpc 1ms $ncc $ndc $maxch
$ns build-routing-table
}
#writes all the data to the trace files
proc record {} {
global ns tcpSrc tcpSrc1 cwnd cwnd1 bytes bytes1
$ns at [expr [$ns now] +0.5] "record"
puts $cwnd "[$ns now] [$tcpSrc set bytes_]"
#Today
puts $cwnd1 "[$ns now] [$tcpSrc1 set bytes_]"
puts $bytes "[ns now] [$tcpSrc set bytes_]"
puts $bytes1 "[ns now] [$tcpSrc1 set bytes_]"
}
proc setup-flows {} {
global E
global ns
global tcpSrc tcpSrc1 ns bytes
#global flowsPerNode udpFlowsPerNode
#global ns pkts
set tcpSrc [myconnection TCP/Sack1 $E(0) TCPSink/Sack1 $E(2) 0]
set tcpSrc1 [myconnection TCP/Sack1 $E(0) TCPSink/Sack1 $E(2) 0]
set ftp [new Application/FTP]
set ftp1 [new Application/FTP]
$ftp attach-agent $tcpSrc
$ftp1 attach-agent $tcpSrc1
$tcpSrc set windowOption_ 8
$tcpSrc1 set windowOption_ 8
$ns at 0.0 "$ftp start"
$ns at 0.0 "$ftp1 start"
}
proc myconnection {s_type source d_type dest pktClass} {
global s_agent d_agent bytes
global ns
set s_agent [new Agent/$s_type]
set d_agent [new Agent/$d_type]
$s_agent set fid_ $pktClass
$d_agent set fid_ $pktClass
$ns attach-agent $source $s_agent
$ns attach-agent $dest $d_agent
$ns connect $s_agent $d_agent
return $d_agent
return $s_agent
}
create_topology
setup-flows
$ns at 0.0 "record"
$ns at 500 "finish"
$ns run