java.lang.Object
net.i2p.util.SimpleTimer2.TimedEvent
net.i2p.client.streaming.impl.Connection.RetransmitEvent
- All Implemented Interfaces:
Runnable
- Enclosing class:
Connection
A single retransmit timer for all packets. See RFCs 5681 and 6298.
Field Summary
FieldsFields inherited from class SimpleTimer2.TimedEvent
_state, DEFAULT_FUZZModifier and TypeFieldDescriptionprotected SimpleTimer2.TimedEventStateState of the current event.protected static final intDefault fuzz threshold in milliseconds.Constructor Summary
ConstructorsMethod Summary
Public MethodsModifier and TypeMethodDescriptionbooleancancel()Cancel the pending retransmission timer.(package private) booleanChecks 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.(package private) booleanRecords a retransmit timer firing and detects stalls.voidForce immediate reschedule with minimum delay, cancelling any pending timer.(package private) longgetRetransmitStallAgeMs(long now) Length of the current run of retransmit firings without forward ACK progress.voidpushBackRTO(int rto) Push back the retransmission timeout to the given RTO.voidpushBackRTOBounded(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.booleanscheduleIfNotRunning(long delay) Schedule the retransmit timer if it is not already running.voidRetransmit packets and adjust congestion state when the timer fires.Methods inherited from class SimpleTimer2.TimedEvent
forceReschedule, reschedule, reschedule, run, schedule, setFuzz, setPool, toStringModifier and TypeMethodDescriptionvoidforceReschedule(long timeoutMs) Always use the new time - ignores fuzz.voidreschedule(long timeoutMs) Use the earliest of the new time and the old time May be called from within timeReached(), but schedule() is better there.voidreschedule(long timeoutMs, boolean useEarliestTime) May be called from within timeReached(), but schedule() is better there.voidrun()voidschedule(long timeoutMs) Schedule this event.voidsetFuzz(int fuzz) Reschedule threshold in ms.voidsetPool(SimpleTimer2 pool) Timer pool for this event.toString()Timer summary for log messages.
Field Details
_scheduled
private boolean _scheduledWhether the timer is active.
Constructor Details
RetransmitEvent
RetransmitEvent()Retransmit event.
Method Details
cancel
public boolean cancel()Cancel the pending retransmission timer.- Overrides:
cancelin classSimpleTimer2.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:
timeReachedin classSimpleTimer2.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