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 00040 00041 00045 class Packet_Generator { 00046 public: 00048 Packet_Generator(const int Packet_size = 150, const unsigned long int Max_packets = 0); 00050 virtual ~Packet_Generator(); 00052 Signal<Packet*> output; 00054 Slot<Packet_Generator, bool> start; 00056 void set_parameters(const int Packet_size, const unsigned long int Max_packets); 00058 int get_packet_size(); 00060 int get_max_packets(); 00061 protected: 00063 virtual Ttype delta_t() = 0; 00064 private: 00065 Slot<Packet_Generator, Packet*> next; 00066 void handle_next(Packet*); 00067 void handle_start(const bool run); 00068 bool keep_running; 00069 unsigned long int id; 00070 int packet_size; 00071 unsigned long int max_packets; 00072 }; 00073 00074 00078 class Poisson_Packet_Generator : public Packet_Generator { 00079 public: 00081 Poisson_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const unsigned long int Max_packets = 0); 00083 virtual ~Poisson_Packet_Generator(); 00085 void set_parameters(const double Avg_bit_rate, const int Packet_size, const unsigned long int Max_packets); 00087 double get_avg_bit_rate(); 00088 protected: 00090 virtual Ttype delta_t(); 00092 double avg_delta_t; 00094 double avg_bit_rate; 00096 Exponential_RNG ee; 00097 }; 00098 00099 00103 class Constant_Rate_Packet_Generator : public Poisson_Packet_Generator { 00104 public: 00106 Constant_Rate_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const unsigned long int Max_packets = 0); 00108 virtual ~Constant_Rate_Packet_Generator(); 00109 protected: 00111 virtual Ttype delta_t(); 00112 }; 00113 00117 class Burst_WWW_Packet_Generator : public Poisson_Packet_Generator { 00118 public: 00120 Burst_WWW_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const int Max_packets = 0); 00122 virtual ~Burst_WWW_Packet_Generator(); 00123 protected: 00125 virtual Ttype delta_t(); 00127 int N; 00129 int Navg; 00131 double Ti; 00133 double Tr; 00134 }; 00135 00136 00140 class Sink { 00141 public: 00143 Sink(const unsigned long int Max_packets = 1000); 00145 ~Sink(); 00146 // -- Slots -- // 00148 Slot<Sink, Packet*> packet_input; 00149 private: 00150 void handle_packet_input(Packet* packet); 00151 unsigned long int Ncp; 00152 unsigned long int Nbytes; 00153 unsigned long int max_packets; 00154 Ttype start_time; 00155 }; 00156 00158 00159 } // namespace itpp 00160 00161 #endif // #ifndef PACKET_GENERATOR_H 00162
Generated on Sun Sep 14 18:57:05 2008 for IT++ by Doxygen 1.5.6