napabaselibs / monl / plugins / loss_measure.cpp @ 507372bb
History  View  Annotate  Download (2.57 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 021101301 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) { 
24 
mSeqWin = NULL;

25 
tx_every = 10;

26 
} 
27  
28 
void LossMeasure::init() {

29 
mSeqWin = NULL;

30 
} 
31  
32 
void LossMeasure::stop() {

33 
r_tx_list[R_LOSS] = r_rx_list[R_LOSS] = NAN; 
34 
mSeqWin = NULL;

35 
} 
36  
37 
result LossMeasure::RxPkt(result *r,ExecutionList *el) { 
38 
if(isnan(r[R_SEQWIN]))

39 
return NAN;

40  
41 
if(mSeqWin == NULL) { 
42 
if(el>find(SEQWIN) == el>end()) {

43 
error("MONL: LOSS missing dependency");

44 
return NAN;

45 
} 
46 
mSeqWin = (*el)[SEQWIN]; 
47 
} 
48  
49 
if(r[R_SEQWIN] > mSeqWin>getParameter(P_SEQN_WIN_SIZE) &&

50 
r[R_SEQWIN] < mSeqWin>getParameter(P_SEQN_WIN_OVERFLOW_TH)) { 
51 
r[R_LOSS] = 1;

52 
} 
53 
else if (r[R_SEQWIN] == mSeqWin>getParameter(P_SEQN_WIN_SIZE)) 
54 
r[R_LOSS] = 0;

55 
char dbg[512]; 
56 
snprintf(dbg, sizeof(dbg), "Ts: %f Loss: %f", r[R_RECEIVE_TIME], r[R_LOSS]); 
57 
debugOutput(dbg); 
58 
return every(r[R_LOSS]);

59 
} 
60  
61 
result LossMeasure::RxData(result *r,ExecutionList *el) { 
62 
return RxPkt(r,el);

63 
} 
64 
/*

65 
// if(delta_sn_win == 0)

66 
// dups++;

67 
// if(p_sn != largest_sn +1)

68 
// ooo++;

69 

70 

71 
} else {

72 
if(delta_sn_win >= param_values[LOSS_WIN_OVERFLOW_TH]) {

73 
int late; late++;}

74 
else if(delta_sn_win > param_values[LOSS_WIN_SIZE]) {

75 
r[LOSS_PKT] = 1;

76 
sn_win[ind] = p_sn;

77 
} else if(delta_sn_win == param_values[LOSS_WIN_SIZE]) {

78 
r[LOSS_PKT] = 0;

79 
sn_win[ind] = p_sn;

80 
}

81 
}

82 
}*/

83  
84  
85 
LossMeasurePlugin::LossMeasurePlugin() { 
86 
/* Initialise properties: MANDATORY! */

87 
name = "Loss";

88 
desc = "The loss probability between two peers";

89 
id = LOSS; 
90 
/* end of mandatory properties */

91 
addDependency(SEQWIN); 
92 
} 
93  
94  
95 