class VpnWatchdog {

    void handleTimeout() throws AdVpnThread.VpnNetworkException {
        if (!enabled)
            return;
        Log.d(TAG, "handleTimeout: Milliseconds elapsed between last receive and sent: "
                + (lastPacketReceived - lastPacketSent));
        // Receive really timed out.
        if (lastPacketReceived < lastPacketSent && lastPacketSent != 0) {
            initPenalty += INIT_PENALTY_INC;
            if (initPenalty > INIT_PENALTY_END)
                initPenalty = INIT_PENALTY_END;
            throw new AdVpnThread.VpnNetworkException("Watchdog timed out");
        }
        // We received a packet after sending it, so we can be more confident and grow our wait
        // time.
        pollTimeout *= POLL_TIMEOUT_GROW;
        if (pollTimeout > POLL_TIMEOUT_END)
            pollTimeout = POLL_TIMEOUT_END;


        sendPacket();
    }

}