[riot-notifications] [RIOT-OS/RIOT] test_utils: add UDP benchmark (#16710)

Karl Fessel notifications at github.com
Thu Sep 2 13:56:13 CEST 2021


@kfessel commented on this pull request.



> +        printf("\t\tnum RT\t\tRTT");
+    }
+    puts("");
+
+    for (list_node_t* n = head->next; n; n = n->next) {
+        bench_client_t *node = container_of(n, bench_client_t, node);
+        uint8_t addr_len;
+
+        inet_ntop(AF_INET6, &node->addr.sin6_addr, addr_str, INET6_ADDRSTRLEN);
+        addr_len = printf("%s", addr_str);
+
+        if (addr_len > max_addr_len) {
+            max_addr_len = addr_len;
+        }
+
+        unsigned bw = (node->count_rx * (payload_len + sizeof(benchmark_msg_ping_t)))

```suggestion
        unsigned bw = (node->count_rx * (/*bytes_in*/))
```
payload_len may not be the payload length since the client decides about it,
i suggest  storring bytes_in of the last package, that and the bandwidth.


> +        struct sockaddr_in6 src_addr;
+        socklen_t addr_len = sizeof(src_addr);
+
+        /* receive incoming packet */
+        ssize_t bytes_in = recvfrom(sock, buffer, sizeof(buffer), 0,
+                                    (struct sockaddr*)&src_addr, &addr_len);
+
+        if (bytes_in <= 0 || addr_len != sizeof(src_addr)) {
+            continue;
+        }
+
+        bool new_node;
+        bench_client_t *node = _find_or_add(&head, &src_addr, &new_node);
+
+        benchmark_msg_ping_t *ping = (void *)buffer;
+        node->count_tx = ping->seq_no + 1;

since count_tx is the sequenz number of the last recives package, it may be labeled like this in the output

> +                                     ? (100 * node->count_rt) / node->count_tx
+                                     : 0;
+            printf("\t%u (%u%%)\t%u µs", node->count_rt, success_rate_rt, node->rtt_us);
+        }
+        puts("");
+    }
+}
+
+static void dispatch_loop(int sock)
+{
+    list_node_t head = { .next = NULL };
+    struct timeval tv_now, tv_last = { 0 };
+
+    puts("entering loop…");
+    while (1) {
+        uint8_t buffer[BENCH_PAYLOAD_SIZE_MAX + sizeof(benchmark_msg_ping_t)];

?
how about allocating it using calloc according do the cmdline-parameters (make this al little more flexible)
?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16710#pullrequestreview-744946205
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210902/48222fc2/attachment.htm>


More information about the notifications mailing list