tbf.h

Go to the documentation of this file.
00001 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
00002 /*
00003  * Copyright (c) Xerox Corporation 1997. All rights reserved.
00004  *
00005  * This program is free software; you can redistribute it and/or modify it
00006  * under the terms of the GNU General Public License as published by the
00007  * Free Software Foundation; either version 2 of the License, or (at your
00008  * option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, write to the Free Software Foundation, Inc.,
00017  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  *
00019  * Linking this file statically or dynamically with other modules is making
00020  * a combined work based on this file.  Thus, the terms and conditions of
00021  * the GNU General Public License cover the whole combination.
00022  *
00023  * In addition, as a special exception, the copyright holders of this file
00024  * give you permission to combine this file with free software programs or
00025  * libraries that are released under the GNU LGPL and with code included in
00026  * the standard release of ns-2 under the Apache 2.0 license or under
00027  * otherwise-compatible licenses with advertising requirements (or modified
00028  * versions of such code, with unchanged license).  You may copy and
00029  * distribute such a system following the terms of the GNU GPL for this
00030  * file and the licenses of the other code concerned, provided that you
00031  * include the source code of that other code when and as the GNU GPL
00032  * requires distribution of source code.
00033  *
00034  * Note that people who make modified versions of this file are not
00035  * obligated to grant this special exception for their modified versions;
00036  * it is their choice whether to do so.  The GNU General Public License
00037  * gives permission to release a modified version without this exception;
00038  * this exception also makes it possible to release a modified version
00039  * which carries forward this exception.
00040  */
00041 
00042 #ifndef ns_tbf_h
00043 #define ns_tbf_h
00044 
00045 #include "connector.h"
00046 #include "timer-handler.h"
00047 
00048 class TBF;
00049 
00050 class TBF_Timer : public TimerHandler {
00051 public:
00052     TBF_Timer(TBF *t) : TimerHandler() { tbf_ = t;}
00053     
00054 protected:
00055     virtual void expire(Event *e);
00056     TBF *tbf_;
00057 };
00058 
00059 
00060 class TBF : public Connector {
00061 public:
00062     TBF();
00063     ~TBF();
00064     void timeout(int);
00065 protected:
00066     void recv(Packet *, Handler *);
00067     double getupdatedtokens();
00068     double tokens_; //acumulated tokens
00069     double rate_; //token bucket rate
00070     int bucket_; //bucket depth
00071     int qlen_;
00072     double lastupdatetime_;
00073     PacketQueue *q_;
00074     TBF_Timer tbf_timer_;
00075     int init_;
00076 };
00077 
00078 #endif

Generated on Tue Mar 6 16:47:51 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6