Console: Handle zero SSU RTT on /peers (ticket #2443)

PeerState minor cleanups
This commit is contained in:
zzz
2019-02-26 17:38:34 +00:00
parent cf1c0cb3ed
commit c8b7e829db
4 changed files with 23 additions and 10 deletions

View File

@ -431,6 +431,7 @@ public class PeerHelper extends HelperBase {
long resentTotal = 0; long resentTotal = 0;
long dupRecvTotal = 0; long dupRecvTotal = 0;
int numPeers = 0; int numPeers = 0;
int numRTTPeers = 0;
StringBuilder buf = new StringBuilder(512); StringBuilder buf = new StringBuilder(512);
buf.append("<h3 id=\"udpcon\">").append(_t("UDP connections")).append(": ").append(peers.size()); buf.append("<h3 id=\"udpcon\">").append(_t("UDP connections")).append(": ").append(peers.size());
@ -593,7 +594,10 @@ public class PeerHelper extends HelperBase {
int rto = peer.getRTO(); int rto = peer.getRTO();
buf.append("<td class=\"cells\" align=\"right\">"); buf.append("<td class=\"cells\" align=\"right\">");
buf.append(DataHelper.formatDuration2(rtt)); if (rtt > 0)
buf.append(DataHelper.formatDuration2(rtt));
else
buf.append("n/a");
buf.append("</td>"); buf.append("</td>");
//buf.append("<td class=\"cells\" align=\"right\">"); //buf.append("<td class=\"cells\" align=\"right\">");
@ -651,7 +655,10 @@ public class PeerHelper extends HelperBase {
uptimeMsTotal += uptime; uptimeMsTotal += uptime;
cwinTotal += sendWindow; cwinTotal += sendWindow;
rttTotal += rtt; if (rtt > 0) {
rttTotal += rtt;
numRTTPeers++;
}
rtoTotal += rto; rtoTotal += rto;
sendTotal += sent; sendTotal += sent;
@ -679,7 +686,10 @@ public class PeerHelper extends HelperBase {
buf.append(cwinTotal/(numPeers*1024) + "K"); buf.append(cwinTotal/(numPeers*1024) + "K");
buf.append("</b></td><td>&nbsp;</td>\n" + buf.append("</b></td><td>&nbsp;</td>\n" +
"<td align=\"right\"><b>"); "<td align=\"right\"><b>");
buf.append(DataHelper.formatDuration2(rttTotal/numPeers)); if (numRTTPeers > 0)
buf.append(DataHelper.formatDuration2(rttTotal/numRTTPeers));
else
buf.append("n/a");
//buf.append("</b></td><td>&nbsp;</td><td align=\"center\"><b>"); //buf.append("</b></td><td>&nbsp;</td><td align=\"center\"><b>");
buf.append("</b></td><td align=\"right\"><b>"); buf.append("</b></td><td align=\"right\"><b>");
buf.append(DataHelper.formatDuration2(rtoTotal/numPeers)); buf.append(DataHelper.formatDuration2(rtoTotal/numPeers));

View File

@ -1,5 +1,11 @@
2019-02-26 zzz
* SSU:
- Fix scheduling of peer test at startup (ticket #2441)
- Fix RTT/RTO calculations (ticket #2443)
2019-02-25 zzz 2019-02-25 zzz
* NetDB: Fix dup publish of RI at startup * NetDB: Fix dup publish of RI at startup
* NTCP: Fix number of SendFinisher threads (ticket #2438)
2019-02-23 zzz 2019-02-23 zzz
* Console: Flip order of router logs * Console: Flip order of router logs

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 10; public final static long BUILD = 11;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "";

View File

@ -1237,14 +1237,11 @@ public class PeerState {
if (_rtt <= 0) { if (_rtt <= 0) {
// first measurement // first measurement
_rtt = (int) lifetime; _rtt = (int) lifetime;
_rttDeviation = (int)(lifetime / 2); _rttDeviation = _rtt / 2;
} else { } else {
// the rttDev calculation matches that recommended in RFC 2988 (beta = 1/4) // the rttDev calculation matches that recommended in RFC 2988 (beta = 1/4)
_rttDeviation = (int)( 0.75*_rttDeviation + 0.25*Math.abs(lifetime-_rtt) ); _rttDeviation = (int)((0.75 * _rttDeviation) + (0.25 * Math.abs(lifetime - _rtt)));
_rtt = (int)((_rtt * (1.0f - RTT_DAMPENING)) + (RTT_DAMPENING * lifetime));
float scale = RTT_DAMPENING;
_rtt = (int)(_rtt*(1.0f-scale) + (scale)*lifetime);
} }
// K = 4 // K = 4
_rto = Math.min(MAX_RTO, Math.max(minRTO(), _rtt + (_rttDeviation<<2))); _rto = Math.min(MAX_RTO, Math.max(minRTO(), _rtt + (_rttDeviation<<2)));