[riot-notifications] [RIOT-OS/RIOT] Send message from host PC to networking boards via border_router (#11534)

talalong notifications at github.com
Thu May 23 17:37:17 CEST 2019

First of all, thank you all for your answers:

> Are you sure that %tap0 is the correct network interface?

@PeterKietzmann yes. after connecting `sam_border(border_router)` to my host pc and calling `make term`.

using `ifconfig` here is what I got from my host pc network interface:

> ep0s3: ...
> lo: ...
> tap0      Link encap:Ethernet  HWaddr fa:f8:65:43:2a:a0  
>           inet6 addr: fe80::f8f8:65ff:fe43:2aa0/64 Scope:Link
>           inet6 addr: fe80::1/64 Scope:Link
>           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>           RX packets:3 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000 
>           RX bytes:240 (240.0 B)  TX bytes:1296 (1.2 KB)


> You register a UDP server. Have a look at the sock API or the implementation of the gnrc_pktdump module whichw as mentioned by @taherrera. I'd recomment the first option though!

adding [A Simple UDP Echo Server](https://doc.riot-os.org/group__net__sock__udp.html) into /gnrc_networking/udp.c, I am able to start my _custom server_ via `shell_commands` and getting message from `udp.c` is possible for now.
**BUT** again I have to run this (command below) on my host maschine instead of using `fe80::%tap0` in order to send the message successfully. -> **Am I wrong?**
`nc -6uv 2001:db8::7b62:311b:efa4:9f9e 8080`
And using `netcat` is also not my goal.
I tried to create a client on my host maschine to send a message to the server what I have created on `sam_node(gnrc_networking)`. using this sample code I have found on the internet, but no success. Is it wrong, how I bind the address ?
#include <stdio.h> 
#include <stdlib.h> 
#include <unistd.h> 
#include <string.h> 
#include <sys/types.h> 
#include <sys/socket.h> 
#include <arpa/inet.h> 
#include <netinet/in.h> 
#define PORT     8080 
#define MAXLINE 1024 
int main() { 
    int sockfd; 
    char buffer[MAXLINE]; 
    char *hello = "Hello from client"; 
    struct sockaddr_in     servaddr;   
    if ( (sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) { 
        perror("socket creation failed"); 
    memset(&servaddr, 0, sizeof(servaddr));     
    // Filling server information 
    servaddr.sin_family = AF_INET; 
    servaddr.sin_port = htons(PORT); 
    //inet_aton("2001:db8::7b62:311b:efa4:9f9e", &servaddr.sin_addr.s_addr);
    servaddr.sin_addr.s_addr = inet_addr("2001:db8::7b62:311b:efa4:9f9e");
    //servaddr.sin_addr.s_addr = //INADDR_ANY;       
    int n, len;      
    sendto(sockfd, (const char *)hello, strlen(hello), 
        MSG_CONFIRM, (const struct sockaddr *) &servaddr,  
    printf("Hello message sent.\n");       
    n = recvfrom(sockfd, (char *)buffer, MAXLINE,  
                MSG_WAITALL, (struct sockaddr *) &servaddr, 
    buffer[n] = '\0'; 
    printf("Server : %s\n", buffer);  
    return 0; 

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190523/05e6fadc/attachment-0001.html>

More information about the notifications mailing list