[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] Question about adding new queue type in ns2.1b6!



I don't do anything with CBQ, I think.
OK,I send my .cc,.h code,I just emulate the droptail code but it doesn't work.
Appreciate your help!

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.
>
> >X-Authentication-Warning: mash.CS.Berkeley.EDU: majrdomo set sender to
> [email protected] using -f
> >Date: Thu, 25 May 2000 17:55:46 +0800
> >From: Wu Wei <[email protected]>
> >X-Accept-Language: zh-CN, en
> >MIME-Version: 1.0
> >To: [email protected]
> >Subject: [ns] Question about adding new queue type in ns2.1b6!
> >Content-Transfer-Encoding: 7bit
> >
> >
> >Hi,ns-users,
> >
> >I asked this question several days ago,but no reply.I have to ask
> >twice,for
> >it's really urgent.
> >I met trouble when I tried to implement one queue type of mine.I
> >inherited a new queue class in c++ from
> >class Queue and implement of mine. Code compiled ok but when I tried to
> >test it,it complained as followed,
> >It seemed to complain that no unblock_on_resume_ variable,but I think it
> >
> >has been declared and initialized
> >in class Queue,I inherited it from Queue.
> >Any hints are welcome.
> >Thanks
> >
> >
> >
> >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
#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