Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

SPLIT: UDP packet size


  • Please log in to reply
2 replies to this topic

#1 NameOfTheDragon

NameOfTheDragon

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationCanterbury, Kent, UK

Posted 31 July 2015 - 08:36 AM

I'm trying to send UDP broadcasts containing a JSON document - over a certain size the broadcast appears to have worked but never arrives at the receiver. I tried increasing the buffer size using code similar to above, but that throws "NotSupportedException" in Netduino.IP...

 

Is there a hard limit on the size of UDP broadcasts? If not, how to I increase the size I can send?

 

--Tim Long



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 August 2015 - 03:35 AM

Hey Tim,

Generally speaking it's best to keep UDP packets down in the <=~500 byte range, but it's possible to make them up to ~1500 bytes in size. Each packet contains the _entire_ message you're sending.

Regarding buffer size (from the original thread): that's for TCP RX buffers. TCP streams data across multiple packets and buffers the stream in memory. UDP doesn't know if one packet is related to another packet.

What is the size of data you're trying to send via UDP? [Perhaps we need to add an extra exception instead of failing gracefully somewhere here.]

Chris

P.S. I've repurposed UDP before for streaming data. If you add a sequence # to the front of your UDP packets, you can reassemble them on the other side. But unless there's a really good reason to do this manually, use TCP: it does this for you.

#3 NameOfTheDragon

NameOfTheDragon

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationCanterbury, Kent, UK

Posted 07 August 2015 - 09:33 PM

Hey Tim,

Generally speaking it's best to keep UDP packets down in the <=~500 byte range, but it's possible to make them up to ~1500 bytes in size. Each packet contains the _entire_ message you're sending.

Regarding buffer size (from the original thread): that's for TCP RX buffers. TCP streams data across multiple packets and buffers the stream in memory. UDP doesn't know if one packet is related to another packet.

What is the size of data you're trying to send via UDP? [Perhaps we need to add an extra exception instead of failing gracefully somewhere here.]

Chris

P.S. I've repurposed UDP before for streaming data. If you add a sequence # to the front of your UDP packets, you can reassemble them on the other side. But unless there's a really good reason to do this manually, use TCP: it does this for you.

Right, thanks Chris. I'm a bit rusty getting this low down in the network stack, I can make broadcasts with TCP, right? If so then that would be the way to go.

 

My data is of indeterminate size because I'm serializing to JSON and it can depend on things like the length of strings, how many decimal places numbers have and so on. If I took a worst-case maximum it would be well over 1500 bytes. So it looks like TCP is the way to go.

 

I definitely think you should throw an exception if you can't complete the request that the user has given you.

 

Best regards,

Tim






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.