[riot-notifications] [RIOT-OS/RIOT] tools/zep_dispatch: add support for advanced topologies (#15773)

Francisco notifications at github.com
Tue Jul 6 17:14:50 CEST 2021


@fjmolinas commented on this pull request.

Could you uncrusitfy the `zep_dispatch` files? Maybe on a separate commit if they were not uncrusitfied before. Otherwise tested and it works as advertised:

```
bin/zep_dispatch -t example.topo -g example.gv ::1 17754
entering loop…
adding node DA:44:B3:25:ED:92:D8:B4
adding node AE:7A:0E:1B:B0:35:D5:1F
adding node AA:C8:95:35:3B:18:92:82
can't add DE:1E:30:63:D6:9B:F7:7D - topology full
can't add DE:1E:30:63:D6:9B:F7:7D - topology full
can't add DE:1E:30:63:D6:9B:F7:7D - topology full
can't add DE:1E:30:63:D6:9B:F7:7D - topology full
```

```
 327159    1376  111388  439923   6b673 /home/francisco/workspace/RIOT2/examples/gnrc_networking/bin/native/gnrc_networking.elf
/home/francisco/workspace/RIOT2/examples/gnrc_networking/bin/native/gnrc_networking.elf -z [::1]:17754 /dev/ttyACM0
RIOT native interrupts/signals initialized.
LED_RED_OFF
LED_GREEN_ON
RIOT native board initialized.
RIOT native hardware initialization complete.

main(): This is RIOT! (Version: 2021.04-devel-695-g42055-pr-15773)
RIOT network stack example application
All up, running the shell now
> ping ff02::1 -c 10
ping ff02::1 -c 10
12 bytes from fe80::d844:b325:ed92:d8b4%7: icmp_seq=1 ttl=64 rssi=255 dBm time=2.166 ms
12 bytes from fe80::d844:b325:ed92:d8b4%7: icmp_seq=3 ttl=64 rssi=255 dBm time=1.975 ms
12 bytes from fe80::d844:b325:ed92:d8b4%7: icmp_seq=5 ttl=64 rssi=255 dBm time=1.737 ms
12 bytes from fe80::d844:b325:ed92:d8b4%7: icmp_seq=6 ttl=64 rssi=255 dBm time=2.352 ms
12 bytes from fe80::ac7a:e1b:b035:d51f%7: icmp_seq=6 ttl=64 rssi=255 dBm time=2.520 ms (DUP!)
12 bytes from fe80::d844:b325:ed92:d8b4%7: icmp_seq=8 ttl=64 rssi=255 dBm time=1.515 ms
12 bytes from fe80::d844:b325:ed92:d8b4%7: icmp_seq=9 ttl=64 rssi=255 dBm time=1.546 ms

--- ff02::1 PING statistics ---
10 packets transmitted, 6 packets received, 1 duplicates, 40% packet loss
round-trip min/avg/max = 1.515/1.973/2.520 ms
>
```


> @@ -7,10 +9,29 @@ bin:
 	mkdir bin
 
 RIOTBASE:=../../..

```suggestion
RIOTBASE := ../../..
```

> @@ -7,10 +9,29 @@ bin:
 	mkdir bin
 
 RIOTBASE:=../../..
-RIOT_INCLUDE=$(RIOTBASE)/core/include
+
+ZEP_PORT_BASE ?= 17754
+TOPOLOGY      ?= example.topo
+GV_OUT        ?= example.gv
+
+RIOT_INCLUDE += -I$(RIOTBASE)/core/include
+RIOT_INCLUDE += -I$(RIOTBASE)/cpu/native/include
+RIOT_INCLUDE += -I$(RIOTBASE)/drivers/include
+RIOT_INCLUDE += -I$(RIOTBASE)/sys/include
+
 SRCS:=$(wildcard *.c)

```suggestion
SRCS := $(wildcard *.c)
``` 

>  clean:
 	rm -f $(BINARY)
+
+run: $(BINARY)
+	$(BINARY) -t $(TOPOLOGY) -g $(GV_OUT) ::1 $(ZEP_PORT_BASE)
+
+graph:

Can these targets be documented?

> +
+void topology_send(const topology_t *t, int sock,
+                   const uint8_t *mac_src, size_t mac_src_len,
+                   void *buffer, size_t len)
+{
+    for (list_node_t *edge = t->edges.next; edge; edge = edge->next) {
+        struct edge *super = container_of(edge, struct edge, next);
+
+        if (!super->a->mac_len || !super->b->mac_len) {
+            continue;
+        }
+
+        if ((mac_src_len == super->a->mac_len) &&
+            (memcmp(super->a->mac, mac_src, mac_src_len) == 0)) {
+            /* packet loss */
+            if (random() > super->weight_a_b * INT_MAX) {

Shouldn't it compare to `RAND_MAX`?

> +                   (memcmp(super->b->mac, mac_src, mac_src_len) == 0)) {
+            /* packet loss */
+            if (random() > super->weight_b_a * INT_MAX) {
+                return;
+            }
+            zep_set_lqi(buffer, super->weight_b_a * 0xFF);
+            sendto(sock, buffer, len, 0, (struct sockaddr*)&super->a->addr, sizeof(super->a->addr));
+        }
+    }
+}
+
+bool topology_add(topology_t *t, const uint8_t *mac, uint8_t mac_len,
+                  struct sockaddr_in6 *addr)
+{
+    struct node *empty = NULL;
+    char addr_str[3 * HW_ADDR_MAX_LEN];

Why 3?

> +    e->b = _find_or_create_node(nodes, b);
+    e->weight_a_b = atof(e_ab);
+    e->weight_b_a = atof(e_ba);
+
+    list_add(edges, &e->next);
+
+    return true;
+}
+
+int topology_print(const char *file, const topology_t *t)
+{
+    FILE *out;
+    char addr_str[3 * HW_ADDR_MAX_LEN];
+
+    if (t->flat) {
+        // TODO

?

>  clean:
 	rm -f $(BINARY)
+
+run: $(BINARY)
+	$(BINARY) -t $(TOPOLOGY) -g $(GV_OUT) ::1 $(ZEP_PORT_BASE)
+
+graph:

If it's going to kill running processes maybe add a small `echo "killing running zep_dispatch`, could be nice to add a comment on why it must be killed.

-- 
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/15773#pullrequestreview-700055201
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210706/2ed72431/attachment-0001.htm>


More information about the notifications mailing list