Statistics
| Branch: | Revision:

napa-baselibs / monl / plugins / loss_measure.cpp @ d2cfc5c9

History | View | Annotate | Download (2.58 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_measure.h"
21
#include "napa_log.h"
22

    
23
LossMeasure::LossMeasure(class MeasurePlugin *m, MeasurementCapabilities mc, class MeasureDispatcher *md): MonMeasure(m,mc,md,10) {
24
        mSeqWin = NULL;
25
}
26

    
27
void LossMeasure::init() {
28
        mSeqWin = NULL;
29
}
30

    
31
void LossMeasure::stop() {
32
        r_tx_list[R_LOSS] = r_rx_list[R_LOSS] = NAN;
33
        mSeqWin = NULL;
34
}
35

    
36
result LossMeasure::RxPkt(result *r,ExecutionList *el) {
37
        if(isnan(r[R_SEQWIN]))
38
                return NAN;
39

    
40
//        if(mSeqWin == NULL) { dirty trick to test bug
41
                if(el->find(SEQWIN) == el->end()) {
42
                        error("MONL: LOSS missing dependency");
43
                        return NAN;
44
                }
45
                mSeqWin = (*el)[SEQWIN];
46
//        }
47

    
48
        if(r[R_SEQWIN] > mSeqWin->getParameter(P_SEQN_WIN_SIZE) && 
49
                r[R_SEQWIN] < mSeqWin->getParameter(P_SEQN_WIN_OVERFLOW_TH)) {
50
                r[R_LOSS] = 1;
51
        }
52
        else if (r[R_SEQWIN] == mSeqWin->getParameter(P_SEQN_WIN_SIZE))
53
                r[R_LOSS] = 0;
54
        char dbg[512];
55
        snprintf(dbg, sizeof(dbg), "Ts: %f Loss: %f", r[R_RECEIVE_TIME],  r[R_LOSS]);
56
        debugOutput(dbg);
57
        return every(r[R_LOSS]);
58
}
59

    
60
result LossMeasure::RxData(result *r,ExecutionList *el) {
61
        return RxPkt(r,el);
62
}
63
/*
64
//        if(delta_sn_win == 0)
65
//                dups++;
66
//        if(p_sn != largest_sn +1)
67
//                ooo++;
68

69
        
70
        } else {
71
                if(delta_sn_win >= param_values[LOSS_WIN_OVERFLOW_TH]) {
72
                        int late; late++;}
73
                else if(delta_sn_win > param_values[LOSS_WIN_SIZE]) {
74
                        r[LOSS_PKT] = 1;
75
                        sn_win[ind] = p_sn;
76
                } else if(delta_sn_win == param_values[LOSS_WIN_SIZE]) {
77
                        r[LOSS_PKT] = 0;
78
                        sn_win[ind] = p_sn;
79
                }
80
        }
81
}*/
82

    
83

    
84
LossMeasurePlugin::LossMeasurePlugin() {
85
        /* Initialise properties: MANDATORY! */
86
        name = "Loss";
87
        desc = "The loss probability between two peers";
88
        id = LOSS;
89
        /* end of mandatory properties */
90
        addDependency(SEQWIN);
91
}
92

    
93

    
94