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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
 def receive_packet(self, packet):
     self.time_ms.append(packet.arrival_time_ms)
     self.packets.append(packet)
     # Use delay as a signal.
     # 1) Subtract Baseline.
     # 2) Apply Median filter.
     # 3) Apply Exponential Smoothing Filter.
     # 4) Non-linear Estimate queuing delay warping.
     delay_ms = packet.arrival_time_ms - packet.send_time_ms
     self.baseline_delay_ms = min(self.baseline_delay_ms, delay_ms)
     self.delay_signals_ms.append(delay_ms - self.baseline_delay_ms)
     self.median_filtered_delays_ms.append(self.__median_filter())
     self.exp_smoothed_delays_ms.append(self.__exp_smoothing_filter())
     self.est_queuing_delays_ms.append(self.__non_linear_warping())
     self.loss_ratios.append(loss_ratio(self.packets, NadaReceiver.LOSS_RATIO_TIME_WINDOW_MS))
     self.receiving_rates_kbps.append(receiving_rate_kbps(self.packets, NadaReceiver.RECEIVING_RATE_TIME_WINDOW_MS))
     self.congestion_signals_ms.append(self.est_queuing_delays_ms[-1] + NadaReceiver.LOSS_PENALTY_MS * self.loss_ratios[-1])
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 def test_loss_ratio_no_packets(self):
     self.assertEqual(loss_ratio(None, 0.0), 0.0)
     self.assertEqual(loss_ratio(None, 50.0), 0.0)
     self.assertEqual(loss_ratio([], 0.0), 0.0)
     self.assertEqual(loss_ratio([], 50.0), 0.0)
 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)
 def test_loss_ratio_no_packets(self):
     self.assertEqual(loss_ratio(None, 0.0), 0.0)
     self.assertEqual(loss_ratio(None, 50.0), 0.0)
     self.assertEqual(loss_ratio([], 0.0), 0.0)
     self.assertEqual(loss_ratio([], 50.0), 0.0)