Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
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/protocol/packet.h
>
33
#include <
itpp/base/random.h
>
34
35
36
namespace
itpp
37
{
38
40
41
45
class
Packet_Generator
46
{
47
public
:
49
Packet_Generator
(
const
int
Packet_size = 150,
const
unsigned
long
int
Max_packets = 0);
51
virtual
~Packet_Generator
();
53
Signal<Packet*>
output
;
55
Slot<Packet_Generator, bool>
start
;
57
void
set_parameters
(
const
int
Packet_size,
const
unsigned
long
int
Max_packets);
59
int
get_packet_size
();
61
int
get_max_packets
();
62
protected
:
64
virtual
Ttype
delta_t
() = 0;
65
private
:
66
Slot<Packet_Generator, Packet*>
next;
67
void
handle_next(
Packet
*);
68
void
handle_start(
const
bool
run);
69
bool
keep_running;
70
unsigned
long
int
id;
71
int
packet_size;
72
unsigned
long
int
max_packets;
73
};
74
75
79
class
Poisson_Packet_Generator
:
public
Packet_Generator
80
{
81
public
:
83
Poisson_Packet_Generator
(
const
double
Avg_bit_rate = 1.0,
const
int
Packet_size = 150,
const
unsigned
long
int
Max_packets = 0);
85
virtual
~Poisson_Packet_Generator
();
87
void
set_parameters
(
const
double
Avg_bit_rate,
const
int
Packet_size,
const
unsigned
long
int
Max_packets);
89
double
get_avg_bit_rate
();
90
protected
:
92
virtual
Ttype
delta_t
();
94
double
avg_delta_t
;
96
double
avg_bit_rate
;
98
Exponential_RNG
ee
;
99
};
100
101
105
class
Constant_Rate_Packet_Generator
:
public
Poisson_Packet_Generator
106
{
107
public
:
109
Constant_Rate_Packet_Generator
(
const
double
Avg_bit_rate = 1.0,
const
int
Packet_size = 150,
const
unsigned
long
int
Max_packets = 0);
111
virtual
~Constant_Rate_Packet_Generator
();
112
protected
:
114
virtual
Ttype
delta_t
();
115
};
116
120
class
Burst_WWW_Packet_Generator
:
public
Poisson_Packet_Generator
121
{
122
public
:
124
Burst_WWW_Packet_Generator
(
const
double
Avg_bit_rate = 1.0,
const
int
Packet_size = 150,
const
int
Max_packets = 0);
126
virtual
~Burst_WWW_Packet_Generator
();
127
protected
:
129
virtual
Ttype
delta_t
();
131
int
N
;
133
int
Navg
;
135
double
Ti
;
137
double
Tr
;
138
};
139
140
144
class
Sink
145
{
146
public
:
148
Sink
(
const
unsigned
long
int
Max_packets = 1000);
150
~Sink
();
151
// -- Slots -- //
153
Slot<Sink, Packet*>
packet_input
;
154
private
:
155
void
handle_packet_input(
Packet
* packet);
156
unsigned
long
int
Ncp;
157
unsigned
long
int
Nbytes;
158
unsigned
long
int
max_packets;
159
Ttype
start_time;
160
};
161
163
164
}
// namespace itpp
165
166
#endif // #ifndef PACKET_GENERATOR_H
167
Generated on Fri Mar 21 2014 17:14:13 for IT++ by
Doxygen
1.8.1.2