diff --git a/examples/gnrc_border_router/main.c b/examples/gnrc_border_router/main.c index 73aa63c6cc..654b411a50 100644 --- a/examples/gnrc_border_router/main.c +++ b/examples/gnrc_border_router/main.c @@ -21,9 +21,16 @@ #include #include "shell.h" +#include "msg.h" + +#define MAIN_QUEUE_SIZE (8) +static msg_t _main_msg_queue[MAIN_QUEUE_SIZE]; int main(void) { + /* we need a message queue for the thread running the shell in order to + * receive potentially fast incoming networking packets */ + msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); puts("RIOT border router example application"); /* start shell */ diff --git a/examples/gnrc_networking/main.c b/examples/gnrc_networking/main.c index c3c66f9978..6301f4291d 100644 --- a/examples/gnrc_networking/main.c +++ b/examples/gnrc_networking/main.c @@ -21,6 +21,10 @@ #include #include "shell.h" +#include "msg.h" + +#define MAIN_QUEUE_SIZE (8) +static msg_t _main_msg_queue[MAIN_QUEUE_SIZE]; extern int udp_cmd(int argc, char **argv); @@ -31,6 +35,9 @@ static const shell_command_t shell_commands[] = { int main(void) { + /* we need a message queue for the thread running the shell in order to + * receive potentially fast incoming networking packets */ + msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); puts("RIOT network stack example application"); /* start shell */ diff --git a/sys/shell/commands/sc_icmpv6_echo.c b/sys/shell/commands/sc_icmpv6_echo.c index 61af94b193..c02a846b26 100644 --- a/sys/shell/commands/sc_icmpv6_echo.c +++ b/sys/shell/commands/sc_icmpv6_echo.c @@ -136,6 +136,7 @@ int _icmpv6_ping(int argc, char **argv) timex_t delay = { 1, 0 }; char *addr_str; ipv6_addr_t addr; + msg_t msg; gnrc_netreg_entry_t *ipv6_entry, my_entry = { NULL, ICMPV6_ECHO_REP, thread_getpid() }; @@ -211,7 +212,6 @@ int _icmpv6_ping(int argc, char **argv) vtimer_now(&start); while ((remaining--) > 0) { - msg_t msg; gnrc_pktsnip_t *pkt; timex_t start, stop, timeout = { 5, 0 }; @@ -284,6 +284,13 @@ int _icmpv6_ping(int argc, char **argv) stop = timex_sub(stop, start); gnrc_netreg_unregister(GNRC_NETTYPE_ICMPV6, &my_entry); + while(msg_try_receive(&msg) > 0) { + if (msg.type == GNRC_NETAPI_MSG_TYPE_RCV) { + printf("dropping additional response packet (probably caused by duplicates)\n"); + gnrc_pktsnip_t *pkt = (gnrc_pktsnip_t *)msg.content.ptr; + gnrc_pktbuf_release(pkt); + } + } printf("--- %s ping statistics ---\n", addr_str);