python构造IGMPv2成员关系报告报文并发出

该代码示例展示了如何使用Python库Scapy创建并发送一个IP数据包,其中包含IGMP(InternetGroupManagementProtocol)版本2的成员报告。数据包的目标地址是235.5.5.5,源地址是172.16.16.51,并通过以太网接口发送。
摘要由CSDN通过智能技术生成

代码如下:

from scapy.all import *
import scapy.contrib.igmp

ip = IP(src="172.16.16.51",dst="235.5.5.5")
igmp = scapy.contrib.igmp.IGMP(type=0x16, gaddr="235.5.5.5")
p = ip/igmp
p[scapy.contrib.igmp.IGMP].igmpize()
p.show()
send(p,iface="以太网")

运行结果:
###[ IP ]###
version = 4
ihl = None
tos = 0x0
len = None
id = 1
flags =
frag = 0
ttl = 1
proto = 2
chksum = None
src = 172.16.16.51
dst = 235.5.5.5
\options
|###[ IP Option Router Alert ]###
| copy_flag = 1
| optclass = control
| option = router_alert
| length = 4
| alert = router_shall_examine_packet
###[ IGMP ]###
type = Version 2 - Membership Report
mrcode = 0
chksum = None
gaddr = 235.5.5.5

.
Sent 1 packets.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值