IPv6 Neighbor Solicitation & Advertisement

Der folgende Code sollte in einer Mininet-Umgebung funktionieren (gestartet mit –mac), und simuliert das Senden einer Solicitation von Host 1 an Host 2:

from scapy.all import *
 
# Solicitation
head = IPv6()
head.dst = "ff02::1:ff00:0002"
 
ns=ICMPv6ND_NS(tgt="2001:db8::2")
llSrcAdd=ICMPv6NDOptSrcLLAddr(lladdr="00:00:00:00:00:01")
 
sol = head/ns/llSrcAdd
 
sol.show()
send(sol)
 
 
 
# Advertisement
head = IPv6()
head.dst = "ff02::1"
 
na=ICMPv6ND_NA(tgt="2001:db8::2",R=0, S=0, O=0)
# R=1 Sender is router, S=1 advertisement send as response to solicitation
# O=1 override flag
 
llDstAdd=ICMPv6NDOptDstLLAddr(lladdr="00:00:00:00:00:02")
 
adv = head/na/llDstAdd
 
adv.show()
send(adv)