Comments (9)
- tests/cpp11_* are failing on native, but work on iotlab-m3
There seems to be a library on your host system needed for that (for Ubuntu and gcc 4.8 it is libstdc++-4.8-dev:i386
), but I still got a linker issue.
from release-specs.
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).
from release-specs.
Should we write a test application for that?
from release-specs.
I know, but I guess copying the application and modifying it to fit the needs is not too complicated.
from release-specs.
Should we write a test application for that?
Probably wouldn't hurt.
from release-specs.
I just patched gnrc_networking
[edit: forgot to release packets in UDP server]
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);
from release-specs.
Note, that since gnrc_pktdump
was removed you need to add od
if you want to use the patched-in pktbuf
command.
from release-specs.
See RIOT-OS/RIOT#4038 and RIOT-OS/RIOT#4039 respectively about the C++ issue.
from release-specs.
We forgot to close this ;-)
from release-specs.
Related Issues (20)
- Release 2022.07 - RC2 HOT 4
- Release 2022.07 - RC3 HOT 7
- Release 2022.07 - RC4 HOT 25
- Release 2022.10 - RC1 HOT 7
- Release 2022.10 - RC2 HOT 9
- Release 2022.10 - RC3 HOT 18
- Release 2023.01 - RC1 HOT 3
- Release 2023.01 - RC2 HOT 2
- Release 2023.01 - RC3 HOT 14
- 08 - Task 11: Building zephyr on atsamr21_xpro not possible HOT 4
- Release 2023.04 - RC1 HOT 12
- [RFC] Restructure/update Release Specs HOT 2
- Release 2023.04 - RC2 HOT 5
- Release 2023.04 - RC3 HOT 3
- Release 2023.07 - RC5 HOT 15
- Release 2023.10 - RC1 HOT 11
- Release 2023.10 - RC2 HOT 5
- Release 2023.10 - RC3 HOT 4
- Release 2024.01 - RC1 HOT 4
- Release 2024.01 - RC2 HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from release-specs.