ICMPv6 example in ANDi scripts

ICMPv6 Master script

  • Running the following script will simulate running an ICMPv6 Master in order to respond to ICMPv6 neighbor solicitation message request.

  • “channel_1” is the link channel where the ICMPv6 neighbor solicitation message requests will be sent.

from andi.filters import pcap_filter

# Callback function, invoked on each incoming PTP message
def on_msg_received(msg):
    # Create a response message
    res = msg.create_response()
    # Check if the message is created 
    if res:
        # Send Created Message
        res.send()

# Create ICMPv6 message
msg_icmpv6 = message_builder.create_icmpv6_message("channel_1","channel_1")
# Assign source mac address
msg_icmpv6.ethernet_header.mac_address_source = "00:11:22:33:44:55"
# Get solicited multicast address
solicited_address = IP.get_solicited_multicast_address(msg_icmpv6.ipv6_header.ip_address_source)
# Build filter
icmpv6_filter = '(icmp6) and (dst net ' + solicited_address + ')'
# Create a filter
filter = pcap_filter(icmpv6_filter) 
# Register callback function
msg_icmpv6.on_message_received += on_msg_received
# Start live capturing for ICMPv6 message
msg_icmpv6.start_capture(filter)

ICMPv6 Solicit script

  • Running the following script will send ICMPv6 neighbor solicitation message request.

  • “channel_1” is the link channel where the ICMPv6 neighbor solicitation message requests will be sent.

# Create ICMPv6 message
msg_icmpv6 = message_builder.create_icmpv6_message("channel_1","channel_1")
# Makes current message a ICMPv6 neighbor solicitation message to specific target destination address
msg_icmpv6.solicit("fe80::1111:2222:3333:4444") 
# Send Message
msg_icmpv6.send()