sendProbe method

bool sendProbe({
  1. int? maxDatagram,
})

Sends the PTO's probes: the ptoProbes oldest outstanding packets, re-sent under fresh sequences (RFC 9002 section 6.2.4: a probe carries data when there is data to carry). They are not declared lost (an ACK will say), their bytes stay in flight, and neither the window nor the pacer is consulted: a probe is allowed out when nothing else is (RFC 9002 section 7.7 exempts probes from pacing), though it is drawn from the pacing budget so that what follows it is paced as if it had been. maxDatagram, when given, is what the path carries now: a larger packet is re-chunked to fit. Returns whether anything went out.

This used to send a PING under lastSentPacketNumber, the sequence of a data packet still in flight; both peers acknowledge a numbered PING, so a lost data packet could be marked acknowledged by its probe's ACK and never re-sent.

Implementation

bool sendProbe({int? maxDatagram}) {
  var sent = false;
  for (final oldest in oldestUnacked(ptoProbes)) {
    // Re-chunked if the path no longer carries it (fitToPath): after a
    // black hole, the probe is the first packet that can get through.
    final pieces = maxDatagram == null ? [oldest] : fitToPath(oldest, maxDatagram);
    for (final piece in pieces) {
      final newSeq = resend(piece);
      if (newSeq == null) continue;
      sent = true;
      onPacketRetransmitEvent?.call(newSeq, piece.retransmitCount, congestionController.pto);
      onRetransmit?.call(piece);
      // Drawn from the pacing budget, so what follows the probe is paced
      // as if it had been (section 7.7 exempts the probe itself).
      congestionController.pacingController.onPacketSent(piece.wireSize ?? piece.toBytes().length);
    }
  }
  return sent;
}