Statistics
| Branch: | Revision:

napa-baselibs / monl / plugins / loss_burst_measure.cpp @ 507372bb

History | View | Annotate | Download (1.9 KB)

1
/***************************************************************************
2
 *   Copyright (C) 2009 by Robert Birke
3
 *   robert.birke@polito.it
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2.1 of the License, or (at your option) any later version.
9

10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14

15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA 
18
 ***********************************************************************/
19

    
20
#include "loss_burst_measure.h"
21
#include "napa_log.h"
22

    
23
LossBurstMeasure::LossBurstMeasure(class MeasurePlugin *m, MeasurementCapabilities mc, class MeasureDispatcher *md): MonMeasure(m,mc,md) {
24
}
25

    
26
void LossBurstMeasure::init() {
27
        burst = 0;
28
}
29

    
30
void LossBurstMeasure::stop() {
31
        r_tx_list[R_LOSS_BURST] = r_rx_list[R_LOSS_BURST] = NAN;
32
}
33

    
34
result LossBurstMeasure::RxPkt(result *r,ExecutionList *el) {
35
        if(isnan(r[R_LOSS]))
36
                return NAN;
37

    
38
        if(r[R_LOSS] != 0)
39
                burst++;
40
        else {
41
                r[R_LOSS_BURST] = burst;
42
                burst = 0;
43
                char dbg[512];
44
                snprintf(dbg, sizeof(dbg), "Ts: %f Lb: %f", r[R_RECEIVE_TIME], r[R_LOSS_BURST]);
45
                debugOutput(dbg);
46
        }
47

    
48
        return r[R_LOSS_BURST];
49
}
50

    
51
result LossBurstMeasure::RxData(result *r,ExecutionList *el) {
52
        return RxPkt(r,el);
53
}
54

    
55
LossBurstMeasurePlugin::LossBurstMeasurePlugin() {
56
        /* Initialise properties: MANDATORY! */
57
        name = "Loss Burst";
58
        desc = "The loss burst length";
59
        id = LOSS_BURST;
60
        /* end of mandatory properties */
61
        addDependency(LOSS);
62
}
63

    
64

    
65