UDP over v6: payload truncated at 1024 bytes

Peter Lund peter@REDACTED
Mon Apr 5 14:58:57 CEST 2004


> On Monday 05 April 2004 14.10, Peter Lund wrote:
>> At least in IPv4 (and TCP) you cannot ever count on any packet
>> of any size to arrive at the destination without being fragmented
>> into 2 or more parts. If this is different for UDP and in v6,
>> I do not know. But hopefully someone else can tell...
>
> But surely the operating system should re-assemble the two fragments
> before
> passing it to the application, even for UDP, no?

No! The OS (any OS) does not help you when running TCP/IPv4.

Using gen_tcp in erlang you will have to receive packets one at
the time and after receiving each packet, you need to concatenate
with any previous rest message and then decide if you have got it
all or not. If all has arrived, then process...

A common technique is to first send a length indicator, and then
the actual message itself.

In JAVA there is a special read
<someSocketOrDataInputClass>.readFully(Buffer)
That locks until the whole bufferlength has been filled to assist
in this. In erlang you have to code it yourself.

-- 
Peter Lund
mobile: +46 70 543 9416
http://www.lundata.se




More information about the erlang-questions mailing list