Hi,

On 18.07.19 15:25, oliver wrote:
Hello together,

I'm trying to understand, how the UDP sock API [1] works, but the
documentation /example are very bad / useless.
That's a little bit harsh when you consider that there is a full working example in the link you provided. But feel free to send improvements and actual criticism i guess.
1:
How can I create an UDP server which listen on a specific port and has
an unique IPv6 addr ?? The example [1] isn't very helpful. I don't
understand why some variables like "local" [2] are defined. The
documentation does not help. The documentation says "Common IP-based
transport layer end point." for the struct sock_udp_ep_t. But why do I
need this?? I want to receive and send udp packages to other boards. Why
is this so difficult to implement ??

To send to and receive from a socket you need an endpoint. That's how sockets works. In POSIX your endpoint is just a file descriptor.

You can use the POSIX socket wrapper if you like but if you click on SOCK_ADDR_ANY_NETIF it shows exactly what it means.

"Special netif ID for "any interface"."

So this endpoint just listen on any interface your board provides. you can also listen on a specific address/interface if you want. (See below)

"local.port <https://doc.riot-os.org/struct__sock__tl__ep.html#a00b5dbff09ee8e87806fff6280966140>= 12345;"

This is your UDP port.

2:
How can I send an udp package with the following parameters given:
- message
- portnumber
- dst ipv6 addr

The documentation / example does not help here either.

There is a UDP Client in the documentation which works perfectly for me. To be fair this example uses multicast addresses but you can exchange "ipv6_addr_set_all_nodes_multicast" with "ipv6_addr_from_str" to set "remote.addr <https://doc.riot-os.org/struct__sock__tl__ep.html#ab2be8d7dee78c9a5462d074b56ff1406>.ipv6 <https://doc.riot-os.org/struct__sock__tl__ep.html#ac57a885cc2ffcebc1759e3ac4c60cec9>" for unicast. (Also checkout [1])

Further, you can have a look into the "gnrc_networking" example in the official sources. IIRC it does exactly what you want.

3:
How can I get the unique Ipv6 addr from my device (samr21-xpro). I want
to call "getIPv6()" and want the Ipv6 addr which this device has.

That's not how networking with IPv6 works. You got one or more interfaces available to your OS. Every interface can have a number of IPv6 addresses with different scopes.

Normally every interface should have a link local scope address. You can have a look in the ifconfig shell command if you want a code example. Also there is a documentation under [2]. You can use the "gnrc_netif_iter" function to iterate over all network interfaces and have a look into the ipv6 member of the returned structs to get the actual addresses.


Robin

[1] https://doc.riot-os.org/group__net__ipv6__addr.html

[2] https://doc.riot-os.org/group__net__gnrc__netif.html

_______________________________________________
users mailing list
[email protected]
https://lists.riot-os.org/mailman/listinfo/users

Reply via email to