{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}
module Network.QUIC.Recovery.Timer (
getLossTimeAndSpace,
getPtoTimeAndSpace,
setLossDetectionTimer,
beforeAntiAmp,
ldccTimer,
) where
import qualified Data.Sequence as Seq
import Network.QUIC.Event
import UnliftIO.STM
import Network.QUIC.Connector
import Network.QUIC.Imports
import Network.QUIC.Qlog
import Network.QUIC.Recovery.Constants
import Network.QUIC.Recovery.Detect
import Network.QUIC.Recovery.Metrics
import Network.QUIC.Recovery.Misc
import Network.QUIC.Recovery.Persistent
import Network.QUIC.Recovery.Release
import Network.QUIC.Recovery.Types
import Network.QUIC.Recovery.Utils
import Network.QUIC.Types
noInFlightPacket :: LDCC -> EncryptionLevel -> IO Bool
noInFlightPacket :: LDCC -> EncryptionLevel -> IO Bool
noInFlightPacket LDCC{Array EncryptionLevel (IORef Bool)
Array EncryptionLevel (IORef PeerPacketNumbers)
Array EncryptionLevel (IORef LossDetection)
Array EncryptionLevel (IORef SentPackets)
TVar (Maybe EncryptionLevel)
TVar TimerInfoQ
TVar CC
TVar SentPackets
IORef Bool
IORef Int
IORef (Maybe TimeoutKey)
IORef (Maybe TimerInfo)
IORef PeerPacketNumbers
IORef RTT
ConnState
PlainPacket -> IO ()
QLogger
timerInfoQ :: LDCC -> TVar TimerInfoQ
previousRTT1PPNs :: LDCC -> IORef PeerPacketNumbers
peerPacketNumbers :: LDCC -> Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: LDCC -> IORef Int
speedingUp :: LDCC -> IORef Bool
ptoPing :: LDCC -> TVar (Maybe EncryptionLevel)
lostCandidates :: LDCC -> TVar SentPackets
timerInfo :: LDCC -> IORef (Maybe TimerInfo)
timerKey :: LDCC -> IORef (Maybe TimeoutKey)
lossDetection :: LDCC -> Array EncryptionLevel (IORef LossDetection)
sentPackets :: LDCC -> Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: LDCC -> Array EncryptionLevel (IORef Bool)
recoveryCC :: LDCC -> TVar CC
recoveryRTT :: LDCC -> IORef RTT
putRetrans :: LDCC -> PlainPacket -> IO ()
ldccQlogger :: LDCC -> QLogger
ldccState :: LDCC -> ConnState
timerInfoQ :: TVar TimerInfoQ
previousRTT1PPNs :: IORef PeerPacketNumbers
peerPacketNumbers :: Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: IORef Int
speedingUp :: IORef Bool
ptoPing :: TVar (Maybe EncryptionLevel)
lostCandidates :: TVar SentPackets
timerInfo :: IORef (Maybe TimerInfo)
timerKey :: IORef (Maybe TimeoutKey)
lossDetection :: Array EncryptionLevel (IORef LossDetection)
sentPackets :: Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: Array EncryptionLevel (IORef Bool)
recoveryCC :: TVar CC
recoveryRTT :: IORef RTT
putRetrans :: PlainPacket -> IO ()
ldccQlogger :: QLogger
ldccState :: ConnState
..} EncryptionLevel
lvl = do
SentPackets Seq SentPacket
db <- forall a. IORef a -> IO a
readIORef (Array EncryptionLevel (IORef SentPackets)
sentPackets forall i e. Ix i => Array i e -> i -> e
! EncryptionLevel
lvl)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. Seq a -> Bool
Seq.null Seq SentPacket
db
getLossTimeAndSpace :: LDCC -> IO (Maybe (TimeMicrosecond, EncryptionLevel))
getLossTimeAndSpace :: LDCC -> IO (Maybe (TimeMicrosecond, EncryptionLevel))
getLossTimeAndSpace LDCC{Array EncryptionLevel (IORef Bool)
Array EncryptionLevel (IORef PeerPacketNumbers)
Array EncryptionLevel (IORef LossDetection)
Array EncryptionLevel (IORef SentPackets)
TVar (Maybe EncryptionLevel)
TVar TimerInfoQ
TVar CC
TVar SentPackets
IORef Bool
IORef Int
IORef (Maybe TimeoutKey)
IORef (Maybe TimerInfo)
IORef PeerPacketNumbers
IORef RTT
ConnState
PlainPacket -> IO ()
QLogger
timerInfoQ :: TVar TimerInfoQ
previousRTT1PPNs :: IORef PeerPacketNumbers
peerPacketNumbers :: Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: IORef Int
speedingUp :: IORef Bool
ptoPing :: TVar (Maybe EncryptionLevel)
lostCandidates :: TVar SentPackets
timerInfo :: IORef (Maybe TimerInfo)
timerKey :: IORef (Maybe TimeoutKey)
lossDetection :: Array EncryptionLevel (IORef LossDetection)
sentPackets :: Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: Array EncryptionLevel (IORef Bool)
recoveryCC :: TVar CC
recoveryRTT :: IORef RTT
putRetrans :: PlainPacket -> IO ()
ldccQlogger :: QLogger
ldccState :: ConnState
timerInfoQ :: LDCC -> TVar TimerInfoQ
previousRTT1PPNs :: LDCC -> IORef PeerPacketNumbers
peerPacketNumbers :: LDCC -> Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: LDCC -> IORef Int
speedingUp :: LDCC -> IORef Bool
ptoPing :: LDCC -> TVar (Maybe EncryptionLevel)
lostCandidates :: LDCC -> TVar SentPackets
timerInfo :: LDCC -> IORef (Maybe TimerInfo)
timerKey :: LDCC -> IORef (Maybe TimeoutKey)
lossDetection :: LDCC -> Array EncryptionLevel (IORef LossDetection)
sentPackets :: LDCC -> Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: LDCC -> Array EncryptionLevel (IORef Bool)
recoveryCC :: LDCC -> TVar CC
recoveryRTT :: LDCC -> IORef RTT
putRetrans :: LDCC -> PlainPacket -> IO ()
ldccQlogger :: LDCC -> QLogger
ldccState :: LDCC -> ConnState
..} =
[EncryptionLevel]
-> Maybe (TimeMicrosecond, EncryptionLevel)
-> IO (Maybe (TimeMicrosecond, EncryptionLevel))
loop [EncryptionLevel
InitialLevel, EncryptionLevel
HandshakeLevel, EncryptionLevel
RTT1Level] forall a. Maybe a
Nothing
where
loop :: [EncryptionLevel]
-> Maybe (TimeMicrosecond, EncryptionLevel)
-> IO (Maybe (TimeMicrosecond, EncryptionLevel))
loop [] Maybe (TimeMicrosecond, EncryptionLevel)
r = forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (TimeMicrosecond, EncryptionLevel)
r
loop (EncryptionLevel
l : [EncryptionLevel]
ls) Maybe (TimeMicrosecond, EncryptionLevel)
r = do
Maybe TimeMicrosecond
mt <- LossDetection -> Maybe TimeMicrosecond
lossTime forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. IORef a -> IO a
readIORef (Array EncryptionLevel (IORef LossDetection)
lossDetection forall i e. Ix i => Array i e -> i -> e
! EncryptionLevel
l)
case Maybe TimeMicrosecond
mt of
Maybe TimeMicrosecond
Nothing -> [EncryptionLevel]
-> Maybe (TimeMicrosecond, EncryptionLevel)
-> IO (Maybe (TimeMicrosecond, EncryptionLevel))
loop [EncryptionLevel]
ls Maybe (TimeMicrosecond, EncryptionLevel)
r
Just TimeMicrosecond
t -> case Maybe (TimeMicrosecond, EncryptionLevel)
r of
Maybe (TimeMicrosecond, EncryptionLevel)
Nothing -> [EncryptionLevel]
-> Maybe (TimeMicrosecond, EncryptionLevel)
-> IO (Maybe (TimeMicrosecond, EncryptionLevel))
loop [EncryptionLevel]
ls forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (TimeMicrosecond
t, EncryptionLevel
l)
Just (TimeMicrosecond
t0, EncryptionLevel
_)
| TimeMicrosecond
t forall a. Ord a => a -> a -> Bool
< TimeMicrosecond
t0 -> [EncryptionLevel]
-> Maybe (TimeMicrosecond, EncryptionLevel)
-> IO (Maybe (TimeMicrosecond, EncryptionLevel))
loop [EncryptionLevel]
ls forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (TimeMicrosecond
t, EncryptionLevel
l)
| Bool
otherwise -> [EncryptionLevel]
-> Maybe (TimeMicrosecond, EncryptionLevel)
-> IO (Maybe (TimeMicrosecond, EncryptionLevel))
loop [EncryptionLevel]
ls Maybe (TimeMicrosecond, EncryptionLevel)
r
getPtoTimeAndSpace :: LDCC -> IO (Maybe (TimeMicrosecond, EncryptionLevel))
getPtoTimeAndSpace :: LDCC -> IO (Maybe (TimeMicrosecond, EncryptionLevel))
getPtoTimeAndSpace ldcc :: LDCC
ldcc@LDCC{Array EncryptionLevel (IORef Bool)
Array EncryptionLevel (IORef PeerPacketNumbers)
Array EncryptionLevel (IORef LossDetection)
Array EncryptionLevel (IORef SentPackets)
TVar (Maybe EncryptionLevel)
TVar TimerInfoQ
TVar CC
TVar SentPackets
IORef Bool
IORef Int
IORef (Maybe TimeoutKey)
IORef (Maybe TimerInfo)
IORef PeerPacketNumbers
IORef RTT
ConnState
PlainPacket -> IO ()
QLogger
timerInfoQ :: TVar TimerInfoQ
previousRTT1PPNs :: IORef PeerPacketNumbers
peerPacketNumbers :: Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: IORef Int
speedingUp :: IORef Bool
ptoPing :: TVar (Maybe EncryptionLevel)
lostCandidates :: TVar SentPackets
timerInfo :: IORef (Maybe TimerInfo)
timerKey :: IORef (Maybe TimeoutKey)
lossDetection :: Array EncryptionLevel (IORef LossDetection)
sentPackets :: Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: Array EncryptionLevel (IORef Bool)
recoveryCC :: TVar CC
recoveryRTT :: IORef RTT
putRetrans :: PlainPacket -> IO ()
ldccQlogger :: QLogger
ldccState :: ConnState
timerInfoQ :: LDCC -> TVar TimerInfoQ
previousRTT1PPNs :: LDCC -> IORef PeerPacketNumbers
peerPacketNumbers :: LDCC -> Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: LDCC -> IORef Int
speedingUp :: LDCC -> IORef Bool
ptoPing :: LDCC -> TVar (Maybe EncryptionLevel)
lostCandidates :: LDCC -> TVar SentPackets
timerInfo :: LDCC -> IORef (Maybe TimerInfo)
timerKey :: LDCC -> IORef (Maybe TimeoutKey)
lossDetection :: LDCC -> Array EncryptionLevel (IORef LossDetection)
sentPackets :: LDCC -> Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: LDCC -> Array EncryptionLevel (IORef Bool)
recoveryCC :: LDCC -> TVar CC
recoveryRTT :: LDCC -> IORef RTT
putRetrans :: LDCC -> PlainPacket -> IO ()
ldccQlogger :: LDCC -> QLogger
ldccState :: LDCC -> ConnState
..} = do
CC{Int
Maybe TimeMicrosecond
CCMode
ccMode :: CC -> CCMode
numOfAckEliciting :: CC -> Int
bytesAcked :: CC -> Int
ssthresh :: CC -> Int
congestionRecoveryStartTime :: CC -> Maybe TimeMicrosecond
congestionWindow :: CC -> Int
bytesInFlight :: CC -> Int
ccMode :: CCMode
numOfAckEliciting :: Int
bytesAcked :: Int
ssthresh :: Int
congestionRecoveryStartTime :: Maybe TimeMicrosecond
congestionWindow :: Int
bytesInFlight :: Int
..} <- forall (m :: * -> *) a. MonadIO m => TVar a -> m a
readTVarIO TVar CC
recoveryCC
if Int
bytesInFlight forall a. Ord a => a -> a -> Bool
<= Int
0
then do
Bool
validated <- LDCC -> IO Bool
peerCompletedAddressValidation LDCC
ldcc
if Bool
validated
then do
forall q. KeepQlog q => q -> Debug -> IO ()
qlogDebug LDCC
ldcc forall a b. (a -> b) -> a -> b
$ LogStr -> Debug
Debug LogStr
"getPtoTimeAndSpace: validated"
forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
else do
RTT
rtt <- forall a. IORef a -> IO a
readIORef IORef RTT
recoveryRTT
EncryptionLevel
lvl <- forall a. Connector a => a -> IO EncryptionLevel
getEncryptionLevel LDCC
ldcc
let pto :: Microseconds
pto = Microseconds -> Int -> Microseconds
backOff (RTT -> Maybe EncryptionLevel -> Microseconds
calcPTO RTT
rtt forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just EncryptionLevel
lvl) (RTT -> Int
ptoCount RTT
rtt)
TimeMicrosecond
ptoTime <- Microseconds -> IO TimeMicrosecond
getFutureTimeMicrosecond Microseconds
pto
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (TimeMicrosecond
ptoTime, EncryptionLevel
lvl)
else do
Bool
completed <- forall a. Connector a => a -> IO Bool
isConnectionEstablished LDCC
ldcc
let lvls :: [EncryptionLevel]
lvls
| Bool
completed = [EncryptionLevel
InitialLevel, EncryptionLevel
HandshakeLevel, EncryptionLevel
RTT1Level]
| Bool
otherwise = [EncryptionLevel
InitialLevel, EncryptionLevel
HandshakeLevel]
[EncryptionLevel] -> IO (Maybe (TimeMicrosecond, EncryptionLevel))
loop [EncryptionLevel]
lvls
where
loop :: [EncryptionLevel] -> IO (Maybe (TimeMicrosecond, EncryptionLevel))
loop :: [EncryptionLevel] -> IO (Maybe (TimeMicrosecond, EncryptionLevel))
loop [] = forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
loop (EncryptionLevel
l : [EncryptionLevel]
ls) = do
Bool
notInFlight <- LDCC -> EncryptionLevel -> IO Bool
noInFlightPacket LDCC
ldcc EncryptionLevel
l
if Bool
notInFlight
then [EncryptionLevel] -> IO (Maybe (TimeMicrosecond, EncryptionLevel))
loop [EncryptionLevel]
ls
else do
LossDetection{Int
Maybe TimeMicrosecond
TimeMicrosecond
AckInfo
timeOfLastAckElicitingPacket :: LossDetection -> TimeMicrosecond
previousAckInfo :: LossDetection -> AckInfo
largestAckedPacket :: LossDetection -> Int
lossTime :: Maybe TimeMicrosecond
timeOfLastAckElicitingPacket :: TimeMicrosecond
previousAckInfo :: AckInfo
largestAckedPacket :: Int
lossTime :: LossDetection -> Maybe TimeMicrosecond
..} <- forall a. IORef a -> IO a
readIORef (Array EncryptionLevel (IORef LossDetection)
lossDetection forall i e. Ix i => Array i e -> i -> e
! EncryptionLevel
l)
if TimeMicrosecond
timeOfLastAckElicitingPacket forall a. Eq a => a -> a -> Bool
== TimeMicrosecond
timeMicrosecond0
then [EncryptionLevel] -> IO (Maybe (TimeMicrosecond, EncryptionLevel))
loop [EncryptionLevel]
ls
else do
RTT
rtt <- forall a. IORef a -> IO a
readIORef IORef RTT
recoveryRTT
let pto0 :: Microseconds
pto0 = Microseconds -> Int -> Microseconds
backOff (RTT -> Maybe EncryptionLevel -> Microseconds
calcPTO RTT
rtt forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just EncryptionLevel
l) (RTT -> Int
ptoCount RTT
rtt)
pto :: Microseconds
pto = forall a. Ord a => a -> a -> a
max Microseconds
pto0 Microseconds
kGranularity
ptoTime :: TimeMicrosecond
ptoTime = TimeMicrosecond
timeOfLastAckElicitingPacket TimeMicrosecond -> Microseconds -> TimeMicrosecond
`addMicroseconds` Microseconds
pto
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (TimeMicrosecond
ptoTime, EncryptionLevel
l)
cancelLossDetectionTimer :: LDCC -> IO ()
cancelLossDetectionTimer :: LDCC -> IO ()
cancelLossDetectionTimer ldcc :: LDCC
ldcc@LDCC{Array EncryptionLevel (IORef Bool)
Array EncryptionLevel (IORef PeerPacketNumbers)
Array EncryptionLevel (IORef LossDetection)
Array EncryptionLevel (IORef SentPackets)
TVar (Maybe EncryptionLevel)
TVar TimerInfoQ
TVar CC
TVar SentPackets
IORef Bool
IORef Int
IORef (Maybe TimeoutKey)
IORef (Maybe TimerInfo)
IORef PeerPacketNumbers
IORef RTT
ConnState
PlainPacket -> IO ()
QLogger
timerInfoQ :: TVar TimerInfoQ
previousRTT1PPNs :: IORef PeerPacketNumbers
peerPacketNumbers :: Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: IORef Int
speedingUp :: IORef Bool
ptoPing :: TVar (Maybe EncryptionLevel)
lostCandidates :: TVar SentPackets
timerInfo :: IORef (Maybe TimerInfo)
timerKey :: IORef (Maybe TimeoutKey)
lossDetection :: Array EncryptionLevel (IORef LossDetection)
sentPackets :: Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: Array EncryptionLevel (IORef Bool)
recoveryCC :: TVar CC
recoveryRTT :: IORef RTT
putRetrans :: PlainPacket -> IO ()
ldccQlogger :: QLogger
ldccState :: ConnState
timerInfoQ :: LDCC -> TVar TimerInfoQ
previousRTT1PPNs :: LDCC -> IORef PeerPacketNumbers
peerPacketNumbers :: LDCC -> Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: LDCC -> IORef Int
speedingUp :: LDCC -> IORef Bool
ptoPing :: LDCC -> TVar (Maybe EncryptionLevel)
lostCandidates :: LDCC -> TVar SentPackets
timerInfo :: LDCC -> IORef (Maybe TimerInfo)
timerKey :: LDCC -> IORef (Maybe TimeoutKey)
lossDetection :: LDCC -> Array EncryptionLevel (IORef LossDetection)
sentPackets :: LDCC -> Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: LDCC -> Array EncryptionLevel (IORef Bool)
recoveryCC :: LDCC -> TVar CC
recoveryRTT :: LDCC -> IORef RTT
putRetrans :: LDCC -> PlainPacket -> IO ()
ldccQlogger :: LDCC -> QLogger
ldccState :: LDCC -> ConnState
..} = do
forall (m :: * -> *) a. MonadIO m => STM a -> m a
atomically forall a b. (a -> b) -> a -> b
$ forall a. TVar a -> a -> STM ()
writeTVar TVar TimerInfoQ
timerInfoQ TimerInfoQ
Empty
Maybe TimeoutKey
mk <- forall a b. IORef a -> (a -> (a, b)) -> IO b
atomicModifyIORef' IORef (Maybe TimeoutKey)
timerKey (forall a. Maybe a
Nothing,)
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ Maybe TimeoutKey
mk forall a b. (a -> b) -> a -> b
$ \TimeoutKey
k -> do
TimerManager
mgr <- IO TimerManager
getSystemTimerManager
TimerManager -> TimeoutKey -> IO ()
unregisterTimeout TimerManager
mgr TimeoutKey
k
forall a. IORef a -> a -> IO ()
writeIORef IORef (Maybe TimerInfo)
timerInfo forall a. Maybe a
Nothing
forall q. KeepQlog q => q -> IO ()
qlogLossTimerCancelled LDCC
ldcc
updateLossDetectionTimer :: LDCC -> TimerInfo -> IO ()
updateLossDetectionTimer :: LDCC -> TimerInfo -> IO ()
updateLossDetectionTimer ldcc :: LDCC
ldcc@LDCC{Array EncryptionLevel (IORef Bool)
Array EncryptionLevel (IORef PeerPacketNumbers)
Array EncryptionLevel (IORef LossDetection)
Array EncryptionLevel (IORef SentPackets)
TVar (Maybe EncryptionLevel)
TVar TimerInfoQ
TVar CC
TVar SentPackets
IORef Bool
IORef Int
IORef (Maybe TimeoutKey)
IORef (Maybe TimerInfo)
IORef PeerPacketNumbers
IORef RTT
ConnState
PlainPacket -> IO ()
QLogger
timerInfoQ :: TVar TimerInfoQ
previousRTT1PPNs :: IORef PeerPacketNumbers
peerPacketNumbers :: Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: IORef Int
speedingUp :: IORef Bool
ptoPing :: TVar (Maybe EncryptionLevel)
lostCandidates :: TVar SentPackets
timerInfo :: IORef (Maybe TimerInfo)
timerKey :: IORef (Maybe TimeoutKey)
lossDetection :: Array EncryptionLevel (IORef LossDetection)
sentPackets :: Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: Array EncryptionLevel (IORef Bool)
recoveryCC :: TVar CC
recoveryRTT :: IORef RTT
putRetrans :: PlainPacket -> IO ()
ldccQlogger :: QLogger
ldccState :: ConnState
timerInfoQ :: LDCC -> TVar TimerInfoQ
previousRTT1PPNs :: LDCC -> IORef PeerPacketNumbers
peerPacketNumbers :: LDCC -> Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: LDCC -> IORef Int
speedingUp :: LDCC -> IORef Bool
ptoPing :: LDCC -> TVar (Maybe EncryptionLevel)
lostCandidates :: LDCC -> TVar SentPackets
timerInfo :: LDCC -> IORef (Maybe TimerInfo)
timerKey :: LDCC -> IORef (Maybe TimeoutKey)
lossDetection :: LDCC -> Array EncryptionLevel (IORef LossDetection)
sentPackets :: LDCC -> Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: LDCC -> Array EncryptionLevel (IORef Bool)
recoveryCC :: LDCC -> TVar CC
recoveryRTT :: LDCC -> IORef RTT
putRetrans :: LDCC -> PlainPacket -> IO ()
ldccQlogger :: LDCC -> QLogger
ldccState :: LDCC -> ConnState
..} TimerInfo
tmi = do
Maybe TimerInfo
mtmi <- forall a. IORef a -> IO a
readIORef IORef (Maybe TimerInfo)
timerInfo
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Maybe TimerInfo
mtmi forall a. Eq a => a -> a -> Bool
/= forall a. a -> Maybe a
Just TimerInfo
tmi) forall a b. (a -> b) -> a -> b
$ do
if TimerInfo -> EncryptionLevel
timerLevel TimerInfo
tmi forall a. Eq a => a -> a -> Bool
== EncryptionLevel
RTT1Level
then forall (m :: * -> *) a. MonadIO m => STM a -> m a
atomically forall a b. (a -> b) -> a -> b
$ forall a. TVar a -> a -> STM ()
writeTVar TVar TimerInfoQ
timerInfoQ forall a b. (a -> b) -> a -> b
$ TimerInfo -> TimerInfoQ
Next TimerInfo
tmi
else LDCC -> TimerInfo -> IO ()
updateLossDetectionTimer' LDCC
ldcc TimerInfo
tmi
ldccTimer :: LDCC -> IO ()
ldccTimer :: LDCC -> IO ()
ldccTimer ldcc :: LDCC
ldcc@LDCC{Array EncryptionLevel (IORef Bool)
Array EncryptionLevel (IORef PeerPacketNumbers)
Array EncryptionLevel (IORef LossDetection)
Array EncryptionLevel (IORef SentPackets)
TVar (Maybe EncryptionLevel)
TVar TimerInfoQ
TVar CC
TVar SentPackets
IORef Bool
IORef Int
IORef (Maybe TimeoutKey)
IORef (Maybe TimerInfo)
IORef PeerPacketNumbers
IORef RTT
ConnState
PlainPacket -> IO ()
QLogger
timerInfoQ :: TVar TimerInfoQ
previousRTT1PPNs :: IORef PeerPacketNumbers
peerPacketNumbers :: Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: IORef Int
speedingUp :: IORef Bool
ptoPing :: TVar (Maybe EncryptionLevel)
lostCandidates :: TVar SentPackets
timerInfo :: IORef (Maybe TimerInfo)
timerKey :: IORef (Maybe TimeoutKey)
lossDetection :: Array EncryptionLevel (IORef LossDetection)
sentPackets :: Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: Array EncryptionLevel (IORef Bool)
recoveryCC :: TVar CC
recoveryRTT :: IORef RTT
putRetrans :: PlainPacket -> IO ()
ldccQlogger :: QLogger
ldccState :: ConnState
timerInfoQ :: LDCC -> TVar TimerInfoQ
previousRTT1PPNs :: LDCC -> IORef PeerPacketNumbers
peerPacketNumbers :: LDCC -> Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: LDCC -> IORef Int
speedingUp :: LDCC -> IORef Bool
ptoPing :: LDCC -> TVar (Maybe EncryptionLevel)
lostCandidates :: LDCC -> TVar SentPackets
timerInfo :: LDCC -> IORef (Maybe TimerInfo)
timerKey :: LDCC -> IORef (Maybe TimeoutKey)
lossDetection :: LDCC -> Array EncryptionLevel (IORef LossDetection)
sentPackets :: LDCC -> Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: LDCC -> Array EncryptionLevel (IORef Bool)
recoveryCC :: LDCC -> TVar CC
recoveryRTT :: LDCC -> IORef RTT
putRetrans :: LDCC -> PlainPacket -> IO ()
ldccQlogger :: LDCC -> QLogger
ldccState :: LDCC -> ConnState
..} = forall (f :: * -> *) a b. Applicative f => f a -> f b
forever forall a b. (a -> b) -> a -> b
$ do
forall (m :: * -> *) a. MonadIO m => STM a -> m a
atomically forall a b. (a -> b) -> a -> b
$ do
TimerInfoQ
x <- forall a. TVar a -> STM a
readTVar TVar TimerInfoQ
timerInfoQ
Bool -> STM ()
checkSTM (TimerInfoQ
x forall a. Eq a => a -> a -> Bool
/= TimerInfoQ
Empty)
Microseconds -> IO ()
delay Microseconds
timerGranularity
LDCC -> IO ()
updateWithNext LDCC
ldcc
updateWithNext :: LDCC -> IO ()
updateWithNext :: LDCC -> IO ()
updateWithNext ldcc :: LDCC
ldcc@LDCC{Array EncryptionLevel (IORef Bool)
Array EncryptionLevel (IORef PeerPacketNumbers)
Array EncryptionLevel (IORef LossDetection)
Array EncryptionLevel (IORef SentPackets)
TVar (Maybe EncryptionLevel)
TVar TimerInfoQ
TVar CC
TVar SentPackets
IORef Bool
IORef Int
IORef (Maybe TimeoutKey)
IORef (Maybe TimerInfo)
IORef PeerPacketNumbers
IORef RTT
ConnState
PlainPacket -> IO ()
QLogger
timerInfoQ :: TVar TimerInfoQ
previousRTT1PPNs :: IORef PeerPacketNumbers
peerPacketNumbers :: Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: IORef Int
speedingUp :: IORef Bool
ptoPing :: TVar (Maybe EncryptionLevel)
lostCandidates :: TVar SentPackets
timerInfo :: IORef (Maybe TimerInfo)
timerKey :: IORef (Maybe TimeoutKey)
lossDetection :: Array EncryptionLevel (IORef LossDetection)
sentPackets :: Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: Array EncryptionLevel (IORef Bool)
recoveryCC :: TVar CC
recoveryRTT :: IORef RTT
putRetrans :: PlainPacket -> IO ()
ldccQlogger :: QLogger
ldccState :: ConnState
timerInfoQ :: LDCC -> TVar TimerInfoQ
previousRTT1PPNs :: LDCC -> IORef PeerPacketNumbers
peerPacketNumbers :: LDCC -> Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: LDCC -> IORef Int
speedingUp :: LDCC -> IORef Bool
ptoPing :: LDCC -> TVar (Maybe EncryptionLevel)
lostCandidates :: LDCC -> TVar SentPackets
timerInfo :: LDCC -> IORef (Maybe TimerInfo)
timerKey :: LDCC -> IORef (Maybe TimeoutKey)
lossDetection :: LDCC -> Array EncryptionLevel (IORef LossDetection)
sentPackets :: LDCC -> Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: LDCC -> Array EncryptionLevel (IORef Bool)
recoveryCC :: LDCC -> TVar CC
recoveryRTT :: LDCC -> IORef RTT
putRetrans :: LDCC -> PlainPacket -> IO ()
ldccQlogger :: LDCC -> QLogger
ldccState :: LDCC -> ConnState
..} = do
TimerInfoQ
x <- forall (m :: * -> *) a. MonadIO m => TVar a -> m a
readTVarIO TVar TimerInfoQ
timerInfoQ
case TimerInfoQ
x of
TimerInfoQ
Empty -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
Next TimerInfo
tmi -> LDCC -> TimerInfo -> IO ()
updateLossDetectionTimer' LDCC
ldcc TimerInfo
tmi
updateLossDetectionTimer' :: LDCC -> TimerInfo -> IO ()
updateLossDetectionTimer' :: LDCC -> TimerInfo -> IO ()
updateLossDetectionTimer' ldcc :: LDCC
ldcc@LDCC{Array EncryptionLevel (IORef Bool)
Array EncryptionLevel (IORef PeerPacketNumbers)
Array EncryptionLevel (IORef LossDetection)
Array EncryptionLevel (IORef SentPackets)
TVar (Maybe EncryptionLevel)
TVar TimerInfoQ
TVar CC
TVar SentPackets
IORef Bool
IORef Int
IORef (Maybe TimeoutKey)
IORef (Maybe TimerInfo)
IORef PeerPacketNumbers
IORef RTT
ConnState
PlainPacket -> IO ()
QLogger
timerInfoQ :: TVar TimerInfoQ
previousRTT1PPNs :: IORef PeerPacketNumbers
peerPacketNumbers :: Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: IORef Int
speedingUp :: IORef Bool
ptoPing :: TVar (Maybe EncryptionLevel)
lostCandidates :: TVar SentPackets
timerInfo :: IORef (Maybe TimerInfo)
timerKey :: IORef (Maybe TimeoutKey)
lossDetection :: Array EncryptionLevel (IORef LossDetection)
sentPackets :: Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: Array EncryptionLevel (IORef Bool)
recoveryCC :: TVar CC
recoveryRTT :: IORef RTT
putRetrans :: PlainPacket -> IO ()
ldccQlogger :: QLogger
ldccState :: ConnState
timerInfoQ :: LDCC -> TVar TimerInfoQ
previousRTT1PPNs :: LDCC -> IORef PeerPacketNumbers
peerPacketNumbers :: LDCC -> Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: LDCC -> IORef Int
speedingUp :: LDCC -> IORef Bool
ptoPing :: LDCC -> TVar (Maybe EncryptionLevel)
lostCandidates :: LDCC -> TVar SentPackets
timerInfo :: LDCC -> IORef (Maybe TimerInfo)
timerKey :: LDCC -> IORef (Maybe TimeoutKey)
lossDetection :: LDCC -> Array EncryptionLevel (IORef LossDetection)
sentPackets :: LDCC -> Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: LDCC -> Array EncryptionLevel (IORef Bool)
recoveryCC :: LDCC -> TVar CC
recoveryRTT :: LDCC -> IORef RTT
putRetrans :: LDCC -> PlainPacket -> IO ()
ldccQlogger :: LDCC -> QLogger
ldccState :: LDCC -> ConnState
..} TimerInfo
tmi = do
forall (m :: * -> *) a. MonadIO m => STM a -> m a
atomically forall a b. (a -> b) -> a -> b
$ forall a. TVar a -> a -> STM ()
writeTVar TVar TimerInfoQ
timerInfoQ TimerInfoQ
Empty
let tim :: TimeMicrosecond
tim = TimerInfo -> TimeMicrosecond
timerTime TimerInfo
tmi
Microseconds Int
us0 <- TimeMicrosecond -> IO Microseconds
getTimeoutInMicrosecond TimeMicrosecond
tim
let us :: Int
us
| Int
us0 forall a. Ord a => a -> a -> Bool
<= Int
0 = Int
10000
| Bool
otherwise = Int
us0
Int -> IO ()
update Int
us
forall q. KeepQlog q => q -> (TimerInfo, Microseconds) -> IO ()
qlogLossTimerUpdated LDCC
ldcc (TimerInfo
tmi, Int -> Microseconds
Microseconds Int
us)
where
update :: Int -> IO ()
update Int
us = do
TimerManager
mgr <- IO TimerManager
getSystemTimerManager
TimeoutKey
key <- TimerManager -> Int -> IO () -> IO TimeoutKey
registerTimeout TimerManager
mgr Int
us (LDCC -> IO ()
onLossDetectionTimeout LDCC
ldcc)
Maybe TimeoutKey
mk <- forall a b. IORef a -> (a -> (a, b)) -> IO b
atomicModifyIORef' IORef (Maybe TimeoutKey)
timerKey (forall a. a -> Maybe a
Just TimeoutKey
key,)
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ Maybe TimeoutKey
mk forall a b. (a -> b) -> a -> b
$ TimerManager -> TimeoutKey -> IO ()
unregisterTimeout TimerManager
mgr
forall a. IORef a -> a -> IO ()
writeIORef IORef (Maybe TimerInfo)
timerInfo forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just TimerInfo
tmi
setLossDetectionTimer :: LDCC -> EncryptionLevel -> IO ()
setLossDetectionTimer :: LDCC -> EncryptionLevel -> IO ()
setLossDetectionTimer ldcc :: LDCC
ldcc@LDCC{Array EncryptionLevel (IORef Bool)
Array EncryptionLevel (IORef PeerPacketNumbers)
Array EncryptionLevel (IORef LossDetection)
Array EncryptionLevel (IORef SentPackets)
TVar (Maybe EncryptionLevel)
TVar TimerInfoQ
TVar CC
TVar SentPackets
IORef Bool
IORef Int
IORef (Maybe TimeoutKey)
IORef (Maybe TimerInfo)
IORef PeerPacketNumbers
IORef RTT
ConnState
PlainPacket -> IO ()
QLogger
timerInfoQ :: TVar TimerInfoQ
previousRTT1PPNs :: IORef PeerPacketNumbers
peerPacketNumbers :: Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: IORef Int
speedingUp :: IORef Bool
ptoPing :: TVar (Maybe EncryptionLevel)
lostCandidates :: TVar SentPackets
timerInfo :: IORef (Maybe TimerInfo)
timerKey :: IORef (Maybe TimeoutKey)
lossDetection :: Array EncryptionLevel (IORef LossDetection)
sentPackets :: Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: Array EncryptionLevel (IORef Bool)
recoveryCC :: TVar CC
recoveryRTT :: IORef RTT
putRetrans :: PlainPacket -> IO ()
ldccQlogger :: QLogger
ldccState :: ConnState
timerInfoQ :: LDCC -> TVar TimerInfoQ
previousRTT1PPNs :: LDCC -> IORef PeerPacketNumbers
peerPacketNumbers :: LDCC -> Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: LDCC -> IORef Int
speedingUp :: LDCC -> IORef Bool
ptoPing :: LDCC -> TVar (Maybe EncryptionLevel)
lostCandidates :: LDCC -> TVar SentPackets
timerInfo :: LDCC -> IORef (Maybe TimerInfo)
timerKey :: LDCC -> IORef (Maybe TimeoutKey)
lossDetection :: LDCC -> Array EncryptionLevel (IORef LossDetection)
sentPackets :: LDCC -> Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: LDCC -> Array EncryptionLevel (IORef Bool)
recoveryCC :: LDCC -> TVar CC
recoveryRTT :: LDCC -> IORef RTT
putRetrans :: LDCC -> PlainPacket -> IO ()
ldccQlogger :: LDCC -> QLogger
ldccState :: LDCC -> ConnState
..} EncryptionLevel
lvl0 = do
Maybe (TimeMicrosecond, EncryptionLevel)
mtl <- LDCC -> IO (Maybe (TimeMicrosecond, EncryptionLevel))
getLossTimeAndSpace LDCC
ldcc
case Maybe (TimeMicrosecond, EncryptionLevel)
mtl of
Just (TimeMicrosecond
earliestLossTime, EncryptionLevel
lvl) -> do
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (EncryptionLevel
lvl0 forall a. Eq a => a -> a -> Bool
== EncryptionLevel
lvl) forall a b. (a -> b) -> a -> b
$ do
let tmi :: TimerInfo
tmi = TimeMicrosecond -> EncryptionLevel -> TimerType -> TimerInfo
TimerInfo TimeMicrosecond
earliestLossTime EncryptionLevel
lvl TimerType
LossTime
LDCC -> TimerInfo -> IO ()
updateLossDetectionTimer LDCC
ldcc TimerInfo
tmi
Maybe (TimeMicrosecond, EncryptionLevel)
Nothing -> do
CC{Int
Maybe TimeMicrosecond
CCMode
ccMode :: CCMode
numOfAckEliciting :: Int
bytesAcked :: Int
ssthresh :: Int
congestionRecoveryStartTime :: Maybe TimeMicrosecond
congestionWindow :: Int
bytesInFlight :: Int
ccMode :: CC -> CCMode
numOfAckEliciting :: CC -> Int
bytesAcked :: CC -> Int
ssthresh :: CC -> Int
congestionRecoveryStartTime :: CC -> Maybe TimeMicrosecond
congestionWindow :: CC -> Int
bytesInFlight :: CC -> Int
..} <- forall (m :: * -> *) a. MonadIO m => TVar a -> m a
readTVarIO TVar CC
recoveryCC
Bool
validated <- LDCC -> IO Bool
peerCompletedAddressValidation LDCC
ldcc
if Int
numOfAckEliciting forall a. Ord a => a -> a -> Bool
<= Int
0 Bool -> Bool -> Bool
&& Bool
validated
then
LDCC -> IO ()
cancelLossDetectionTimer LDCC
ldcc
else do
Maybe (TimeMicrosecond, EncryptionLevel)
mx <- LDCC -> IO (Maybe (TimeMicrosecond, EncryptionLevel))
getPtoTimeAndSpace LDCC
ldcc
case Maybe (TimeMicrosecond, EncryptionLevel)
mx of
Maybe (TimeMicrosecond, EncryptionLevel)
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just (TimeMicrosecond
ptoTime, EncryptionLevel
lvl) -> do
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (EncryptionLevel
lvl0 forall a. Eq a => a -> a -> Bool
== EncryptionLevel
lvl) forall a b. (a -> b) -> a -> b
$ do
let tmi :: TimerInfo
tmi = TimeMicrosecond -> EncryptionLevel -> TimerType -> TimerInfo
TimerInfo TimeMicrosecond
ptoTime EncryptionLevel
lvl TimerType
PTO
LDCC -> TimerInfo -> IO ()
updateLossDetectionTimer LDCC
ldcc TimerInfo
tmi
beforeAntiAmp :: LDCC -> IO ()
beforeAntiAmp :: LDCC -> IO ()
beforeAntiAmp LDCC
ldcc = LDCC -> IO ()
cancelLossDetectionTimer LDCC
ldcc
onLossDetectionTimeout :: LDCC -> IO ()
onLossDetectionTimeout :: LDCC -> IO ()
onLossDetectionTimeout ldcc :: LDCC
ldcc@LDCC{Array EncryptionLevel (IORef Bool)
Array EncryptionLevel (IORef PeerPacketNumbers)
Array EncryptionLevel (IORef LossDetection)
Array EncryptionLevel (IORef SentPackets)
TVar (Maybe EncryptionLevel)
TVar TimerInfoQ
TVar CC
TVar SentPackets
IORef Bool
IORef Int
IORef (Maybe TimeoutKey)
IORef (Maybe TimerInfo)
IORef PeerPacketNumbers
IORef RTT
ConnState
PlainPacket -> IO ()
QLogger
timerInfoQ :: TVar TimerInfoQ
previousRTT1PPNs :: IORef PeerPacketNumbers
peerPacketNumbers :: Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: IORef Int
speedingUp :: IORef Bool
ptoPing :: TVar (Maybe EncryptionLevel)
lostCandidates :: TVar SentPackets
timerInfo :: IORef (Maybe TimerInfo)
timerKey :: IORef (Maybe TimeoutKey)
lossDetection :: Array EncryptionLevel (IORef LossDetection)
sentPackets :: Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: Array EncryptionLevel (IORef Bool)
recoveryCC :: TVar CC
recoveryRTT :: IORef RTT
putRetrans :: PlainPacket -> IO ()
ldccQlogger :: QLogger
ldccState :: ConnState
timerInfoQ :: LDCC -> TVar TimerInfoQ
previousRTT1PPNs :: LDCC -> IORef PeerPacketNumbers
peerPacketNumbers :: LDCC -> Array EncryptionLevel (IORef PeerPacketNumbers)
pktNumPersistent :: LDCC -> IORef Int
speedingUp :: LDCC -> IORef Bool
ptoPing :: LDCC -> TVar (Maybe EncryptionLevel)
lostCandidates :: LDCC -> TVar SentPackets
timerInfo :: LDCC -> IORef (Maybe TimerInfo)
timerKey :: LDCC -> IORef (Maybe TimeoutKey)
lossDetection :: LDCC -> Array EncryptionLevel (IORef LossDetection)
sentPackets :: LDCC -> Array EncryptionLevel (IORef SentPackets)
spaceDiscarded :: LDCC -> Array EncryptionLevel (IORef Bool)
recoveryCC :: LDCC -> TVar CC
recoveryRTT :: LDCC -> IORef RTT
putRetrans :: LDCC -> PlainPacket -> IO ()
ldccQlogger :: LDCC -> QLogger
ldccState :: LDCC -> ConnState
..} = do
Bool
alive <- forall a. Connector a => a -> IO Bool
getAlive LDCC
ldcc
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
alive forall a b. (a -> b) -> a -> b
$ do
Maybe TimerInfo
mtmi <- forall a. IORef a -> IO a
readIORef IORef (Maybe TimerInfo)
timerInfo
case Maybe TimerInfo
mtmi of
Maybe TimerInfo
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just TimerInfo
tmi -> do
let lvl :: EncryptionLevel
lvl = TimerInfo -> EncryptionLevel
timerLevel TimerInfo
tmi
Bool
discarded <- LDCC -> EncryptionLevel -> IO Bool
getPacketNumberSpaceDiscarded LDCC
ldcc EncryptionLevel
lvl
if Bool
discarded
then LDCC -> IO ()
updateWithNext LDCC
ldcc
else EncryptionLevel -> TimerInfo -> IO ()
lossTimeOrPTO EncryptionLevel
lvl TimerInfo
tmi
where
lossTimeOrPTO :: EncryptionLevel -> TimerInfo -> IO ()
lossTimeOrPTO EncryptionLevel
lvl TimerInfo
tmi = do
forall q. KeepQlog q => q -> IO ()
qlogLossTimerExpired LDCC
ldcc
case TimerInfo -> TimerType
timerType TimerInfo
tmi of
TimerType
LossTime -> do
Seq SentPacket
lostPackets <- LDCC -> EncryptionLevel -> IO (Seq SentPacket)
detectAndRemoveLostPackets LDCC
ldcc EncryptionLevel
lvl
Seq SentPacket
lostPackets' <- LDCC -> Seq SentPacket -> IO (Seq SentPacket)
mergeLostCandidatesAndClear LDCC
ldcc Seq SentPacket
lostPackets
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall (t :: * -> *) a. Foldable t => t a -> Bool
null Seq SentPacket
lostPackets') forall a b. (a -> b) -> a -> b
$ forall q. KeepQlog q => q -> Debug -> IO ()
qlogDebug LDCC
ldcc forall a b. (a -> b) -> a -> b
$ LogStr -> Debug
Debug LogStr
"onLossDetectionTimeout: null"
LDCC -> Seq SentPacket -> IO ()
onPacketsLost LDCC
ldcc Seq SentPacket
lostPackets'
LDCC -> Seq SentPacket -> IO ()
retransmit LDCC
ldcc Seq SentPacket
lostPackets'
LDCC -> EncryptionLevel -> IO ()
setLossDetectionTimer LDCC
ldcc EncryptionLevel
lvl
TimerType
PTO -> do
CC{Int
Maybe TimeMicrosecond
CCMode
ccMode :: CCMode
numOfAckEliciting :: Int
bytesAcked :: Int
ssthresh :: Int
congestionRecoveryStartTime :: Maybe TimeMicrosecond
congestionWindow :: Int
bytesInFlight :: Int
ccMode :: CC -> CCMode
numOfAckEliciting :: CC -> Int
bytesAcked :: CC -> Int
ssthresh :: CC -> Int
congestionRecoveryStartTime :: CC -> Maybe TimeMicrosecond
congestionWindow :: CC -> Int
bytesInFlight :: CC -> Int
..} <- forall (m :: * -> *) a. MonadIO m => TVar a -> m a
readTVarIO TVar CC
recoveryCC
if Int
bytesInFlight forall a. Ord a => a -> a -> Bool
> Int
0
then do
LDCC -> EncryptionLevel -> IO ()
sendPing LDCC
ldcc EncryptionLevel
lvl
else do
Bool
validated <- LDCC -> IO Bool
peerCompletedAddressValidation LDCC
ldcc
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
validated forall a b. (a -> b) -> a -> b
$ forall q. KeepQlog q => q -> Debug -> IO ()
qlogDebug LDCC
ldcc forall a b. (a -> b) -> a -> b
$ LogStr -> Debug
Debug LogStr
"onLossDetectionTimeout: RTT1"
EncryptionLevel
lvl' <- forall a. Connector a => a -> IO EncryptionLevel
getEncryptionLevel LDCC
ldcc
LDCC -> EncryptionLevel -> IO ()
sendPing LDCC
ldcc EncryptionLevel
lvl'
LDCC -> IO () -> IO ()
metricsUpdated LDCC
ldcc forall a b. (a -> b) -> a -> b
$
forall a. IORef a -> (a -> a) -> IO ()
atomicModifyIORef'' IORef RTT
recoveryRTT forall a b. (a -> b) -> a -> b
$
\RTT
rtt -> RTT
rtt{ptoCount :: Int
ptoCount = RTT -> Int
ptoCount RTT
rtt forall a. Num a => a -> a -> a
+ Int
1}
LDCC -> EncryptionLevel -> IO ()
setLossDetectionTimer LDCC
ldcc EncryptionLevel
lvl