interfaces.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package ackhandler
  2. import (
  3. "time"
  4. "v2ray.com/core/external/github.com/lucas-clemente/quic-go/internal/protocol"
  5. "v2ray.com/core/external/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. // only to be called once the handshake is complete
  26. GetLowestPacketNotConfirmedAcked() protocol.PacketNumber
  27. DequeuePacketForRetransmission() *Packet
  28. DequeueProbePacket() (*Packet, error)
  29. PeekPacketNumber() (protocol.PacketNumber, protocol.PacketNumberLen)
  30. PopPacketNumber() protocol.PacketNumber
  31. GetAlarmTimeout() time.Time
  32. OnAlarm() error
  33. }
  34. // ReceivedPacketHandler handles ACKs needed to send for incoming packets
  35. type ReceivedPacketHandler interface {
  36. ReceivedPacket(pn protocol.PacketNumber, encLevel protocol.EncryptionLevel, rcvTime time.Time, shouldInstigateAck bool) error
  37. IgnoreBelow(protocol.PacketNumber)
  38. GetAlarmTimeout() time.Time
  39. GetAckFrame(protocol.EncryptionLevel) *wire.AckFrame
  40. }