Remove RTT and packet loss estimation code.
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 11 Jan 2015 13:44:15 +0000 (14:44 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 11 Jan 2015 13:44:15 +0000 (14:44 +0100)
This is not working at all anymore. Just remove it, and we'll do another
attempt at RTT, bandwidth and packet loss estimation after the new
probing code stabilizes.

src/net_packet.c
src/node.h

index 76b3c5e..f666fd9 100644 (file)
@@ -117,10 +117,6 @@ static void udp_probe_h(node_t *n, vpn_packet_t *packet, length_t len) {
                        uint8_t *data = DATA(packet);
                        *data++ = 2;
                        uint16_t len16 = htons(len); memcpy(data, &len16, 2); data += 2;
-                       struct timeval now;
-                       gettimeofday(&now, NULL);
-                       uint32_t sec = htonl(now.tv_sec); memcpy(data, &sec, 4); data += 4;
-                       uint32_t usec = htonl(now.tv_usec); memcpy(data, &usec, 4); data += 4;
                        packet->len = MIN_PROBE_SIZE;
                } else {
                        /* Legacy protocol: n won't understand type 2 probe replies. */
@@ -171,31 +167,6 @@ static void udp_probe_h(node_t *n, vpn_packet_t *packet, length_t len) {
                        n->minmtu = probelen;
                        try_fix_mtu(n);
                }
-
-               /* Calculate RTT.
-                  The RTT is the time between the MTU probe burst was sent and the first
-                  reply is received.
-                */
-
-               struct timeval now, diff;
-               gettimeofday(&now, NULL);
-               timersub(&now, &n->probe_time, &diff);
-
-               struct timeval probe_timestamp = now;
-               if (DATA(packet)[0] == 2 && packet->len >= 11) {
-                       uint32_t sec; memcpy(&sec, DATA(packet) + 3, 4);
-                       uint32_t usec; memcpy(&usec, DATA(packet) + 7, 4);
-                       probe_timestamp.tv_sec = ntohl(sec);
-                       probe_timestamp.tv_usec = ntohl(usec);
-               }
-               
-               n->probe_counter++;
-
-               if(n->probe_counter == 1) {
-                       n->rtt = diff.tv_sec + diff.tv_usec * 1e-6;
-                       n->probe_time = probe_timestamp;
-                       logger(DEBUG_TRAFFIC, LOG_DEBUG, "%s (%s) RTT %.2f ms, rx packet loss %.2f %%", n->name, n->hostname, n->rtt * 1e3, n->packetloss * 1e2);
-               }
        }
 }
 
@@ -1000,7 +971,7 @@ static void try_mtu(node_t *n) {
           mtuprobes ==    -1: send one >maxmtu probe every pingtimeout */
 
        struct timeval elapsed;
-       timersub(&now, &n->probe_sent_time, &elapsed);
+       timersub(&now, &n->mtu_ping_sent, &elapsed);
        if(n->mtuprobes >= 0) {
                if(n->mtuprobes != 0 && elapsed.tv_sec == 0 && elapsed.tv_usec < 333333)
                        return;
@@ -1009,6 +980,8 @@ static void try_mtu(node_t *n) {
                        return;
        }
 
+       n->mtu_ping_sent = now;
+
        try_fix_mtu(n);
 
        if(n->mtuprobes < 0) {
@@ -1061,23 +1034,6 @@ static void try_mtu(node_t *n) {
                if(n->mtuprobes >= 0)
                        n->mtuprobes++;
        }
-
-       n->probe_counter = 0;
-       n->probe_sent_time = now;
-       n->probe_time = now;
-
-       /* Calculate the packet loss of incoming traffic by comparing the rate of
-          packets received to the rate with which the sequence number has increased.
-          TODO: this is unrelated to PMTU discovery - it should be moved elsewhere.
-        */
-
-       if(n->received > n->prev_received)
-               n->packetloss = 1.0 - (n->received - n->prev_received) / (float)(n->received_seqno - n->prev_received_seqno);
-       else
-               n->packetloss = n->received_seqno <= n->prev_received_seqno;
-
-       n->prev_received_seqno = n->received_seqno;
-       n->prev_received = n->received;
 }
 
 /* These functions try to establish a tunnel to a node (or its relay) so that
index cd9e2d9..aadb0b5 100644 (file)
@@ -88,18 +88,15 @@ typedef struct node_t {
        uint32_t farfuture;                     /* Packets in a row that have arrived from the far future */
        unsigned char* late;                    /* Bitfield marking late packets */
 
-       struct timeval udp_ping_sent;           /* Last time a ping probe was sent */
+       struct timeval udp_ping_sent;           /* Last time a UDP probe was sent */
        timeout_t udp_ping_timeout;             /* Ping timeout event */
 
+       struct timeval mtu_ping_sent;           /* Last time a MTU probe was sent */
+
        length_t mtu;                           /* Maximum size of packets to send to this node */
        length_t minmtu;                        /* Probed minimum MTU */
        length_t maxmtu;                        /* Probed maximum MTU */
        int mtuprobes;                          /* Number of probes */
-       struct timeval probe_sent_time;         /* Time the last probe was sent */
-       struct timeval probe_time;              /* Time the last probe was sent or received */
-       int probe_counter;                      /* Number of probes received since last burst was sent */
-       float rtt;                              /* Last measured round trip time */
-       float packetloss;                       /* Last measured packet loss rate */
 
        uint64_t in_packets;
        uint64_t in_bytes;