IT++ Logo
packet_generator.h
Go to the documentation of this file.
00001 
00029 #ifndef PACKET_GENERATOR_H
00030 #define PACKET_GENERATOR_H
00031 
00032 #include <itpp/protocol/packet.h>
00033 #include <itpp/base/random.h>
00034 
00035 
00036 namespace itpp
00037 {
00038 
00040 
00041 
00045 class Packet_Generator
00046 {
00047 public:
00049   Packet_Generator(const int Packet_size = 150, const unsigned long int Max_packets = 0);
00051   virtual ~Packet_Generator();
00053   Signal<Packet*> output;
00055   Slot<Packet_Generator, bool> start;
00057   void set_parameters(const int Packet_size, const unsigned long int Max_packets);
00059   int get_packet_size();
00061   int get_max_packets();
00062 protected:
00064   virtual Ttype delta_t() = 0;
00065 private:
00066   Slot<Packet_Generator, Packet*> next;
00067   void handle_next(Packet*);
00068   void handle_start(const bool run);
00069   bool keep_running;
00070   unsigned long int id;
00071   int packet_size;
00072   unsigned long int max_packets;
00073 };
00074 
00075 
00079 class Poisson_Packet_Generator : public Packet_Generator
00080 {
00081 public:
00083   Poisson_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const unsigned long int Max_packets = 0);
00085   virtual ~Poisson_Packet_Generator();
00087   void set_parameters(const double Avg_bit_rate, const int Packet_size, const unsigned long int Max_packets);
00089   double get_avg_bit_rate();
00090 protected:
00092   virtual Ttype delta_t();
00094   double avg_delta_t;
00096   double avg_bit_rate;
00098   Exponential_RNG ee;
00099 };
00100 
00101 
00105 class Constant_Rate_Packet_Generator : public Poisson_Packet_Generator
00106 {
00107 public:
00109   Constant_Rate_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const unsigned long int Max_packets = 0);
00111   virtual ~Constant_Rate_Packet_Generator();
00112 protected:
00114   virtual Ttype delta_t();
00115 };
00116 
00120 class Burst_WWW_Packet_Generator : public Poisson_Packet_Generator
00121 {
00122 public:
00124   Burst_WWW_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const int Max_packets = 0);
00126   virtual ~Burst_WWW_Packet_Generator();
00127 protected:
00129   virtual Ttype delta_t();
00131   int N;
00133   int Navg;
00135   double Ti;
00137   double Tr;
00138 };
00139 
00140 
00144 class Sink
00145 {
00146 public:
00148   Sink(const unsigned long int Max_packets = 1000);
00150   ~Sink();
00151   // -- Slots -- //
00153   Slot<Sink, Packet*> packet_input;
00154 private:
00155   void handle_packet_input(Packet* packet);
00156   unsigned long int Ncp;
00157   unsigned long int Nbytes;
00158   unsigned long int max_packets;
00159   Ttype start_time;
00160 };
00161 
00163 
00164 } // namespace itpp
00165 
00166 #endif // #ifndef PACKET_GENERATOR_H
00167 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SourceForge Logo

Generated on Sat Jul 9 2011 15:21:32 for IT++ by Doxygen 1.7.4