* Tunnel:
- Adjust the random drop probability for the message size
This commit is contained in:
@ -35,7 +35,7 @@ public class InboundGatewayReceiver implements TunnelGateway.Receiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_context.tunnelDispatcher().shouldDropParticipatingMessage())
|
if (_context.tunnelDispatcher().shouldDropParticipatingMessage("IBGW", encrypted.length))
|
||||||
return -1;
|
return -1;
|
||||||
_config.incrementSentMessages();
|
_config.incrementSentMessages();
|
||||||
TunnelDataMessage msg = new TunnelDataMessage(_context);
|
TunnelDataMessage msg = new TunnelDataMessage(_context);
|
||||||
|
@ -43,7 +43,7 @@ public class OutboundTunnelEndpoint {
|
|||||||
+ (toTunnel != null ? toTunnel.getTunnelId() + "" : ""));
|
+ (toTunnel != null ? toTunnel.getTunnelId() + "" : ""));
|
||||||
// don't drop it if we are the target
|
// don't drop it if we are the target
|
||||||
if ((!_context.routerHash().equals(toRouter)) &&
|
if ((!_context.routerHash().equals(toRouter)) &&
|
||||||
_context.tunnelDispatcher().shouldDropParticipatingMessage())
|
_context.tunnelDispatcher().shouldDropParticipatingMessage("OBEP " + msg.getType(), msg.getMessageSize()))
|
||||||
return;
|
return;
|
||||||
_config.incrementSentMessages();
|
_config.incrementSentMessages();
|
||||||
_outDistributor.distribute(msg, toRouter, toTunnel);
|
_outDistributor.distribute(msg, toRouter, toTunnel);
|
||||||
|
@ -540,8 +540,17 @@ public class TunnelDispatcher implements Service {
|
|||||||
* This is similar to the code in ../RouterThrottleImpl.java
|
* This is similar to the code in ../RouterThrottleImpl.java
|
||||||
* We drop in proportion to how far over the limit we are.
|
* We drop in proportion to how far over the limit we are.
|
||||||
* Perhaps an exponential function would be better?
|
* Perhaps an exponential function would be better?
|
||||||
|
*
|
||||||
|
* The drop probability is adjusted for the size of the message.
|
||||||
|
* At this stage, participants and IBGWs see a standard 1024 byte message.
|
||||||
|
* OBEPs however may see a wide variety of sizes.
|
||||||
|
*
|
||||||
|
* @param type unused except for logging
|
||||||
|
* @param length the length of the message
|
||||||
*/
|
*/
|
||||||
public boolean shouldDropParticipatingMessage() {
|
public boolean shouldDropParticipatingMessage(String type, int length) {
|
||||||
|
if (length <= 0)
|
||||||
|
return false;
|
||||||
RateStat rs = _context.statManager().getRate("tunnel.participatingBandwidth");
|
RateStat rs = _context.statManager().getRate("tunnel.participatingBandwidth");
|
||||||
if (rs == null)
|
if (rs == null)
|
||||||
return false;
|
return false;
|
||||||
@ -574,13 +583,19 @@ public class TunnelDispatcher implements Service {
|
|||||||
float pctDrop = (used - maxBps) / used;
|
float pctDrop = (used - maxBps) / used;
|
||||||
if (pctDrop <= 0)
|
if (pctDrop <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
// drop in proportion to size w.r.t. a standard 1024-byte message
|
||||||
|
// this is a little expensive but we want to adjust the curve between 0 and 1
|
||||||
|
// Most messages are 1024, only at the OBEP do we see other sizes
|
||||||
|
if (length != 1024)
|
||||||
|
pctDrop = (float) Math.pow(pctDrop, 1024d / length);
|
||||||
float rand = _context.random().nextFloat();
|
float rand = _context.random().nextFloat();
|
||||||
boolean reject = rand <= pctDrop;
|
boolean reject = rand <= pctDrop;
|
||||||
if (reject) {
|
if (reject) {
|
||||||
if (_log.shouldLog(Log.WARN)) {
|
if (_log.shouldLog(Log.WARN)) {
|
||||||
int availBps = (int) (((maxKBps*1024)*share) - used);
|
int availBps = (int) (((maxKBps*1024)*share) - used);
|
||||||
_log.warn("Drop part. msg. avail/max/used " + availBps + "/" + (int) maxBps + "/"
|
_log.warn("Drop part. msg. avail/max/used " + availBps + "/" + (int) maxBps + "/"
|
||||||
+ used + " %Drop = " + pctDrop);
|
+ used + " %Drop = " + pctDrop
|
||||||
|
+ ' ' + type + ' ' + length);
|
||||||
}
|
}
|
||||||
_context.statManager().addRateData("tunnel.participatingMessageDropped", 1, 0);
|
_context.statManager().addRateData("tunnel.participatingMessageDropped", 1, 0);
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ public class TunnelParticipant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void send(HopConfig config, TunnelDataMessage msg, RouterInfo ri) {
|
private void send(HopConfig config, TunnelDataMessage msg, RouterInfo ri) {
|
||||||
if (_context.tunnelDispatcher().shouldDropParticipatingMessage())
|
if (_context.tunnelDispatcher().shouldDropParticipatingMessage("TDM", 1024))
|
||||||
return;
|
return;
|
||||||
_config.incrementSentMessages();
|
_config.incrementSentMessages();
|
||||||
long oldId = msg.getUniqueId();
|
long oldId = msg.getUniqueId();
|
||||||
|
Reference in New Issue
Block a user