Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Increase Bandwidth Restriction

Discussion in 'Multiplayer' started by Dreamteck, Aug 18, 2015.

  1. Dreamteck

    Dreamteck

    Joined:
    Feb 12, 2015
    Posts:
    336
    TL;DR version: Is there some configuration I have to make regarding network bandwidth restriction or is my method for sending files not good and I have to make changes there ?

    Hello, I had to migrate a simple file transfer system from the old Networking system to UNET and I encountered a problem with the send speed. My files are read into byte arrays and then using a ReliableSequenced channel transferred to another client into chunks of 1300 bytes. I don't send all the chunks at once, I have a loop that sends N chunks at a time and then waits for a response from the receiver before it sends the next group of chunks. However, sending seems to be really slow and messages stack into the send and receive buffers (I had to increase connectionConfig.MaxSentMessageQueueSize). Now I must point out that the sender and the receiver are both running on the same machine and are connected directly through the localhost IP so this is not a network issue. No matter how many chunks at a time I send I always get the same slow speed. Literally, sending one 1300 byte chunk and waiting for a response performs exactly as sending 50 chunks and then waitinf for a response. I opened the task manager (I'm on Windows) while transferring the file and both the sender and receiver used below 0.0Mbps occasionally going to 0.1 for a brief period of time. That didn't happen with the previous networking system and on a local machine I could almost instantly transfer the file between the peers.
     
  2. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    There is buffering in NetworkConnection that could be effecting the rate. Try setting SetMaxDelay(0) on the connection object, or using a separate transport layer connection.
     
  3. Dreamteck

    Dreamteck

    Joined:
    Feb 12, 2015
    Posts:
    336
    Hi seanr,
    I tried using SetMaxDelay(0) on the connection but it had no effect. I looked it up in the documentation and it says:
    "The maximum time in seconds that messages are buffered before being sent.". But what does that mean ? Does it mean that by setting this to zero no messages will be buffered and all messages will be sent directly ? Could that affect the sequence of the messages when sending multiple messages at once ?
    I will try using a separate transport layer connection but do you mean that I have to establish a new client-server connection in parallel on a different port or just initialize the NetworkTransport and create a new connection and send data over it ?
     
  4. sebeisdrache

    sebeisdrache

    Joined:
    Jan 16, 2015
    Posts:
    34
    Hello,

    i have a very similar problem, but if I set the MaxDelay to zero by the networkmanager class I got a disconnect too but with this console output:

     
  5. leizzer

    leizzer

    Joined:
    Jun 26, 2013
    Posts:
    39
    Did you solve it? I have this error too
     
  6. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    501
    Please Unity 5 Networking Team could you look into this Reliable Sequenced slow send rate issue. I'm getting it also and its just impossible to get a working application running with send rates so slow.
     
  7. leizzer

    leizzer

    Joined:
    Jun 26, 2013
    Posts:
    39
    If you are having the same problem that I had, which was that the data was too big for Reliable Sequenced.

    I fixed it by adding an other channel that is a Reliable Fragmented to your networkmanager, in my case Channel #2, then you have to specify that the function should send the message through that channel like this:

    Code (csharp):
    1.  
    2. @ClientRpc(channel=2)
    3. function RpcMyFatData(data : byte[]){
    4.   // function body
    5. }
    6.