Statistics
| Branch: | Revision:

streamers / measures.c @ 7405358f

History | View | Annotate | Download (2.75 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], NULL, st , sizeof(st)/sizeof(enum stat_types), NULL);
29
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
30
        j++;
31
        // TX bytes
32
        id->mhs[j] = monCreateMeasure(BYTE, TXONLY | PACKET | IN_BAND);
33
//        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
34
        //Uncomment the following line to publish results
35
        monPublishStatisticalType(id->mhs[j], NULL, st , sizeof(st)/sizeof(enum stat_types), NULL);
36
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
37
        j++;
38
        /* HopCount */
39
        id->mhs[j] = monCreateMeasure(HOPCOUNT, TXRXUNI | PACKET | IN_BAND);
40
//        monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
41
        //Uncomment the following line to publish results
42
        monPublishStatisticalType(id->mhs[j], NULL, st , sizeof(st)/sizeof(enum stat_types), NULL);
43
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
44
        j++;
45
        /* Round Trip Time */
46
        id->mhs[j] = monCreateMeasure(RTT, TXRXBI | PACKET | IN_BAND);
47
        //monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
48
        //Uncomment the following line to publish results
49
        monPublishStatisticalType(id->mhs[j], NULL, st , sizeof(st)/sizeof(enum stat_types), NULL);
50
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_ANY);
51
        j++;
52
        /* Loss */
53
        id->mhs[j] = monCreateMeasure(LOSS, TXRXUNI | PACKET | IN_BAND);
54
        //monSetParameter (id->mhs[j], P_PUBLISHING_RATE, 100);
55
        //monSetParameter (id->mhs[j], P_WINDOW_SIZE, 100);
56
        //Uncomment the following line to publish results
57
        monPublishStatisticalType(id->mhs[j], NULL, st , sizeof(st)/sizeof(enum stat_types), NULL);
58
        monActivateMeasure(id->mhs[j], id->addr, MSG_TYPE_CHUNK);
59
        j++;
60
        // for static must not be more then 10 or whatever size is in net_helper-ml.c
61
        id->n_mhs = j;
62
}
63

    
64
void delete_measures(struct nodeID *id)
65
{
66
        int j;
67
        dprintf("deleting measures from %s\n",node_addr(id));
68
        for(j = 0; j < id->n_mhs; j++) {
69
                monDestroyMeasure(id->mhs[j]);
70
        }
71
}
72

    
73
double get_measure(struct nodeID *id, int j, enum stat_types st)
74
{
75
        return monRetrieveResult(id->mhs[j], st);
76
}
77

    
78
//in seconds
79
double get_rtt(struct nodeID *id){
80
        return get_measure(id, 3, WIN_AVG);
81
}
82

    
83
double get_lossrate(struct nodeID *id){
84
        return get_measure(id, 4, WIN_AVG);
85
}