문제

I am trying to figure out how to read IP flags (not TCP) using scapy library. I know it is stored in "flags" and it is FlagsField type. According to IP protocol specification there are 3 flags R, MF, and DF. I've search, and searched and could not find any info on how to read these flags. Any ideas?

Thank you all for your input.

도움이 되었습니까?

해결책

For example, creating an IP packet with the DF (Don't Fragment) flag set:

>>> packet = IP(flags=2)  # alternatively, IP(flags='DF')
>>> packet
<IP  flags=DF |>

Reading a packet's flags:

>>> packet.flags
2

As for the flag bits, Wikipedia outlines this succinctly. It's a three-bit value with the following meaning:

  • bit 0: Reserved; must be zero.
  • bit 1: Don't Fragment (DF)
  • bit 2: More Fragments (MF)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top