Beispiel #1
0
    def test_main_path(self):

        link_delay = {(1, 2): 2, (2, 3): 10, (2, 1): 4, (3, 2): 20}
        view = type('MockNetworkView', (), {
            'link_delay': lambda s, u, v: link_delay[(u, v)]
        })()

        c = collectors.LatencyCollector(view)

        c.start_session(3.0, 1, 'CONTENT')
        c.request_hop(1, 2)
        c.content_hop(2, 1)
        c.end_session()

        c.start_session(5.0, 1, 'CONTENT')
        c.request_hop(1, 2)
        c.request_hop(2, 3)
        c.request_hop(2, 1, main_path=False)
        c.content_hop(3, 2)
        c.content_hop(2, 1)
        c.content_hop(2, 3, main_path=False)
        c.end_session()

        res = c.results()
        self.assertEqual((10 + 20 + 2 * (2 + 4)) / 2, res['MEAN'])
Beispiel #2
0
    def test_main_path(self):

        link_delay = {(1, 2): 2, (2, 3): 10, (2, 1): 4, (3, 2): 20}
        view = type("MockNetworkView", (), {
            "link_delay": lambda s, u, v: link_delay[(u, v)]
        })()

        c = collectors.LatencyCollector(view)

        c.start_session(3.0, 1, "CONTENT")
        c.request_hop(1, 2)
        c.content_hop(2, 1)
        c.end_session()

        c.start_session(5.0, 1, "CONTENT")
        c.request_hop(1, 2)
        c.request_hop(2, 3)
        c.request_hop(2, 1, main_path=False)
        c.content_hop(3, 2)
        c.content_hop(2, 1)
        c.content_hop(2, 3, main_path=False)
        c.end_session()

        res = c.results()
        assert (10 + 20 + 2 * (2 + 4)) / 2 == res["MEAN"]