def test_global_loss_ratio_shuffled_packets(self): for i in range(10): first_id = random.randint(0,100) number_packets = random.randint(0,1000) packets = [Packet(first_id+i, None, None) for i in range(number_packets)] random.shuffle(packets) self.assertEqual(global_loss_ratio(packets), 0.0)
def test_global_loss_ratio_contiguous_packets(self): for i in range(10): first_id = random.randint(0, 100) number_packets = random.randint(0, 1000) packets = [ Packet(first_id + i, None, None) for i in range(number_packets) ] self.assertEqual(global_loss_ratio(packets), 0.0)
def __print(receiver): """ Output results: Global packet loss and Average Metrics: bitrate and delay. """ print("Average bitrate (kbps) =", average_bitrate_kbps(receiver.packets)) print("Average delay (ms) =", average_delay_ms(receiver.packets)) print("Global packet loss =", global_loss_ratio(receiver.packets))
def test_global_loss_ratio_sparsed_packets(self): p1 = Packet(1, None, None) p2 = Packet(1000, None, None) self.assertEqual(global_loss_ratio([p1, p2]), 1.0 - float(2) / 1000)
def test_global_loss_ratio_no_packets(self): self.assertEqual(global_loss_ratio(None), 0.0)
def test_global_loss_ratio_sparsed_packets(self): p1 = Packet(1, None, None) p2 = Packet(1000, None, None) self.assertEqual(global_loss_ratio([p1, p2]), 1.0 - float(2)/1000)