Class Pacer
java.lang.Object
io.github.mahmoudimus.quic.connection.Pacer
A token-bucket pacer (RFC 9002 section 7.7). Its capacity is the part of the congestion window
sent in one burst; the bucket refills at 1.25 congestion windows per RTT, and an empty bucket
delays the next packet. Times and durations are nanoseconds.
Threads. Not thread-safe; owned by one connection.
-
Constructor Summary
ConstructorsConstructorDescriptionPacer(long smoothedRtt, long window, int mtu, long maxBytesPerSecond, long now) A pacer with a full bucket. -
Method Summary
Modifier and TypeMethodDescriptionlongdelay(long smoothedRtt, long bytesToSend, int mtu, long window, long now) When the next packet may be sent.longThe rate limit this pacer was built with.voidonTransmit(int packetLength) Records that a packet was sent.
-
Constructor Details
-
Pacer
public Pacer(long smoothedRtt, long window, int mtu, long maxBytesPerSecond, long now) A pacer with a full bucket.- Parameters:
smoothedRtt- the smoothed RTT, in nanosecondswindow- the congestion window, in bytesmtu- the path's maximum UDP payload sizemaxBytesPerSecond- a sending rate limit in bytes per second, or -1 for nonenow- the current time
-
-
Method Details
-
maxBytesPerSecond
public long maxBytesPerSecond()The rate limit this pacer was built with.- Returns:
- bytes per second, or -1 for none
-
onTransmit
public void onTransmit(int packetLength) Records that a packet was sent.- Parameters:
packetLength- the packet's size in bytes
-
delay
public long delay(long smoothedRtt, long bytesToSend, int mtu, long window, long now) When the next packet may be sent.- Parameters:
smoothedRtt- the smoothed RTT, in nanosecondsbytesToSend- the size of the next packetmtu- the path's maximum UDP payload sizewindow- the congestion window, nonzeronow- the current time- Returns:
- the time to try again, or
NanoClock.NONEif the packet may be sent now
-