[ns] problem : New protocol implementation
ns-2
ns-2 at mmamun.org
Wed Apr 6 08:49:12 PDT 2005
Hi
I tried to inherit the TCP and developed my own tcp protocol(with no functionality. just for test).
But when I use that in my TCL script it gives error. I dont understand what should I do. I am using ns-all-in-one-2.28(the newest one). Somebody pls help me to solve this.(I am attaching the error, my header file ,the source file and the TCL file for your review)
Thanking you
Shuvo
The error I got is :
invalid command name "Agent/TCP/myTcp"
while executing
"Agent/TCP/myTcp create _o86 "
invoked from within
"catch "$className create $o $args" msg"
invoked from within
"if [catch "$className create $o $args" msg] {
if [string match "__FAILED_SHADOW_OBJECT_" $msg] {
delete $o
return ""
}
global errorInfo
error "class $..."
(procedure "new" line 3)
invoked from within
"new Agent/TCP/myTcp"
invoked from within
"set tcpinner [new Agent/TCP/myTcp]"
(file "/root/Thesis/thesis-testbed.tcl" line 48)
Header file: tcp-js.h
-------------------------------
#include "tcp.h"
class myTcpAgent : public TcpAgent {
public:
myTcpAgent();
};
Source file: tcp-js.cc
-----------------------------
#include "tcp-js.h"
static class myTcpAgentClass : public TclClass {
public:
myTcpAgentClass() : TclClass("Agent/TCP/MyTcp") {}
TclObject* create(int, const char*const*) {
return (new myTcpAgent());
}
} class_mytcp_agent;
myTcpAgent::myTcpAgent() : TcpAgent()
{
}
TCL Script:
-------------------
#Create a simulator object
set ns [new Simulator]
#Define different colors for data flows (for NAM)
$ns color 1 Blue
$ns color 2 Red
set nf [open testbed.tr w]
$ns trace-all $nf
#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
exit 0
}
#Create four nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
#Create links between the nodes
$ns duplex-link $n0 $n1 2Mb 10ms DropTail
$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns duplex-link $n2 $n3 1.7Mb 20ms DropTail
#Set Queue Size of link (n2-n3) to 10
$ns queue-limit $n1 $n2 5
#Setup a outer TCP connection
set tcpouter [new Agent/TCP]
$tcpouter set fid_ 1
$ns attach-agent $n0 $tcpouter
set sinkouter [new Agent/TCPSink]
$ns attach-agent $n3 $sinkouter
$ns connect $tcpouter $sinkouter
#Setup a inner TCP connection
set tcpinner [new Agent/TCP/myTcp]
$tcpinner set fid_ 2
$ns attach-agent $n1 $tcpinner
set sinkinner [new Agent/TCPSink]
$ns attach-agent $n2 $sinkinner
$ns connect $tcpinner $sinkinner
#Setup a FTP over outer TCP connection
set ftpouter [new Application/FTP]
$ftpouter attach-agent $tcpouter
$ftpouter set type_ FTP
$ns at 0.1 "$ftpinner start"
$ns at 1.0 "$ftpouter start"
$ns at 4.0 "$ftpouter stop"
$ns at 4.5 "$ftpinner stop"
#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"
#Run the simulation
$ns run
More information about the Ns-users
mailing list