Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
itpp
protocol
packet_generator.h
Go to the documentation of this file.
1
29
#ifndef PACKET_GENERATOR_H
30
#define PACKET_GENERATOR_H
31
32
#include <
itpp/base/random.h
>
33
34
#if (defined(_MSC_VER) && defined(ITPP_SHARED_LIB) && !(defined(itpp_EXPORTS) || defined(itpp_debug_EXPORTS)))
35
36
#ifndef ITPP_PROTOCOL_EXCLUDED
37
#define ITPP_PROTOCOL_EXCLUDED
38
#pragma message( "PROTOCOL definitions are not available for MSVC shared builds" )
39
#endif
40
41
#else
42
43
#include <
itpp/protocol/packet.h
>
44
45
namespace
itpp
46
{
47
49
50
54
class
Packet_Generator
55
{
56
public
:
58
Packet_Generator
(
const
int
Packet_size = 150,
const
unsigned
long
int
Max_packets = 0);
60
virtual
~Packet_Generator
();
62
Signal<Packet*>
output
;
64
Slot<Packet_Generator, bool>
start
;
66
void
set_parameters
(
const
int
Packet_size,
const
unsigned
long
int
Max_packets);
68
int
get_packet_size
();
70
int
get_max_packets
();
71
protected
:
73
virtual
Ttype
delta_t
() = 0;
74
private
:
75
Slot<Packet_Generator, Packet*>
next;
76
void
handle_next(
Packet
*);
77
void
handle_start(
const
bool
run);
78
bool
keep_running;
79
unsigned
long
int
id;
80
int
packet_size;
81
unsigned
long
int
max_packets;
82
};
83
84
88
class
Poisson_Packet_Generator
:
public
Packet_Generator
89
{
90
public
:
92
Poisson_Packet_Generator
(
const
double
Avg_bit_rate = 1.0,
const
int
Packet_size = 150,
const
unsigned
long
int
Max_packets = 0);
94
virtual
~Poisson_Packet_Generator
();
96
void
set_parameters
(
const
double
Avg_bit_rate,
const
int
Packet_size,
const
unsigned
long
int
Max_packets);
98
double
get_avg_bit_rate
();
99
protected
:
101
virtual
Ttype
delta_t
();
103
double
avg_delta_t
;
105
double
avg_bit_rate
;
107
Exponential_RNG
ee
;
108
};
109
110
114
class
Constant_Rate_Packet_Generator
:
public
Poisson_Packet_Generator
115
{
116
public
:
118
Constant_Rate_Packet_Generator
(
const
double
Avg_bit_rate = 1.0,
const
int
Packet_size = 150,
const
unsigned
long
int
Max_packets = 0);
120
virtual
~Constant_Rate_Packet_Generator
();
121
protected
:
123
virtual
Ttype
delta_t
();
124
};
125
129
class
Burst_WWW_Packet_Generator
:
public
Poisson_Packet_Generator
130
{
131
public
:
133
Burst_WWW_Packet_Generator
(
const
double
Avg_bit_rate = 1.0,
const
int
Packet_size = 150,
const
int
Max_packets = 0);
135
virtual
~Burst_WWW_Packet_Generator
();
136
protected
:
138
virtual
Ttype
delta_t
();
140
int
N
;
142
int
Navg
;
144
double
Ti
;
146
double
Tr
;
147
};
148
149
153
class
Sink
154
{
155
public
:
157
Sink
(
const
unsigned
long
int
Max_packets = 1000);
159
~Sink
();
160
// -- Slots -- //
162
Slot<Sink, Packet*>
packet_input
;
163
private
:
164
void
handle_packet_input(
Packet
* packet);
165
unsigned
long
int
Ncp;
166
unsigned
long
int
Nbytes;
167
unsigned
long
int
max_packets;
168
Ttype
start_time;
169
};
170
172
173
}
// namespace itpp
174
175
#endif
176
177
#endif // #ifndef PACKET_GENERATOR_H
178
Generated on Sat Jul 6 2013 10:54:24 for IT++ by
Doxygen
1.8.2