def test_all_replies_with_fragmentation(self): self.ifx.replies_with( util.pad( IPv6( src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) self.ifx.replies_with( fragment6( util.pad( IPv6( src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True), 1400)) self.ifx.replies_with(None) self.ifx.replies_with( fragment6( util.pad( IPv6( src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True), 1280)) o = self.get_outcome(suite.ReducePMTUOffLinkTestCase) self.assertCheckPasses(o)
def test_valid(self): self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) self.ifx.replies_with( fragment6( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True), 1304)) self.ifx.replies_with(None) self.ifx.replies_with( fragment6( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True), 1304)) o = self.get_outcome(suite.MTUIncreaseTestCase) self.assertCheckPasses(o)
def test_pmtu_increase_too_early(self): self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) for i in range(0, 5): self.ifx.replies_with( fragment6( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True), 1304)) for i in range(5, 6): self.ifx.replies_with( fragment6( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True), 1500)) o = self.get_outcome(suite.CheckingForIncreaseInPMTUTestCase) self.assertCheckFails(o)
def run(self): self.logger.info("Forwarding ICMPv6 echo request from TN2 to NUT...") self.node(2).send( \ util.pad( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1500, True)) self.logger.info("Checking for a reply...") r1 = self.node(2).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual(1, len(r1), "expected to receive an ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertNotFragmented(r1[0]) self.logger.info("Sending Router Advertisement from TR1, with the MTU option set to 1280") self.router(1).send( IPv6(src=str(self.router(1).link_local_ip(iface=1)), dst="ff01::2")/ ICMPv6ND_RA()/ ICMPv6NDOptMTU(mtu=1280), iface=1) self.logger.info("Forwarding another ICMPv6 echo request from TN2 to NUT...") for f in fragment6(util.pad(IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ICMPv6EchoRequest(seq=self.next_seq()), 1500, True), 1280): self.node(2).send(f) self.ui.wait(5) self.logger.info("Checking for replies...") r2 = self.node(2).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual(1, len(r2), "expected to receive an ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertFragmented(r2[0], self.node(1).received(), count=2, size=1280, reassemble_to=1500)
def run(self): self.logger.info("Forwarding ICMPv6 echo request from TN2 to NUT...") self.node(2).send( \ util.pad( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1280, True)) self.logger.info("Checking for a reply...") r1 = self.node(2).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual(1, len(r1), "expected to receive an ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertNotFragmented(r1[0]) self.logger.info("Sending Packet Too Big message to NUT for Echo Reply with MTU set to %d" % (self.mtu)) self.router(1).send( IPv6(src=str(self.router(1).global_ip(iface=1)), dst=str(self.target(1).global_ip()))/ ICMPv6PacketTooBig(mtu=56)/ Raw(load=r1[0].build()[:(56-48)]), iface=1) self.node(2).clear_received() self.logger.info("Forwarding another ICMPv6 echo request from TN2 to NUT...") self.node(2).send( \ util.pad( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1280, True)) self.ui.wait(5) self.logger.info("Checking for replies...") r2 = self.node(2).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual(1, len(r2), "expected to receive an ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertHasLayer(IPv6ExtHdrFragment, r2[0], "expected the Echo Reply to contain a fragment header")
def run(self): self.logger.info("Forwarding ICMPv6 echo request from TN2 to NUT") self.node(2).send( \ util.pad( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1500, True)) self.logger.info("Checking for a reply...") r1 = self.node(2).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual(1, len(r1), "expected to receive a ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertNotFragmented(r1[0]) self.logger.info("Sending Packet Too Big message to NUT for Echo Reply for TN2") self.node(2).send( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6PacketTooBig(mtu=1280, code=0xFF)/ Raw(load=r1[0].build()[:(1280-48)])) self.node(2).clear_received() self.logger.info("Forwarding ICMPv6 echo request from TN2 to NUT") self.node(2).send( \ util.pad( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1500, True)) self.logger.info("Checking for fragmented replies...") r2 = self.node(2).received(src=self.target(1).global_ip()) self.ui.wait(5) self.logger.info("Checking for replies...") r2 = self.node(2).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual(1, len(r2), "expected to receive an ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertFragmented(r2[0], self.node(2).received(), count=2, size=1280, reassemble_to=1500)
def test_valid(self): self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1280)) o = self.get_outcome(suite.RouterAdvertisementWithMTUOptionTestCase) self.assertCheckPasses(o)
def test_all_replies_with_fragmentation(self): self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) self.ifx.replies_with( fragment6( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True), 1400)) self.ifx.replies_with(None) self.ifx.replies_with( fragment6( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True), 1280)) o = self.get_outcome(suite.ReducePMTUOffLinkTestCase) self.assertCheckPasses(o)
def test_third_reply_fragmented_size_increased(self): self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) self.ifx.replies_with( fragment6( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True), 1304)) self.ifx.replies_with(None) self.ifx.replies_with( fragment6( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True), 1500)) o = self.get_outcome(suite.MTUEqualTo0x1ffffffTestCase) self.assertCheckFails(o)
def test_second_reply_not_fragmented(self): self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) o = self.get_outcome(suite.RouterAdvertisementWithMTUOptionTestCase) self.assertCheckFails(o)
def test_no_subsequent_replies(self): self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1304)) o = self.get_outcome(suite.CheckingForIncreaseInPMTUTestCase) self.assertCheckFails(o)
def test_unfragmented_reply_without_fragmentation_header(self): self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1280, True)) self.ifx.replies_with(None) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1280, True)) o = self.get_outcome(suite.MTUEqualTo56TestCase) self.assertCheckFails(o)
def test_valid_fragmentation(self): # or lack thereof self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1280, True)) self.ifx.replies_with(None) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1280, True)) o = self.get_outcome(suite.MTUEqualTo56TestCase) self.assertCheckPasses(o)
def test_first_and_second_no_fragmentation(self): self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True)) o = self.get_outcome(suite.ReducePMTUOffLinkTestCase) self.assertCheckFails(o)
def test_no_reply_to_third_echo_request(self): self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1304)) o = self.get_outcome(suite.MTUIncreaseTestCase) self.assertCheckFails(o)
def test_second_reply_is_not_fragmented(self): self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True)) o = self.get_outcome(suite.MTUEqualTo0x1ffffffTestCase) self.assertCheckFails(o)
def test_fragmented_below_minimum_mtu(self): self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1280, True)) self.ifx.replies_with(None) self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1280, True), 1279)) o = self.get_outcome(suite.MTUEqualTo1279TestCase) self.assertCheckFails(o)
def test_second_reply_not_fragmented(self): self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) o = self.get_outcome(suite.CheckingForIncreaseInPMTUTestCase) self.assertCheckFails(o)
def test_valid(self): self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1304)) self.ifx.replies_with(None) self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1304)) o = self.get_outcome(suite.MTUEqualTo0x1ffffffTestCase) self.assertCheckPasses(o)
def test_all_replies(self): # Step 14: We expect the NUT to respond to echo requests from TN1, TN2 # and TN3 with fragmented packets, because we have changed the # MTU on the links. self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn1.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn3.global_ip()))/ICMPv6EchoReply(), 1500, True)) # Step 5: we have sent a Packet Too Big message from TN2, it gets no # reply self.ifx.replies_with(None) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn1.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1400)) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn3.global_ip()))/ICMPv6EchoReply(), 1500, True)) # Step 10: we have sent a Packet Too Big message from TN3, it gets no # reply self.ifx.replies_with(None) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn1.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1400)) self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn3.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1280)) o = self.get_outcome(suite.StoredPMTUTestCase) self.assertCheckPasses(o)
def test_all_replies_fragmented_to_maximum_mtu(self): # Step 14: We expect the NUT to respond to echo requests from TN1, TN2 # and TN3 a second time, with packets from TN2 fragmented # because we have changed the MTU on the links. # We actually, deliver fragments that are too large. self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn1.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn3.global_ip()))/ICMPv6EchoReply(), 1500, True)) # Step 5: we have sent a Packet Too Big message from TN2, it gets no # reply self.ifx.replies_with(None) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn1.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1400)) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn3.global_ip()))/ICMPv6EchoReply(), 1500, True)) # Step 10: we have sent a Packet Too Big message from TN3, it gets no # reply self.ifx.replies_with(None) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn1.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1400)) self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn3.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1400)) o = self.get_outcome(suite.StoredPMTUTestCase) self.assertCheckFails(o)
def test_first_reply_from_tn3_missing(self): # Step 4: We expect the NUT to respond to echo requests from TN1, TN2 # and TN3. # We actually, only deliver the replies from TN1 and TN2. self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn1.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) o = self.get_outcome(suite.StoredPMTUTestCase) self.assertCheckFails(o)
def test_second_reply_not_fragmented(self): self.ifx.replies_with( util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 1500, True) ) self.ifx.replies_with( util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 1500, True) ) o = self.get_outcome(suite.RouterAdvertisementWithMTUOptionTestCase) self.assertCheckFails(o)
def test_pmtu_increase_too_early(self): self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) for i in range(0, 5): self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1304)) for i in range(5, 6): self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1500)) o = self.get_outcome(suite.CheckingForIncreaseInPMTUTestCase) self.assertCheckFails(o)
def run(self): self.logger.info("Forwarding ICMPv6 echo request from TN2 to NUT...") self.node(2).send( \ util.pad( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1500, True)) self.logger.info("Checking for a reply...") r1 = self.node(2).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual(1, len(r1), "expected to receive an ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertNotFragmented(r1[0]) self.logger.info("Sending a Packet Too Big message to NUT with MTU set to 1304...") self.router(1).send( \ IPv6(src=str(self.router(1).global_ip(iface=1)), dst=str(self.target(1).global_ip()))/ ICMPv6PacketTooBig(mtu=1304)/ Raw(load=r1[0].build()[:(1304-48)]), iface=1) self.node(2).clear_received() self.logger.info("Forwarding another ICMPv6 echo request from TN2 to NUT...") self.node(2).send( \ util.pad( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1500, True)) self.ui.wait(5) self.logger.info("Checking for replies...") r2 = self.node(2).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual(1, len(r2), "expected to receive an ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertFragmented(r2[0], self.node(2).received(), count=2, size=1304, reassemble_to=1500) for i in range(0,5): self.ui.wait(30) self.node(2).clear_received() self.logger.info("Forwarding another ICMPv6 echo request from TN2 to NUT (%d)..." % (i)) self.node(2).send( \ util.pad( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1500, True)) self.ui.wait(5) self.logger.info("Checking for replies...") r2 = self.node(2).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual(1, len(r2), "expected to receive an ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertFragmented(r2[0], self.node(2).received(), count=2, size=1304, reassemble_to=1500)
def test_unfragmented_reply_without_fragmentation_header(self): self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 1280, True)) self.ifx.replies_with(None) self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 1280, True)) o = self.get_outcome(suite.MTUEqualTo56TestCase) self.assertCheckFails(o)
def test_valid_fragmentation(self): # or lack thereof self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 1280, True)) self.ifx.replies_with(None) self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1280, True)) o = self.get_outcome(suite.MTUEqualTo1279TestCase) self.assertCheckPasses(o)
def test_first_and_second_no_fragmentation(self): self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True)) o = self.get_outcome(suite.ReducePMTUOffLinkTestCase) self.assertCheckFails(o)
def run(self): self.logger.info("Sending ICMPv6 echo request from TN4 to TN2, via 6in6 tunnel.") self.node(4).send( util.pad(IPv6(src=str(self.node(4).global_ip()), dst=str(self.node(2).global_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1360, True)) self.logger.info("Checking for the ICMPv6 Echo Request forwarded to TR1...") r1 = self.router(1).received(iface=1, seq=self.seq(), type=ICMPv6EchoRequest) assertEqual(1, len(r1), "expected the Echo Request to be tunnelled to TR1") self.logger.info("Sending packet too big message from TR1 to RUT.") self.node(1).send(( IPv6(src=str(self.router(1).iface(1).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6PacketTooBig(mtu=1280)/ r1[0])[0:1280]) self.logger.info("Checking that RUT has forwarded a Packet Too Big message to TN4...") r2 = self.node(4).received(type=ICMPv6PacketTooBig) assertEqual(1, len(r2), "expected the RUT to forward a Packet Too Big message to TN4") assertEqual(0x00, r2[0][ICMPv6PacketTooBig].code, "expected the Unreachable Node to have a Code field = 0") assertHasLayer(ICMPv6EchoRequest, r2[0], "expected the Hop Limit Exceeded message to contain the original Echo Request") assertEqual(self.seq(), r2[0][ICMPv6EchoRequest].seq, "expected the Hop Limit Exceeded message to contain the original Echo Request") assertEqual(ICMPv6EchoRequest, r2[0][ICMPv6PacketTooBig][2].__class__, "did not expect the error message to include the tunnel frame")
def test_no_reply_to_second_echo_request(self): self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) o = self.get_outcome(suite.MTUEqualTo0x1ffffffTestCase) self.assertCheckFails(o)
def run(self): assertTrue(self.ui.ask("Does the RUT support multicast routing?", True)) # TODO: configure the RUT's link MTU on link C to be 1280, the minimum # IPv6 MTU self.logger.info("Sending packet from TN1 to TN2") self.node(1).send( \ util.pad( \ IPv6(src=str(self.node(1).global_ip()), dst="ff1e::1:2")/ ICMPv6EchoRequest(seq=self.next_seq()), 1500, True, False)) self.logger.info("Checking for a forwarded ICMPv6 Echo Request...") r1 = self.node(4).received(type=ICMPv6EchoRequest) assertEqual(0, len(r1), "did not expect the ICMPv6 Echo Request to be forwarded to TN4") self.logger.info("Checking for an ICMPv6 Packet Too Big message...") r2 = self.node(1).received(type=ICMPv6PacketTooBig) assertEqual(1, len(r2), "expected to receive an ICMPv6 Packet Too Big message") self.logger.info("Checking MTU of PacketTooBig is set to 1280") assertEqual(1280, r2[0].getlayer(ICMPv6PacketTooBig).mtu, "Expecting mtu of packet too big error to equal 1280") self.logger.info("Checking src is correct") assertTrue(r2[0].getlayer(IPv6).src in self.target(1).ip(offset='*', scope='*')) self.logger.info("Checking code is correct") assertEqual(0, r2[0].getlayer(ICMPv6PacketTooBig).code, "Expecting code to equal 0") self.logger.info("Checking MTU of packet does not exceed minimum MTU") assertLessThan(1281, len(r2[0]), "Expecting MTU of received packet not to exceed 1280")
def test_all_replies_round1_with_fragmentation(self): self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn1.global_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1280)) o = self.get_outcome(suite.ReducePMTUOnLinkGlobalTestCase) self.assertCheckFails(o)
def test_second_reply_from_tn1_missing(self): # Step 9: We expect the NUT to respond to echo requests from TN1, TN2 # and TN3 a second time. # We do not deliver any of the second round of packets. self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn1.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip()))/ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn3.global_ip()))/ICMPv6EchoReply(), 1500, True)) # Step 5: we have sent a Packet Too Big message from TN2, it gets no # reply self.ifx.replies_with(None) o = self.get_outcome(suite.StoredPMTUTestCase) self.assertCheckFails(o)
def test_second_reply_is_not_fragmented(self): self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True)) o = self.get_outcome(suite.MTUIncreaseTestCase) self.assertCheckFails(o)
def run(self): self.logger.info("Transmitting ICMPv6 echo request from TR1 to NUT") self.node(1).send( \ util.pad( \ IPv6(src=str(self.node(1).link_local_ip()), dst=str(self.target(1).link_local_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1500, True)) self.logger.info("Checking for a reply...") r1 = self.node(1).received(src=self.target(1).link_local_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual( 1, len(r1), "expected to receive a ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertNotFragmented(r1[0]) self.logger.info( "Sending Packet Too Big message to NUT for Echo Reply") self.node(1).send( \ IPv6(src=str(self.node(1).link_local_ip()), dst=str(self.target(1).link_local_ip()))/ ICMPv6PacketTooBig(mtu=1280)/ Raw(load=r1[0].build()[:(1280-48)])) self.node(1).clear_received() self.logger.info( "Transmitting another ICMPv6 echo request (but fragmented) from TR1 to NUT" ) for p in fragment6( util.pad( IPv6(src=str(self.node(1).link_local_ip()), dst=str(self.target(1).link_local_ip())) / ICMPv6EchoRequest(seq=self.next_seq()), 1500, True), 1280): self.node(1).send(p) self.ui.wait(5) self.logger.info("Checking for replies...") r2 = self.node(1).received(src=self.target(1).link_local_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual( 1, len(r2), "expected to receive an ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertFragmented(r2[0], self.node(1).received(), count=2, size=1280, reassemble_to=1500)
def run(self): self.logger.info("Forwarding ICMPv6 echo request from TN2 to NUT") self.node(2).send( \ util.pad( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1500, True)) self.logger.info("Checking for a reply...") r1 = self.node(2).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual( 1, len(r1), "expected to receive a ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertNotFragmented(r1[0]) self.logger.info( "Sending Packet Too Big message to NUT for Echo Reply for TN2") self.node(2).send( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6PacketTooBig(mtu=1280, code=0xFF)/ Raw(load=r1[0].build()[:(1280-48)])) self.node(2).clear_received() self.logger.info("Forwarding ICMPv6 echo request from TN2 to NUT") self.node(2).send( \ util.pad( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1500, True)) self.logger.info("Checking for fragmented replies...") r2 = self.node(2).received(src=self.target(1).global_ip()) self.ui.wait(5) self.logger.info("Checking for replies...") r2 = self.node(2).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual( 1, len(r2), "expected to receive an ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertFragmented(r2[0], self.node(2).received(), count=2, size=1280, reassemble_to=1500)
def test_all_replies(self): self.ifx.replies_with(IPv6(src=str(self.ifx.link_local_ip()), dst=str(self.tn1.link_local_ip()))/ICMPv6EchoReply()) self.ifx.replies_with(None) self.ifx.replies_with(fragment6(util.pad(IPv6(src=str(self.ifx.link_local_ip()), dst=str(self.tn1.link_local_ip()))/IPv6ExtHdrFragment()/ICMPv6EchoReply(), 1500, True), 1280)) o = self.get_outcome(suite.ReducePMTUOnLinkLinkLocalTestCase) self.assertCheckPasses(o)
def test_fragmented_below_minimum_mtu(self): self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 1280, True)) self.ifx.replies_with(None) self.ifx.replies_with( fragment6( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1280, True), 56)) o = self.get_outcome(suite.MTUEqualTo56TestCase) self.assertCheckFails(o)
def run(self): self.logger.info("Sending ICMP echo request, with a Payload Length of %s." % self.plen) self.node(1).send(util.pad(IPv6(src=str(self.node(1).global_ip()), dst=str(self.target(1).global_ip()))/ICMPv6EchoRequest(seq=self.next_seq()), self.plen - 8, False)) self.logger.info("Checking for a reply...") r1 = self.node(1).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual(1, len(r1), "expected an ICMPv6 Echo Reply, got %d (seq: %d)" % (len(r1), self.seq()))
def test_no_subsequent_replies(self): self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) self.ifx.replies_with( fragment6( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True), 1304)) o = self.get_outcome(suite.CheckingForIncreaseInPMTUTestCase) self.assertCheckFails(o)
def run(self): self.logger.info("Forwarding ICMPv6 echo request from TN2 to NUT...") self.node(2).send( \ util.pad( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1280, True)) self.logger.info("Checking for a reply...") r1 = self.node(2).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual( 1, len(r1), "expected to receive an ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertNotFragmented(r1[0]) self.logger.info( "Sending Packet Too Big message to NUT for Echo Reply with MTU set to %d" % (self.mtu)) self.router(1).send(IPv6(src=str(self.router(1).global_ip(iface=1)), dst=str(self.target(1).global_ip())) / ICMPv6PacketTooBig(mtu=56) / Raw(load=r1[0].build()[:(56 - 48)]), iface=1) self.node(2).clear_received() self.logger.info( "Forwarding another ICMPv6 echo request from TN2 to NUT...") self.node(2).send( \ util.pad( \ IPv6(src=str(self.node(2).global_ip()), dst=str(self.target(1).global_ip()))/ ICMPv6EchoRequest(seq=self.next_seq()), 1280, True)) self.ui.wait(5) self.logger.info("Checking for replies...") r2 = self.node(2).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual( 1, len(r2), "expected to receive an ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertHasLayer(IPv6ExtHdrFragment, r2[0], "expected the Echo Reply to contain a fragment header")
def test_echo_reply_correct_size(self): self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 64, True)) o = self.get_outcome(suite.ICMPv6EchoRequest64OctetsTestCase) self.assertCheckPasses(o)
def test_valid(self): self.ifx.replies_with( util.pad(IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 1500, True) ) self.ifx.replies_with( fragment6( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True, ), 1280, ) ) o = self.get_outcome(suite.RouterAdvertisementWithMTUOptionTestCase) self.assertCheckPasses(o)
def run(self): self.logger.debug("Sending ICMPv6 echo-request, with Payload Length = 0x33") self.node(4).send( \ util.pad( \ IPv6(src=str(self.node(4).global_ip()), dst=str(self.node(1).global_ip()), plen=0x33, nh=58)/ ICMPv6EchoRequest(seq=self.next_seq()), 51 - 8, False)) self.logger.info("Checking for packets...") r1 = self.node(1).received(src=self.node(4).global_ip(), seq=self.seq(), type=ICMPv6EchoRequest) assertEqual(1, len(r1), "expected to receive a ICMPv6 Echo Request (seq: %d)" % (self.seq()))
def test_no_reply_to_second_echo_request(self): self.ifx.replies_with( util.pad( IPv6(src=str(self.ifx.global_ip()), dst=str(self.tn2.global_ip())) / ICMPv6EchoReply(), 1500, True)) self.ifx.replies_with(None) o = self.get_outcome(suite.MTUIncreaseTestCase) self.assertCheckFails(o)
def run(self): self.logger.info("Transmitting ICMPv6 echo request from TR1 to NUT") self.node(1).send( util.pad( IPv6(src=str(self.node(1).global_ip()), dst=str(self.target(1).global_ip())) / ICMPv6EchoRequest(seq=self.next_seq()), 1500, True, ) ) self.logger.info("Checking for a reply...") r1 = self.node(1).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual(1, len(r1), "expected to receive a ICMPv6 Echo Reply (seq: %d)" % (self.seq())) self.logger.info("Sending Packet Too Big message to NUT for Echo Reply") self.node(1).send( IPv6(src=str(self.node(1).global_ip()), dst=str(self.target(1).global_ip())) / ICMPv6PacketTooBig(mtu=1280) / Raw(load=r1[0].build()[: (1280 - 48)]) ) self.node(1).clear_received() self.logger.info("Transmitting another ICMPv6 echo request (but fragmented) from TR1 to NUT") for p in fragment6( util.pad( IPv6(src=str(self.node(1).global_ip()), dst=str(self.target(1).global_ip())) / ICMPv6EchoRequest(seq=self.next_seq()), 1500, True, ), 1280, ): self.node(1).send(p) self.ui.wait(5) self.logger.info("Checking for replies...") r2 = self.node(1).received(src=self.target(1).global_ip(), seq=self.seq(), type=ICMPv6EchoReply) assertEqual(1, len(r2), "expected to receive an ICMPv6 Echo Reply (seq: %d)" % (self.seq())) assertFragmented(r2[0], self.node(1).received(), count=2, size=1280, reassemble_to=1500)
def test_all_replies_round1_with_fragmentation(self): self.ifx.replies_with( fragment6( util.pad( IPv6(src=str(self.ifx.link_local_ip()), dst=str(self.tn1.link_local_ip())) / IPv6ExtHdrFragment() / ICMPv6EchoReply(), 1500, True), 1280)) o = self.get_outcome(suite.ReducePMTUOnLinkLinkLocalTestCase) self.assertCheckFails(o)
def send_fragments(self): self.logger.info("Sending ICMPv6 Echo Request fragments through IPv6-IPv4 tunnel.") u1, u2, u3 = fragment6( \ util.pad( \ IPv6(src=str(self.node(1).ip(type="6in4")), dst=str(self.target(1).ip(type="6in4")))/ IPv6ExtHdrFragment()/ ICMPv6EchoRequest(seq=self.next_seq()), 1500, True), 600) e1, e2, e3 = map(lambda f: IP(src=str(self.node(1).ip(type="v4")), dst=str(self.target(1).ip(type="v4")))/f, [u1, u2, u3]) self.node(1).send(e1) self.node(1).send(e2) self.node(1).send(e3)
def run(self): self.logger.info("Sending invalid destination options to nut") self.node(1).send( \ util.pad( \ IPv6(src=str(self.node(1).global_ip().solicited_node()), dst=str(self.target(1).global_ip()))/ IPv6ExtHdrDestOpt(options=[HBHOptUnknown(otype=135,optlen=4)])/ ICMPv6EchoRequest(seq=self.next_seq()), 1500, True, False)) self.logger.info("Checking for reply") r1 = self.node(1).received(type=ICMPv6ParamProblem, dst=self.node(1).global_ip().solicited_node()) assertEqual(0, len(r1), "did not expect to receive an ICMPv6 Parameter Problem message")
def run(self): self.logger.info("Sending invalid destination options to nut") self.node(1).send( \ util.pad( \ IPv6(src=str(self.router(1).global_ip().network()), dst=str(self.target(1).global_ip()))/ IPv6ExtHdrDestOpt(options=[HBHOptUnknown(otype=135,optlen=4)])/ ICMPv6EchoRequest(), 1500, True, False)) self.logger.info("Checking for reply") r1 = self.node(1).received(type=ICMPv6ParamProblem) assertEqual(0, len(r1), "did not expect to receive an ICMPv6 Parameter Problem message")
def run(self): # TODO: configure the RUT's link MTU on link C to be 1280, the minimum # IPv6 MTU self.logger.info("Sending large echo request to nut") self.node(1).send( \ util.pad( \ IPv6(src=str(self.router(1).global_ip().network()), dst=str(self.node(4).global_ip()))/ ICMPv6EchoRequest(), 1500, True, False)) self.logger.info("Checking for reply") r1 = self.node(1).received(type=ICMPv6PacketTooBig) assertEqual(0, len(r1), "did not expect to receive an ICMPv6 Packet Too Big message")
def run(self): self.logger.info("Sending large echo request to nut") self.node(1).send( \ util.pad( \ IPv6(src="::", dst=str(self.target(1).global_ip()))/ IPv6ExtHdrDestOpt(options=[HBHOptUnknown(otype=135,optlen=4)])/ ICMPv6EchoRequest(seq=self.next_seq()), 1500, True, False)) self.logger.info("Checking for reply") r1 = self.node(1).received(type=ICMPv6ParamProblem) assertEqual(0, len(r1), "did not expect to receive an ICMPv6 Parameter Problem")
def run(self): self.logger.info("Sending fragment to nut") self.node(1).send( \ util.pad( \ IPv6(src=str(self.router(1).global_ip().network()), dst=str(self.target(1).global_ip()))/ IPv6ExtHdrFragment(offset=0, m=1)/ ICMPv6EchoRequest(), 1500, True, False)) self.ui.wait(55) self.logger.info("Checking for reply") r1 = self.node(1).received(type=ICMPv6TimeExceeded) assertEqual(0, len(r1), "did not expect to receive an ICMPv6 Time Exceeded message")
def test_dont_fragment_bit_is_not_set(self): u1, u2, u3 = fragment6( \ util.pad( \ IPv6(src=str(self.ifx.ip(type="6in4")), dst=str(self.tn1.ip(type="6in4")))/ IPv6ExtHdrFragment()/ ICMPv6EchoReply(), 1500, True), 600) e1, e2, e3 = map( lambda x: IP(src=str(self.ifx.ip(type="v4")), dst=(self.tn1.ip(type="v4"))) / x, [u1, u2, u3]) self.ifx.replies_with(e1) self.ifx.replies_with(e2) self.ifx.replies_with(e3) o = self.get_outcome(suite.DontFragmentBitNotSetTestCase) self.assertCheckPasses(o)