Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

trafgen.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  * License is granted to copy, to use, and to make and to use derivative
00006  * works for research and evaluation purposes, provided that Xerox is
00007  * acknowledged in all documentation pertaining to any such copy or derivative
00008  * work. Xerox grants no other licenses expressed or implied. The Xerox trade
00009  * name should not be used in any advertising without its written permission.
00010  *  
00011  * XEROX CORPORATION MAKES NO REPRESENTATIONS CONCERNING EITHER THE
00012  * MERCHANTABILITY OF THIS SOFTWARE OR THE SUITABILITY OF THIS SOFTWARE
00013  * FOR ANY PARTICULAR PURPOSE.  The software is provided "as is" without
00014  * express or implied warranty of any kind.
00015  *
00016  * These notices must be retained in any copies of any part of this software.
00017  *
00018  * Changes by the Daedalus group, http://daedalus.cs.berkeley.edu
00019  *      Add Application interface
00020  *
00021  * @(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/tools/trafgen.h,v 1.6 1998/06/27 01:03:28 gnguyen Exp $ (Xerox)
00022  */
00023 
00024 #ifndef ns_trafgen_h
00025 #define ns_trafgen_h
00026 
00027 #include "app.h"
00028 #include "timer-handler.h"
00029 
00030 class TrafficGenerator;
00031 
00032 class TrafficTimer : public TimerHandler {
00033 public:
00034         TrafficTimer(TrafficGenerator* tg) : tgen_(tg) {}
00035 protected:
00036         void expire(Event*);
00037         TrafficGenerator* tgen_;
00038 };
00039 
00040 
00041 /* abstract class for traffic generation modules.  derived classes
00042  * must define  the next_interval() function.  the traffic generation 
00043  * module schedules an event for a UDP_Agent when it is time to 
00044  * generate a new packet.  it passes the packet size with the event 
00045  * (to accommodate traffic generation modules that may not use fixed 
00046  * size packets).
00047  */
00048 
00049 /* abstract class for traffic generation modules.  derived classes
00050  * must define the next_interva() function that is invoked by
00051  * UDP_Agent.  This function returns the time to the next packet
00052  * is generated and sets the size of the packet (which is passed
00053  * by reference).  The init() method is called from the start()
00054  * method of the UDP_Agent.  It can do any one-time initialization
00055  * needed by the traffic generation process.
00056  */
00057 
00058 class TrafficGenerator : public Application {
00059 public:
00060         TrafficGenerator();
00061         virtual double next_interval(int &) = 0;
00062         virtual void init() {}
00063         virtual double interval() { return 0; }
00064         virtual int on() { return 0; }
00065         virtual void timeout();
00066 
00067         virtual void recv() {}
00068         virtual void resume() {}
00069 
00070 protected:
00071         virtual void start();
00072         virtual void stop();
00073 
00074         double nextPkttime_;
00075         int size_;
00076         int running_;
00077         TrafficTimer timer_;
00078 };
00079 
00080 #endif

Generated on Tue Apr 20 12:14:37 2004 for NS2.26SourcesOriginal by doxygen 1.3.3