-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathcongestion-controller-model.h
More file actions
212 lines (177 loc) · 10.5 KB
/
congestion-controller-model.h
File metadata and controls
212 lines (177 loc) · 10.5 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#ifndef CONGESTION_CONTROLLER_MODEL_H
#define CONGESTION_CONTROLLER_MODEL_H
/**
* congestion-controller-model.h -- Organizing state and behavior for congestion management
* this header file differs from congesiton-controller-core.h in that this one has c++ structures
* in so that c++ is used for network models that use it but not CODES core.
* Neil McGlohon
*
* Copyright (c) 2019 Rensselaer Polytechnic Institute
*/
#include <ross.h>
#include <codes/codes_mapping.h>
#include <codes/congestion-controller-core.h>
#include <map>
#include <set>
#include <vector>
#include <set>
#include <map>
#include <string.h>
#include <string>
using namespace std;
/* Port/VC Channel tree structure
* Used to efficiently determine how many packets are currently located on the router
* and to what terminals they originated from. Each node contains a map of terminal ID to
* the number of packets on said router, port, or vc.
* The root of this tree represents a 'router', the next level is ports, the last level is VCs
* This structure is designed to obey the child sum property. The values stored in a parent represents
* the sum of the values of its children
*/
typedef enum portchan_node_type {
ROOT = 0,
PORT = 1,
VC = 2
} portchan_node_type;
class Portchan_node {
private:
portchan_node_type type; //what level of the tree are we?
unsigned long long packet_count; //number of packets on this node and children
bool is_congested;
tw_stime next_possible_normal_time;
set<unsigned int> abated_terminals_this_node;
map<unsigned int, unsigned int> abated_terminal_child_counter; //maps terminal ID to number of children nodes that it is under abatement on
map<unsigned int, unsigned long long> term_count_map; //maps terminal ID to number of packets on this node and children
map<unsigned int, unsigned long long> app_count_map; //maps application ID to number of packets on this node and children
map<unsigned int, map<unsigned int, unsigned long long> > app_to_terminal_counter; //maps application ID to a map of terminals from said application and their packet counts on this node and children
vector<Portchan_node *> children; //pointers to children
public:
Portchan_node(portchan_node_type pnt, int router_radix, int vcs_per_port);
~Portchan_node();
unsigned long long get_packet_count();
unsigned long long get_packet_count_from_term(unsigned int term_id);
unsigned long long get_packet_count_from_app(unsigned int app_id);
unsigned long long get_packet_count_by_port(int port_no);
unsigned long long get_packet_count_by_port_from_term(int port_no, unsigned int term_id);
unsigned long long get_packet_count_by_port_from_app(int port_no, unsigned int app_id);
unsigned long long get_packet_count_by_port_vc(int port_no, int vc_no);
unsigned long long get_packet_count_by_port_vc_from_term(int port_no, int vc_no, unsigned int term_id);
unsigned long long get_packet_count_by_port_vc_from_app(int port_no, int vc_no, unsigned int app_id);
map<unsigned int, unsigned long long> get_term_count_map();
map<unsigned int, unsigned long long> get_app_count_map();
map<unsigned int, unsigned long long> get_term_count_map_by_port(int port_no);
map<unsigned int, unsigned long long> get_app_count_map_by_port(int port_no);
map<unsigned int, unsigned long long> get_term_count_map_by_port_vc(int port_no, int vc_no);
map<unsigned int, unsigned long long> get_app_count_map_by_port_vc(int port_no, int vc_no);
map<unsigned int, unsigned long long> get_term_count_map_from_app(int app_id);
map<unsigned int, unsigned long long> get_term_count_map_by_port_from_app(int port_no, int app_id);
map<unsigned int, unsigned long long> get_term_count_map_by_port_vc_from_app(int port_no, int vc_no, int app_id);
bool is_router_congested();
bool is_port_congested(int port_no);
bool is_port_vc_congested(int port_no, int vc_no);
void set_router_congestion_state(bool is_congested);
void set_port_congestion_state(int port_no, bool is_congested);
void set_port_vc_congested(int port_no, int vc_no, bool is_congested);
void set_next_possible_router_normal_time(tw_stime time);
void set_next_possible_port_normal_time(int port_no, tw_stime time);
void set_next_possible_vc_normal_time(int port_no, int vc_no, tw_stime time);
tw_stime get_next_possible_router_normal_time();
tw_stime get_next_possible_port_normal_time(int port_no);
tw_stime get_next_possible_vc_normal_time(int port_no, int vc_no);
void mark_abated_terminal(unsigned int term_id);
void mark_abated_terminal(int port_no, unsigned int term_id);
void mark_abated_terminal(int port_no, int vc_no, unsigned int term_id);
void mark_unabated_terminal(unsigned int term_id);
void mark_unabated_terminal(int port_no, unsigned int term_id);
void mark_unabated_terminal(int port_no, int vc_no, unsigned int term_id);
bool is_abated_terminal(unsigned int term_id);
set<unsigned int> get_abated_terminals();
set<unsigned int> get_abated_terminals(int port_no);
set<unsigned int> get_abated_terminals(int port_no, int vc_no);
void enqueue_packet(unsigned int packet_size, int port_no, int vc_no, unsigned int term_id, unsigned int app_id);
void dequeue_packet(unsigned int packet_size, int port_no, int vc_no, unsigned int term_id, unsigned int app_id);
};
typedef struct cc_param
{
int router_radix;
int router_vc_per_port;
int router_total_buffer_size;
double terminal_configured_bandwidth;
int chunk_size;
double single_vc_congestion_threshold; //unused currently
double single_port_congestion_threshold;
double single_router_congestion_threshold; //unused currently
double single_port_aggressor_usage_threshold; //percentage of current usage belonging to one app before its classified as an aggressor
double single_vc_decongestion_threshold; //unused currently
double single_port_decongestion_threshold;
double single_router_decongestion_threshold; //unused currently
double notification_latency;
double minimum_abatement_time;
} cc_param;
typedef struct rlc_state
{
cc_param *params;
tw_lp *lp;
int router_id;
int* router_vc_sizes_on_each_port;
double* router_bandwidths_on_each_port;
int* workloads_finished_flag_ptr;
set<int> output_ports;
Portchan_node *packet_counting_tree;
} rlc_state;
typedef struct tlc_state
{
cc_param *params;
tw_lp *lp;
int terminal_id;
int app_id; //needs to be multiple if multiple jobs per terminal can exist.
int abatement_signal_count; //if > 0, abate, if 0, normal
unsigned int window_epoch;
unsigned int ejected_packet_bytes; //in current window
double *ejected_rate_windows;
double cur_average_rate;
bool is_abatement_active;
int* workloads_finished_flag_ptr;
double current_injection_bandwidth_coef;
} tlc_state;
void save_tlc_state(tlc_state * into, tlc_state const * from);
void clean_tlc_state(tlc_state * into);
bool check_tlc_state(tlc_state * before, tlc_state * after);
void print_tlc_state(FILE * out, char const * prefix, tlc_state * state);
congestion_control_message* cc_msg_rc_storage_create();
void cc_msg_rc_storage_delete(void * ptr);
//event method links
void cc_router_local_congestion_event(rlc_state *s, tw_bf *bf, congestion_control_message *msg, tw_lp *lp);
void cc_router_local_congestion_event_rc(rlc_state *s, tw_bf *bf, congestion_control_message *msg, tw_lp *lp);
void cc_router_local_congestion_event_commit(rlc_state *s, tw_bf *bf, congestion_control_message *msg, tw_lp *lp);
void cc_terminal_local_congestion_event(tlc_state *s, tw_bf *bf, congestion_control_message *msg, tw_lp *lp);
void cc_terminal_local_congestion_event_rc(tlc_state *s, tw_bf *bf, congestion_control_message *msg, tw_lp *lp);
void cc_terminal_local_congestion_event_commit(tlc_state *s, tw_bf *bf, congestion_control_message *msg, tw_lp *lp);
// ------------ Local controllers -----------------------
void cc_router_local_controller_init(rlc_state *s, tw_lp *lp, int total_terminals, int router_id, int radix, int num_vcs_per_port, int *vc_sizes, double* bandwidths, int* workload_finished_flag_ptr);
void cc_router_local_controller_add_output_port(rlc_state *s, int port_no);
void cc_router_received_packet(rlc_state *s, tw_lp *lp, unsigned int packet_size, int port_no, int vc_no, int term_id, int app_id, congestion_control_message *rc_msg);
void cc_router_received_packet_rc(rlc_state *s, tw_lp *lp, unsigned int packet_size, int port_no, int vc_no, int term_id, int app_id, congestion_control_message *rc_msg);
void cc_router_forwarded_packet(rlc_state *s, tw_lp *lp, unsigned int packet_size, int port_no, int vc_no, int term_id, int app_id, congestion_control_message *rc_msg);
void cc_router_forwarded_packet_rc(rlc_state *s, tw_lp *lp, unsigned int packet_size, int port_no, int vc_no, int term_id, int app_id, congestion_control_message *rc_msg);
void cc_router_congestion_check(rlc_state *s, tw_lp *lp, int port_no, int vc_no, congestion_control_message *rc_msg);
void cc_router_congestion_check_rc(rlc_state *s, tw_lp *lp, int port_no, int vc_no, congestion_control_message *rc_msg);
void cc_router_local_controller_finalize(rlc_state *s);
void cc_terminal_local_controller_init(tlc_state *s, tw_lp *lp, int terminal_id, int* workload_finished_flag_ptr);
void cc_terminal_send_ack(tlc_state *s, tw_lpid original_terminal_lpgid);
void cc_terminal_send_ack_rc(tlc_state *s);
void cc_terminal_receive_ack(tlc_state *s);
void cc_terminal_receive_ack_rc(tlc_state *s);
void cc_terminal_start_abatement(tlc_state *s, congestion_control_message *msg);
void cc_terminal_start_abatement_rc(tlc_state *s, congestion_control_message *msg);
void cc_terminal_end_abatement(tlc_state *s, congestion_control_message *msg);
void cc_terminal_end_abatement_rc(tlc_state *s, congestion_control_message *msg);
void cc_terminal_receive_normal_signal(tlc_state *s, congestion_control_message *msg);
void cc_terminal_receive_normal_signal_rc(tlc_state *s, congestion_control_message *msg);
void cc_terminal_receive_abatement_signal(tlc_state *s, congestion_control_message *msg);
void cc_terminal_receive_abatement_signal_rc(tlc_state *s, congestion_control_message *msg);
void cc_terminal_process_bandwidth_check(tlc_state *s, congestion_control_message *msg);
void cc_terminal_process_bandwidth_check_rc(tlc_state *s, congestion_control_message *msg);
double cc_terminal_get_current_injection_bandwidth_coef(tlc_state *s);
bool cc_terminal_is_abatement_active(tlc_state *s);
/************* LP Definition **************************************/
#endif /* end of include guard */