Statistics
| Branch: | Revision:

streamers / measures.c @ 27dc8efa

History | View | Annotate | Download (6.96 KB)

1
#include <mon.h>
2
#include <ml.h>
3

    
4
#include "dbg.h"
5
#include <net_helper.h>
6

    
7
static char* channel = "OfferStreamer2";
8

    
9
typedef struct nodeID {
10
        socketID_handle addr;
11
        int connID;        // connection associated to this node, -1 if myself
12
        int refcnt;
13
        //a quick and dirty static vector for measures TODO: make it dinamic
14
        MonHandler mhs[20];
15
        int n_mhs;
16
} nodeID;
17

    
18
static MonHandler chunk_dup, chunk_playout, neigh_size;
19

    
20
void reg_chunk_duplicate()
21
{
22
        if (!chunk_dup) {
23
                enum stat_types st[] = {SUM};
24
                chunk_dup = monCreateMeasure(GENERIC, 0);
25
                monSetParameter (chunk_dup, P_PUBLISHING_RATE, 120);
26
                monPublishStatisticalType(chunk_dup, "ChunkDuplicates", channel, st , sizeof(st)/sizeof(enum stat_types), NULL);
27
                monActivateMeasure(chunk_dup, NULL, MSG_TYPE_ANY);
28
        }
29
        monNewSample(chunk_dup, 1);
30
}
31

    
32
void reg_chunk_playout(bool b)
33
{
34
        if (!chunk_playout) {
35
                enum stat_types st[] = {AVG, SUM};
36
                chunk_playout = monCreateMeasure(GENERIC, 0);
37
                monSetParameter (chunk_playout, P_PUBLISHING_RATE, 120);
38
                monPublishStatisticalType(chunk_playout, "ChunksPlayed", channel, st , sizeof(st)/sizeof(enum stat_types), NULL);
39
                monActivateMeasure(chunk_playout, NULL, MSG_TYPE_ANY);
40
        }
41
        monNewSample(chunk_playout, b);
42
}
43

    
44
void reg_neigh_size(int s)
45
{
46
        if (!neigh_size) {
47
                enum stat_types st[] = {LAST};
48
                neigh_size = monCreateMeasure(GENERIC, 0);
49
                monSetParameter (neigh_size, P_PUBLISHING_RATE, 120);
50
                monPublishStatisticalType(neigh_size, "NeighSize", channel, st , sizeof(st)/sizeof(enum stat_types), NULL);
51
                monActivateMeasure(neigh_size, NULL, MSG_TYPE_ANY);
52
        }
53
        monNewSample(neigh_size, s);
54
}
55

    
56
void add_measures(struct nodeID *id)
57
{
58
        // Add measures
59
        int j = 0;
60
        enum stat_types stavg[] = {AVG, WIN_AVG};
61
        enum stat_types stsum[] = {SUM};
62

    
63
        dprintf("adding measures to %s\n",node_addr(id));
64

    
65
        /* HopCount */
66
        id->mhs[j] = monCreateMeasure(HOPCOUNT, TXRXUNI | PACKET | IN_BAND);
67
        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 600);
68
        //Uncomment the following line to publish results
69
        monPublishStatisticalType(id->mhs[j], NULL, channel, stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
70
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
71
        j++;
72

    
73
        /* Round Trip Time */
74
        id->mhs[j] = monCreateMeasure(RTT, TXRXBI | PACKET | IN_BAND);
75
        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 60);
76
        //Uncomment the following line to publish results
77
        monPublishStatisticalType(id->mhs[j], "RoundTripDelay", channel, stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
78
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_SIGNALLING);
79
        j++;
80

    
81
        /* Loss */
82
        id->mhs[j] = monCreateMeasure(LOSS, TXRXUNI | PACKET | IN_BAND);
83
        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 60);
84
        //Uncomment the following line to publish results
85
        monPublishStatisticalType(id->mhs[j], NULL, channel, stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
86
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
87
        j++;
88

    
89
        // RX bytes
90
//        id->mhs[j] = monCreateMeasure(BYTE, RXONLY | PACKET | IN_BAND);
91
//        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 120);
92
        //Uncomment the following line to publish results
93
//        monPublishStatisticalType(id->mhs[j], "RxBytes", channel, stsum , sizeof(stsum)/sizeof(enum stat_types), NULL);
94
//        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_ANY);
95
//        j++;
96

    
97
        // TX bytes
98
//        id->mhs[j] = monCreateMeasure(BYTE, TXONLY | PACKET | IN_BAND);
99
//        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 120);
100
        //Uncomment the following line to publish results
101
//        monPublishStatisticalType(id->mhs[j], "TxBytes", channel, stsum , sizeof(stsum)/sizeof(enum stat_types), NULL);
102
//        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_ANY);
103
//        j++;
104

    
105
        // RX bytes
106
        id->mhs[j] = monCreateMeasure(BYTE, RXONLY | PACKET | IN_BAND);
107
        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 600);
108
        //Uncomment the following line to publish results
109
        monPublishStatisticalType(id->mhs[j], "RxBytesChunk", channel, stsum , sizeof(stsum)/sizeof(enum stat_types), NULL);
110
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
111
        j++;
112

    
113
        // TX bytes
114
        id->mhs[j] = monCreateMeasure(BYTE, TXONLY | PACKET | IN_BAND);
115
        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 600);
116
        //Uncomment the following line to publish results
117
        monPublishStatisticalType(id->mhs[j], "TxBytesChunk", channel, stsum , sizeof(stsum)/sizeof(enum stat_types), NULL);
118
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
119
        j++;
120

    
121
        id->mhs[j] = monCreateMeasure(BULK_TRANSFER, RXONLY | PACKET | TIMER_BASED);
122
        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 600);
123
        //Uncomment the following line to publish results
124
        monPublishStatisticalType(id->mhs[j], "RxChunkSec", channel, stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
125
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
126
        j++;
127

    
128
        id->mhs[j] = monCreateMeasure(BULK_TRANSFER, TXONLY | PACKET | TIMER_BASED);
129
        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 600);
130
        //Uncomment the following line to publish results
131
        monPublishStatisticalType(id->mhs[j], "TxChunkSec", channel, stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
132
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
133
        j++;
134

    
135
        id->mhs[j] = monCreateMeasure(BULK_TRANSFER, RXONLY | PACKET | TIMER_BASED);
136
        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 600);
137
        //Uncomment the following line to publish results
138
        monPublishStatisticalType(id->mhs[j], "RxSigSec", channel, stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
139
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_SIGNALLING);
140
        j++;
141

    
142
        id->mhs[j] = monCreateMeasure(BULK_TRANSFER, TXONLY | PACKET | TIMER_BASED);
143
        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 600);
144
        //Uncomment the following line to publish results
145
        monPublishStatisticalType(id->mhs[j], "TxSigSec", channel, stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
146
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_SIGNALLING);
147
        j++;
148

    
149
        id->mhs[j] = monCreateMeasure(COUNTER, RXONLY | DATA);
150
        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 600);
151
        //Uncomment the following line to publish results
152
        monPublishStatisticalType(id->mhs[j], "RxChunks", channel, stsum , sizeof(stsum)/sizeof(enum stat_types), NULL);
153
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
154
        j++;
155

    
156
        id->mhs[j] = monCreateMeasure(COUNTER, TXONLY | DATA);
157
        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 600);
158
        //Uncomment the following line to publish results
159
        monPublishStatisticalType(id->mhs[j], "TxChunks", channel, stsum , sizeof(stsum)/sizeof(enum stat_types), NULL);
160
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
161
        j++;
162

    
163
        // for static must not be more then 10 or whatever size is in net_helper-ml.c
164
        id->n_mhs = j;
165
}
166

    
167
void delete_measures(struct nodeID *id)
168
{
169
        int j;
170
        dprintf("deleting measures from %s\n",node_addr(id));
171
        for(j = 0; j < id->n_mhs; j++) {
172
                monDestroyMeasure(id->mhs[j]);
173
        }
174
}
175

    
176
double get_measure(struct nodeID *id, int j, enum stat_types st)
177
{
178
        return monRetrieveResult(id->mhs[j], st);
179
}
180

    
181
//in seconds
182
double get_rtt(struct nodeID *id){
183
        return get_measure(id, 1, WIN_AVG);
184
}
185

    
186
double get_lossrate(struct nodeID *id){
187
        return get_measure(id, 2, WIN_AVG);
188
}