Understanding TCP Packets

Asked 2 years ago, Updated 2 years ago, 28 views

I would like to determine whether the packet is ACK, PUSH ACK, or SYN ACK by TCP communication on Python 3.However, I would like to know what and how to judge.Please let me know if you have any details.

python

2022-09-30 21:35

1 Answers

If you use TCP on Python, you usually create sockets with socket.socket(socket.AF_INET, socket.SOCK_STREAM), but you cannot set or retrieve the flags ACK, SYN, PSH to automatically process TCP connections.

If you want to set and retrieve the flags ACK, SYN, PSH, use the RAW socket by setting the parameter socket.SOCK_RAW.In this case, you can configure and retrieve the TCP and IP headers yourself.

s=socket.socket(socket.AF_INET, socket.SOCK_RAW)

The PSH(push) flag is a flag that requires that data received be handed over to the application immediately when turned on, but it is not normally used because TCP is implemented even when turned off.

Home stackoverflow: How does TCP PSH work?


2022-09-30 21:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.