コード例 #1
0
 def test_average_bitrate_single_packet(self):
     for i in range(10):
         packet_size_bytes = random.uniform(1.0, 8000.0)
         delay_ms = random.uniform(10.0, 300.0)
         packet = Packet(1, 0.0, packet_size_bytes)
         packet.arrival_time_ms = delay_ms
         self.assertEqual(average_bitrate_kbps([packet]), 8.0 * packet_size_bytes / delay_ms)
コード例 #2
0
 def test_average_bitrate_single_packet(self):
     for i in range(10):
         packet_size_bytes = random.uniform(1.0, 8000.0)
         delay_ms = random.uniform(10.0, 300.0)
         packet = Packet(1, 0.0, packet_size_bytes)
         packet.arrival_time_ms = delay_ms
         self.assertEqual(average_bitrate_kbps([packet]),
                          8.0 * packet_size_bytes / delay_ms)
コード例 #3
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))
コード例 #4
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))
コード例 #5
0
 def test_average_bitrate_multiple_packets(self):
     for i in range(10):
         packet_size_bytes = random.uniform(1.0, 8000.0)
         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, packet_size_bytes))
             packets[j].arrival_time_ms = packets[j].send_time_ms + delay_ms
         self.assertNear(average_bitrate_kbps(packets), 8.0 * packet_size_bytes / gap_ms, 0.001)
コード例 #6
0
 def test_average_bitrate_two_packets(self):
     for i in range(10):
         packet_size_bytes = random.uniform(1.0, 8000.0)
         delay_ms = random.uniform(10.0, 300.0)
         gap_ms = random.uniform(10.0, 50.0)
         packet1 = Packet(1, 0.0, packet_size_bytes)
         packet2 = Packet(2, gap_ms, packet_size_bytes)
         packet1.arrival_time_ms = delay_ms
         packet2.arrival_time_ms = gap_ms + delay_ms
         self.assertNear(average_bitrate_kbps([packet1, packet2]), 8.0 * packet_size_bytes / gap_ms, 0.001)
コード例 #7
0
 def test_average_bitrate_multiple_packets(self):
     for i in range(10):
         packet_size_bytes = random.uniform(1.0, 8000.0)
         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, packet_size_bytes))
             packets[j].arrival_time_ms = packets[j].send_time_ms + delay_ms
         self.assertNear(average_bitrate_kbps(packets),
                         8.0 * packet_size_bytes / gap_ms, 0.001)
コード例 #8
0
 def test_average_bitrate_two_packets(self):
     for i in range(10):
         packet_size_bytes = random.uniform(1.0, 8000.0)
         delay_ms = random.uniform(10.0, 300.0)
         gap_ms = random.uniform(10.0, 50.0)
         packet1 = Packet(1, 0.0, packet_size_bytes)
         packet2 = Packet(2, gap_ms, packet_size_bytes)
         packet1.arrival_time_ms = delay_ms
         packet2.arrival_time_ms = gap_ms + delay_ms
         self.assertNear(average_bitrate_kbps([packet1, packet2]),
                         8.0 * packet_size_bytes / gap_ms, 0.001)
コード例 #9
0
 def test_average_bitrate_no_packets(self):
     self.assertEqual(average_bitrate_kbps(None), 0.0)
     self.assertEqual(average_bitrate_kbps([]), 0.0)
コード例 #10
0
 def test_average_bitrate_no_packets(self):
     self.assertEqual(average_bitrate_kbps(None), 0.0)
     self.assertEqual(average_bitrate_kbps([]), 0.0)