Statistics
| Branch: | Revision:

streamers / measures.c @ 4fb864eb

History | View | Annotate | Download (5.22 KB)

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

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

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

    
16

    
17
void add_measures(struct nodeID *id)
18
{
19
        // Add measures
20
        int j = 0;
21
        enum stat_types stavg[] = {AVG, WIN_AVG};
22
        enum stat_types stsum[] = {SUM};
23

    
24
        dprintf("adding measures to %s\n",node_addr(id));
25

    
26
        /* HopCount */
27
        id->mhs[j] = monCreateMeasure(HOPCOUNT, TXRXUNI | PACKET | IN_BAND);
28
//        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
29
        //Uncomment the following line to publish results
30
        monPublishStatisticalType(id->mhs[j], NULL, "OfferStreamer", stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
31
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
32
        j++;
33

    
34
        /* Round Trip Time */
35
        id->mhs[j] = monCreateMeasure(RTT, TXRXBI | PACKET | IN_BAND);
36
        //monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
37
        //Uncomment the following line to publish results
38
        monPublishStatisticalType(id->mhs[j], "RoundTripDelay", "OfferStreamer", stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
39
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_SIGNALLING);
40
        j++;
41

    
42
        /* Loss */
43
        id->mhs[j] = monCreateMeasure(LOSS, TXRXUNI | PACKET | IN_BAND);
44
        //monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
45
        //monSetParameter (id->mhs[j], P_WINDOW_SIZE, 100);
46
        //Uncomment the following line to publish results
47
        monPublishStatisticalType(id->mhs[j], NULL, "OfferStreamer", stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
48
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
49
        j++;
50

    
51
        // RX bytes
52
//        id->mhs[j] = monCreateMeasure(BYTE, RXONLY | PACKET | IN_BAND);
53
//        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
54
        //Uncomment the following line to publish results
55
//        monPublishStatisticalType(id->mhs[j], "RxBytes", "OfferStreamer", stsum , sizeof(stsum)/sizeof(enum stat_types), NULL);
56
//        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_ANY);
57
//        j++;
58

    
59
        // TX bytes
60
//        id->mhs[j] = monCreateMeasure(BYTE, TXONLY | PACKET | IN_BAND);
61
//        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
62
        //Uncomment the following line to publish results
63
//        monPublishStatisticalType(id->mhs[j], "TxBytes", "OfferStreamer", stsum , sizeof(stsum)/sizeof(enum stat_types), NULL);
64
//        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_ANY);
65
//        j++;
66

    
67
        // RX bytes
68
        id->mhs[j] = monCreateMeasure(BYTE, RXONLY | PACKET | IN_BAND);
69
//        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
70
        //Uncomment the following line to publish results
71
        monPublishStatisticalType(id->mhs[j], "RxBytesChunk", "OfferStreamer", stsum , sizeof(stsum)/sizeof(enum stat_types), NULL);
72
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
73
        j++;
74

    
75
        // TX bytes
76
        id->mhs[j] = monCreateMeasure(BYTE, TXONLY | PACKET | IN_BAND);
77
//        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
78
        //Uncomment the following line to publish results
79
        monPublishStatisticalType(id->mhs[j], "TxBytesChunk", "OfferStreamer", stsum , sizeof(stsum)/sizeof(enum stat_types), NULL);
80
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
81
        j++;
82

    
83
        id->mhs[j] = monCreateMeasure(BULK_TRANSFER, RXONLY | PACKET | TIMER_BASED);
84
        //monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
85
        //Uncomment the following line to publish results
86
        monPublishStatisticalType(id->mhs[j], "RxBulkTransferChunk", "OfferStreamer", stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
87
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
88
        j++;
89

    
90
        id->mhs[j] = monCreateMeasure(BULK_TRANSFER, TXONLY | PACKET | TIMER_BASED);
91
        //monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
92
        //Uncomment the following line to publish results
93
        monPublishStatisticalType(id->mhs[j], "TxBulkTransferChunk", "OfferStreamer", stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
94
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
95
        j++;
96

    
97
        id->mhs[j] = monCreateMeasure(BULK_TRANSFER, RXONLY | PACKET | TIMER_BASED);
98
        //monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
99
        //Uncomment the following line to publish results
100
        monPublishStatisticalType(id->mhs[j], "RxBulkTransferSig", "OfferStreamer", stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
101
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_SIGNALLING);
102
        j++;
103

    
104
        id->mhs[j] = monCreateMeasure(BULK_TRANSFER, TXONLY | PACKET | TIMER_BASED);
105
        //monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
106
        //Uncomment the following line to publish results
107
        monPublishStatisticalType(id->mhs[j], "TxBulkTransferSig", "OfferStreamer", stavg , sizeof(stavg)/sizeof(enum stat_types), NULL);
108
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_SIGNALLING);
109
        j++;
110

    
111
        // for static must not be more then 10 or whatever size is in net_helper-ml.c
112
        id->n_mhs = j;
113
}
114

    
115
void delete_measures(struct nodeID *id)
116
{
117
        int j;
118
        dprintf("deleting measures from %s\n",node_addr(id));
119
        for(j = 0; j < id->n_mhs; j++) {
120
                monDestroyMeasure(id->mhs[j]);
121
        }
122
}
123

    
124
double get_measure(struct nodeID *id, int j, enum stat_types st)
125
{
126
        return monRetrieveResult(id->mhs[j], st);
127
}
128

    
129
//in seconds
130
double get_rtt(struct nodeID *id){
131
        return get_measure(id, 1, WIN_AVG);
132
}
133

    
134
double get_lossrate(struct nodeID *id){
135
        return get_measure(id, 2, WIN_AVG);
136
}