pub fn classify(&mut self, rott: f64, num_lost_packets: u32) -> PacketLoss {
        assert!(rott >= 0.0);
        assert!(num_lost_packets > 0);

        self.rott_mean = (1.0 - self.alpha) * self.rott_mean + self.alpha * rott;
        self.rott_dev = (1.0 - 2.0 * self.alpha) + 2.0 * self.alpha * (rott - self.rott_mean).abs();

        match num_lost_packets {
            1 => {
                if rott < self.rott_mean - self.rott_dev {
                    PacketLoss::Wireless
                } else {
                    PacketLoss::Congestion
                }
            }
            2 => {
                if rott < self.rott_mean - self.rott_dev / 2.0 {
                    PacketLoss::Wireless
                } else {
                    PacketLoss::Congestion
                }
            }
            3 => {
                if rott < self.rott_mean {
                    PacketLoss::Wireless
                } else {
                    PacketLoss::Congestion
                }
            }
            _ => {
                if rott < self.rott_mean + self.rott_dev / 2.0 {
                    PacketLoss::Wireless
                } else {
                    PacketLoss::Congestion
                }
            }
        }
    }
/// Classifies the reason of packet loss based on the ROTT of the current packet.
///
/// This function is called with the ROTT (relative one-way trip time) of the current
/// packet if previous packets were lost
///
/// # Arguments
///
/// - `rott`: relative one-way trip time of the current packet.
/// - `num_lost_packets`: the number of packets that have been lost.
Classifies the reason of packet loss based on the ROTT of the current packet.
This function is called with the ROTT (relative one-way trip time) of the current
packet if previous packets were lost
Classifies the reason of packet loss based on the ROTT of the current packet . This function is called with the ROTT ( relative one - way trip time ) of the current packet if previous packets were lost
pub fn classify(&mut self, rott: f64, num_lost_packets: u32) -> PacketLoss {
        assert!(rott >= 0.0);
        assert!(num_lost_packets > 0);
        self.rott_mean = (1.0 - self.alpha) * self.rott_mean + self.alpha * rott;
        self.rott_dev = (1.0 - 2.0 * self.alpha) + 2.0 * self.alpha * (rott - self.rott_mean).abs();
        match num_lost_packets {
            1 => {
                if rott < self.rott_mean - self.rott_dev {
                    PacketLoss::Wireless
                } else {
                    PacketLoss::Congestion
                }
            }
            2 => {
                if rott < self.rott_mean - self.rott_dev / 2.0 {
                    PacketLoss::Wireless
                } else {
                    PacketLoss::Congestion
                }
            }
            3 => {
                if rott < self.rott_mean {
                    PacketLoss::Wireless
                } else {
                    PacketLoss::Congestion
                }
            }
            _ => {
                if rott < self.rott_mean + self.rott_dev / 2.0 {
                    PacketLoss::Wireless
                } else {
                    PacketLoss::Congestion
                }
            }
        }
    }
pub fn classify ( & mut self , rott : f64 , num_lost_packets : u32 ) -> PacketLoss { assert ! ( rott 0.0 ) ; assert ! ( num_lost_packets 0 ) ; self . rott_mean = ( 1.0 - self . alpha ) * self . rott_mean + self . alpha * rott ; self . rott_dev = ( 1.0 - 2.0 * self . alpha ) + 2.0 * self . alpha * ( rott - self . rott_mean ) . abs ( ) ; match num_lost_packets { 1 => { if rott < self . rott_mean - self . rott_dev { PacketLoss :: Wireless } else { PacketLoss :: Congestion } } 2 => { if rott < self . rott_mean - self . rott_dev / 2.0 { PacketLoss :: Wireless } else { PacketLoss :: Congestion } } 3 => { if rott < self . rott_mean { PacketLoss :: Wireless } else { PacketLoss :: Congestion } } _ => { if rott < self . rott_mean + self . rott_dev / 2.0 { PacketLoss :: Wireless } else { PacketLoss :: Congestion } } } }
Classifies the reason of packet loss based on the ROTT of the current packet.
Classifies the reason of packet loss based on the ROTT of the current packet .
&mut self
rott
f64
relative one-way trip time of the current packet.
relative one - way trip time of the current packet .
num_lost_packets
u32
the number of packets that have been lost.
the number of packets that have been lost .