代码如下:
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.