IT++ Logo

packet_generator.h

Go to the documentation of this file.
00001 
00030 #ifndef PACKET_GENERATOR_H
00031 #define PACKET_GENERATOR_H
00032 
00033 #include <itpp/protocol/packet.h>
00034 #include <itpp/base/random.h>
00035 
00036 
00037 namespace itpp
00038 {
00039 
00041 
00042 
00046 class Packet_Generator
00047 {
00048 public:
00050   Packet_Generator(const int Packet_size = 150, const unsigned long int Max_packets = 0);
00052   virtual ~Packet_Generator();
00054   Signal<Packet*> output;
00056   Slot<Packet_Generator, bool> start;
00058   void set_parameters(const int Packet_size, const unsigned long int Max_packets);
00060   int get_packet_size();
00062   int get_max_packets();
00063 protected:
00065   virtual Ttype delta_t() = 0;
00066 private:
00067   Slot<Packet_Generator, Packet*> next;
00068   void handle_next(Packet*);
00069   void handle_start(const bool run);
00070   bool keep_running;
00071   unsigned long int id;
00072   int packet_size;
00073   unsigned long int max_packets;
00074 };
00075 
00076 
00080 class Poisson_Packet_Generator : public Packet_Generator
00081 {
00082 public:
00084   Poisson_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const unsigned long int Max_packets = 0);
00086   virtual ~Poisson_Packet_Generator();
00088   void set_parameters(const double Avg_bit_rate, const int Packet_size, const unsigned long int Max_packets);
00090   double get_avg_bit_rate();
00091 protected:
00093   virtual Ttype delta_t();
00095   double avg_delta_t;
00097   double avg_bit_rate;
00099   Exponential_RNG ee;
00100 };
00101 
00102 
00106 class Constant_Rate_Packet_Generator : public Poisson_Packet_Generator
00107 {
00108 public:
00110   Constant_Rate_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const unsigned long int Max_packets = 0);
00112   virtual ~Constant_Rate_Packet_Generator();
00113 protected:
00115   virtual Ttype delta_t();
00116 };
00117 
00121 class Burst_WWW_Packet_Generator : public Poisson_Packet_Generator
00122 {
00123 public:
00125   Burst_WWW_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const int Max_packets = 0);
00127   virtual ~Burst_WWW_Packet_Generator();
00128 protected:
00130   virtual Ttype delta_t();
00132   int N;
00134   int Navg;
00136   double Ti;
00138   double Tr;
00139 };
00140 
00141 
00145 class Sink
00146 {
00147 public:
00149   Sink(const unsigned long int Max_packets = 1000);
00151   ~Sink();
00152   // -- Slots -- //
00154   Slot<Sink, Packet*> packet_input;
00155 private:
00156   void handle_packet_input(Packet* packet);
00157   unsigned long int Ncp;
00158   unsigned long int Nbytes;
00159   unsigned long int max_packets;
00160   Ttype start_time;
00161 };
00162 
00164 
00165 } // namespace itpp
00166 
00167 #endif // #ifndef PACKET_GENERATOR_H
00168 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SourceForge Logo

Generated on Wed Mar 2 2011 22:05:08 for IT++ by Doxygen 1.7.3