-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcongestion_control.h
91 lines (73 loc) · 2.28 KB
/
congestion_control.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
#ifndef _CCONTROL_H_
#define _CCONTROL_H_
#include "bitset.h"
#include "hercules.h"
#include <pthread.h>
#define RCTS_INTERVALS 4 // Must be even
// PCC state machine states
enum pcc_state {
pcc_uninitialized, pcc_startup, pcc_decision, pcc_adjust, pcc_terminated
};
struct rct {
u32 rate;
float utility;
};
// RCTs result
enum rcts_result {
increase, decrease, inconclusive
};
typedef u32 sequence_number;
struct ccontrol_state {
// Cons
u32 max_rate_limit; // Max sending rate that the CC algorithm should not exceed
u32 num_paths;
u32 total_num_paths;
_Atomic double pcc_mi_duration;
_Atomic double rtt; // Round-trip time in seconds
// Monitoring interval values
sequence_number mi_seq_start;
sequence_number mi_seq_end;
sequence_number excess_npkts;
sequence_number mi_seq_min;
sequence_number mi_seq_max;
sequence_number mi_seq_max_rcvd;
u32 num_nacks, num_nack_pkts;
struct bitset mi_nacked;
sequence_number last_seqnr;
u32 prev_rate;
u32 curr_rate;
float prev_utility;
float eps;
float sign;
int adjust_iter;
unsigned long mi_start;
unsigned long mi_end;
u32 mi_tx_npkts;
u32 mi_tx_npkts_monitored;
u32 total_tx_npkts;
u32 rate_before_rcts;
struct rct rcts[RCTS_INTERVALS];
int rcts_iter;
enum pcc_state state;
bool ignored_first_mi;
pthread_spinlock_t lock;
};
/*!
* @function init_ccontrol_state
* @abstract Initialize the congestion control state and return it.
* @param total_chunks the total number of chunks, needed for the rolling ACK accounting
* @result A ccontrol_state struct
*/
// Initialize congestion control state
struct ccontrol_state *
init_ccontrol_state(u32 max_rate_limit, u32 total_chunks, size_t num_paths, size_t max_paths, size_t total_num_paths);
void terminate_ccontrol(struct ccontrol_state *cc_state);
void continue_ccontrol(struct ccontrol_state *cc_state);
void ccontrol_update_rtt(struct ccontrol_state *cc_state, u64 rtt);
u32 ccontrol_can_send_npkts(struct ccontrol_state *cc_state, u64 now);
void kick_ccontrol(struct ccontrol_state *cc_state);
void destroy_ccontrol_state(struct ccontrol_state *cc_states, size_t num_paths);
void ccontrol_start_monitoring_interval(struct ccontrol_state *cc_state);
// Apply PCC control decision, return new rate
u32 pcc_control(struct ccontrol_state *cc_state, float throughput, float loss);
#endif