packet_generator.h
Go to the documentation of this file.
#ifndef PACKET_GENERATOR_H
#define PACKET_GENERATOR_H
#include <itpp/base/random.h>
#if (defined(_MSC_VER) && defined(ITPP_SHARED_LIB) && !(defined(itpp_EXPORTS) || defined(itpp_debug_EXPORTS)))
#ifndef ITPP_PROTOCOL_EXCLUDED
#define ITPP_PROTOCOL_EXCLUDED
#pragma message( "PROTOCOL definitions are not available for MSVC shared builds" )
#endif
#else
#include <itpp/protocol/packet.h>
namespace itpp
{
class Packet_Generator
{
public:
Packet_Generator(const int Packet_size = 150, const unsigned long int Max_packets = 0);
virtual ~Packet_Generator();
Signal<Packet*> output;
Slot<Packet_Generator, bool> start;
void set_parameters(const int Packet_size, const unsigned long int Max_packets);
int get_packet_size();
int get_max_packets();
protected:
virtual Ttype delta_t() = 0;
private:
Slot<Packet_Generator, Packet*> next;
void handle_next(Packet*);
void handle_start(const bool run);
bool keep_running;
unsigned long int id;
int packet_size;
unsigned long int max_packets;
};
class Poisson_Packet_Generator : public Packet_Generator
{
public:
Poisson_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const unsigned long int Max_packets = 0);
virtual ~Poisson_Packet_Generator();
void set_parameters(const double Avg_bit_rate, const int Packet_size, const unsigned long int Max_packets);
double get_avg_bit_rate();
protected:
virtual Ttype delta_t();
double avg_delta_t;
double avg_bit_rate;
Exponential_RNG ee;
};
class Constant_Rate_Packet_Generator : public Poisson_Packet_Generator
{
public:
Constant_Rate_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const unsigned long int Max_packets = 0);
virtual ~Constant_Rate_Packet_Generator();
protected:
virtual Ttype delta_t();
};
class Burst_WWW_Packet_Generator : public Poisson_Packet_Generator
{
public:
Burst_WWW_Packet_Generator(const double Avg_bit_rate = 1.0, const int Packet_size = 150, const int Max_packets = 0);
virtual ~Burst_WWW_Packet_Generator();
protected:
virtual Ttype delta_t();
int N;
int Navg;
double Ti;
double Tr;
};
class Sink
{
public:
Sink(const unsigned long int Max_packets = 1000);
~Sink();
// -- Slots -- //
Slot<Sink, Packet*> packet_input;
private:
void handle_packet_input(Packet* packet);
unsigned long int Ncp;
unsigned long int Nbytes;
unsigned long int max_packets;
Ttype start_time;
};
} // namespace itpp
#endif
#endif // #ifndef PACKET_GENERATOR_H
itpp::Poisson_Packet_Generator::Poisson_Packet_Generator
Poisson_Packet_Generator(const double Avg_bit_rate=1.0, const int Packet_size=150, const unsigned long int Max_packets=0)
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:86
itpp::Ttype
double Ttype
64-bit floating point time
Definition: events.h:54
itpp::Packet_Generator::start
Slot< Packet_Generator, bool > start
ADD DOCUMENTATION HERE.
Definition: packet_generator.h:64
itpp::Sink
Definition: packet_generator.h:153
itpp::Poisson_Packet_Generator::get_avg_bit_rate
double get_avg_bit_rate()
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:106
itpp::Poisson_Packet_Generator
Definition: packet_generator.h:88
itpp::Packet_Generator::get_packet_size
int get_packet_size()
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:54
itpp::Packet
Definition: packet.h:55
itpp::Poisson_Packet_Generator::~Poisson_Packet_Generator
virtual ~Poisson_Packet_Generator()
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:93
itpp::Constant_Rate_Packet_Generator::~Constant_Rate_Packet_Generator
virtual ~Constant_Rate_Packet_Generator()
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:122
itpp::Constant_Rate_Packet_Generator::Constant_Rate_Packet_Generator
Constant_Rate_Packet_Generator(const double Avg_bit_rate=1.0, const int Packet_size=150, const unsigned long int Max_packets=0)
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:120
itpp::Sink::Sink
Sink(const unsigned long int Max_packets=1000)
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:162
itpp::Packet_Generator::~Packet_Generator
virtual ~Packet_Generator()
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:44
itpp::Packet_Generator::get_max_packets
int get_max_packets()
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:59
itpp::Burst_WWW_Packet_Generator::Navg
int Navg
ADD DOCUMENTATION HERE.
Definition: packet_generator.h:142
itpp::Poisson_Packet_Generator::delta_t
virtual Ttype delta_t()
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:112
itpp::Sink::packet_input
Slot< Sink, Packet * > packet_input
ADD DOCUMENTATION HERE.
Definition: packet_generator.h:162
itpp::Poisson_Packet_Generator::avg_delta_t
double avg_delta_t
ADD DOCUMENTATION HERE.
Definition: packet_generator.h:103
itpp::Burst_WWW_Packet_Generator::Burst_WWW_Packet_Generator
Burst_WWW_Packet_Generator(const double Avg_bit_rate=1.0, const int Packet_size=150, const int Max_packets=0)
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:133
itpp::Burst_WWW_Packet_Generator::N
int N
ADD DOCUMENTATION HERE.
Definition: packet_generator.h:140
itpp::Packet_Generator::delta_t
virtual Ttype delta_t()=0
ADD DOCUMENTATION HERE.
itpp::Poisson_Packet_Generator::set_parameters
void set_parameters(const double Avg_bit_rate, const int Packet_size, const unsigned long int Max_packets)
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:95
itpp
itpp namespace
Definition: itmex.h:36
itpp::Sink::~Sink
~Sink()
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:172
itpp::Exponential_RNG
Exponential distribution.
Definition: random.h:405
itpp::Slot
Slot Class.
Definition: signals_slots.h:57
itpp::Signal
Signals and slots.
Definition: signals_slots.h:55
itpp::Burst_WWW_Packet_Generator::Ti
double Ti
ADD DOCUMENTATION HERE.
Definition: packet_generator.h:144
itpp::Burst_WWW_Packet_Generator::Tr
double Tr
ADD DOCUMENTATION HERE.
Definition: packet_generator.h:146
itpp::Packet_Generator
Definition: packet_generator.h:54
itpp::Poisson_Packet_Generator::ee
Exponential_RNG ee
ADD DOCUMENTATION HERE.
Definition: packet_generator.h:107
itpp::Burst_WWW_Packet_Generator::delta_t
virtual Ttype delta_t()
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:146
itpp::Packet_Generator::output
Signal< Packet * > output
ADD DOCUMENTATION HERE.
Definition: packet_generator.h:62
packet.h
Definition of a Packet class.
itpp::Burst_WWW_Packet_Generator
Definition: packet_generator.h:129
itpp::Constant_Rate_Packet_Generator::delta_t
virtual Ttype delta_t()
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:124
random.h
Definition of classes for random number generators.
itpp::Packet_Generator::set_parameters
void set_parameters(const int Packet_size, const unsigned long int Max_packets)
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:46
itpp::Constant_Rate_Packet_Generator
Definition: packet_generator.h:114
itpp::Burst_WWW_Packet_Generator::~Burst_WWW_Packet_Generator
virtual ~Burst_WWW_Packet_Generator()
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:141
itpp::Packet_Generator::Packet_Generator
Packet_Generator(const int Packet_size=150, const unsigned long int Max_packets=0)
ADD DOCUMENTATION HERE.
Definition: packet_generator.cpp:35
itpp::Poisson_Packet_Generator::avg_bit_rate
double avg_bit_rate
ADD DOCUMENTATION HERE.
Definition: packet_generator.h:105

Generated on Thu Aug 20 2015 21:02:51 for IT++ by Doxygen 1.8.9.1