Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

比较 seq 或 ack 时,为何使用 set 类型 #25

Open
peter-way opened this issue Aug 25, 2018 · 1 comment
Open

比较 seq 或 ack 时,为何使用 set 类型 #25

peter-way opened this issue Aug 25, 2018 · 1 comment

Comments

@peter-way
Copy link

下面的 ack_data 为何要使用 set 类型?

            ack_data = {specify_stream[start + 4], specify_stream[start + 5]}
            if ack_data == {ack, seq}:
@sunpudding
Copy link
Owner

当C->S时(seq=5,ack=6,len=10),PUSH一条请求,server端接收时,Flags_ack为1,且ack等于client的seq与请求len相加(seq=6,ack=15)==client(ack=6,seq=5+len);当S->C时(seq=5,ack=6,len=10),PUSH一条请求,client端接收时,Flags_ack为1,ack等于server的seq与请求len相加(seq=6,ack=15)==server(ack=6,seq=5+len),之前化分的较为细致,set无序的类型方便进行比较,修改后,未对此部分深入思考,经大神提醒发现,可以进行改善。

        while start < len(specify_stream):
            flags_push = specify_stream[start + 6] & 0x08  # 8
            flags_ack = specify_stream[start + 6] & 0x10  # 16
            flags_fin = specify_stream[start + 6] & 0x01  # 1
            seq, ack = specify_stream[start + 4], specify_stream[start + 5]
            if flags_fin:
                return reassemble_data
            if not (flags_ack and flags_push):
                start += 9
                continue
            seq += len(specify_stream[start + 7])
            start += 9
            if seq == specify_stream[start + 5] and ack == specify_stream[start + 4]:
                reassemble_data.extend(specify_stream[start - 9:start])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants