-
Notifications
You must be signed in to change notification settings - Fork 0
/
random_trafficgenerator.h
91 lines (69 loc) · 2.27 KB
/
random_trafficgenerator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* random_trafficgenerator.h
* PhoenixSim
*
* Created by Johnnie Chan on 7/8/11.
* Copyright 2011 Johnnie Chan. All rights reserved.
*
*/
#ifndef __RANDOM_TRAFFICGENERATOR_H__
#define __RANDOM_TRAFFICGENERATOR_H__
#include "systemc.h"
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/exponential_distribution.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/variate_generator.hpp>
#include "trafficgenerator.h"
#include "trafficgeneratorfactory.h"
#include "electronicmessage.h"
#include "address.h"
namespace PhoenixSim
{
class Random_TrafficGeneratorParameters: public TrafficGeneratorParameters
{
public:
Random_TrafficGeneratorParameters();
Address addressSpace;
Address nodeAddress;
sc_time interarrivalTime;
int messageSize;
int numOfMessages;
};
class Random_TrafficGenerator: public TrafficGenerator
{
public:
Random_TrafficGenerator();
~Random_TrafficGenerator();
void SetTrafficGeneratorParameters(TrafficGeneratorParameters *p_parameters);
virtual ElectronicMessage* CreateFirstMessage();
virtual ElectronicMessage* MessageReceived(ElectronicMessage* incomingMessage);
virtual ElectronicMessage* MessageCreated();
virtual sc_time WaitTime(ElectronicMessage* message);
Address addressSpace;
Address nodeAddress;
sc_time interarrivalTime;
int messageSize;
int numOfMessagesSent;
int totalNumOfMessagesToSend;
private:
boost::variate_generator<boost::mt19937&, boost::exponential_distribution<> >* rng_interarrivaltime;
boost::variate_generator<boost::mt19937&, boost::uniform_int<> >* rng_nodeDestination;
boost::variate_generator<boost::mt19937&, boost::uniform_int<> >* rng_concDestination;
static boost::mt19937 gen;
bool waitForPreviousMessage;
bool firstMessage;
Address RandomDestination();
ElectronicMessage *SendDataMessage();
};
// Register with TrafficGeneratorFactory
namespace
{
TrafficGenerator* CreateRandomTrafficGenerator()
{
return new Random_TrafficGenerator;
}
const std::string identifier_tg_random = "random";
const bool registered_tg_random = TrafficGeneratorFactory::Instance()->RegisterTrafficGenerator(CreateRandomTrafficGenerator, identifier_tg_random);
}
}
#endif // __RANDOM_TRAFFIC_GENERATOR_H_