def test(self, raw, super_parse, isd_as): inst = TracerouteExt() inst.append_hop = create_mock() data = create_mock(["pop"]) data.pop.side_effect = ( None, "isd as 1", bytes.fromhex('1111 2222'), "isd as 2", bytes.fromhex('3333 4444'), ) raw.return_value = data isd_as.LEN = 4 isd_as.side_effect = "1-11", "2-22" dlen = inst.MIN_LEN + 2 * inst.HOP_LEN arg = bytes([2]) + bytes(dlen - 1) # Call inst._parse(arg) # Tests raw.assert_called_once_with(arg, "TracerouteExt", dlen, min_=True) super_parse.assert_called_once_with(inst, data) assert_these_calls(isd_as, (call("isd as 1"), call("isd as 2"))) assert_these_calls(inst.append_hop, ( call("1-11", 0x1111, 0x2222), call("2-22", 0x3333, 0x4444), ))
def test(self): inst = TracerouteExt() inst.hops = [1] inst._hdr_len = 3 # Call inst.append_hop("3-4", 5, 6) # Tests ntools.eq_(inst.hops, [1, ("3-4", 5, 6)])
def _create_extensions(self): # Determine number of border routers on path in single direction routers_no = (self.path.get_as_hops() - 1) * 2 # Number of router for round-trip (return path is symmetric) routers_no *= 2 # Extensions exts = [] # Create empty Traceroute extensions with allocated space exts.append(TracerouteExt.from_values(routers_no)) # Create PathTransportExtension # One with data-plane path. of_path = PathTransOFPath.from_values(self.addr, self.dst, self.path) exts.append( PathTransportExt.from_values(PathTransType.OF_PATH, of_path)) return exts
def test(self): inst = TracerouteExt() inst._check_len = create_mock() inst._hdr_len = 3 isd_as_1_2 = create_mock(["pack"]) isd_as_1_2.pack.return_value = b"1-2" isd_as_5_6 = create_mock(["pack"]) isd_as_5_6.pack.return_value = b"5-6" inst.hops = [(isd_as_1_2, 3, 4), (isd_as_5_6, 7, 8)] expected = b"".join( (b'\x02', bytes(inst.PADDING_LEN), b'1-2', bytes.fromhex('0003 0004'), b'5-6', bytes.fromhex('0007 0008'))) # Call ntools.eq_(inst.pack(), expected) # Tests inst._check_len.assert_called_once_with(expected)
def _create_extensions(self): return [TracerouteExt.from_values(5)]
def _create_extensions(self): exts = [] exts.append(TracerouteExt.from_values(5)) exts.append(SCMPExt.from_values(error=False)) return exts
def _create_extensions(self): exts = [] for i in range(MAX_HOPBYHOP_EXT + 1): exts.append(TracerouteExt.from_values(5)) return exts