-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatasource.cpp
58 lines (48 loc) · 1.46 KB
/
datasource.cpp
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
/*
* DataSource
*/
#include "datasource.h"
using namespace std;
DataSource::DataSource(TrafficLogger *logger,
uint64_t flowsize,
simtime_picosec duration)
: EventSource("datasource"),
_flowsize(flowsize),
_duration(duration),
_start_time(0),
_deadline(0),
_packets_sent(0),
_highest_sent(0),
_last_acked(0),
_enable_deadline(false),
_flowgen(NULL),
_flow(logger)
{
// constructor
}
void
DataSource::setFlowGenerator(FlowGenerator *flowgen)
{
_flowgen = flowgen;
}
void
DataSource::setDeadline(simtime_picosec deadline)
{
_deadline = deadline;
}
void
DataSource::connect(simtime_picosec start_time,
route_t &route_fwd,
route_t &route_rev,
DataSink &sink)
{
_route_fwd = &route_fwd;
_route_rev = &route_rev;
_start_time = start_time;
_sink = &sink;
_flow.id = id; // identify the packet flow with the datasource that generated it
// Ming added _flowsize
cout << str() << " " << timeAsUs(_start_time) << " " << id << " " << _flowsize << " " << _node_id << " " << _sink->_node_id << endl;
_sink->connect(*this, *_route_rev);
EventList::Get().sourceIsPending(*this, _start_time);
}