Revision 598b51d8 measures.c

View differences:

measures.c
19 19
static MonHandler rx_bytes_chunk_per_sec, tx_bytes_chunk_per_sec, rx_bytes_sig_per_sec, tx_bytes_sig_per_sec;
20 20
static MonHandler rx_chunks, tx_chunks;
21 21

  
22
/*
23
 * Initialize one measure
24
*/
22 25
void add_measure(MonHandler *mh, MeasurementId id, MeasurementCapabilities mc, MonParameterValue rate, const char *pubname, enum stat_types st[], int length, SocketId dst, MsgType mt)
23 26
{
24 27
	*mh = monCreateMeasure(id, mc);
......
27 30
	monActivateMeasure(*mh, dst, mt);
28 31
}
29 32

  
33
/*
34
 * Register duplicate arrival
35
*/
30 36
void reg_chunk_duplicate()
31 37
{
32 38
	if (!chunk_dup) {
......
36 42
	monNewSample(chunk_dup, 1);
37 43
}
38 44

  
45
/*
46
 * Register playout/loss of a chunk before playout
47
*/
39 48
void reg_chunk_playout(bool b)
40 49
{
41 50
	if (!chunk_playout && b) {	//don't count losses before the first arrived chunk
......
45 54
	monNewSample(chunk_playout, b);
46 55
}
47 56

  
57
/*
58
 * Register actual neghbourhood size
59
*/
48 60
void reg_neigh_size(int s)
49 61
{
50 62
	if (!neigh_size) {
......
54 66
	monNewSample(neigh_size, s);
55 67
}
56 68

  
69
/*
70
 * Initialize peer level measurements
71
*/
57 72
void init_measures()
58 73
{
59 74
	enum stat_types stavg[] = {AVG, WIN_AVG};
......
70 85
       add_measure(&tx_chunks, COUNTER, TXONLY | DATA | IN_BAND, 120, "TxChunks", stsum, sizeof(stsum)/sizeof(enum stat_types), NULL, MSG_TYPE_CHUNK);	//[chunks]
71 86
}
72 87

  
88
/*
89
 * Initialize p2p measurements towards a peer
90
*/
73 91
void add_measures(struct nodeID *id)
74 92
{
75 93
	// Add measures
......
108 126
	id->n_mhs = j;
109 127
}
110 128

  
129
/*
130
 * Delete p2p measurements towards a peer
131
*/
111 132
void delete_measures(struct nodeID *id)
112 133
{
113 134
	int j;
......
117 138
	}
118 139
}
119 140

  
141
/*
142
 * Helper to retrieve a measure
143
*/
120 144
double get_measure(struct nodeID *id, int j, enum stat_types st)
121 145
{
122 146
	return monRetrieveResult(id->mhs[j], st);
123 147
}
124 148

  
125
//in seconds
149
/*
150
 * RTT to a given peer in seconds
151
*/
126 152
double get_rtt(struct nodeID *id){
127 153
	return get_measure(id, 1, WIN_AVG);
128 154
}
129 155

  
156
/*
157
 * loss ratio from a given peer as 0..1
158
*/
130 159
double get_lossrate(struct nodeID *id){
131 160
	return get_measure(id, 2, WIN_AVG);
132 161
}

Also available in: Unified diff