Merge pull request #1228 from lucas-clemente/sent-packet-handler-packet-number-len

calculate the packet number length in the sent packet handler
This commit is contained in:
Marten Seemann
2018-03-08 00:59:09 +07:00
committed by GitHub
8 changed files with 34 additions and 37 deletions

View File

@@ -32,7 +32,7 @@ type SentPacketHandler interface {
GetStopWaitingFrame(force bool) *wire.StopWaitingFrame
GetLowestPacketNotConfirmedAcked() protocol.PacketNumber
DequeuePacketForRetransmission() (packet *Packet)
GetLeastUnacked() protocol.PacketNumber
GetPacketNumberLen(protocol.PacketNumber) protocol.PacketNumberLen
GetAlarmTimeout() time.Time
OnAlarm()

View File

@@ -349,8 +349,8 @@ func (h *sentPacketHandler) DequeuePacketForRetransmission() *Packet {
return packet
}
func (h *sentPacketHandler) GetLeastUnacked() protocol.PacketNumber {
return h.lowestUnacked()
func (h *sentPacketHandler) GetPacketNumberLen(p protocol.PacketNumber) protocol.PacketNumberLen {
return protocol.GetPacketNumberLengthForHeader(p, h.lowestUnacked())
}
func (h *sentPacketHandler) GetStopWaitingFrame(force bool) *wire.StopWaitingFrame {

View File

@@ -59,9 +59,10 @@ var _ = Describe("SentPacketHandler", func() {
return nil
}
It("gets the LeastUnacked packet number", func() {
It("determines the packet number length", func() {
handler.largestAcked = 0x1337
Expect(handler.GetLeastUnacked()).To(Equal(protocol.PacketNumber(0x1337 + 1)))
Expect(handler.GetPacketNumberLen(0x1338)).To(Equal(protocol.PacketNumberLen2))
Expect(handler.GetPacketNumberLen(0xfffffff)).To(Equal(protocol.PacketNumberLen4))
})
Context("registering sent packets", func() {