mirror of
https://github.com/nonoo/kappanhang.git
synced 2026-02-24 16:34:18 +01:00
Add missing stuff from previous commit
This commit is contained in:
parent
8d2d81d3a9
commit
5df5ceb393
|
|
@ -25,6 +25,8 @@ type streamCommon struct {
|
|||
|
||||
pkt0 pkt0Type
|
||||
pkt7 pkt7Type
|
||||
|
||||
lastSeqBufFrontRxSeq uint16
|
||||
}
|
||||
|
||||
func (s *streamCommon) send(d []byte) error {
|
||||
|
|
@ -167,6 +169,36 @@ func (s *streamCommon) sendRetransmitRequestForRanges(seqNumRanges []seqNumRange
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *streamCommon) requestRetransmitIfNeeded(gotSeq uint16) error {
|
||||
prevExpectedSeq := gotSeq - 1
|
||||
if s.lastSeqBufFrontRxSeq != prevExpectedSeq {
|
||||
var missingPkts int
|
||||
var sr seqNumRange
|
||||
if prevExpectedSeq > s.lastSeqBufFrontRxSeq {
|
||||
sr[0] = s.lastSeqBufFrontRxSeq
|
||||
sr[1] = prevExpectedSeq
|
||||
missingPkts = int(prevExpectedSeq) - int(s.lastSeqBufFrontRxSeq)
|
||||
} else {
|
||||
sr[0] = prevExpectedSeq
|
||||
sr[1] = s.lastSeqBufFrontRxSeq
|
||||
missingPkts = int(prevExpectedSeq) + 65536 - int(s.lastSeqBufFrontRxSeq)
|
||||
}
|
||||
if missingPkts == 1 {
|
||||
log.Debug("request pkt #", sr[1], " retransmit")
|
||||
if err := s.sendRetransmitRequest(sr[1]); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if missingPkts < 50 {
|
||||
log.Debug("request pkt #", sr[0], "-#", sr[1], " retransmit")
|
||||
if err := s.sendRetransmitRequestForRanges([]seqNumRange{sr}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
s.lastSeqBufFrontRxSeq = gotSeq
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *streamCommon) sendDisconnect() error {
|
||||
log.Print(s.name + "/disconnecting")
|
||||
p := []byte{0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||
|
|
|
|||
Loading…
Reference in a new issue