Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking my TCL code!

Status
Not open for further replies.

BabyPinky8888

Programmer
Feb 24, 2009
10
0
0
US
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
 
Of course the two lines
Code:
  return $d_agent
  return $s_agent
won't return two values, as only the first one is executed: you probably want to say
Code:
  return [list $d_agent $s_agent]
Please, whenever you post code or data, use the [ignore]
Code:
code here...
[/ignore] tags. However we are not going here to examine a long piece of code for you: as your specific question has been answered, please be also specific with questions if you come back.

Franco
: Online engineering calculations
: Magnetic brakes for fun rides
: Air bearing pads
 
Hi Franco:

Thanks for ur reply.. I tried returning the s_agent and d_agent as a list as
return [list s_agent, d_agent]

but now i get a new set of errors:(you can see my code above)

no such agent _o198 _o197
(_o202 cmd line 1)
invoked from within
"_o202 cmd attach-agent {_o198 _o197}"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o202" line 2)
(SplitObject unknown line 2)
invoked from within
"$ftp attach-agent $tcpSrc"
(procedure "setup-flows" line 18)
invoked from within
"setup-flows"
(file "ModifiedFirst.tcl" line 180)
[kbhaskaran@cluster ~]$

 
I understand that, there is a problem in the myconnection() with the s_agent and d_agent but I am not able to figure out exactly as to what's going wrong..please assist!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top