I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 5f12688a authored by zzz's avatar zzz
Browse files

* Console: Add a tunnel share ratio estimate

parent f8d9af87
No related branches found
No related tags found
No related merge requests found
...@@ -378,6 +378,12 @@ public class SummaryBarRenderer { ...@@ -378,6 +378,12 @@ public class SummaryBarRenderer {
.append(_("Participating")) .append(_("Participating"))
.append(":</b></td><td align=\"right\">") .append(":</b></td><td align=\"right\">")
.append(_helper.getParticipatingTunnels()) .append(_helper.getParticipatingTunnels())
.append("</td></tr>\n" +
"<tr><td align=\"left\"><b>")
.append(_("Share ratio"))
.append(":</b></td><td align=\"right\">")
.append(_helper.getShareRatio())
.append("</td></tr>\n" + .append("</td></tr>\n" +
"</table><hr><h3><a href=\"/jobs.jsp\" target=\"_top\" title=\"") "</table><hr><h3><a href=\"/jobs.jsp\" target=\"_top\" title=\"")
......
...@@ -499,6 +499,15 @@ public class SummaryHelper extends HelperBase { ...@@ -499,6 +499,15 @@ public class SummaryHelper extends HelperBase {
return _context.tunnelManager().getParticipatingCount(); return _context.tunnelManager().getParticipatingCount();
} }
/** @since 0.7.10 */
public String getShareRatio() {
if (_context == null)
return "0";
double sr = _context.tunnelManager().getShareRatio();
DecimalFormat fmt = new DecimalFormat("##0.00");
return fmt.format(sr);
}
/** /**
* How lagged our job queue is over the last minute (pretty printed with * How lagged our job queue is over the last minute (pretty printed with
* the units attached) * the units attached)
......
...@@ -92,7 +92,12 @@ shared bandwidth, and amount of locally-generated traffic. ...@@ -92,7 +92,12 @@ shared bandwidth, and amount of locally-generated traffic.
The recommended method for limiting participating tunnels is The recommended method for limiting participating tunnels is
to change your share percentage on the <a href="config.jsp#help">configuration page</a>. to change your share percentage on the <a href="config.jsp#help">configuration page</a>.
You may also limit the total number by setting <tt>router.maxParticipatingTunnels=nnn</tt> on You may also limit the total number by setting <tt>router.maxParticipatingTunnels=nnn</tt> on
the <a href="configadvanced.jsp">advanced configuration page</a>. <a href="configstats.jsp#tunnel.participatingTunnels">[Enable graphing]</a>.</ul> the <a href="configadvanced.jsp">advanced configuration page</a>. <a href="configstats.jsp#tunnel.participatingTunnels">[Enable graphing]</a>.
<li class="tidylist"><b>Share ratio:</b>
The number of participating tunnels you route for others, divided by the total number of hops in
all your exploratory and client tunnels.
A number greater than 1.00 means you are contributing more tunnels to the network than you are using.
</ul>
<h3>Congestion</h3><div align="justify"> <h3>Congestion</h3><div align="justify">
Some basic indications of router overload:</div><ul> Some basic indications of router overload:</div><ul>
......
...@@ -35,6 +35,7 @@ class DummyTunnelManagerFacade implements TunnelManagerFacade { ...@@ -35,6 +35,7 @@ class DummyTunnelManagerFacade implements TunnelManagerFacade {
public int getFreeTunnelCount() { return 0; } public int getFreeTunnelCount() { return 0; }
public int getOutboundTunnelCount() { return 0; } public int getOutboundTunnelCount() { return 0; }
public int getInboundClientTunnelCount() { return 0; } public int getInboundClientTunnelCount() { return 0; }
public double getShareRatio() { return 0d; }
public int getOutboundClientTunnelCount() { return 0; } public int getOutboundClientTunnelCount() { return 0; }
public long getLastParticipatingExpiration() { return -1; } public long getLastParticipatingExpiration() { return -1; }
public void buildTunnels(Destination client, ClientTunnelSettings settings) {} public void buildTunnels(Destination client, ClientTunnelSettings settings) {}
......
...@@ -51,6 +51,7 @@ public interface TunnelManagerFacade extends Service { ...@@ -51,6 +51,7 @@ public interface TunnelManagerFacade extends Service {
public int getInboundClientTunnelCount(); public int getInboundClientTunnelCount();
/** how many outbound client tunnels do we have available? */ /** how many outbound client tunnels do we have available? */
public int getOutboundClientTunnelCount(); public int getOutboundClientTunnelCount();
public double getShareRatio();
/** When does the last tunnel we are participating in expire? */ /** When does the last tunnel we are participating in expire? */
public long getLastParticipatingExpiration(); public long getLastParticipatingExpiration();
......
...@@ -193,6 +193,29 @@ public class TunnelPoolManager implements TunnelManagerFacade { ...@@ -193,6 +193,29 @@ public class TunnelPoolManager implements TunnelManagerFacade {
public int getParticipatingCount() { return _context.tunnelDispatcher().getParticipatingCount(); } public int getParticipatingCount() { return _context.tunnelDispatcher().getParticipatingCount(); }
public long getLastParticipatingExpiration() { return _context.tunnelDispatcher().getLastParticipatingExpiration(); } public long getLastParticipatingExpiration() { return _context.tunnelDispatcher().getLastParticipatingExpiration(); }
/**
* @return (number of part. tunnels) / (estimated total number of hops in our expl.+client tunnels)
* 100 max.
* We just use length setting, not variance, for speed
* @since 0.7.10
*/
public double getShareRatio() {
int part = getParticipatingCount();
if (part <= 0)
return 0d;
List<TunnelPool> pools = new ArrayList();
listPools(pools);
int count = 0;
for (int i = 0; i < pools.size(); i++) {
TunnelPool pool = pools.get(i);
count += pool.size() * pool.getSettings().getLength();
}
if (count <= 0)
return 100d;
return Math.min(part / (double) count, 100d);
}
public boolean isValidTunnel(Hash client, TunnelInfo tunnel) { public boolean isValidTunnel(Hash client, TunnelInfo tunnel) {
if (tunnel.getExpiration() < _context.clock().now()) if (tunnel.getExpiration() < _context.clock().now())
return false; return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment