
    @OOf                         U d dl Z d dlmZmZmZmZmZ ddlmZ dZ	dZ
dZ G d de j                        Z G d	 d
e      Z G d d      Zi Zeeef   ed<   dededefdZdededdfdZy)    N)AnyDictIterableOptionalProtocol   )QuicSentPacketgMbP?
   c                   f   e Zd ZU dZdZeed<   dZeed<   dZe	e   ed<   deddfd	Z
ej                  d
ededdfd       Zej                  deddfd       Zej                  dee   ddfd       Zej                  d
edee   ddfd       Zej                  d
ededdfd       Zdeeef   fdZy)QuicCongestionControlz<
    Base class for congestion control implementations.
    r   bytes_in_flightcongestion_windowNssthreshmax_datagram_sizereturnc                     t         |z  | _        y N)K_INITIAL_WINDOWr   selfr   s     ]/var/www/premiumrankchecker/venv/lib/python3.12/site-packages/aioquic/quic/congestion/base.py__init__zQuicCongestionControl.__init__   s    !14E!E    nowpacketc                     y r    )r   r   r   s      r   on_packet_ackedz%QuicCongestionControl.on_packet_acked   s    NQr   c                     y r   r   )r   r   s     r   on_packet_sentz$QuicCongestionControl.on_packet_sent   s    ADr   packetsc                     y r   r   )r   r!   s     r   on_packets_expiredz(QuicCongestionControl.on_packets_expired   s    PSr   c                     y r   r   )r   r   r!   s      r   on_packets_lostz%QuicCongestionControl.on_packets_lost    s     r   rttc                     y r   r   )r   r   r&   s      r   on_rtt_measurementz(QuicCongestionControl.on_rtt_measurement%   s    EHr   c                 n    | j                   | j                  d}| j                  | j                  |d<   |S )N)cwndr   r   )r   r   r   )r   datas     r   get_log_dataz"QuicCongestionControl.get_log_data(   s5    ..4CWCWX==$#}}Dr   )__name__
__module____qualname____doc__r   int__annotations__r   r   r   r   abcabstractmethodfloatr	   r   r    r   r#   r%   r(   r   strr   r,   r   r   r   r   r      s    OSs"Hhsm"FS FT F 	QeQ^QQ QDD4D DSXn-ES$S S&.~&>	  	HHUHtH Hd38n r   r   c                       e Zd ZdedefdZy)QuicCongestionControlFactoryr   r   c                     y r   r   r   s     r   __call__z%QuicCongestionControlFactory.__call__0   s    r   N)r-   r.   r/   r1   r   r:   r   r   r   r8   r8   /   s    OSO5JOr   r8   c                   <    e Zd ZdZd	dZdeddfdZdededefdZy)
QuicRttMonitorz-
    Roundtrip time monitor for HyStart.
    r   Nc                     d| _         d | _        d| _        d| _        d | _        d| _        d | _        d | _        d| _        t        | j                        D cg c]  }d c}| _
        y c c}w )Nr   F   g        )
_increases
_last_time_ready_size_filtered_min_sample_idx_sample_max_sample_min_sample_timerange_samples)r   is     r   r   zQuicRttMonitor.__init__8   sd    
.2,0,0&+DJJ&7888s   	A)r&   c                   || j                   | j                  <   | xj                  dz  c_        | j                  | j                  k\  rd| _        d| _        | j                  rk| j                   d   | _        | j                   d   | _        | j                   dd  D ]0  }|| j
                  k  r|| _        || j                  kD  s*|| _        2 y y )N   r   T)rI   rD   rB   rA   rE   rF   )r   r&   samples      r   add_rttzQuicRttMonitor.add_rttF   s    *-d&&'Atzz) DDK;;#}}Q/D#}}Q/D--+ .D,,,'-D$d...'-D$	. r   r   c                   || j                   t        z   kD  r| j                  |       || _         | j                  r| j                  | j                  | j
                  kD  r| j
                  | _        | j                  | j                  z
  }|dz  | j                  k\  r0| xj                  dz  c_        | j                  | j                  k\  ryy|dkD  rd| _        y)N)r&      rL   Tr   F)	rG   K_GRANULARITYrN   rA   rC   rE   rF   r?   rB   )r   r   r&   deltas       r   is_rtt_increasingz QuicRttMonitor.is_rtt_increasingW   s    ""]22LLSL! #D{{%%-1C1CdFVFV1V)-)9)9D&((4+=+==19 2 22OOq(O$**4#  QY&'DOr   )r   N)	r-   r.   r/   r0   r   r5   rN   boolrS   r   r   r   r<   r<   3   s9    9.e . ." E d r   r<   
_factoriesnamer   r   c                ^    	 t         |    } ||      S # t        $ r t        d|        w xY w)zH
    Create an instance of the `name` congestion control algorithm.
    z&Unknown congestion control algorithm: )r   )rU   KeyError	Exception)rV   r   factorys      r   create_congestion_controlr[   m   sF    IT" %677  I@GHHIs   	 ,rZ   c                     |t         | <   y)z?
    Register a congestion control algorithm named `name`.
    N)rU   )rV   rZ   s     r   register_congestion_controlr]   z   s     Jtr   )r3   typingr   r   r   r   r   packet_builderr	   rQ   r   K_MINIMUM_WINDOWABCr   r8   r<   rU   r6   r2   r1   r[   r]   r   r   r   <module>rb      s    
 : : +  !CGG !HP8 P4 4n 79
D223 8
8

8%(
8
8
4	r   