def test_average_delay_multiple_packets(self): self.assertEqual(average_delay_ms(None), 0.0) self.assertEqual(average_delay_ms([]), 0.0) for i in range(10): delay_ms = random.uniform(10.0, 300.0) gap_ms = random.uniform(10.0, 50.0) packets = [] for j in range(1000): packets.append(Packet(j + 1, j * gap_ms, 1200.0)) packets[j].arrival_time_ms = packets[j].send_time_ms + delay_ms self.assertNear(average_delay_ms(packets), delay_ms, 0.001)
def test_average_delay_multiple_packets(self): self.assertEqual(average_delay_ms(None), 0.0) self.assertEqual(average_delay_ms([]), 0.0) for i in range(10): delay_ms = random.uniform(10.0, 300.0) gap_ms = random.uniform(10.0, 50.0) packets = [] for j in range(1000): packets.append(Packet(j+1, j*gap_ms, 1200.0)) packets[j].arrival_time_ms = packets[j].send_time_ms + delay_ms self.assertNear(average_delay_ms(packets), delay_ms, 0.001)
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_average_delay_no_packets(self): self.assertEqual(average_delay_ms(None), 0.0) self.assertEqual(average_delay_ms([]), 0.0)