[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] Question about adding new queue type in ns2.1b6!
I tried $ns duplex-link $ns1 $ns2 5Mb 2ms Queue/Prob
but it does not work,because it complains no Queue/Queue/Prob exists,so I think
it is not this problem.
I wonder what I should do when I want to add a new queue type,because my code is
very similiar to
DropTail . I add my code to ns source code dir and add items in Makefile and
default value in ns-default.tcl.
Do I need do more?
I wonder it complains "unblock_on_resume_" ,which is declared in queue.h ,can't
be found.But I do inherit
class Queue . Any hints are welcome! (this mail attach my code and test file)
Thanks
error followed:
>can't read "unblock_on_resume_": no such variable
> (Object set line 1)
> invoked from within
>"Queue/Prob set unblock_on_resume_"
> invoked from within
>"catch "$c set $var" val"
> (procedure "_o16" line 1)
> (SplitObject unknown line 1)
> invoked from within
>"$queue_ target $link_"
> (procedure "_o17" line 24)
> (SimpleLink init line 24)
> invoked from within
>"_o17 init _o12 _o14 5Mb 2ms _o16"
> (Class create line 1)
> invoked from within
>"SimpleLink create _o17 _o12 _o14 5Mb 2ms _o16"
> invoked from within
>"catch "$className create $o $args" msg"
> (procedure "new" line 3)
> invoked from within
>"new SimpleLink $n1 $n2 $bw $delay $q"
> ("default" arm line 2)
> invoked from within
>"switch -exact $qtypeOrig {
>RTM {
>set c [lindex $args 1]
>set link_($sid:$did) [new CBQLink $n1 $n2 $bw $delay $q $c]
>}
>CBQ -
>CBQ/WRR {
>if {[llen..."
> (procedure "_o3" line 27)
> (Simulator simplex-link line 27)
> invoked from within
>"_o3 simplex-link _o12 _o14 5Mb 2ms Prob"
> ("eval" body line 1)
> invoked from within
>"eval $self simplex-link $n1 $n2 $bw $delay $type $args"
> (procedure "_o3" line 9)
> (Simulator duplex-link line 9)
> invoked from within
>"$ns duplex-link $n1 $n2 5Mb 2ms Prob"
> (file "probtest.tcl" line 11)
>
Tarik Alj wrote:
> Are you using this with CBQ? Try testing with a simple script first.
>
> I suggest you examine your constructor and the command function. Compare with
> others like DropTail for example.
>
> If you want you can send me your .h/.cc files and I can try looking at them.
#ifndef ns_prob_queue_h
#define ns_prob_queue_h
#include <string.h>
#include "queue.h"
#include "config.h"
#include "random.h"
class ProbQueue : public Queue {
public:
ProbQueue();
~ProbQueue() {
delete q_;
}
protected:
int command(int argc,const char*const* argv);
void enque(Packet*);
Packet* deque();
PacketQueue *q_;
double prob_;
};
#endif
#include "probqueue.h"
static class ProbQueueClass : public TclClass {
public:
ProbQueueClass() : TclClass("Queue/Prob") {}
TclObject* create(int,const char*const*) {
return(new ProbQueue);
}
} class_prob;
ProbQueue::ProbQueue() {
q_=new PacketQueue;
pq_=q_;
bind("prob_",&prob_);
}
int ProbQueue::command(int argc,const char*const* argv) {
if (argc==2) {
if (strcmp(argv[1],"get-curr-length")==0) {
Tcl& tcl = Tcl::instance();
tcl.resultf("%d",length());
return TCL_OK ;
}
}
if(argc==3) {
if(!strcmp(argv[1],"packetqueue-attach")) {
delete q_;
if (!(q_ = (PacketQueue*) TclObject::lookup(argv[2])))
return (TCL_ERROR);
else {
pq_ = q_;
return (TCL_OK);
}
}
}
}
void ProbQueue::enque(Packet* p)
{
double drop_prob=Random::uniform();
q_->enque(p);
if((drop_prob<prob_)||(q_->length()>=qlim_)) {
q_->remove(p);
drop(p);
}
}
Packet* ProbQueue::deque()
{
return q_->deque();
}
probtest.tcl