[erlang-questions] UDP questions

Artie Gold the.artiegold@REDACTED
Thu Jan 28 02:34:02 CET 2016


If, of course, it arrives at all. Larger messages, spanning several MTUs are more likely to be dropped.

Sent from my iPhone

> On Jan 27, 2016, at 7:24 PM, Serge Aleynikov <serge@REDACTED> wrote:
> 
> In addition to what others have said, the max UDP binary size that can be sent/received is:
> 64k - (sizeof(IPHeader) + sizeof(UDPHeader)) = 65535- (20 + 8) = 65507.  This is the UDP protocol's limitation.  I would say if you use UDP, the {packet, N} option makes little sense, since each udp message is delivered as a whole (UDP is message oriented vs. TCP that is byte-oriented).
> 
> I see between your 3rd and 4th questions there's some confusion. UDP fragmentation may happen at the network layer (IP) when sending a large datagram (> MTU size), but it's defragmented by the network stack, and delivered to the transport layer (UDP) and consequently the user space as a whole message (preserving message boundaries).
> 
> Regards,
> 
> Serge
> 
>> On Wed, Jan 27, 2016 at 10:27 AM, Joe Armstrong <erlang@REDACTED> wrote:
>> Hello,
>> 
>> I have a simple UDP client/server
>> 
>> The server is on a fixed port 4567 - I open it like this
>> 
>>     {ok, Socket} = gen_udp:open(4567, [binary]),
>> 
>> then wait for registrations
>>     receive
>> {udp, Socket, _Ip, _Port, <<"register">>) ->
>> 
>> 
>> Clients do this:
>> 
>>      {ok, Socket} = gen_udp:open(0, [binary]),
>>      gen_udp:send(Socket, "localhost", 44567, <<"register">>),
>>      ...
>> 
>> I'm testing on "localhost"
>> 
>> After registration the processes send binaries to each other
>> 
>> This works fine for small binaries but gen_udp:send fails  with
>> {error,emsgsize} for large binaries
>> 
>> So I have a few questions:
>> 
>>     1) Can I find out the max binary size that can be sent/received?
>>     2) Can I increase the max size?
>>     3) Is there a guaranteed minimum packet length that will not be fragemented?
>>     3) Can received packets be fragmented - TCP has a  {packet,N}
>>        option and some built-in defragmentation, what's the story for
>>        UDP?
>> 
>> I think I know the answers to these but I'm not really sure - could somebody
>> who really knows enlighten me?
>> 
>> Thanks
>> 
>> /Joe
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160127/ebe68dc6/attachment.htm>


More information about the erlang-questions mailing list