好难好难好难 窗口控制失效 主要表现为 segment.data.Size() 在 cap操作后进入下个循环时恢复初始值 截取失败

This commit is contained in:
impact-eintr
2022-12-14 21:45:51 +08:00
parent 0b6ffaa995
commit 57fcf28f83
7 changed files with 139 additions and 26 deletions

View File

@@ -114,6 +114,20 @@ func (s *segment) incRef() {
atomic.AddInt32(&s.refCnt, 1)
}
// logicalLen is the segment length in the sequence number space. It's defined
// as the data length plus one for each of the SYN and FIN bits set.
// 计算tcp段的逻辑长度包括负载数据的长度如果有控制标记需要加1
func (s *segment) logicalLen() seqnum.Size {
l := seqnum.Size(s.data.Size())
if s.flagIsSet(flagSyn) {
l++
}
if s.flagIsSet(flagFin) {
l++
}
return l
}
func (s *segment) parse() bool {
h := header.TCP(s.data.First())
offset := int(h.DataOffset())