-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release 2015.09 - RC4 #7
Comments
There seems to be a library on your host system needed for that (for Ubuntu and gcc 4.8 it is |
Task 06.01 is little bit tricky to do with the given applications: it can't send packets of size 1kB and it does not count the received packets (nor checks if they are duplicates of some sort). |
Should we write a test application for that? |
I know, but I guess copying the application and modifying it to fit the needs is not too complicated. |
Probably wouldn't hurt. |
I just patched diff --git a/examples/gnrc_networking/Makefile b/examples/gnrc_networking/Makefile
index f91d1f3..495d1bf 100644
--- a/examples/gnrc_networking/Makefile
+++ b/examples/gnrc_networking/Makefile
@@ -21,8 +21,6 @@ USEMODULE += gnrc_ipv6_router_default
USEMODULE += gnrc_udp
# Add a routing protocol
USEMODULE += gnrc_rpl
-# This application dumps received packets to STDIO using the pktdump module
-USEMODULE += gnrc_pktdump
# Additional networking modules that can be dropped if not needed
USEMODULE += gnrc_icmpv6_echo
# Add also the shell, some shell commands
diff --git a/examples/gnrc_networking/udp.c b/examples/gnrc_networking/udp.c
index 2344045..304ce90 100644
--- a/examples/gnrc_networking/udp.c
+++ b/examples/gnrc_networking/udp.c
@@ -22,22 +22,68 @@
#include <inttypes.h>
#include "kernel.h"
+#include "msg.h"
#include "net/gnrc.h"
#include "net/gnrc/ipv6.h"
#include "net/gnrc/udp.h"
-#include "net/gnrc/pktdump.h"
+#include "thread.h"
#include "timex.h"
#include "vtimer.h"
+#define SERVER_MSG_QUEUE_SIZE (8U)
+#define SERVER_PRIO (THREAD_PRIORITY_MAIN - 1)
+#define SERVER_STACKSIZE (THREAD_STACKSIZE_MAIN)
+
static gnrc_netreg_entry_t server = { NULL, GNRC_NETREG_DEMUX_CTX_ALL, KERNEL_PID_UNDEF };
+static char server_stack[SERVER_STACKSIZE];
+static msg_t server_queue[SERVER_MSG_QUEUE_SIZE];
+static kernel_pid_t server_pid = KERNEL_PID_UNDEF;
+static uint8_t send_count = 0;
+
+static void *_eventloop(void *arg)
+{
+ (void)arg;
+ msg_t msg, reply;
+ unsigned int rcv_count = 0, snd_count = 0;
+
+ /* setup the message queue */
+ msg_init_queue(server_queue, SERVER_MSG_QUEUE_SIZE);
+
+ reply.content.value = (uint32_t)(-ENOTSUP);
+ reply.type = GNRC_NETAPI_MSG_TYPE_ACK;
+
+ while (1) {
+ msg_receive(&msg);
+
+ switch (msg.type) {
+ case GNRC_NETAPI_MSG_TYPE_RCV:
+ printf("Packets received: %d\n", ++rcv_count);
+ gnrc_pktbuf_release((gnrc_pktsnip_t *)msg.content.ptr);
+ break;
+ case GNRC_NETAPI_MSG_TYPE_SND:
+ printf("Packets send: %d\n", ++snd_count);
+ gnrc_pktbuf_release((gnrc_pktsnip_t *)msg.content.ptr);
+ break;
+ case GNRC_NETAPI_MSG_TYPE_GET:
+ case GNRC_NETAPI_MSG_TYPE_SET:
+ msg_reply(&msg, &reply);
+ break;
+ default:
+ break;
+ }
+ }
+ /* never reached */
+ return NULL;
+}
-static void send(char *addr_str, char *port_str, char *data, unsigned int num,
+static void send(char *addr_str, char *port_str, char *data_len_str, unsigned int num,
unsigned int delay)
{
uint8_t port[2];
uint16_t tmp;
ipv6_addr_t addr;
+ size_t data_len;
/* parse destination address */
if (ipv6_addr_from_str(&addr, addr_str) == NULL) {
@@ -53,14 +99,21 @@ static void send(char *addr_str, char *port_str, char *data, unsigned int num,
port[0] = (uint8_t)tmp;
port[1] = tmp >> 8;
+ data_len = (size_t)atoi(data_len_str);
+ if (data_len == 0) {
+ puts("Error: unable to parse data_len");
+ return;
+ }
+
for (unsigned int i = 0; i < num; i++) {
gnrc_pktsnip_t *payload, *udp, *ip;
/* allocate payload */
- payload = gnrc_pktbuf_add(NULL, data, strlen(data), GNRC_NETTYPE_UNDEF);
+ payload = gnrc_pktbuf_add(NULL, NULL, data_len, GNRC_NETTYPE_UNDEF);
if (payload == NULL) {
puts("Error: unable to copy data to packet buffer");
return;
}
+ memset(payload->data, send_count++, data_len);
/* allocate UDP header, set source port := destination port */
udp = gnrc_udp_hdr_build(payload, port, 2, port, 2);
if (udp == NULL) {
@@ -103,8 +156,16 @@ static void start_server(char *port_str)
puts("Error: invalid port specified");
return;
}
+ if (server_pid <= KERNEL_PID_UNDEF) {
+ server_pid = thread_create(server_stack, sizeof(server_stack), SERVER_PRIO,
+ CREATE_STACKTEST, _eventloop, NULL, "UDP server");
+ if (server_pid <= KERNEL_PID_UNDEF) {
+ puts("Error: can not start server thread");
+ return;
+ }
+ }
/* start server (which means registering pktdump for the chosen port) */
- server.pid = gnrc_pktdump_getpid();
+ server.pid = server_pid;
server.demux_ctx = (uint32_t)port;
gnrc_netreg_register(GNRC_NETTYPE_UDP, &server);
printf("Success: started UDP server on port %" PRIu16 "\n", port); |
Note, that since |
See RIOT-OS/RIOT#4038 and RIOT-OS/RIOT#4039 respectively about the C++ issue. |
We forgot to close this ;-) |
testutils.mixins: use assignment instead of equality
This issue lists the status of all tests for the Release Candidate 4 of the 2015.09 release.
Specs tested:
1000 packets transmitted, 1000 received, 0% packet loss, time 10.06155388 s
(and pktbuf is empty)1000 packets transmitted, 1000 received, 0% packet loss, time 100.06267042 s
3600 packets transmitted, 3600 received, 0% packet loss, time 3600.06266335 s
1000 packets transmitted, 1000 received, 0% packet loss, time 18.06298406 s
1000 packets transmitted, 1000 received, 0% packet loss, time 119.06712665 s
(and pktbuf is empty)1000 packets transmitted, 998 received, 1% packet loss, time 243.06217368 s
10000 packets transmitted, 9996 received, 1% packet loss, time 1222.06596852 s
100 packets transmitted, 100 received, 0% packet loss, time 1.0619766 s
100 packets transmitted, 99 received, 1% packet loss, time 16.06761171 s
10 packets transmitted, 10 received, 0% packet loss, time 0.0693490 s
Packets received: 999
(forgot to addod
, so nopktbuf
check possible, but should be alright)1000000 packets transmitted, 1000000 received, 0% packet loss, time 33466ms
100000 packets transmitted, 100000 received, 0% packet loss, time 3684ms
100000 packets transmitted, 100000 received, 0% packet loss, time 3.06685815 s
100000 packets transmitted, 99648 received, 0% packet loss, time 1010348ms
100000 packets transmitted, 93395 received, 7% packet loss, time 21539.06641653 s
The text was updated successfully, but these errors were encountered: