Ejemplo n.º 1
0
/* removes every ack'd packet from unackd_packets
 * should be called AFTER updating send_unack
 */
static void packet_t_remove(context_t *ctx) {
    while (list_size(ctx->unackd_packets) > 0) {
        packet_t *oldpack = list_get_at(ctx->unackd_packets, 0);

        /* update RTO given this packet */
        update_rto(ctx, oldpack);


        /* if all the data in the packet was acknowledged, discard and delete from list */
        if (ctx->send_unack >= oldpack->seq_num + (oldpack->packet_size - sizeof(STCPHeader))) {
            free(oldpack->packet);
            oldpack->packet = NULL;
            list_delete_at(ctx->unackd_packets, 0);
        }
        else
            /* this packet and all beyond it are unacknowledged */
            break;
    }
    return;
}
Ejemplo n.º 2
0
    /*
      When a subsequent RTT measurement R' is made, a host MUST set

      RTTVAR <- (1 - beta) * RTTVAR + beta * |SRTT - R'|
      SRTT <- (1 - alpha) * SRTT + alpha * R'

      The value of SRTT used in the update to RTTVAR is its value
      before updating SRTT itself using the second assignment.  That
      is, updating RTTVAR and SRTT MUST be computed in the above
      order.

      The above SHOULD be computed using alpha=1/8 and beta=1/4 (as
      suggested in [JK88]).

      After the computation, a host MUST update
      RTO <- SRTT + max (G, K*RTTVAR)
    */
    inline void sub_rtt_measurement(duration_t R) {
        RTTVAR = (1 - beta) * RTTVAR + beta * std::abs(SRTT-R);
        SRTT = (1 - alpha) * SRTT + alpha * R;
        update_rto();
    }
Ejemplo n.º 3
0
    /*
      When the first RTT measurement R is made, the host MUST set

      SRTT <- R
      RTTVAR <- R/2
      RTO <- SRTT + max (G, K*RTTVAR)

      where K = 4.
    */
    inline void first_rtt_measurement(duration_t R) {
        SRTT = R;
        RTTVAR = R/2;
        update_rto();
    }