/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
/*
 * Copyright (c) 1999, Federal University of Pernambuco - Brazil.
 * All rights reserved.
 *
 * License is granted to copy, to use, and to make and to use derivative
 * works for research and evaluation purposes.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * Contributed by Carlos Alberto Kamienski <cak@di.ufpe.br>
 *
 */

#ifndef ns_dsshapper_h
#define ns_dsshapper_h

#include "packet.h"
#include "connector.h"
#include "queue.h"

class DSShaper;

class DSShaperHandler : public Handler {
public:
	DSShaperHandler(DSShaper *s) : shaper_(s) {}
	void handle(Event *e);
private:
	DSShaper *shaper_;
};


class DSShaper: public Connector {
private:
	int		received_packets ;
	int		sent_packets ;
	int		shaped_packets ;
	int		dropped_packets ;
	int         max_queue_length;
	PacketQueue shape_queue;
	double		peak_ ;
	int		burst_size_ ;
	int		curr_bucket_contents ;
	int		flow_id_;
	double      last_time ;
        bool        shape_packet(Packet *p) ;	
        void        schedule_packet(Packet *p) ;
        bool        in_profile(Packet *p) ;
	void		update_bucket_contents() ;
	void        reset_counters();
	DSShaperHandler sh_;
public:
			DSShaper() ;
	void 		resume();
	void		recv(Packet *p, Handler *h) ;
	int		command(int argc, const char*const* argv) ;
} ;

#endif
