java.lang.Object
net.i2p.util.SimpleTimer2.TimedEvent
net.i2p.client.streaming.impl.Connection.RetransmitEvent
All Implemented Interfaces:
Runnable
Enclosing class:
Connection

class Connection.RetransmitEventextends SimpleTimer2.TimedEvent
A single retransmit timer for all packets. See RFCs 5681 and 6298.
  • Field Details

    • _scheduled

      private boolean _scheduled
      Whether the timer is active.
  • Constructor Details

    • RetransmitEvent

      RetransmitEvent()
      Retransmit event.
  • Method Details

    • cancel

      public boolean cancel()
      Cancel the pending retransmission timer.
      Overrides:
      cancel in class SimpleTimer2.TimedEvent
      Returns:
      true if the event will not execute, false if already idle/cancelled
    • scheduleIfNotRunning

      public boolean scheduleIfNotRunning(long delay)
      Schedule the retransmit timer if it is not already running.
      Parameters:
      delay - how long from now to wait before firing the retransmit (ms), normally the packet's timeout
      Returns:
      true if the timer was armed, false if one was already running and the pending schedule was left untouched
    • forceRescheduleNow

      public void forceRescheduleNow()
      Force immediate reschedule with minimum delay, cancelling any pending timer. Used by scheduleSoftFailureRetransmit() so that a soft-failure notification triggers a retransmit without waiting for the current RTO to elapse.

      Unlike pushBackRTO(int), this always schedules a new timer event rather than relying on reschedule(..., false) which won't shorten a running timer.

    • pushBackRTO

      public void pushBackRTO(int rto)
      Push back the retransmission timeout to the given RTO.
      Parameters:
      rto - the new retransmission timeout (ms)
    • pushBackRTOBounded

      public void pushBackRTOBounded(int delayMs)
      Push back the retransmission timer to the given DELAY FROM NOW, but allow the fire time to move EARLIER if the new deadline is earlier than the currently scheduled one. RFC 6298 section 5.3 restarts the timer at the full RTO on every new ACK; with trickle ACKs that keeps deferring an overdue head-of-line retransmission indefinitely (the mid-download freeze). Callers anchor the delay to the oldest unacked packet's send time + RTO so the timer is guaranteed to fire.
      Parameters:
      delayMs - delay from now (the anchored deadline minus now); a value <= 0 forces an immediate fire
    • timeReached

      public void timeReached()
      Retransmit packets and adjust congestion state when the timer fires.
      Specified by:
      timeReached in class SimpleTimer2.TimedEvent
    • checkRetransmitStall

      boolean checkRetransmitStall()
      Records a retransmit timer firing and detects stalls. If ackPackets() was called since the last retransmit, resets the counter. Otherwise increments it; after 2 consecutive firings without ACK progress, signals a tunnel rotation via _nextSendFreshConnection.
      Returns:
      true if a retransmit stall was detected
    • getRetransmitStallAgeMs

      long getRetransmitStallAgeMs(long now)
      Length of the current run of retransmit firings without forward ACK progress.
      Parameters:
      now - the clock reading to measure from (ms since the epoch)
      Returns:
      ms elapsed since the run began, or 0 if none is in progress
    • checkLivenessBackstop

      boolean checkLivenessBackstop()
      Checks liveness backstops: if the oldest unacked packet has been in flight beyond the worst-case retransmit budget measured from creation, or the remote has been silent for the full inactivity window, forces a disconnect.
      Returns:
      true if a liveness backstop disconnect should be triggered