forked from quic-go/quic-go
implemenet OutgoingPacketAckHandler.DequeuePacketForRetransmission(), fix minor error
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
errEntropy = errors.New("OutgoingPacketAckHandler: Wrong entropy")
|
errEntropy = errors.New("OutgoingPacketAckHandler: Wrong entropy")
|
||||||
errMapAccess = errors.New("OutgoingPacketAckHandler: Packet does not exist in PacketHistory")
|
errMapAccess = errors.New("OutgoingPacketAckHandler: Packet does not exist in PacketHistory")
|
||||||
retransmissionThreshold = uint8(1) // ToDo: use 3 as recommended in the RFC here
|
retransmissionThreshold = uint8(3)
|
||||||
)
|
)
|
||||||
|
|
||||||
type outgoingPacketAckHandler struct {
|
type outgoingPacketAckHandler struct {
|
||||||
@@ -168,7 +168,6 @@ func (h *outgoingPacketAckHandler) ReceivedAck(ackFrame *frames.AckFrame) error
|
|||||||
packet.MissingReports++
|
packet.MissingReports++
|
||||||
// send out the packet again when it has been NACK more than retransmissionThreshold times
|
// send out the packet again when it has been NACK more than retransmissionThreshold times
|
||||||
if packet.MissingReports > retransmissionThreshold {
|
if packet.MissingReports > retransmissionThreshold {
|
||||||
fmt.Printf("Should retransmit packet %d\n", packet.PacketNumber)
|
|
||||||
h.retransmissionQueue = append(h.retransmissionQueue, packet)
|
h.retransmissionQueue = append(h.retransmissionQueue, packet)
|
||||||
// ToDo: delete the packet from the history, as if it had been acked
|
// ToDo: delete the packet from the history, as if it had been acked
|
||||||
}
|
}
|
||||||
@@ -184,5 +183,10 @@ func (h *outgoingPacketAckHandler) ReceivedAck(ackFrame *frames.AckFrame) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *outgoingPacketAckHandler) DequeuePacketForRetransmission() (packet *Packet) {
|
func (h *outgoingPacketAckHandler) DequeuePacketForRetransmission() (packet *Packet) {
|
||||||
return nil
|
if len(h.retransmissionQueue) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
packet = h.retransmissionQueue[0]
|
||||||
|
h.retransmissionQueue = h.retransmissionQueue[1:]
|
||||||
|
return packet
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -337,6 +337,31 @@ var _ = Describe("AckHandler", func() {
|
|||||||
Expect(len(handler.retransmissionQueue)).To(Equal(1))
|
Expect(len(handler.retransmissionQueue)).To(Equal(1))
|
||||||
Expect(handler.retransmissionQueue[0].PacketNumber).To(Equal(protocol.PacketNumber(2)))
|
Expect(handler.retransmissionQueue[0].PacketNumber).To(Equal(protocol.PacketNumber(2)))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("dequeues a packet for retransmission", func() {
|
||||||
|
retransmissionThreshold = 1
|
||||||
|
nackRange := frames.NackRange{FirstPacketNumber: 2, LastPacketNumber: 2}
|
||||||
|
entropy := EntropyAccumulator(0)
|
||||||
|
entropy.Add(1, packets[0].EntropyBit)
|
||||||
|
entropy.Add(3, packets[2].EntropyBit)
|
||||||
|
ack1 := frames.AckFrame{
|
||||||
|
LargestObserved: 3,
|
||||||
|
Entropy: byte(entropy),
|
||||||
|
NackRanges: []frames.NackRange{nackRange},
|
||||||
|
}
|
||||||
|
err := handler.ReceivedAck(&ack1)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
entropy.Add(4, packets[3].EntropyBit)
|
||||||
|
ack2 := frames.AckFrame{
|
||||||
|
LargestObserved: 4,
|
||||||
|
Entropy: byte(entropy),
|
||||||
|
NackRanges: []frames.NackRange{nackRange},
|
||||||
|
}
|
||||||
|
err = handler.ReceivedAck(&ack2)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(handler.DequeuePacketForRetransmission()).ToNot(BeNil())
|
||||||
|
Expect(handler.DequeuePacketForRetransmission()).To(BeNil())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user