Statistics
| Branch: | Revision:

streamers / measures.c @ 94f320bc

History | View | Annotate | Download (3.61 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[10];
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 st[] = {AVG};
22

    
23
        dprintf("adding measures to %s\n",node_addr(id));
24
        // RX bytes
25
        //id->mhs[j] = monCreateMeasure(BYTE, RXONLY | PACKET | IN_BAND);
26
//        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
27
        //Uncomment the following line to publish results
28
        //monPublishStatisticalType(id->mhs[j], "RxBytesChunk", "OfferStreamer", st , sizeof(st)/sizeof(enum stat_types), NULL);
29
        //monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
30
        //j++;
31

    
32
        // TX bytes
33
        //id->mhs[j] = monCreateMeasure(BYTE, TXONLY | PACKET | IN_BAND);
34
//        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
35
        //Uncomment the following line to publish results
36
        //monPublishStatisticalType(id->mhs[j], "TxBytesChunk", "OfferStreamer", st , sizeof(st)/sizeof(enum stat_types), NULL);
37
        //monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
38
        //j++;
39

    
40
        /* HopCount */
41
        id->mhs[j] = monCreateMeasure(HOPCOUNT, TXRXUNI | PACKET | IN_BAND);
42
//        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
43
        //Uncomment the following line to publish results
44
        monPublishStatisticalType(id->mhs[j], NULL, "OfferStreamer", st , sizeof(st)/sizeof(enum stat_types), NULL);
45
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
46
        j++;
47

    
48
        /* Round Trip Time */
49
        id->mhs[j] = monCreateMeasure(RTT, TXRXBI | PACKET | IN_BAND);
50
        //monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
51
        //Uncomment the following line to publish results
52
        monPublishStatisticalType(id->mhs[j], "RoundTripDelay", "OfferStreamer", st , sizeof(st)/sizeof(enum stat_types), NULL);
53
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
54
        j++;
55

    
56
        /* Loss */
57
        id->mhs[j] = monCreateMeasure(LOSS, TXRXUNI | PACKET | IN_BAND);
58
        //monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
59
        //monSetParameter (id->mhs[j], P_WINDOW_SIZE, 100);
60
        //Uncomment the following line to publish results
61
        monPublishStatisticalType(id->mhs[j], NULL, "OfferStreamer", st , sizeof(st)/sizeof(enum stat_types), NULL);
62
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
63
        j++;
64

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

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

    
81
        // for static must not be more then 10 or whatever size is in net_helper-ml.c
82
        id->n_mhs = j;
83
}
84

    
85
void delete_measures(struct nodeID *id)
86
{
87
        int j;
88
        dprintf("deleting measures from %s\n",node_addr(id));
89
        for(j = 0; j < id->n_mhs; j++) {
90
                monDestroyMeasure(id->mhs[j]);
91
        }
92
}
93

    
94
double get_measure(struct nodeID *id, int j, enum stat_types st)
95
{
96
        return monRetrieveResult(id->mhs[j], st);
97
}
98

    
99
//in seconds
100
double get_rtt(struct nodeID *id){
101
        return get_measure(id, 1, WIN_AVG);
102
}
103

    
104
double get_lossrate(struct nodeID *id){
105
        return get_measure(id, 2, WIN_AVG);
106
}