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

Re: can you help me?



> I want to add a new queue in c++ code,
> though I have spent 5 days researching it, 
> I am confused that relation of member function and member variable 
> is in the new queue.
> in general,I find that a type of queue has member function below:
> 
> e.g. class NewQueue:public Queue {
>         public:
>             ...
>             int command(int argc,char const * argv);
>             void recv(Packet* p, Handler* h);
>             void enque(Packet * pkt);
>             Packet* deque();
> 
>             PacketQueue *q_;     
>             ...
>         }

I'm not sure that I understand your problem: I think that you want an
explanation of the above class.

The command() method is used to provide TCL access to the class - this can
be used say to reset variables in the class, empty the queue, or say to
configure the queue using multiple parameters simultaneously, or other
functionality you might want to be able to access from TCL.

The recv() method is where packets arrive in the queue. Often this just
checks if the queue is idle - if not the packet is enqued (if there are
enough resources obviously), and if so, then the packet is enqued, and the
queue is made active and the packet is dequeued.

The enque() method determines if the packet should be enqued, and enques
the packet appropriately. For example in the priority queue case, the
enque method checks to see if the packet is a priority packet, and if so,
enques it at the head of the queue.

The deque() method is called to remove the next packet from the queue - in
some situations, this has to determine what the next packet is.

The PacketQueue object is typically where the packets are stored.

To implement a new queue, you also need to tell TCL about it. Code to do
this is typically at the top of the files containing the queue code (e.g.
cbq.cc (class CBQueueClass), sfq.cc (class SFQClass) ).

If you register your new queue type with TCL as "Queue/<your new queue
type>", then I think that you should be able to create a duplex link with
your queues on it using 

$ns duplex-link $n1 $n2 $rate $delay <your new queue type>

Hth,
Sean.
-----
Sean Murphy,			Email: [email protected]
Teltec Ireland,			Phone: +353-1-7045080
DCU, Dublin 9,			Fax:   +353-1-7045092
Ireland.