[erlang-questions] UDP questions

Joe Armstrong erlang@REDACTED
Thu Jan 28 16:40:51 CET 2016


On Thu, Jan 28, 2016 at 2:24 AM, 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).

Yes - it was my understanding that the UDP packet if it is received
by the application is not fragmented - but I wasn't sure.

/Joe

>
> 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
>
>



More information about the erlang-questions mailing list