This commit is contained in:
esrrhs 2019-10-26 21:22:14 +08:00
parent 9e1d5d61b2
commit bf39ee41b2
2 changed files with 46 additions and 12 deletions

View File

@ -231,6 +231,9 @@ func (fm *FrameMgr) addToRecvWin(rf *Frame) bool {
if !fm.isIdInRange((int)(rf.Id), FRAME_MAX_ID) {
loggo.Debug("recv frame not in range %d %d", rf.Id, fm.recvid)
if !fm.isIdOld((int)(rf.Id), FRAME_MAX_ID) {
return true
}
return false
}
@ -257,18 +260,6 @@ func (fm *FrameMgr) addToRecvWin(rf *Frame) bool {
return true
}
func (fm *FrameMgr) compareId(l int, r int) int {
if l < fm.recvid {
l += FRAME_MAX_ID
}
if r < fm.recvid {
r += FRAME_MAX_ID
}
return l - r
}
func (fm *FrameMgr) combineWindowToRecvBuffer() {
for {
@ -401,3 +392,34 @@ func (fm *FrameMgr) isIdInRange(id int, maxid int) bool {
}
return false
}
func (fm *FrameMgr) compareId(l int, r int) int {
if l < fm.recvid {
l += FRAME_MAX_ID
}
if r < fm.recvid {
r += FRAME_MAX_ID
}
return l - r
}
func (fm *FrameMgr) isIdOld(id int, maxid int) bool {
if id > fm.recvid {
return false
}
end := fm.recvid + fm.windowsize*2
if end >= maxid {
if id >= end-maxid && id < fm.recvid {
return true
}
} else {
if id < fm.recvid {
return true
}
}
return false
}

View File

@ -79,4 +79,16 @@ func Test0001(t *testing.T) {
fm.recvid = 10
fm.windowsize = 10000
fmt.Println("fm.isIdInRange = ", fm.isIdInRange(0, FRAME_MAX_ID))
fm.recvid = 7
fm.windowsize = 5
fmt.Println("fm.isIdOld = ", fm.isIdOld(2, 10))
fm.recvid = 7
fm.windowsize = 5
fmt.Println("fm.isIdOld = ", fm.isIdOld(1, 10))
fm.recvid = 3
fm.windowsize = 5
fmt.Println("fm.isIdOld = ", fm.isIdOld(1, 10))
}