Changeset 787def6


Ignore:
Timestamp:
Aug 27, 2009 3:27:46 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
e0dd1f13
Parents:
1f5d7d7
Message:
  • Tunnel:
    • Adjust the random drop probability for the message size
Location:
router/java/src/net/i2p/router/tunnel
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/tunnel/InboundGatewayReceiver.java

    r1f5d7d7 r787def6  
    3636        }
    3737       
    38         if (_context.tunnelDispatcher().shouldDropParticipatingMessage())
     38        if (_context.tunnelDispatcher().shouldDropParticipatingMessage("IBGW", encrypted.length))
    3939            return -1;
    4040        _config.incrementSentMessages();
  • router/java/src/net/i2p/router/tunnel/OutboundTunnelEndpoint.java

    r1f5d7d7 r787def6  
    4444            // don't drop it if we are the target
    4545            if ((!_context.routerHash().equals(toRouter)) &&
    46                 _context.tunnelDispatcher().shouldDropParticipatingMessage())
     46                _context.tunnelDispatcher().shouldDropParticipatingMessage("OBEP " + msg.getType(), msg.getMessageSize()))
    4747                return;
    4848            _config.incrementSentMessages();
  • router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java

    r1f5d7d7 r787def6  
    541541     * We drop in proportion to how far over the limit we are.
    542542     * Perhaps an exponential function would be better?
    543      */
    544     public boolean shouldDropParticipatingMessage() {
     543     *
     544     * The drop probability is adjusted for the size of the message.
     545     * At this stage, participants and IBGWs see a standard 1024 byte message.
     546     * OBEPs however may see a wide variety of sizes.
     547     *
     548     * @param type unused except for logging
     549     * @param length the length of the message
     550     */
     551    public boolean shouldDropParticipatingMessage(String type, int length) {
     552        if (length <= 0)
     553            return false;
    545554        RateStat rs = _context.statManager().getRate("tunnel.participatingBandwidth");
    546555        if (rs == null)
     
    575584        if (pctDrop <= 0)
    576585            return false;
     586        // drop in proportion to size w.r.t. a standard 1024-byte message
     587        // this is a little expensive but we want to adjust the curve between 0 and 1
     588        // Most messages are 1024, only at the OBEP do we see other sizes
     589        if (length != 1024)
     590            pctDrop = (float) Math.pow(pctDrop, 1024d / length);
    577591        float rand = _context.random().nextFloat();
    578592        boolean reject = rand <= pctDrop;
     
    581595                int availBps = (int) (((maxKBps*1024)*share) - used);
    582596                _log.warn("Drop part. msg. avail/max/used " + availBps + "/" + (int) maxBps + "/"
    583                           + used + " %Drop = " + pctDrop);
     597                          + used + " %Drop = " + pctDrop
     598                          + ' ' + type + ' ' + length);
    584599            }
    585600            _context.statManager().addRateData("tunnel.participatingMessageDropped", 1, 0);
  • router/java/src/net/i2p/router/tunnel/TunnelParticipant.java

    r1f5d7d7 r787def6  
    151151
    152152    private void send(HopConfig config, TunnelDataMessage msg, RouterInfo ri) {
    153         if (_context.tunnelDispatcher().shouldDropParticipatingMessage())
     153        if (_context.tunnelDispatcher().shouldDropParticipatingMessage("TDM", 1024))
    154154            return;
    155155        _config.incrementSentMessages();
Note: See TracChangeset for help on using the changeset viewer.