00001 00033 #ifndef PACKET_GENERATOR_H 00034 #define PACKET_GENERATOR_H 00035 00036 #include <itpp/protocol/packet.h> 00037 #include <itpp/base/random.h> 00038 00039 00040 namespace itpp { 00041 00045 class Packet_Generator { 00046 public: 00047 Packet_Generator(const int Packet_size = 150, const unsigned long int Max_packets = 0); 00048 virtual ~Packet_Generator(); 00049 Signal<Packet*> output; 00050 Slot<Packet_Generator, bool> start; 00051 void set_parameters(const int Packet_size, const unsigned long int Max_packets); 00052 int get_packet_size(); 00053 int get_max_packets(); 00054 protected: 00055 virtual Ttype delta_t() = 0; 00056 private: 00057 Slot<Packet_Generator, Packet*> next; 00058 void handle_next(Packet*); 00059 void handle_start(const bool run); 00060 bool keep_running; 00061 unsigned long int id; 00062 int packet_size; 00063 unsigned long int max_packets; 00064 }; 00065 00066 00070 class Poisson_Packet_Generator : public Packet_Generator { 00071 public: 00072 Poisson_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const unsigned long int Max_packets = 0); 00073 virtual ~Poisson_Packet_Generator(); 00074 void set_parameters(const double Avg_bit_rate, const int Packet_size, const unsigned long int Max_packets); 00075 double get_avg_bit_rate(); 00076 protected: 00077 virtual Ttype delta_t(); 00078 double avg_delta_t; 00079 double avg_bit_rate; 00080 Exponential_RNG ee; 00081 }; 00082 00083 00087 class Constant_Rate_Packet_Generator : public Poisson_Packet_Generator { 00088 public: 00089 Constant_Rate_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const unsigned long int Max_packets = 0); 00090 virtual ~Constant_Rate_Packet_Generator(); 00091 protected: 00092 virtual Ttype delta_t(); 00093 }; 00094 00098 class Burst_WWW_Packet_Generator : public Poisson_Packet_Generator { 00099 public: 00100 Burst_WWW_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const int Max_packets = 0); 00101 virtual ~Burst_WWW_Packet_Generator(); 00102 protected: 00103 virtual Ttype delta_t(); 00104 int N, Navg; 00105 double Ti, Tr; 00106 }; 00107 00108 00112 class Sink { 00113 public: 00114 Sink(const unsigned long int Max_packets = 1000); 00115 ~Sink(); 00116 // -- Slots -- // 00117 Slot<Sink, Packet*> packet_input; 00118 private: 00119 void handle_packet_input(Packet* packet); 00120 unsigned long int Ncp; 00121 unsigned long int Nbytes; 00122 unsigned long int max_packets; 00123 Ttype start_time; 00124 }; 00125 00126 } // namespace itpp 00127 00128 #endif // #ifndef PACKET_GENERATOR_H 00129
Generated on Wed Mar 21 12:21:48 2007 for IT++ by Doxygen 1.4.7