本文整理汇总了Python中packet.Packet.arrival_time_ms方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.arrival_time_ms方法的具体用法?Python Packet.arrival_time_ms怎么用?Python Packet.arrival_time_ms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类packet.Packet
的用法示例。
在下文中一共展示了Packet.arrival_time_ms方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_average_bitrate_two_packets
# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import arrival_time_ms [as 别名]
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)
示例2: test_average_bitrate_single_packet
# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import arrival_time_ms [as 别名]
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: test_receiving_rate_kbps_single_packet
# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import arrival_time_ms [as 别名]
def test_receiving_rate_kbps_single_packet(self):
payload_sizes_bytes = [0.0, 500.0, 1200.0] # Empty or non-empty packet.
for payload_size_bytes in payload_sizes_bytes:
# id and send_time don't matter here.
packet = Packet(None, None, payload_size_bytes)
for i in range(10):
packet.arrival_time_ms = i
time_window_ms = random.uniform(100.0, 1000.0)
self.assertEqual(receiving_rate_kbps([packet], time_window_ms),
8.0 * packet.payload_size_bytes / time_window_ms)
示例4: test_loss_ratio_gap_packets
# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import arrival_time_ms [as 别名]
def test_loss_ratio_gap_packets(self):
packets = []
for i in range(10):
# Only id and arrival time matter here
packet = Packet(i, None, None)
packet.arrival_time_ms = 10.0 * i
packets.append(packet)
for i in range(20, 30):
# Only id and arrival time matter here
packet = Packet(i, None, None)
packet.arrival_time_ms = 10.0 * i
packets.append(packet)
# Short time windows won't trigger loss computation.
for t in range(0, 200, 10):
self.assertEqual(loss_ratio(packets, t), 0.0)
for i in range(10):
time_window_ms = 200 + 10*i
loss = 1.0 - float(11 + i)/(21 + i)
self.assertEqual(loss_ratio(packets, time_window_ms), loss)
示例5: test_loss_ratio_single_packet
# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import arrival_time_ms [as 别名]
def test_loss_ratio_single_packet(self):
# Only id and arrival time matter here
packet = Packet(1, None, None)
packet.arrival_time_ms = 10.0
self.assertEqual(loss_ratio([packet], 0.0), 0.0)
self.assertEqual(loss_ratio([packet], 50.0), 0.0)