[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] HELP!
Greetings,
I am beginner in ns, and trying to simulate CNS scheduling. The bellow code
is almost the
same as drop-tail.cc. Any help me with the following errors is appreciated.
Igor
The output:
$ ns proba1.tcl
no such object
(_o21 cmd line 1)
invoked from within
"_o21 cmd target {}"
invoked from within
"catch "$self cmd $args" ret"
(procedure "_o21" line 2)
(SplitObject unknown line 2)
invoked from within
"$deqT_ target [$queue_ target]"
(procedure "_o15" line 21)
(SimpleLink trace line 21)
invoked from within
"$link_([$n1 id]:[$n2 id]) trace $self $file"
(procedure "_o3" line 7)
(Simulator trace-queue line 7)
invoked from within
"$self trace-queue $n1 $n2 $trace"
(procedure "_o3" line 59)
(Simulator simplex-link line 59)
invoked from within
"$ns simplex-link $n1 $n2 5Mb 5ms CNS "
(file "proba1.tcl" line 9)
The files:
cns.h:
class CNS : public Queue {
public:
CNS() {
q_ = new PacketQueue;
pq_ = q_;
bind_bw("link_speed_",&link_speed_);
// bind_time("last_packet_departure_", &last_packet_departure);
bind_time("time_limit",&time_limit);
}
~CNS() {
delete q_;
}
protected:
int command(int argc, const char*const* argv);
void enque(Packet*);
Packet* deque();
PacketQueue *q_;
double last_packet_departure;
double link_speed_;
double time_limit;
};
#endif
cns.cc:
#include "cns.h"
static class CNSClass : public TclClass {
public:
CNSClass() : TclClass("Queue/CNS") {}
TclObject* create(int, const char*const*) {
return (new CNS);
}
} class_cns;
int CNS::command(int argc, const char*const* argv) {
pq_ = q_;
return (TCL_OK);
return Queue::command(argc, argv);
}
void CNS::enque(Packet* p)
{
double temp;
double time=Scheduler::instance().clock();
// double packet_processing_time=link_speed_/p->length();
hdr_cmn* hdr = (hdr_cmn*) p->access(off_cmn_);
double packet_processing_time=(hdr->size() * 8. / link_speed_);
if(q_->length()==0)
{
q_->enque(p);
last_packet_departure=time+packet_processing_time;
}
else
{
if(time>last_packet_departure)
temp=time+packet_processing_time;
else temp=last_packet_departure+packet_processing_time;
if((temp-time)>time_limit)drop(p);
else
{
last_packet_departure=temp;
q_->enque(p);
}
}
}
Packet* CNS::deque() {
return (q_->deque());
}
The TCL code:
set ns [new Simulator]
Queue/CNS set link_speed_ 5Mb
Queue/CNS set time_limit 5ms
set n1 [$ns node]
set n2 [$ns node]
set f [open out.tr w]
$ns trace-all $f
$ns simplex-link $n1 $n2 5Mb 5ms CNS
set source [new Agent/UDP]
$ns attach-agent $n1 $source
set traffic [new Application/Traffic/Exponential]
$traffic set packet-size 1000
$traffic set burst-time 0.32s
$traffic set idle-time 0.32s
$traffic set rate 64k
set sink [new Agent/Null]
$ns attach-agent $n2 $sink
$traffic attach-agent $source
$ns connect $source $sink
$ns at 0.0 "$traffic start"
$ns at 3.0 "finish"
proc finish {} {
global ns f
$ns flush-trace
close $f
exit 0
}
$ns run
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com