Changeset 3b2aa94


Ignore:
Timestamp:
Oct 2, 2010 4:56:02 PM (10 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
042cde2
Parents:
a687180
Message:
  • I2CP:
    • Add new option i2cp.messageReliability=none, which prevents the router from sending MessageStatusMessages? back in reply to an outbound SendMessageMessage?. Since the streaming lib always ignored the MSMs anyway, make it the default for streaming. This will reduce the I2CP traffic significantly. MSM handling now avoided, but it is still fairly broken, see comments in I2PSessionImpl2.
    • Cleanups, javadoc, rate reduction
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java

    ra687180 r3b2aa94  
    131131                opts.setProperty(name, System.getProperty(name));
    132132        }
    133         boolean oldLib = DEFAULT_MANAGER.equals(opts.getProperty(PROP_MANAGER, DEFAULT_MANAGER));
    134         if (oldLib && false) {
     133        //boolean oldLib = DEFAULT_MANAGER.equals(opts.getProperty(PROP_MANAGER, DEFAULT_MANAGER));
     134        //if (oldLib && false) {
    135135            // for the old streaming lib
    136             opts.setProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_GUARANTEED);
     136        //    opts.setProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_GUARANTEED);
    137137            //opts.setProperty("tunnels.depthInbound", "0");
    138         } else {
     138        //} else {
    139139            // for new streaming lib:
    140             opts.setProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_BEST_EFFORT);
     140            //opts.setProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_BEST_EFFORT);
     141            // as of 0.8.1 (I2CP default is BestEffort)
     142            if (!opts.containsKey(I2PClient.PROP_RELIABILITY))
     143                opts.setProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_NONE);
    141144            //p.setProperty("tunnels.depthInbound", "0");
    142         }
     145        //}
    143146
    144147        if (i2cpHost != null)
  • core/java/src/net/i2p/client/I2PClient.java

    ra687180 r3b2aa94  
    3535    /** Reliability value: guaranteed */
    3636    public final static String PROP_RELIABILITY_GUARANTEED = "Guaranteed";
     37    /** @since 0.8.1 */
     38    public final static String PROP_RELIABILITY_NONE = "none";
    3739
    3840    /** protocol flag that must be sent when opening the i2cp connection to the router */
  • core/java/src/net/i2p/client/I2PSessionImpl2.java

    ra687180 r3b2aa94  
    3434
    3535    /** set of MessageState objects, representing all of the messages in the process of being sent */
    36     private /* FIXME final FIXME */ Set _sendingStates;
     36    private /* FIXME final FIXME */ Set<MessageState> _sendingStates;
    3737    /** max # seconds to wait for confirmation of the message send */
    3838    private final static long SEND_TIMEOUT = 60 * 1000; // 60 seconds to send
     
    4040    private final static boolean SHOULD_COMPRESS = true;
    4141    private final static boolean SHOULD_DECOMPRESS = true;
     42    /** Don't expect any MSMs from the router for outbound traffic @since 0.8.1 */
     43    private boolean _noEffort;
    4244
    4345    /** for extension */
     
    5456        _log = ctx.logManager().getLog(I2PSessionImpl2.class);
    5557        _sendingStates = new HashSet(32);
     58        // default is BestEffort
     59        _noEffort = "none".equalsIgnoreCase(options.getProperty(I2PClient.PROP_RELIABILITY));
    5660
    5761        ctx.statManager().createRateStat("i2cp.sendBestEffortTotalTime", "how long to do the full sendBestEffort call?", "i2cp", new long[] { 10*60*1000 } );
     
    6165        //ctx.statManager().createRateStat("i2cp.sendBestEffortStage3", "fourth part of sendBestEffort?", "i2cp", new long[] { 10*60*1000 } );
    6266        //ctx.statManager().createRateStat("i2cp.sendBestEffortStage4", "fifth part of sendBestEffort?", "i2cp", new long[] { 10*60*1000 } );
    63         _context.statManager().createRateStat("i2cp.receiveStatusTime.0", "How long it took to get status=0 back", "i2cp", new long[] { 60*1000, 10*60*1000 });
    64         _context.statManager().createRateStat("i2cp.receiveStatusTime.1", "How long it took to get status=1 back", "i2cp", new long[] { 60*1000, 10*60*1000 });
    65         _context.statManager().createRateStat("i2cp.receiveStatusTime.2", "How long it took to get status=2 back", "i2cp", new long[] { 60*1000, 10*60*1000 });
    66         _context.statManager().createRateStat("i2cp.receiveStatusTime.3", "How long it took to get status=3 back", "i2cp", new long[] { 60*1000, 10*60*1000 });
    67         _context.statManager().createRateStat("i2cp.receiveStatusTime.4", "How long it took to get status=4 back", "i2cp", new long[] { 60*1000, 10*60*1000 });
    68         _context.statManager().createRateStat("i2cp.receiveStatusTime.5", "How long it took to get status=5 back", "i2cp", new long[] { 60*1000, 10*60*1000 });
    69         _context.statManager().createRateStat("i2cp.receiveStatusTime", "How long it took to get any status", "i2cp", new long[] { 60*1000, 10*60*1000 });
    70         _context.statManager().createRateStat("i2cp.tx.msgCompressed", "compressed size transferred", "i2cp", new long[] { 60*1000, 30*60*1000 });
    71         _context.statManager().createRateStat("i2cp.tx.msgExpanded", "size before compression", "i2cp", new long[] { 60*1000, 30*60*1000 });
     67        //_context.statManager().createRateStat("i2cp.receiveStatusTime.0", "How long it took to get status=0 back", "i2cp", new long[] { 60*1000, 10*60*1000 });
     68        _context.statManager().createRateStat("i2cp.receiveStatusTime.1", "How long it took to get status=1 back", "i2cp", new long[] { 10*60*1000 });
     69        // best effort codes unused
     70        //_context.statManager().createRateStat("i2cp.receiveStatusTime.2", "How long it took to get status=2 back", "i2cp", new long[] { 60*1000, 10*60*1000 });
     71        //_context.statManager().createRateStat("i2cp.receiveStatusTime.3", "How long it took to get status=3 back", "i2cp", new long[] { 60*1000, 10*60*1000 });
     72        _context.statManager().createRateStat("i2cp.receiveStatusTime.4", "How long it took to get status=4 back", "i2cp", new long[] { 10*60*1000 });
     73        _context.statManager().createRateStat("i2cp.receiveStatusTime.5", "How long it took to get status=5 back", "i2cp", new long[] { 10*60*1000 });
     74        _context.statManager().createRateStat("i2cp.receiveStatusTime", "How long it took to get any status", "i2cp", new long[] { 10*60*1000 });
     75        _context.statManager().createRateStat("i2cp.tx.msgCompressed", "compressed size transferred", "i2cp", new long[] { 30*60*1000 });
     76        _context.statManager().createRateStat("i2cp.tx.msgExpanded", "size before compression", "i2cp", new long[] { 30*60*1000 });
    7277    }
    7378
     
    187192        _context.statManager().addRateData("i2cp.tx.msgCompressed", compressed, 0);
    188193        _context.statManager().addRateData("i2cp.tx.msgExpanded", size, 0);
    189         return sendBestEffort(dest, payload, keyUsed, tagsSent, expires);
     194        if (_noEffort)
     195            return sendNoEffort(dest, payload, expires);
     196        else
     197            return sendBestEffort(dest, payload, keyUsed, tagsSent, expires);
    190198    }
    191199
     
    214222
    215223    /**
     224     * TODO - Don't need to save MessageState since actuallyWait is false...
     225     * But for now just use sendNoEffort() instead.
     226     *
    216227     * @param keyUsed unused - no end-to-end crypto
    217228     * @param tagsSent unused - no end-to-end crypto
     
    258269                               + (tag == null ? "no tag" : " a valid tag"));
    259270            }
    260        
     271
    261272            if (false) // rekey
    262273                newKey = _context.keyGenerator().generateSessionKey();
     
    372383    }
    373384   
     385    /**
     386     * Same as sendBestEffort(), except we do not expect any MessageStatusMessage responses -
     387     * not for accepted, or success, or failure.
     388     * So we don't create a MessageState and save it on the _sendingStates HashSet
     389     *
     390     * @return true always
     391     * @since 0.8.1
     392     */
     393    protected boolean sendNoEffort(Destination dest, byte payload[], long expires)
     394                    throws I2PSessionException {
     395        // nonce always 0
     396        _producer.sendMessage(this, dest, 0, payload, null, null, null, null, expires);
     397        return true;
     398    }
     399   
     400    /**
     401     *  Only call this with nonzero status, i.e. for outbound messages
     402     *  whose MessageState may be queued on _sendingStates.
     403     *
     404     *  Even when using sendBestEffort(), this is a waste, because the
     405     *  MessageState is removed from _sendingStates immediately and
     406     *  so the lookup here fails.
     407     *  And iterating through the HashSet instead of having a map
     408     *  is bad too.
     409     *
     410     *  This is now pretty much avoided since streaming now sets
     411     *  i2cp.messageReliability = none, which forces sendNoEffort() instead of sendBestEffort(),
     412     *  so the router won't send us any MSM's for outbound traffic.
     413     *
     414     *  @param status != 0
     415     */
    374416    @Override
    375417    public void receiveStatus(int msgId, long nonce, int status) {
     
    414456                    _context.statManager().addRateData("i2cp.receiveStatusTime.1", lifetime, 0);
    415457                    break;
    416                 case 2:
    417                     _context.statManager().addRateData("i2cp.receiveStatusTime.2", lifetime, 0);
    418                     break;
    419                 case 3:
    420                     _context.statManager().addRateData("i2cp.receiveStatusTime.3", lifetime, 0);
    421                     break;
     458                // best effort codes unused
     459                //case 2:
     460                //    _context.statManager().addRateData("i2cp.receiveStatusTime.2", lifetime, 0);
     461                //    break;
     462                //case 3:
     463                //    _context.statManager().addRateData("i2cp.receiveStatusTime.3", lifetime, 0);
     464                //    break;
    422465                case 4:
    423466                    _context.statManager().addRateData("i2cp.receiveStatusTime.4", lifetime, 0);
  • router/java/src/net/i2p/router/client/ClientConnectionRunner.java

    ra687180 r3b2aa94  
    1818import java.util.Set;
    1919
     20import net.i2p.client.I2PClient;
    2021import net.i2p.crypto.SessionKeyManager;
    2122import net.i2p.crypto.TransientSessionKeyManager;
     
    7778     * delivered to the client (so that we can be sure only to update when necessary)
    7879     */
    79     private final List _alreadyProcessed;
     80    private final List<MessageId> _alreadyProcessed;
    8081    private ClientWriterRunner _writer;
    8182    private Hash _destHashCache;
    8283    /** are we, uh, dead */
    8384    private boolean _dead;
     85    /** For outbound traffic. true if i2cp.messageReliability = "none"; @since 0.8.1 */
     86    private boolean _dontSendMSM;
    8487   
    8588    /**
     
    9295        _manager = manager;
    9396        _socket = socket;
    94         _config = null;
    9597        _messages = new ConcurrentHashMap();
    9698        _alreadyProcessed = new ArrayList();
    9799        _acceptedPending = new ConcurrentHashSet();
    98         _dead = false;
    99100    }
    100101   
     
    190191            _log.debug("SessionEstablished called for destination " + _destHashCache.toBase64());
    191192        _config = config;
     193        // This is the only option that is interpreted here, not at the tunnel manager
     194        if (config.getOptions() != null)
     195            _dontSendMSM = "none".equalsIgnoreCase(config.getOptions().getProperty(I2PClient.PROP_RELIABILITY));
    192196        // per-destination session key manager to prevent rather easy correlation
    193197        if (_sessionKeyManager == null)
     
    198202    }
    199203   
     204    /**
     205     * Send a notification to the client that their message (id specified) was
     206     * delivered (or failed delivery)
     207     * Note that this sends the Guaranteed status codes, even though we only support best effort.
     208     * Doesn't do anything if i2cp.messageReliability = "none"
     209     */
    200210    void updateMessageDeliveryStatus(MessageId id, boolean delivered) {
    201         if (_dead) return;
     211        if (_dead || _dontSendMSM)
     212            return;
    202213        _context.jobQueue().addJob(new MessageDeliveryStatusUpdate(id, delivered));
    203214    }
     215
    204216    /**
    205217     * called after a new leaseSet is granted by the client, the NetworkDb has been
     
    255267        if (message instanceof SendMessageExpiresMessage)
    256268            expiration = ((SendMessageExpiresMessage) message).getExpiration().getTime();
    257         _acceptedPending.add(id);
     269        if (!_dontSendMSM)
     270            _acceptedPending.add(id);
    258271
    259272        if (_log.shouldLog(Log.DEBUG))
     
    277290     * Send a notification to the client that their message (id specified) was accepted
    278291     * for delivery (but not necessarily delivered)
    279      *
     292     * Doesn't do anything if i2cp.messageReliability = "none"
    280293     */
    281294    void ackSendMessage(MessageId id, long nonce) {
     295        if (_dontSendMSM)
     296            return;
    282297        SessionId sid = _sessionId;
    283298        if (sid == null) return;
     
    518533
    519534        public String getName() { return "Update Delivery Status"; }
     535
     536        /**
     537         * Note that this sends the Guaranteed status codes, even though we only support best effort.
     538         */
    520539        public void runJob() {
    521540            if (_dead) return;
     
    524543            msg.setMessageId(_messageId.getMessageId());
    525544            msg.setSessionId(_sessionId.getSessionId());
     545            // has to be >= 0, it is initialized to -1
    526546            msg.setNonce(2);
    527547            msg.setSize(0);
Note: See TracChangeset for help on using the changeset viewer.