Python Scapy/运算符,|管道类型

Python Scapy / operator, | pipe in types

有了scapy我们可以做到这一点:

p = Ether() / IP()

'/' 到底做了什么操作? return 是什么对象? 如果我在 python 解释器中输入 p 它 returns this

<Ether  ... | IP ...>

'|'是什么意思在这种情况下是什么意思?

我试图在创建 p 后更改 IP 的字段 dst 而没有完全重新创建对象,但我没有成功,因为我不知道我面对的是哪种对象。

谢谢。

div / 运算符在 Scapy 中用于 stack layers:

The / operator has been used as a composition operator between two layers. When doing so, the lower layer can have one or more of its defaults fields overloaded according to the upper layer.

打印输出中的 | 只是一个文本分隔符,可帮助您区分堆叠层。