嘿伙计们我很有约束力我有这个功能
def send_ra_packet(self,source_link_layer, send_frequency,vlan_id = 0):
ip = IP6.IP6()
ip.set_source_address(self.get_source_address())
ip.set_destination_address(self.get_target_address())
ip.set_traffic_class(0)
ip.set_flow_label(0)
ip.set_hop_limit(64)
s = socket.socket(socket.AF_INET6, socket.SOCK_RAW, socket.IPPROTO_ICMPV6)
payload = self.create_ra_message(source_link_layer)
print send_frequency
for i in range(0, send_frequency):
icmp = ICMP6.ICMP6()
icmp.set_byte(0, 134) # Put Type?
icmp.set_byte(1, 00) # Put Code?
payloadObject = ImpactPacket.Data()
payloadObject.set_data(payload)
icmp.contains(payloadObject)
# Have the IP packet contain the ICMP packet (along with its payload).
ip.contains(icmp)
ip.set_next_header(ip.child().get_ip_protocol_number())
ip.set_payload_length(ip.child().get_size())
eth = ImpactPacket.Ethernet()
vlan = ImpactPacket.EthernetTag()
vlan.set_vid(1)
eth.push_tag(vlan)
icmp.calculate_checksum()
eth.contains(ip)
print icmp.get_packet()
# Send it to the target host.
s.sendto(eth.get_packet(), (self.get_target_address(), 0))
print "Success Sending Packet - %d " % (i)
该功能的快速概述将告诉您我正在创建RA数据包并将其发送到我的网络中,我的问题是我似乎无法发送带有VLAN的RA数据包。
我的附加代码从eth = ImpacketPacket.Ethernet()
开始
会告诉你我创建了一个具有VLAN的Header,并将其作为ip的父级,其实例为IPV6。
我的问题是,当我运行代码时,将要发送的结果数据包是Uknown(0) 这意味着它已损坏或无法理解。
我现在已经坚持了这个问题差不多一个星期了,并尝试了很多方法来发送它。我不确定是什么错误,如果我用icmp发送数据包而不是eth它工作正常。