interfaces.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package ackhandler
  2. import (
  3. "time"
  4. "github.com/lucas-clemente/quic-go/internal/protocol"
  5. "github.com/lucas-clemente/quic-go/internal/wire"
  6. )
  7. // SentPacketHandler handles ACKs received for outgoing packets
  8. type SentPacketHandler interface {
  9. // SentPacket may modify the packet
  10. SentPacket(packet *Packet)
  11. SentPacketsAsRetransmission(packets []*Packet, retransmissionOf protocol.PacketNumber)
  12. ReceivedAck(ackFrame *wire.AckFrame, withPacketNumber protocol.PacketNumber, encLevel protocol.EncryptionLevel, recvTime time.Time) error
  13. SetHandshakeComplete()
  14. // The SendMode determines if and what kind of packets can be sent.
  15. SendMode() SendMode
  16. // TimeUntilSend is the time when the next packet should be sent.
  17. // It is used for pacing packets.
  18. TimeUntilSend() time.Time
  19. // ShouldSendNumPackets returns the number of packets that should be sent immediately.
  20. // It always returns a number greater or equal than 1.
  21. // A number greater than 1 is returned when the pacing delay is smaller than the minimum pacing delay.
  22. // Note that the number of packets is only calculated based on the pacing algorithm.
  23. // Before sending any packet, SendingAllowed() must be called to learn if we can actually send it.
  24. ShouldSendNumPackets() int
  25. GetStopWaitingFrame(force bool) *wire.StopWaitingFrame
  26. GetLowestPacketNotConfirmedAcked() protocol.PacketNumber
  27. DequeuePacketForRetransmission() *Packet
  28. DequeueProbePacket() (*Packet, error)
  29. GetPacketNumberLen(protocol.PacketNumber) protocol.PacketNumberLen
  30. GetAlarmTimeout() time.Time
  31. OnAlarm() error
  32. }
  33. // ReceivedPacketHandler handles ACKs needed to send for incoming packets
  34. type ReceivedPacketHandler interface {
  35. ReceivedPacket(packetNumber protocol.PacketNumber, rcvTime time.Time, shouldInstigateAck bool) error
  36. IgnoreBelow(protocol.PacketNumber)
  37. GetAlarmTimeout() time.Time
  38. GetAckFrame() *wire.AckFrame
  39. }