pub fn retransmit_tcp_timedout(
        &mut self,
        dst: SocketAddrV4,
        src: SocketAddrV4,
    ) -> io::Result<()> {
        let state = self
            .get_state_mut(dst, src)
            .ok_or(io::Error::from(io::ErrorKind::NotFound))?;
        let next_rto = state.next_rto();
        let payload = state.cache_mut().get_timed_out_and_update(next_rto);
        let sequence = state.cache().sequence();
        let size = state.cache().len();

        if size > 0 {
            if payload.len() > 0 {
                // Double RTO
                state.double_rto();

                // Congestion control
                if let Some(cc) = &mut state.cc_mut() {
                    cc.timedout();
                }

                // If all the cache is get, the FIN should also be sent
                if size == payload.len() && state.cache_fin().is_some() {
                    // ACK/FIN
                    state.update_fin_timer();
                    trace!(
                        "retransmit TCP ACK/FIN ({} Bytes) and FIN {} -> {} from {} due to timeout",
                        payload.len(),
                        dst,
                        src,
                        sequence
                    );

                    // Send
                    self.send_tcp_ack(dst, src, sequence, payload.as_slice(), true)?;
                } else {
                    // ACK
                    trace!(
                        "retransmit TCP ACK ({} Bytes) {} -> {} from {} due to timeout",
                        payload.len(),
                        dst,
                        src,
                        sequence
                    );

                    // Send
                    self.send_tcp_ack(dst, src, sequence, payload.as_slice(), false)?;
                }
            }
        } else {
            // FIN
            if let Some(timer) = state.cache_fin() {
                if timer.is_timedout() {
                    // Double RTO
                    state.double_rto();
                    state.update_fin_timer();
                    trace!("retransmit TCP FIN {} -> {} due to timeout", dst, src);

                    // Send
                    self.send_tcp_fin(dst, src)?;
                }
            }
        }

        // Delayed ACK0
        let state = self
            .get_state(dst, src)
            .ok_or(io::Error::from(io::ErrorKind::NotFound))?;
        if state.delayed_ack() {
            self.send_tcp_ack_0(dst, src)?;
        }

        Ok(())
    }
/// Retransmits timed out TCP packets from the cache. This method is used for transmitting
/// timed out data.
Retransmits timed out TCP packets from the cache. This method is used for transmitting
timed out data.
Retransmits timed out TCP packets from the cache . This method is used for transmitting timed out data .
pub fn retransmit_tcp_timedout(
        &mut self,
        dst: SocketAddrV4,
        src: SocketAddrV4,
    ) -> io::Result<()> {
        let state = self
            .get_state_mut(dst, src)
            .ok_or(io::Error::from(io::ErrorKind::NotFound))?;
        let next_rto = state.next_rto();
        let payload = state.cache_mut().get_timed_out_and_update(next_rto);
        let sequence = state.cache().sequence();
        let size = state.cache().len();
        if size > 0 {
            if payload.len() > 0 {
                // Double RTO
                state.double_rto();
                // Congestion control
                if let Some(cc) = &mut state.cc_mut() {
                    cc.timedout();
                }
                // If all the cache is get, the FIN should also be sent
                if size == payload.len() && state.cache_fin().is_some() {
                    // ACK/FIN
                    state.update_fin_timer();
                    trace!(
                        "retransmit TCP ACK/FIN ({} Bytes) and FIN {} -> {} from {} due to timeout",
                        payload.len(),
                        dst,
                        src,
                        sequence
                    );
                    // Send
                    self.send_tcp_ack(dst, src, sequence, payload.as_slice(), true)?;
                } else {
                    // ACK
                    trace!(
                        "retransmit TCP ACK ({} Bytes) {} -> {} from {} due to timeout",
                        payload.len(),
                        dst,
                        src,
                        sequence
                    );
                    // Send
                    self.send_tcp_ack(dst, src, sequence, payload.as_slice(), false)?;
                }
            }
        } else {
            // FIN
            if let Some(timer) = state.cache_fin() {
                if timer.is_timedout() {
                    // Double RTO
                    state.double_rto();
                    state.update_fin_timer();
                    trace!("retransmit TCP FIN {} -> {} due to timeout", dst, src);
                    // Send
                    self.send_tcp_fin(dst, src)?;
                }
            }
        }
        // Delayed ACK0
        let state = self
            .get_state(dst, src)
            .ok_or(io::Error::from(io::ErrorKind::NotFound))?;
        if state.delayed_ack() {
            self.send_tcp_ack_0(dst, src)?;
        }
        Ok(())
    }
pub fn retransmit_tcp_timedout ( & mut self , dst : SocketAddrV4 , src : SocketAddrV4 , ) -> io :: Result < ( ) > { let state = self . get_state_mut ( dst , src ) . ok_or ( io :: Error :: from ( io :: ErrorKind :: NotFound ) ) ? ; let next_rto = state . next_rto ( ) ; let payload = state . cache_mut ( ) . get_timed_out_and_update ( next_rto ) ; let sequence = state . cache ( ) . sequence ( ) ; let size = state . cache ( ) . len ( ) ; if size > 0 { if payload . len ( ) > 0 { // Double RTO state . double_rto ( ) ; // Congestion control if let Some ( cc ) = & mut state . cc_mut ( ) { cc . timedout ( ) ; } // If all the cache is get, the FIN should also be sent if size == payload . len ( ) && state . cache_fin ( ) . is_some ( ) { // ACK/FIN state . update_fin_timer ( ) ; trace ! ( " " payload len ( ) dst src sequence ) ; // Send self . send_tcp_ack ( dst , src , sequence , payload . as_slice ( ) , true ) ? ; } else { // ACK trace ! ( " " payload len ( ) dst src sequence ) ; // Send self . send_tcp_ack ( dst , src , sequence , payload . as_slice ( ) , false ) ? ; } } } else { // FIN if let Some ( timer ) = state . cache_fin ( ) { if timer . is_timedout ( ) { // Double RTO state . double_rto ( ) ; state . update_fin_timer ( ) ; trace ! ( " " dst src ) ; // Send self . send_tcp_fin ( dst , src ) ? ; } } } // Delayed ACK0 let state = self . get_state ( dst , src ) . ok_or ( io :: Error :: from ( io :: ErrorKind :: NotFound ) ) ? ; if state . delayed_ack ( ) { self . send_tcp_ack_0 ( dst , src ) ? ; } Ok ( ( ) ) }
Retransmits timed out TCP packets from the cache.
Retransmits timed out TCP packets from the cache .
&mut self
dst
SocketAddrV4
src
SocketAddrV4
&mut self
dst
SocketAddrV4
src
SocketAddrV4