oldestUnacked method

List<UDXPacket> oldestUnacked(
  1. int n
)

Up to n outstanding packets, lowest sequence first: what a PTO probe re-sends. A re-send takes a fresh sequence, so the lowest numbers are the longest unsent.

Implementation

List<UDXPacket> oldestUnacked(int n) {
  if (_sentPackets.isEmpty || n <= 0) return const [];
  // A path-MTU probe is never re-sent.
  final all = _sentPackets.values.where((p) => !p.isProbe).toList()
    ..sort((a, b) => a.sequence.compareTo(b.sequence));
  return all.length > n ? all.sublist(0, n) : all;
}