Search Unity

[LLAPI] Dealing with QoS Fragmented data limit

Discussion in 'Multiplayer' started by Ghosthowl, Jun 18, 2015.

  1. Ghosthowl

    Ghosthowl

    Joined:
    Feb 2, 2014
    Posts:
    228
    I am trying to find a way to deal with packet fragmentation. I seem to have hit a limit and am confused at how to get around it.

    On joining in my game, I need to send a LOT of data to the connection about the state of the world. I send this data through the QoS ReliableFragmented. On the receiving end, I am having issues with not being able to get this data as I get the error 'buffer <= 0xFFFF' which i assume means the byte[] buffer I use cannot be bigger than 65535? This is about 65kb.

    Based on the post here: http://blogs.unity3d.com/2014/06/11/all-about-the-unity-networking-transport-layer/
    I believed that behind the scenes the data was sent to the LLAPI as a whole, split up into differing packets of a max size, sent individually, then on the receiving end reconstructed. This data would then be available for retrieval as a data event. It sends fine, but I cannot reconstruct the data if it is bigger than this buffer limit. I get the error 'MessageToLong'. I would have thought the upper limit for the buffer would be around 2147483591 but it seems there's a hard limit imposed underneath.

    Is there any way to overcome this?
     
  2. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    Hmm
    1. The maximum send message size is 0xFFFF - headers ~ 65k.
    2. If you will overfull this limit Send() will return false and will set error to MessageToLong.

    3. On receiving size you need to provide buffer enough to hold all data. : something like
    Receive( out host, out conn, out chan, buffer, 65535, out recSize, error ); ...
    or something like
    Receive( out host, out conn, out chan, buffer, 1024, out recSize, error );
    if( error == MessageToLong )
    buffer = new buffer[recSize];
    Receive( out host, out conn, out chan, buffer, 1024, out recSize, error );
     
  3. Ghosthowl

    Ghosthowl

    Joined:
    Feb 2, 2014
    Posts:
    228
    Ah I see.

    Thanks! I got around this by implementing my own fragmentation. Still testing it out but I've run into another separate issue.
     
  4. mRmEEeZ_

    mRmEEeZ_

    Joined:
    Jan 24, 2016
    Posts:
    4
    what about NetworkServer.ConnectionConfig with QoS Channel of "Unreliable Fragmented Sequenced" type ?!
    as it state in the documentation fragmentation will be handled automatically by Unity 2017.3.0.3f

    why is it still throwing this "Overflow size" exception ?!
     
  5. mRmEEeZ_

    mRmEEeZ_

    Joined:
    Jan 24, 2016
    Posts:
    4
    it's for VoIP btw