예제 #1
0
    def run(self):
        #self.ui.ask("Restart DHCPv6 on the NUT. Enter 'y' and press enter when you have done this.")
        self.logger.info("Sending an Information Request message from TN1.")

        q = self.build_dhcpv6_information_request(self.node(2))
        q = self.build_dhcpv6_relay_forward(q, self.node(2), self.router(1))
        self.router(1).send(
            IPv6(src=str(self.router(1).iface(1).link_local_ip()),
                 dst=AllDHCPv6RelayAgentsAndServers) /
            UDP(sport=DHCPv6SourcePort, dport=DHCPv6DestPort) / q,
            iface=1)

        self.logger.info("Checking for a DHCPv6 Relay Reply message.")
        r2 = self.node(1).received(
            src=str(self.target(1).link_local_ip()),
            dst=str(self.router(1).iface(1).link_local_ip()),
            type=DHCP6_RelayReply)
        assertEqual(1, len(r2), "expected to receive a DHCPv6 Relay Reply")
        p = r2[0]

        self.logger.info(
            "Checking that DHCPv6 Relay Reply is properly formatted.")
        assertEqual(q.hopcount, p.hopcount,
                    "DHCPv6 Relay Reply has an incorrect hop count.")
        assertEqual(IPv6Address(q.peeraddr), p.peeraddr,
                    "DHCPv6 Relay Reply has an incorrect peer address.")
        assertEqual(IPv6Address(q.linkaddr), p.linkaddr,
                    "DHCPv6 Relay Reply has an incorrect link address.")
        assertHasLayer(DHCP6OptRelayMsg, p)
    def run(self):
        if self.ui.ask("Is duplicate address detection configured on the device?"):
            self.ui.ask("Please press Y and then restart the interface being tested or restart the UUT. After pressing Y you will have 5 minutes to restart the interface or UUT.")

        # Result 2
        ns_packets = self.wait_for_neighbor_solicitation()
        assertGreaterThan(0, len(ns_packets), "expected ICMPv6 Neighbor Solicitation to be sent.")

        self.logger.info("Waiting for UUT to assign the IP to it's interface.")
        self.ui.wait(3)

        uut_tentative_ip = IPv6Address.identify(ns_packets[0][ICMPv6ND_NS].tgt)

        # Check it has assigned that ip by pinging it
        self.ping_uut(uut_tentative_ip)
        r1 = self.node(1).received(src=self.target(1).link_local_ip(), seq=self.seq(), type=ICMPv6EchoReply)
        assertEqual(1, len(r1), "expected an ICMPv6 Echo Reply")

        # Step 3 Send NS
        self.node(1).clear_received()
        self.send_neighbor_solicitation_from_node_1(dst=uut_tentative_ip.solicited_node(), target=uut_tentative_ip)

        # Result 4 Receive NA in reply
        na = self.node(1).received(src=uut_tentative_ip, dst="ff02::1", type=ICMPv6ND_NA)
        assertEqual(1, len(na), "expected a ICMPv6 Neighbor Advertisement to be sent.")
    def run(self):
        self.ui.tell("Ensure the RUT transmits a Router Advertisement with the site-local prefix FEC0::/10, and configure a site-local address on ifx.")
        
        self.logger.info("Requesting user to enter the address")
        site_local_ip = IPv6Address(self.ui.read("What is the NUT's Site Local address? (starting fec0:)"))

        assertNotNone(site_local_ip, "expected a valid site-local IPv6 address to be assigned")

        self.logger.info("Sending Echo request to NUT site local address")
        self.node(1).send( \
            IPv6(src=str(self.node(1).link_local_ip()), dst=str(site_local_ip))/
                ICMPv6EchoRequest(seq=self.next_seq()))

        self.logger.info("Checking for reply")
        r1 = self.node(1).received(src=site_local_ip, seq=self.seq(), type=ICMPv6EchoReply)

        assertEqual(1, len(r1), "expected a reply to the ICMPv6 Echo Request")

        self.logger.info("Check packets dst is TN1s link local address")
        assertEqual(self.node(1).link_local_ip(), r1[0].getlayer(IPv6).dst, "expected dst to be TN1's link-local address")

        self.logger.info("Check packet has valid checksum")
        p1 = IPv6(r1[0].build())
        p1.getlayer(ICMPv6EchoReply).cksum = None
        p1 = IPv6(p1.build())

        assertEqual(p1.getlayer(ICMPv6EchoReply).cksum, r1[0].getlayer(ICMPv6EchoReply).cksum, "expected the Echo Reply to have a valid checksum")
예제 #4
0
    def run(self):
        if self.ui.ask(
                "Is duplicate address detection configured on the device?"):
            self.ui.ask(
                "Please press Y and then restart the interface being tested or restart the UUT. After pressing Y you will have 5 minutes to restart the interface or UUT."
            )

        # Result 2
        ns_packets = self.wait_for_neighbor_solicitation()
        assertGreaterThan(0, len(ns_packets),
                          "expected ICMPv6 Neighbor Solicitation to be sent.")

        self.logger.info("Waiting for UUT to assign the IP to it's interface.")
        self.ui.wait(3)

        uut_tentative_ip = IPv6Address.identify(ns_packets[0][ICMPv6ND_NS].tgt)

        # Check it has assigned that ip by pinging it
        self.ping_uut(uut_tentative_ip)
        r1 = self.node(1).received(src=self.target(1).link_local_ip(),
                                   seq=self.seq(),
                                   type=ICMPv6EchoReply)
        assertEqual(1, len(r1), "expected an ICMPv6 Echo Reply")

        # Step 3 Send NS
        self.node(1).clear_received()
        self.send_neighbor_solicitation_from_node_1(
            dst=uut_tentative_ip.solicited_node(), target=uut_tentative_ip)

        # Result 4 Receive NA in reply
        na = self.node(1).received(src=uut_tentative_ip,
                                   dst="ff02::1",
                                   type=ICMPv6ND_NA)
        assertEqual(1, len(na),
                    "expected a ICMPv6 Neighbor Advertisement to be sent.")
예제 #5
0
    def run(self):
        if self.ui.ask("Is duplicate address detection configured on the device?"):
# Initialize the Interface
            self.ui.ask("Please press Y and then restart the interface being tested or UUT. After pressing Y you will have 5 minutes to restart the interface or UUT.")

# Wait for NS to get sent out then send invalid
            ns_packets = self.wait_for_neighbor_solicitation()
            assertGreaterThan(0, len(ns_packets), "expected ICMPv6 Neighbor Solicitation to be sent.")

            uut_tentative = IPv6Address.identify(ns_packets[0][ICMPv6ND_NS].tgt)
            self.logger.info("Got UUT tenative link-local: %s", uut_tentative)
            sol_node_multicast = uut_tentative.solicited_node()

            self.node(1).clear_received()

            # Sending Test Case Specific Packet
            self.logger.info("Sending Test Case Packet: ")
            self.node(1).send(self.test_case_packet(sol_node_multicast=sol_node_multicast, uut_tentative=uut_tentative))

# Allow for DAD and SLAAC
            self.logger.info("Waiting for UUT to assign the IP to it's interface.")
            self.ui.wait(3)

# Observable Results
# Not assign address and not transmit any RS
            # ping device on dst ip sent as target in DAD NS to check it has not assigned that ip
            self.ping_uut(str(uut_tentative))
            r1 = self.node(1).received(src=self.target(1).link_local_ip(), dst=self.node(1).link_local_ip(), seq=self.seq(), type=ICMPv6EchoReply)
            assertEqual(0, len(r1), "not expected an ICMPv6 Echo Reply")            

# Send NS
            self.node(1).clear_received()
            self.send_neighbor_solicitation_from_node_1(dst=sol_node_multicast, target=uut_tentative)


# Observable Result
# Don't get NA in return
            na = self.node(1).received(src=uut_tentative, dst="ff02::1", type=ICMPv6ND_NA)
            assertEqual(0, len(na), "expected a ICMPv6 Neighbor Advertisement to be sent.")

# Send NS
            self.node(1).clear_received()
            self.send_neighbor_solicitation_from_node_1(src=str(self.node(1).link_local_ip()), dst=uut_tentative, target=uut_tentative)

# Observation Result
# Don't get NA in return
            na = self.node(1).received(src=uut_tentative, dst=self.node(1).link_local_ip(), type=ICMPv6ND_NA)
            assertEqual(0, len(na), "expected a ICMPv6 Neighbor Advertisement to be sent.")

            self.node(1).clear_received()
            self.logger.info("Send echo request to tn4 through the RUT")
            self.node(1).send(IPv6(src=str(self.node(1).link_local_ip()), dst=str(self.node(4).global_ip))/ICMPv6EchoRequest(seq=self.next_seq()))

            echo_req = self.node(4).received(src=self.target(1).link_local_ip(), seq=self.seq(), type=ICMPv6EchoRequest)
            assertEqual(0, len(echo_req), "not expected an ICMPv6 Echo Request to be forwarded to TN4")
예제 #6
0
    def run(self):
        if self.ui.ask("Is duplicate address detection configured on the device?"):
            # Initialize the Interface
            self.restart_interface_async()

            # Wait for NS to get sent out then send invalid
            ns_packets = self.wait_for_neighbor_solicitation()
            assertGreaterThan(0, len(ns_packets), "expected ICMPv6 Neighbor Solicitation to be sent.")

            uut_tentative = IPv6Address.identify(ns_packets[0][ICMPv6ND_NS].tgt)
            self.logger.info("Got UUT tenative link-local: %s", uut_tentative)
            sol_node_multicast = uut_tentative.solicited_node()

            self.node(1).clear_received()

            # Sending Test Case Specific Packet
            self.logger.info("Sending Test Case Packet:")
            self.node(1).send(self.test_case_packet(sol_node_multicast=sol_node_multicast, uut_tentative=uut_tentative))

            # Allow for DAD and SLAAC
            self.logger.info("Waiting for UUT to assign the IP to it's interface.")
            self.ui.wait(3)

            # Observable result
            # ping device on dst ip sen as target in DAD NS to check it has now assigned that ip
            self.logger.info("Ping UUT on tentative IP")
            self.ping_uut(str(uut_tentative))

            r1 = self.node(1).received(
                src=self.target(1).link_local_ip(),
                dst=self.node(1).link_local_ip(),
                seq=self.seq(),
                type=ICMPv6EchoReply,
            )
            assertEqual(1, len(r1), "expected an ICMPv6 Echo Reply")

            # Send NS
            self.node(1).clear_received()
            self.send_neighbor_solicitation_from_node_1(dst=sol_node_multicast, target=uut_tentative)

            # Observable Result
            # Get NA in return
            na = self.node(1).received(src=uut_tentative, dst="ff02::1", type=ICMPv6ND_NA)
            assertEqual(1, len(na), "expected a ICMPv6 Neighbor Advertisement to be sent.")

            # Send NS
            self.node(1).clear_received()
            self.send_neighbor_solicitation_from_node_1(
                src=str(self.node(1).link_local_ip()), dst=uut_tentative, target=uut_tentative
            )

            # Observation Result
            # Get NA in return
            na = self.node(1).received(src=uut_tentative, dst=self.node(1).link_local_ip(), type=ICMPv6ND_NA)
            assertEqual(1, len(na), "expected a ICMPv6 Neighbor Advertisement to be sent.")
    def run(self):
        self.logger.info("Sending RA for Site-Local prefix")
        self.logger.info("Send Router advertisement with site local prefix FEC0::/10")
        self.router(1).send( \
            IPv6(src=str(self.router(1).link_local_ip(iface=1)), dst="ff02::1")/
                ICMPv6ND_RA(routerlifetime=90, reachabletime=10, retranstimer=1)/
                    ICMPv6NDOptSrcLLAddr(lladdr=self.router(1).iface(1).ll_addr)/
                    ICMPv6NDOptMTU(mtu=self.router(1).iface(1).ll_protocol.mtu)/
                    ICMPv6NDOptPrefixInfo(validlifetime=90, preferredlifetime=90, prefix="fec0::", prefixlen=64), iface=1)
        # TODO: review the use of the prefix length 64, technically it should
        #       be 10, but this results in an error stating the prefix is
        #       invalid
        
        self.logger.info("Requesting user to enter the address")
        site_local_ip = IPv6Address(self.ui.read("What is the NUT's Site Local address? (starting fec0:)"))

        assertNotNone(site_local_ip, "expected a valid site-local IPv6 address to be assigned")
        
        self.logger.info("Sending Echo request to NUT site local address")
        self.node(1).send( \
            IPv6(src=str(self.node(1).link_local_ip()), dst=str(site_local_ip))/
                ICMPv6EchoRequest(seq=self.next_seq()))
        
        self.logger.info("Checking for reply")
        r1 = self.node(1).received(src=site_local_ip, seq=self.seq(), type=ICMPv6EchoReply)

        assertEqual(1, len(r1), "expected a reply to the ICMPv6 Echo Request")
        
        self.logger.info("Check packets dst is TN1s link local address")
        assertEqual(self.node(1).link_local_ip(), r1[0].getlayer(IPv6).dst, "expected dst to be TN1's link-local address")

        self.logger.info("Check packet has valid checksum")
        p1 = IPv6(r1[0].build())
        p1.getlayer(ICMPv6EchoReply).cksum = None
        p1 = IPv6(p1.build())

        assertEqual(p1.getlayer(ICMPv6EchoReply).cksum, r1[0].getlayer(ICMPv6EchoReply).cksum, "expected the Echo Reply to have a valid checksum")
예제 #8
0
    def test_it_should_identify_a_v6_address_as_multicast(self):
        ip = IPv6Address("ff01::2")

        self.assertTrue(ip.is_multicast())
예제 #9
0
    def test_it_should_get_the_canonical_form_of_a_v6_address(self):
        ip = IPv6Address("2001:500:88:200::10")

        self.assertEqual("2001:0500:0088:0200:0000:0000:0000:0010", ip.canonical_form())
예제 #10
0
    def test_it_should_get_the_short_form_of_a_v6_address(self):
        ip = IPv6Address("2001:500:88:200::10")

        self.assertEqual("2001:500:88:200::10", ip.short_form())
예제 #11
0
 def test_it_should_recognise_a_short_form_ipv6_address(self):
     self.assertTrue(IPv6Address.is_valid("2001:500:88:200::10"))
예제 #12
0
    def test_it_should_have_a_netmask(self):
        ip = IPv6Address("2001:500:88:200::10")

        self.assertEqual("ffff:ffff:ffff:ffff:0000:0000:0000:0000", ip.netmask())
예제 #13
0
    def test_it_should_identify_a_v6_address_as_a_tunnel(self):
        ip = IPv6Address("2002:500:88:200::10")

        self.assertTrue(ip.is_tunnel())
예제 #14
0
    def run(self):
        if self.ui.ask("Is duplicate address detection configured on the device?"):
            # Initialize the Interface
            self.restart_interface_async()

            # Wait for NS to get sent out then send invalid
            ns_packets = self.wait_for_neighbor_solicitation()
            assertGreaterThan(0, len(ns_packets), "expected ICMPv6 Neighbor Solicitation to be sent.")

            uut_tentative = IPv6Address.identify(ns_packets[0][ICMPv6ND_NS].tgt)
            self.logger.info("Got UUT tenative link-local: %s", uut_tentative)
            sol_node_multicast = uut_tentative.solicited_node()

            self.node(1).clear_received()

            # Sending Test Case Specific Packet
            self.logger.info("Sending Test Case Packet:")
            self.node(1).send(self.test_case_packet(sol_node_multicast=sol_node_multicast, uut_tentative=uut_tentative))

            # Allow for DAD and SLAAC
            self.logger.info("Waiting for UUT to assign the IP to it's interface.")
            self.ui.wait(3)

            # Observable Results
            # Not assign address and not transmit any RS
            # ping device on dst ip sent as target in DAD NS to check it has not assigned that ip
            self.ping_uut(str(uut_tentative))
            r1 = self.node(1).received(
                src=self.target(1).link_local_ip(),
                dst=self.node(1).link_local_ip(),
                seq=self.seq(),
                type=ICMPv6EchoReply,
            )
            assertEqual(0, len(r1), "not expected an ICMPv6 Echo Reply")

            self.logger.info("Check no router solicitations have been sent out by the UUT.")

            # check no router solicitations were sent out
            self.ui.wait(1)
            rs = self.node(1).received(src=uut_tentative, dst="ff02::2", type=ICMPv6ND_RS)
            assertEqual(0, len(rs), "not expecting router solicitation")

            # Send NS
            self.node(1).clear_received()
            self.send_neighbor_solicitation_from_node_1(dst=sol_node_multicast, target=uut_tentative)

            # Observable Result
            # Don't get NA in return
            na = self.node(1).received(src=uut_tentative, dst="ff02::1", type=ICMPv6ND_NA)
            assertEqual(0, len(na), "expected a ICMPv6 Neighbor Advertisement to be sent.")

            # Send NS
            self.node(1).clear_received()
            self.send_neighbor_solicitation_from_node_1(
                src=str(self.node(1).link_local_ip()), dst=uut_tentative, target=uut_tentative
            )

            # Observation Result
            # Don't get NA in return
            na = self.node(1).received(src=uut_tentative, dst=self.node(1).link_local_ip(), type=ICMPv6ND_NA)
            assertEqual(0, len(na), "expected a ICMPv6 Neighbor Advertisement to be sent.")

            # Send RA with prefix
            self.logger.info(
                "Sending Router Advertisement with prefix %s", self.router(1).iface(0).global_ip().network()
            )
            ll_info = ICMPv6NDOptSrcLLAddr(lladdr=self.router(1).iface(0).ll_addr)
            link_mtu_info = ICMPv6NDOptMTU(mtu=self.router(1).iface(0).ll_protocol.mtu)
            prefix_info = ICMPv6NDOptPrefixInfo(
                validlifetime=20,
                preferredlifetime=20,
                prefixlen=self.router(1).iface(0).global_ip().prefix_size,
                prefix=self.router(1).iface(0).global_ip().network(),
            )
            self.router(1).send(
                IPv6(src=str(self.router(1).iface(0).link_local_ip()), dst="ff02::1")
                / ICMPv6ND_RA()
                / ll_info
                / link_mtu_info
                / prefix_info,
                iface=1,
            )

            # Send NS for global address
            self.node(1).clear_received()
            self.send_neighbor_solicitation_from_node_1(src="::", dst=uut_tentative, target=self.target(1).global_ip())

            # Observation Result
            # Don't get NA in return
            na = self.node(1).received(src=uut_tentative, dst=self.node(1).link_local_ip(), type=ICMPv6ND_NA)
            assertEqual(0, len(na), "expected a ICMPv6 Neighbor Advertisement for global address to be sent.")
예제 #15
0
    def test_it_should_implement__ne__for_a_pair_of_v6_addresses(self):
        ip1 = IPv6Address("2001:500:88:200::10")
        ip2 = IPv6Address("2001:500:88:200::20")

        self.assertTrue(ip1 != ip2)
        self.assertFalse(ip1 != ip1)
예제 #16
0
 def test_it_should_not_recognise_an_ipv4_address_as_v6(self):
     self.assertFalse(IPv6Address.is_valid("192.0.43.10"))
예제 #17
0
    def test_it_should_implement__eq__for_a_v6_and_a_v6str_addresses(self):
        ip1 = IPv6Address("2001:500:88:200::10")
        ip2 = IPv6Address("2001:500:88:200::20")

        self.assertTrue(ip1 == str(ip1))
        self.assertFalse(ip1 == str(ip2))
예제 #18
0
    def test_it_should_implement__eq__for_a_v4str_and_a_v6_addresses(self):
        ip1 = IPv4Address("192.0.43.10")
        ip2 = IPv6Address("2001:500:88:200::20")

        self.assertFalse(str(ip2) == ip1)
예제 #19
0
    def test_it_should_calculate_the_network_prefix_of_a_slash_96(self):
        ip = IPv6Address("2001:500:88:200::10")
        ip.prefix_size = 96

        self.assertEqual("2001:0500:0088:0200:0000:0000:0000:0000", ip.network())
예제 #20
0
 def test_it_should_not_recognise_a_non_ip_address_as_v6(self):
     self.assertFalse(IPv6Address.is_valid("not a v6 address"))
예제 #21
0
    def test_it_should_change_the_netmask_to_reflect_the_subnet_prefix_size(self):
        ip = IPv6Address("2001:500:88:200::10")
        ip.prefix_size = 96

        self.assertEqual("ffff:ffff:ffff:ffff:ffff:ffff:0000:0000", ip.netmask())
예제 #22
0
 def test_it_should_recognise_a_valid_ipv6_address(self):
     self.assertTrue(IPv6Address.is_valid("2001:0500:0088:0200:0000:0000:0000:0010"))
예제 #23
0
    def run(self):
        if self.ui.ask(
                "Is duplicate address detection configured on the device?"):
            # Initialize the Interface
            self.ui.ask(
                "Please press Y and then restart the interface being tested or UUT. After pressing Y you will have 5 minutes to restart the interface or UUT."
            )

            # Wait for NS to get sent out then send invalid
            ns_packets = self.wait_for_neighbor_solicitation()
            assertGreaterThan(
                0, len(ns_packets),
                "expected ICMPv6 Neighbor Solicitation to be sent.")

            uut_tentative = IPv6Address.identify(
                ns_packets[0][ICMPv6ND_NS].tgt)
            self.logger.info("Got UUT tenative link-local: %s", uut_tentative)
            sol_node_multicast = uut_tentative.solicited_node()

            self.node(1).clear_received()

            # Sending Test Case Specific Packet
            self.logger.info("Sending Test Case Packet:")
            self.node(1).send(
                self.test_case_packet(sol_node_multicast=sol_node_multicast,
                                      uut_tentative=uut_tentative))

            # Allow for DAD and SLAAC
            self.logger.info(
                "Waiting for UUT to assign the IP to it's interface.")
            self.ui.wait(3)

            # Observable result
            # ping device on dst ip sen as target in DAD NS to check it has now assigned that ip
            self.logger.info("Ping UUT on tentative IP")
            self.ping_uut(str(uut_tentative))

            r1 = self.node(1).received(src=self.target(1).link_local_ip(),
                                       dst=self.node(1).link_local_ip(),
                                       seq=self.seq(),
                                       type=ICMPv6EchoReply)
            assertEqual(1, len(r1), "expected an ICMPv6 Echo Reply")

            # Send NS
            self.node(1).clear_received()
            self.send_neighbor_solicitation_from_node_1(dst=sol_node_multicast,
                                                        target=uut_tentative)

            # Observable Result
            # Get NA in return
            na = self.node(1).received(src=uut_tentative,
                                       dst="ff02::1",
                                       type=ICMPv6ND_NA)
            assertEqual(
                1, len(na),
                "expected a ICMPv6 Neighbor Advertisement to be sent.")

            # Send NS
            self.node(1).clear_received()
            self.send_neighbor_solicitation_from_node_1(src=str(
                self.node(1).link_local_ip()),
                                                        dst=uut_tentative,
                                                        target=uut_tentative)

            # Observation Result
            # Get NA in return
            na = self.node(1).received(src=uut_tentative,
                                       dst=self.node(1).link_local_ip(),
                                       type=ICMPv6ND_NA)
            assertEqual(
                1, len(na),
                "expected a ICMPv6 Neighbor Advertisement to be sent.")
예제 #24
0
    def test_it_should_not_identify_a_v6_address_as_multicast(self):
        ip = IPv6Address("2001:500:88:200::10")

        self.assertFalse(ip.is_multicast())
예제 #25
0
    def test_it_should_identify_a_v6_multicast_address_as_global_scope(self):
        ip = IPv6Address("ffe0::200:10")

        self.assertEqual('global', ip.scope())
예제 #26
0
    def test_it_should_identify_a_v6_multicast_address_as_organisation_local_scope(self):
        ip = IPv6Address("ff80::200:10")

        self.assertEqual('organisation-local', ip.scope())
예제 #27
0
    def test_it_should_canonicalise_a_v6_address(self):
        ip = IPv6Address("2001:500:88:200::10")

        self.assertEqual("2001:0500:0088:0200:0000:0000:0000:0010", str(ip))
예제 #28
0
    def test_it_should_identify_a_v6_multicast_address_as_site_local_scope(self):
        ip = IPv6Address("ff50::200:10")

        self.assertEqual('site-local', ip.scope())
예제 #29
0
    def test_it_should_canonicalise_a_v4_mapped_address(self):
        ip = IPv6Address("::ffff:10.0.0.1")

        self.assertEqual("0000:0000:0000:0000:0000:ffff:0a00:0001", str(ip))
예제 #30
0
    def test_it_should_compare_ipv6_addresses_case_insensitively(self):
        ip1 = IPv6Address("2001:db8::1")

        self.assertTrue(ip1 == "2001:DB8::1")
        
예제 #31
0
    def test_it_should_have_a_subnet_prefix_size(self):
        ip = IPv6Address("2001:500:88:200::10")

        self.assertEqual(64, ip.prefix_size)
예제 #32
0
    def run(self):
        if self.ui.ask(
                "Is duplicate address detection configured on the device?"):
            # Initialize the Interface
            self.ui.ask(
                "Please press Y and then restart the interface being tested or UUT. After pressing Y you will have 5 minutes to restart the interface or UUT."
            )

            # Wait for NS to get sent out then send invalid
            ns_packets = self.wait_for_neighbor_solicitation()
            assertGreaterThan(
                0, len(ns_packets),
                "expected ICMPv6 Neighbor Solicitation to be sent.")

            uut_tentative = IPv6Address.identify(
                ns_packets[0][ICMPv6ND_NS].tgt)
            self.logger.info("Got UUT tenative link-local: %s", uut_tentative)
            sol_node_multicast = uut_tentative.solicited_node()

            self.node(1).clear_received()

            # Sending Test Case Specific Packet
            self.logger.info("Sending Test Case Packet:")
            self.node(1).send(
                self.test_case_packet(sol_node_multicast=sol_node_multicast,
                                      uut_tentative=uut_tentative))

            # Allow for DAD and SLAAC
            self.logger.info(
                "Waiting for UUT to assign the IP to it's interface.")
            self.ui.wait(3)

            # Observable Results
            # Not assign address and not transmit any RS
            # ping device on dst ip sent as target in DAD NS to check it has not assigned that ip
            self.ping_uut(str(uut_tentative))
            r1 = self.node(1).received(src=self.target(1).link_local_ip(),
                                       dst=self.node(1).link_local_ip(),
                                       seq=self.seq(),
                                       type=ICMPv6EchoReply)
            assertEqual(0, len(r1), "not expected an ICMPv6 Echo Reply")

            self.logger.info(
                "Check no router solicitations have been sent out by the UUT.")

            # check no router solicitations were sent out
            self.ui.wait(1)
            rs = self.node(1).received(src=uut_tentative,
                                       dst="ff02::2",
                                       type=ICMPv6ND_RS)
            assertEqual(0, len(rs), "not expecting router solicitation")

            # Send NS
            self.node(1).clear_received()
            self.send_neighbor_solicitation_from_node_1(dst=sol_node_multicast,
                                                        target=uut_tentative)

            # Observable Result
            # Don't get NA in return
            na = self.node(1).received(src=uut_tentative,
                                       dst="ff02::1",
                                       type=ICMPv6ND_NA)
            assertEqual(
                0, len(na),
                "expected a ICMPv6 Neighbor Advertisement to be sent.")

            # Send NS
            self.node(1).clear_received()
            self.send_neighbor_solicitation_from_node_1(src=str(
                self.node(1).link_local_ip()),
                                                        dst=uut_tentative,
                                                        target=uut_tentative)

            # Observation Result
            # Don't get NA in return
            na = self.node(1).received(src=uut_tentative,
                                       dst=self.node(1).link_local_ip(),
                                       type=ICMPv6ND_NA)
            assertEqual(
                0, len(na),
                "expected a ICMPv6 Neighbor Advertisement to be sent.")

            # Send RA with prefix
            self.logger.info("Sending Router Advertisement with prefix %s",
                             self.router(1).iface(0).global_ip().network())
            ll_info = ICMPv6NDOptSrcLLAddr(
                lladdr=self.router(1).iface(0).ll_addr)
            link_mtu_info = ICMPv6NDOptMTU(
                mtu=self.router(1).iface(0).ll_protocol.mtu)
            prefix_info = ICMPv6NDOptPrefixInfo(
                validlifetime=20,
                preferredlifetime=20,
                prefixlen=self.router(1).iface(0).global_ip().prefix_size,
                prefix=self.router(1).iface(0).global_ip().network())
            self.router(1).send(
                IPv6(src=str(self.router(1).iface(0).link_local_ip()),
                     dst="ff02::1") / ICMPv6ND_RA() / ll_info / link_mtu_info /
                prefix_info,
                iface=1)

            # Send NS for global address
            self.node(1).clear_received()
            self.send_neighbor_solicitation_from_node_1(
                src="::", dst=uut_tentative, target=self.target(1).global_ip())

            # Observation Result
            # Don't get NA in return
            na = self.node(1).received(src=uut_tentative,
                                       dst=self.node(1).link_local_ip(),
                                       type=ICMPv6ND_NA)
            assertEqual(
                0, len(na),
                "expected a ICMPv6 Neighbor Advertisement for global address to be sent."
            )
예제 #33
0
 def test_it_should_return_a_v6_address_as_a_string(self):
     ip = IPv6Address("2001:0500:0088:0200:0000:0000:0000:0010")
     
     self.assertEqual("2001:0500:0088:0200:0000:0000:0000:0010", str(ip))
예제 #34
0
 def global_ip_y(self):
     return  IPv6Address(self.prefix_y() + in6_mactoifaceid(self.target(1).ll_addr()))
예제 #35
0
    def test_it_should_return_the_version_of_a_v6_address(self):
        ip = IPv6Address("2001:0500:0088:0200:0000:0000:0000:0010")

        self.assertEqual(6, ip.version())