Jump to content

uIP doesn't seem to be receiving broadcast UDP


avockley
 Share

Recommended Posts

I have an application on my computer that is both broadcasting and unicasting udp. Anything that it sends to a unicast IP is picked up correctly by the app running on my LPC core. The issue is that anything that is sent to the broadcast address on the network is not being received. I have a debug messasge at the first level of the UIP_TASK_UIP_AppCall function that should show all incoming data, and only the unicast packets make it that far. The strange thing is that all incoming packets, unicast and broadcast, cause the activity light on the lpcxpresso to blink. Is there something I have to do to enable uIP to receive broadcast UDP, or is there some other issue on my network or computer?

Edited by avockley
Link to comment
Share on other sites

No, you have to use the uip_udp_bind function.

Just have a look into the osc_server.c file (I guess that you remember this file).

Search for osc_local_port, it gives you all the places where I'm "installing" and checking for the port number.

Note that only ports announced with uip_udp_bind will notify the OSC_SERVER_AppCall() function about new packets.

There are other possibilities of course, but this would require a change in the original uIP code (search for UDP in uip.c)

I tried to find a solution which is compatible (although not optimal).

Best Regards, Thorsten.

Link to comment
Share on other sites

The issue with using uip_udp_bind is that it requires that I know the ip address of the remote peer before running the app. My app gets the remote ip address from data in a broadcast packet, and also (if I follow all specs) should be able to receive from multiple ip addresses on the same local port. The second part isn't really important, but I would have to bind to a port to get the ip address to set up the port binding..... which obviously won't work. Is my best option to try rewriting parts of uip.c?

Edit: And as I just realized, the point of using broadcast in this particular protocol is so that my device doesn't need to know anything about the network it is on. It just gets all the data and sorts out what it needs. I don't want to have to give it the ip of the remote device. The remote ip may not even be available always, as this protocol is designed to work on a closed LAN without any computers, only embedded devices.

Edited by avockley
Link to comment
Share on other sites

Ok, seems that I just was just to lazy to type "grep -i broadcast $MIOS32_PATH/modules/uip/uip/*" for you! ;-)

There is an option called "UIP_BROADCAST", which is derived from "UIP_CONF_BROADCAST"

I guess that this flag has to be inserted into the local uip-conf.h file of your application:


#define UIP_CONF_BROADCAST 1
[/code] For more background details, just search for the keyword "broadcast" in uip.c E.g. following part indicates, that this option checks for an All-One IP address (255.255.255.255):
[code]
#if UIP_BROADCAST
DEBUG_PRINTF("UDP IP checksum 0x%04x\n", uip_ipchksum());
if(BUF->proto == UIP_PROTO_UDP &&
uip_ipaddr_cmp(BUF->destipaddr, all_ones_addr)
/*&&
uip_ipchksum() == 0xffff*/) {
goto udp_input;
}
#endif /* UIP_BROADCAST */

Forget what I wrote about port 65535, this was related to a different topic.

Best Regards, Thorsten.

Link to comment
Share on other sites

I actually already found that option. I have it enabled, but It doesn't seem to fix any of my issues.

Edit: And I've just figured it out. I missed the "all ones" address in uip.c. The broadcast address this protocol uses is 2.255.255.255. I think that is the issue.

Edited by avockley
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...