I am able to send data from node to a server code running on Linux through border router. I achieved that using https://github.com/contiki-os/contiki/blob/master/examples/udp-ipv6/udp-client.c example code from Contiki. I am running a python code to receive those data on Linux board, see this Linux userspace code to communicate between Linux board and each node running contiki udp sender example code. Let's call a node NODE_A, the second node NODE_B, and the Linux board as the NODE_C. NODE_A and NODE_B data are reaching to NODE_C, I also want NODE_A and NODE_B to talk to each other. How can I make NODE_A and NODE_B talk to each other? Thanks!
On NODE_A edit udp_client.c example something like this where address of NODE_B : fd00::abcd:aaaa:bbbb, NODE_B: fd00:dddd:aaaa:bbbb NODE_C : fd00::1
uip_ipaddr_t NODE_B;
uip_ipaddr_t NODE_C;
uip_ip6addr(&NODE_C, 0xfd00, 0, 0, 0, 0, 0, 0, 1);
uip_ip6addr(&NODE_B, 0xfd00, 0, 0, 0, 0, 0xabcd, 0xaaaa, 0xbbbb);
/* new connection with remote host */
client_conn_NODE_B = udp_new(&NODE_C, UIP_HTONS(3000), NULL);
udp_bind(client_conn_NODE_B, UIP_HTONS(3001));
/* new connection with remote host */
client_conn_NODE_B = udp_new(&NODE_B, UIP_HTONS(3002), NULL);
udp_bind(client_conn_NODE_B, UIP_HTONS(3003));
on NODE_B
uip_ipaddr_t NODE_A;
uip_ipaddr_t NODE_C;
uip_ip6addr(&NODE_C, 0xfd00, 0, 0, 0, 0, 0, 0, 1);
uip_ip6addr(&NODE_A, 0xfd00, 0, 0, 0, 0, 0xdddd, 0xaaaa, 0xbbbb);
/* new connection with remote host */
client_conn_NODE_B = udp_new(&NODE_C, UIP_HTONS(3000), NULL);
udp_bind(client_conn_NODE_B, UIP_HTONS(3001));
/* new connection with remote host */
client_conn_NODE_B = udp_new(&NODE_B, UIP_HTONS(3003), NULL);
udp_bind(client_conn_NODE_B, UIP_HTONS(3002));
NODE_C is my Linux board I wrote a test code something like this
import socket, struct
UDP_LOCAL_IP = 'aaaa::1'
UDP_LOCAL_PORT = 5678
try:
socket_rx = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
socket_rx.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
socket_rx.bind((UDP_LOCAL_IP, UDP_LOCAL_PORT))
except Exception:
print "ERROR: Server Port Binding Failed"
print 'UDP server ready: %s'% UDP_LOCAL_PORT
print
while True:
data, addr = socket_rx.recvfrom(1024)
print "address : ", addr
print "received message: ", data
print "\n"
socket_rx.sendto("Hello from serevr\n", (UDP_REMOTE_IP, UDP_REMOTE_PORT))