Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Unity Multiplayer New multiplayer transport release

Discussion in 'Multiplayer Networking' started by aabramychev, Oct 7, 2016.

  1. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    42
    Are you decide to bug when the client reconnects to another servers more than 16 times? Or is there any advice how to reconnect more than 16 times without getting: maximum hosts cannot exceed {16}.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Networking;
    3.  
    4. public class NetworkClientMy : NetworkClient
    5. {
    6.     public NetworkClientMy(string _host, int _port) {
    7.         Connect(_host, _port);
    8.     }
    9.  
    10. // In 16th ReConnect error occurs: maximum hosts cannot exceed {16}
    11.     public void ReConnect(string _host, int _port)
    12.     {
    13.         if(isConnected)
    14.         {
    15.             Disconnect();
    16. //                   NetworkTransport.RemoveHost(connection.hostId);
    17.         }
    18.  
    19.                Connect(_host, _port);
    20. //                  ReconnectToNewHost(_host, _port);
    21.     }
    22. }
     
  2. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    Please, leave here messages related to this thread only. What do you tell is a bug, and you need to report it as usual. Or if you want ask me personally send please direct email to me. Please...

    According your question, connect in client will create host inside, so if you cannot connect, try to delete NetworkClient object and recreate them again... Or/and report the bug
     
  3. larus

    larus

    Unity Technologies

    Joined:
    Oct 12, 2007
    Posts:
    243
    We'd very much like to hear from people who have tried this build on a real project. Like did you see it works and is stable? Does it work just like the old version? It works and is better than the old version? We'll be using that when judging when this change can go to trunk and enter a release version.
     
    isidro02139 likes this.
  4. Bitiquinho

    Bitiquinho

    Joined:
    Jun 16, 2015
    Posts:
    5
    Yes, that's what I mean. Something like calling, under the hood:

    - For each server's Add[Multicast]Group()/AddHost() with multicast address call:
    Code (csharp):
    1.  
    2.     int multicastTTL = 255;
    3.     // For IPv6
    4.     setsockopt( socketFD, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (const char*) &multicastTTL, sizeof(multicastTTL));
    5.     unsigned int interfaceIndex = 0;
    6.     setsockopt( socketFD, IPPROTO_IPV6, IPV6_MULTICAST_IF, (const char*) &interfaceIndex, sizeof(interfaceIndex));
    7.  
    8.     // For IPv4
    9.     setsockopt( socketFD, IPPROTO_IP, IP_MULTICAST_TTL, (const char*) &multicastTTL, sizeof(multicastTTL));
    10.     in_addr_t interface = htonl( INADDR_ANY );
    11.     setsockopt( socketFD, IPPROTO_IP, IP_MULTICAST_IF, (const char*) &interface, sizeof(interface));
    12.  
    - And for each client's Join[Multicast]Group()/Connect() with multicast address call:
    Code (csharp):
    1.  
    2.     // For IPv6 socketFD and struct sockaddr_in6* address
    3.     struct ipv6_mreq multicastRequest;
    4.     memcpy( &multicastRequest.ipv6mr_multiaddr, &(address->sin6_addr), sizeof(multicastRequest.ipv6mr_multiaddr) );
    5.  
    6.     multicastRequest.ipv6mr_interface = 0;
    7.     setsockopt( socketFD, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char*) &multicastRequest, sizeof(multicastRequest) );
    8.  
    9.     // For IPv4 socketFD and struct sockaddr_in* address
    10.    struct ip_mreq multicastRequest;
    11.    memcpy( &(multicastRequest.imr_multiaddr), &(address->sin_addr), sizeof(multicastRequest.imr_multiaddr) );
    12.  
    13.     multicastRequest.imr_interface.s_addr = htonl( INADDR_ANY );
    14.     setsockopt( socketFD, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*) &multicastRequest, sizeof(multicastRequest));
    15.  
    So that a single Send/sendto call to the chosen multicast address would send the message to all subscribed clients.
     
  5. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    @Bitiquinho Yes, absolute make sense. Cannot promise to implement this fast, but definitely we will
     
    isidro02139 likes this.
  6. Bitiquinho

    Bitiquinho

    Joined:
    Jun 16, 2015
    Posts:
    5
    That's really great to know. Thanks so much for all the feedback.
     
  7. Jouni-Mannonen

    Jouni-Mannonen

    Joined:
    Nov 23, 2015
    Posts:
    24
    We're using the latest build on a real project and so far everything seems to be working quite nicely - our local multiplayer over Wifi is now synchronizing at 60 fps on an average latency of ~1 frame. I can only comment on the LLAPI side of things though since it's a low level implementation and relies on just a very narrow set of API functions. Both clients run the game at 60 fps (all physics and gameplay internally run on a fixed 60 fps time step, which is then interpolated for rendering if necessary) and send limited state updates over on every frame. This is obviously impossible to achieve on the trunk/release version of Unity.

    I should be able to share some video or maybe even a build for internal testing later, but here's a screenshot from a video recorded from running the game on two computers on the same wireless network. Basically, they're synchronized within the average 1 frame of latency and object positions are compensated by using the latency information and the motion vectors. Messages are also custom but constructed using the network API MessageBase class and simple types. Local network discovery and matchmaking is handled with broadcasts. Internet-matchmaking is not yet implemented, going to wait for NAT punch through etc. before I want to go there.

    By the way, is there any way for me to find out the time when packets arrive on the low level API? Because the information comes in on the update cycle, that's a granularity of 1/60th of a second for ping times which is not very useful on local network. Obviously the old network API was able to show the average latency in milliseconds, but since I'm using the new LLAPI it would seem very redundant to open a secondary connection just to find out the latency of the primary connection.

    screenshot.png
     
  8. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    65
    Are that improvements in the Unity5.5.0b10 ?

    Because i have a serious bug with QOS channel (and so Transport layer ?). My first QOS channel is reliableSequenced, so it's definetly reliable, but not sequenced ...

    I call a CMD function for a client, the CMD will call the same function but in RPC "mode" in the reliableSequencedChannel.

    And finally, for 2 differents functions, all in this channel, the others clients will call them in a bad order when recept the final RPC functions.

    Is this by concept ?
     
  9. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    HI @Jouni-Mannonen
    Thanks for report. Unfortunately I cannot get your question: By the way, is there any way for me to find out the time when packets arrive on the low level API?
    1. What time do you want to know? Timing service is still work, so you can add timestampt to your message by using GetNetworkTimestamp() and then get delay of the message by using GetRemoteDelayTimeMS ( int hostId, int connectionId, int remoteTime, out byte error ). Do you need something else?
    2. About statistics, yes you are right. In current version I'm specially removed all stat function, as we want to get feedback from our user first and do not implement function which won't be used (primarily because they can confuse users) We will definitely add stat functions in final version, but now we will be happy to know what do you think, what we need to add?
    3. I'm not sure that we can implement else before final release (there is a limit for new features for each release + time is limiting factor too). But in our close plans is make websocket working with android and ios + record/playback implementation (+ statistic for sure). Hope we will be able to implement this soon.

    @Driiades
    Yes you are right we do not support 5.5 branches so far. What do you report is looking as a bug, but it is difficult to say if this bug in hlapi or in transport layer :( Can you try your game with this build (pinned in first message?)

    About 5.5 support, it will require significant efforts right now, so I can do this for you, but if you insist ( :) ) only. I mean if you really need this. It is why I ask you check you game against current build. If you understand that this release makes you happy, ping me please and I will try support them in 5.5 too.
     
    isidro02139 likes this.
  10. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    65
    @aabramychev Thank your for your effort ^^. I can't switch the version because you renamed a lot of thing with 5.4->5.5, so i don't want to rename all i have.

    i have my own NetworkManager (because your own had a lot of bug in the past (sorry ^^) and didn't convince me at this time).


    The 5.5 version gives me the possibility of locking match (and it's ABSOLUTLY necessary for my game) and a lot of work on particuleSystem (light/noise essentially ) so.... I can't switch :( .

    I don't really need this at this moment (take your time, but do your work well :p ) but in 1-2 months.... maybe ^^".

    AND : Yes this is a bug, and it's really anoying because my character works with State/subState, subState are available for somes states (my design ^^") and i receive state and substate activation in the wrong order !

    For explaning the bug (but you are working on a new and better version .. maybe there is no more bugs) :

    The first channel i add in NetworkServer is QOS.ReliableSequenced

    For CMD/RPC i use channel=0 (corresponding to QOS.ReliableSequenced), i tried to specify the channel or to use the default behaviour : it's the same behaviour.

    On Client : -CMDActiveSubState(string "nameOfTheSubState");
    -CMDChangeState(string "nameOftheState")

    The server receive the CMD and so call the method and do (i don't know the call order) :
    -RPCActiveSubState(string "nameOfTheSubState");
    -RPCChangeState(string "nameOftheState")

    On Client that receives RPC : State is changed and subState want to be actived : but the subState in the next state is not available so my character Debug.LogWarning("Substate not available") : it was call in a bad order !


    What is interesting in this bug is that :

    1- it's totally reproductible until you have the bug (it was not here in previous version of my prototype and i changed nothing ! )
    2- I added a lot of RPC/CMD call until the bug appears, maybe it's that ?
    3- it seems to not appear with NetworkServer.Send or client.Send or NetworkServer.Spawn because i use this to clearly synchronise some variables when a client connect (create a gameObject and assign it to the corresponding player on all clients).


    It's seems to be very difficult to synchronise things with network, so good luck ^^.





    (sry for my english :D )
     
  11. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    @Driiades Ok fair enough. I cannot promise to do this quickly but I will try to publish 5.5 based version in these two weeks. (Cannot do this faster :( )

    >and i receive state and substate activation in the wrong order !
    if it is happened persistently in local network environment without packet dropping and so on - it is a bug! please report it with reproducing steps. After reporting you can try to ping me, i will take a look (if it is urgent)
     
    Last edited: Nov 8, 2016
    isidro02139 likes this.
  12. Jouni-Mannonen

    Jouni-Mannonen

    Joined:
    Nov 23, 2015
    Posts:
    24


    Thanks, I'll see if this works for me - I just want to know the latency in finer granularity than number of frame when the packet was received. I'll try this and let you know.

    By the way, should the Android platform work exactly the same as Windows Standalone? I'm getting the kind of network issues when connected to an Android device that make it seem like the SendDelay parameter is being ignored, however I didn't debug this for a long time yet. Our game supports VR so I'd love to run it head to head with two GearVR devices, but network performance is currently the primary roadblock.
     
  13. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    @Jouni-Mannonen
    >should the Android platform work exactly the same as Windows Standalone? (Almost the same, exception work will be done in one thread)
    What issues? Only SendDelay? I will check, thanks for report
     
    isidro02139 likes this.
  14. Jouni-Mannonen

    Jouni-Mannonen

    Joined:
    Nov 23, 2015
    Posts:
    24
    Well, I didn't get an error that would tell me exactly what was going on - only a very heavily fluctuating latency which to me suggests that maybe somehow the buffers were getting congested the same way they did before the SendDelay fix. I'm building with the Unity 5.4.2f2 network code branch and the same code and app that runs smoothly on Windows-to-Windows seems to now have problems on Windows-to-Android. I can compare results on the 5.4.1 version tomorrow to see if anything has changed on my end, I had previously experienced smooth gameplay on that build between both Windows and Android.

    I'm setting SendDelay to 0 and currently sending and processing packets with every Update() at 60fps - this might seem a bit overkill but works well for our local multiplayer since the packets aren't that big.
     
  15. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    829
    Guys I told this several times I guess but for cross-play only server needs to have all connections in one game
     
  16. Jouni-Mannonen

    Jouni-Mannonen

    Joined:
    Nov 23, 2015
    Posts:
    24
    With a bit of added testing, SendDelay etc. seems to work fine. I'm experiencing a bit of slowdown on my GearVR version, which was probably causing my latency issues when my client lagged behind my server, so I'll have to profile code on my end. I'm sending multiple packets each frame at 60fps and it's still holding together just fine, most of the time.

    Are there any special performance considerations with regards to work being done in the single thread, or specific things to look out for?
     
    Last edited: Nov 12, 2016
  17. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    @Jouni-Mannonen Could you please tell more about Android-Win problem: How many messages do you send, what is latency what is jitter, what qos do you use. I will try to test here locally
     
    isidro02139 likes this.
  18. Jouni-Mannonen

    Jouni-Mannonen

    Joined:
    Nov 23, 2015
    Posts:
    24
    It seems my Android-Win issue was just something unrelated to the network library itself, and I've not had it replicate since. However, I'm trying to optimize the game performance on Android so any tips on how to maintain high performance with the network library are welcome.

    I'm sending 60 messages per second and seem to be hitting 1-3 frames of latency with Update() also running at 60 fps, which is pretty much as good as I'd expect right now. My parameters are set so that SendDelay = 0, IsAcksLong = true, MaxSentMessageQueueSize = 1024 and FragmentSize = 1024. Only using LLAPI with NetworkTransport.Send() with raw messages extended from Networking.MessageBase with automatically generated serialization.

    In summary - no problems for me in Windows-Android connection right now, but performance tips welcome.
     
  19. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    Thanks a lot. I've already asked our qa engineer to switch focus from PC to mobile platform to see what is performance and stability. Will update when I will receive result :)
     
    isidro02139 likes this.
  20. Jouni-Mannonen

    Jouni-Mannonen

    Joined:
    Nov 23, 2015
    Posts:
    24
    By the way, if there's a 2ms minimum delay before packets are being sent in multi-threaded environment (delay with thread yield), when are they sent on the single threaded (mobile) implementation? Right away (in which case are packets ever combined)? Up to 2ms after frame is finished? First/last thing on every frame?

    Basically I'm sometimes sending more than one packet per frame if there are rare state changes and I wonder if they get combined or introduce some delay. I could always combine everything internally to a single payload, but I don't know if that would make any difference.
     
  21. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    there is still artificial delay ==1ms when io thread will wait before pumping out queue, I will remove this delay (not now but will). It will explain 1ms delay, but where we lost second ms - it is a question... Hm, thanks, will check.
     
    isidro02139 likes this.
  22. Jouni-Mannonen

    Jouni-Mannonen

    Joined:
    Nov 23, 2015
    Posts:
    24
    Sorry, I thought the initial post in this thread said 2ms but checking now it says 1ms - I don't mean you have an extra delay, I just wondered when the delays happen - i.e. do they always happen at end of frame, or any context change like between Update() and LateUpdate()?

    Assuming I call Send() twice, on Android mobile device, during one frame of rendering
    - is the delay before sending the message(s) only 1 ms total?
    - will there be only one data packet sent out (if the combined payload is small enough)?
    - if I call Send() once during Update() and once during LateUpdate() will there be 1ms or 1ms+1ms delay, and are the packets still combined?

    Thanks. :)
     
  23. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    Aha, it is interesting thing. So far network subsystem doesn't sync with frames.
    algorithm works like, when you call send function it will awake thread immediately, and with senddelay = 0; thread will immediately utilize all incoming messages from this connection. Most probably it will be only one message. So when you set up senddelay = 0 and loading is not very high it will be one packet per message. To avoid this you can try batch your sending: (for (int i = 0; i < messages.Count; ++i) Send(); ) in this case you can expect that messages will be combined together in one packet.

    Hence, probably it make sense to create another pair of functions, like sendDelay, and sendBatch...
    Where sendDelay() just put message in the queue and does not awake thread, while sendBatch() will just awake them. In this case you will be (almost) sure that messages will send at the time when you need (for example end of frame) (will in sync with main thread). I put almost, as if batch will > than bandwidth some of the messages will delayed.

    Not sure about function names :(

    Make sense?
     
  24. Jouni-Mannonen

    Jouni-Mannonen

    Joined:
    Nov 23, 2015
    Posts:
    24
    Thanks, this makes sense and should be rather trivial for me to implement. Actions in our game are already logically limited so that there can be only one packet of its kind on every frame (i.e. you can either catch the ball if it's free, or you can kick the ball if you're holding it, but not both actions at the same time). Batch sending will simply be a question of holding on to the packets until I have resolved the whole frame.

    I'd tell you the performance differential but unfortunately it's quite impossible for me to profile this. :)
     
  25. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    OK. Sounds good. I'm going to restore statistic function on this week, and think I can add the sendBatch() SendDelay() function too. So I guess I can publish the next release before end of the next week.
     
    Jouni-Mannonen and isidro02139 like this.
  26. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    65
    @aabramychev

    It was my fault for the error on bad order for RPC/Cmd message. I tried with a clean Unity project and that works great !
    So sorry ^^.

    I wait a new Unity version for testing your new Transport layer :)
     
  27. perplex_bcn

    perplex_bcn

    Joined:
    Mar 1, 2013
    Posts:
    15
    @aabramychev So Sorry for the delay. Didn't read your answer till now. We've moved to another solution. Thak you for your interest!
     
  28. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    1,674
    Are the new changes in 5.4.3p1 or 5.5. already, or is your 5.4.2p2 version still the latest Unity version that we can test it with? If it's not in the latest version, do you already know when it will be? I am really looking forward to that multithreading part.
     
  29. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    Hi vis good question, I merged new version of transport with last 5.4.3f1 yesterday, with goal publish it today... but, by some reason i cannot get 100% test coverage for this build, failed test no related to unet, but i cannot publish them without double check.... so, waiting. Everything ready, except this strange problem...

    For 5.5, I promised to publish but, sorry, I did take a look how many work should be done (merging + testing). it i a lot of work. So, not sure that I will be able to do this before Christmas.

    Good news, unet new transport has been officially settled in trunk and will be officially realized in 5.6.

    again, i'm sorry for delaying :(
     
    PhilSA likes this.
  30. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    1,674
    Sounds good, thanks
     
  31. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    aha, found the problem :) I merged with p3 too early... so if everything will go right i will publish a little bit later
     
    Jouni-Mannonen, moco2k and vis2k like this.
  32. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    65
    Hi !

    Not for the 5.5 and not before christmas is ok !

    I Finally built my game : https://ragequit-studio.itch.io/dolls?password=F9k4>\~u .

    But if you test it, sometime (not every time, it's more at 20 hours to 22 hours of the night) Unet doesn't work very well.
    We get some disconnections (no timeout, just disconnected for no reason) and the service isn't very stable. Can you check it ?

    Can you also fix and be more explicit about hostId ? I fought again this for the LAN mode and the switch betwen Online(Unet)/LAN.
     
  33. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    @Driiades
    Sorry, do not understand you :)
    it is for this experiential build?

    >Can you also fix and be more explicit about hostId ?
    what do you mean?
     
  34. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    65
    Hummm sry, so i try again to be more explicit @,@.

    "it is for this experiential build?" Yes i work with Unet for this game, but we have still some issues with your server and the system (disconnection... but why ?). It's a personnal project, i'm student ^^.


    The hostId is not very clear. I didn't understand it's purpose. The majority of time i wanted to NetworkTransport.Shutdown() or close the listening of LAN match BUT : hostId caused some errors. (hostId out of bound {0} max {1}, or sometime (because that changes) bound{1} max {0} ... )

    Why do you not handle this error automatically ?

    the typical example of what i was doing :
    -Searching online match
    -Switching to LAN match
    -Switching to online match by stopping the discovery of LAN match ----> hostId error.
    -Create a match (and so close the discovery of LAN match) -> hostId error.
    -Close a match and enable listing of LAN match -> hostId error.

    So, what i did : i forget NetworkTransport.Shutdown(); and that... works, but why ? i don't know.

    Maybe i'm just bad because i don't have so much network knowledge ^^ .
     
    Last edited: Dec 2, 2016
  35. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    65
    But you can test my project, you will see very soon the problem. You are connected, all things are ok and ..... dumb disconnected. And that's not true for every party.

    You have more tools on the server side that i have ^^ .
     
  36. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    ok i will take a look
     
  37. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    @Driiades, I don't understand how I suppose to take a look on your game without sources?
     
  38. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    65
    Just to see the disconnection occured for no reason.
    I can send you my sources, but it's a ton of lines ^^.
    Mp if you really want.
     
    Last edited: Dec 2, 2016
  39. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    Hm, I'm not a wizard :) I cannot fix a bugs by just looking on them :( I'm sorry about.

    So if you want, I can take a look on problem, but i will need source code (better stripping source without all of unnecessary details) and step by step description what I should to do for reproducing the problem. Just looking on problem usually takes couple of hours so if you need help, please, be prepared :)
     
  40. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    New version deployed see, first message in the thread
     
    Jouni-Mannonen and vis2k like this.
  41. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    1,674
    @aabramychev I am testing the new version with a server and client running on the same computer. I want to send large amounts of packets to the client, so that I can see how much CPU power the server utilizies with ThreadPoolSize=8.

    I am running into all kinds of UNET errors, crashes and possibly memory leaks when getting anywhere near 200KB/s already (that's what OSX Network Info shows). Can you advise on which config settings to use to send large amounts of packets to a client running on the same computer? Or is 200KB/s already the limit that can be sent to one client? Or maybe did I find a UNET bug? Or maybe the HLAPI can't keep up with your LLAPI?

    Here is my config:
    Screenshot at Dec 06 11-23-13.png

    I send messages with a simple script attached to the player:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Networking;
    3.  
    4. public class Spam : MessageBase {
    5.     public static short MsgId = 5000;
    6.     public string text;
    7. }
    8.  
    9. public class PacketSpam : NetworkBehaviour {
    10.     [TextArea] public string message = "xxxxxxxxxxxxxx";
    11.     public int amount = 200;
    12.  
    13.     public override void OnStartLocalPlayer() {
    14.         NetworkManager.singleton.client.RegisterHandler(Spam.MsgId, OnSpam);
    15.     }
    16.  
    17.     [ServerCallback]
    18.     void FixedUpdate () {
    19.         for (int i = 0; i < amount; ++i) {
    20.             var msg = new Spam();
    21.             msg.text = message + i;
    22.             connectionToClient.Send(Spam.MsgId, msg);
    23.         }
    24.     }
    25.  
    26.     void OnSpam(NetworkMessage netMsg) {
    27.         var msg = netMsg.ReadMessage<Spam>();
    28.     }
    29. }
    Sending 100 messages per FixedUpdate works.
    Sending 200 messages per FixedUpdate works for 10-20 seconds, then UNET errors appear.
    Sending 500 messages per FixedUpdate causes errors almost immediately.

    Server Errors:
    Client Errors:
    (I reported this one a long time ago on the forums and on the bug tracker: https://issuetracker.unity3d.com/is...lash-readbytes-out-of-range-errors-in-clients . It's HLAPI so probably not your problem)

    I can also send you the project if you want, it's just a NetworkManager, a Player and two scripts.
     
    Last edited: Dec 6, 2016
  42. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    Hm, see,

    you set your bandwidth to 0, while provide packetSize and MinUpdateTimeout, so your bandwidth will calculate using these parameters: Band = packetSize*MinUpdateTimepit = 2000/0.01 == 200,000 bytes per sec... Set your bandwidth to expected value should fix one of the problem.

    Thread pooling won't help with one connection, each new connection will be load balanced through the thread pool.

    What crashes? It is interesting :) If you have time could you check please with/without HLAPI ? (bandwidth 200K and loading about 200K?) If you have no time could you add more explanation i will ask qa to check.

    thanks for report Alex
     
  43. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    @vis2k Yes it would be nice :) (sending project)
     
  44. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    So, I would say there are 3 big feature will come (we will try to implement before release):
    1. Session record/play back + encoding (allow user record his network session then encode it or/and playback it)
    2. dynamical window for reliable message (allow send more than 64 reliable packets before first ack will received)
    3. restore network simulator

    Actually we would like to see suggestions from your guys what we need too :)
     
    vis2k likes this.
  45. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    332
    Personally, what I want the most at the moment is not a feature, but a proof of performance and reliability of the basic UNET functions. I'd love to see a publicly-available UNET test game project that we can all join and stress-test. As long as it is pretty demanding network-wise, it wouldn't really matter what the game is. I think a networking system like this is just too vast and complex for simple closed-off tests to mean anything. It has to be tested in a real-life scenario (aka a complete game)

    I think lots of people in here would feel more comfortable using UNET if we had something like that. People don't trust it enough at the moment, and many are still looking for alternatives
     
    Last edited: Dec 7, 2016
  46. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    Unfortunately Im not a game developer :(, so you are welcome to create such project :)
     
  47. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    1,674
    Thanks, I will try your suggestions and send you the project when I am back home later today.

    I have some suggestions based on my experience with uMMORPG, uMOBA and VOXL.

    Features:
    I was able to implement just about any feature that I needed already, thanks to the HLAPI source being available on Bitbucket (which could be updated every now and then by the way). The last feature that I would like to see is an option for SyncVars and SyncLists to only sync to the owner player instead of all players around him. This would save so much bandwidth. Think about an MMORPG inventory. SyncLists make it very easy to implement, but sending it to all players instead of just the owner player is a huge waste of bandwidth.

    Stability:
    (this is pretty much all HLAPI since I can't see the LLAPI source code)
    But what's most important really is the stability. This is the obvious answer and what everyone on the forums is constantly complaining about and while it's gotten better lately, it's still not enough.

    Take a look at the 'curl' library. The developers have to be ultra careful because every tiny bug would be a disaster. This is what we want. We want you to treat the code with care so that we can have a 100% perfect UNET library. This includes the practice of always fixing all existing UNET bugs before adding any new feature. Good engineering practices like splitting everything into small, reusable functions, white box tests where possible, using modern C# features to keep the code short (less code == less bugs), etc.

    Reality Check
    We would all love to see a small UNET project that uses all the features, and testing it under heavy load 24/7. If you don't have the time to develop test projects, talk to us. I would be more than happy to test uMMORPG on your servers with some heavy load, or develop a simple UNET stress test project.

    Disclaimer
    I saw your Unite talk alex, and you mentioned that the HLAPI was meant as an example and that it's really all about the LLAPI. This explains everything and kinda sucks for you guys since everyone here, including myself, is giving you such a hard time for something that was only meant as an example. However it's clear that we all here really need a great HLAPI too, hence all the whining.
     
    Last edited: Dec 7, 2016
    tvirus06 and akuno like this.
  48. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    @vis2k Thanks man :)
    I like your critics and personally I lice to be compared with curl :) which started in 1999 and tons of bugs have been fixing from this time... :) Anyway thanks for the feedback, and I personally like that this feedback is not positive.

    Step by Step, why I'm going to add those 3 features:
    1. Session recording: The usual feedback which I receive from customers sounds like: Nothing work or in better case sometime i get disconnect somewhere... This information (unfortunately) is not enough to make any suggestions what's going on. Session recording give us possibility to understand what's going on and probably fix the problem.
    2. Floating ack window, I'm personally not sure that it is good idea to send 10000 reliable messages per sec to the same peer, unfortunately there are different opinions about this, so by increasing this buffer we will close problem with our nightmares about "no free event for the message" log. If you want - you can.
    3. we've never received any feedback about this feature, but need to support them (it is additional code, timer, allocating resources) which injected in the code and required support. But in the moment when we decided to remove this feature because nobody use this, one of the customer ask us about this. So we just should to restore.

    About others features, we have long list different features which must to have (as bluetooth, wifi direct, steam, voip and so on) but we need to limit and we limit number of new features per each release. So, actually we implementing only necessary features. If you take a look on the new transport layer api you will see that so far we added only sendqueuedmessages() function, and, it is actually because it was easy to implement. Before, publishing this build we stressed this implementation for a 3 month, and only when we was not able to find bugs we publish it as experimental build. The goal was, any new bugs opened by customer with this build will fix asap, + we are ready to work (and we are working) with customers directly here without bug submitting process. Customer use cases sometimes are different that we can forecast in our lab, it is the reason of publishing experimental build first. I guess it make sense, test now, open the bug and immediately receive fix, then waiting for a month after submitting. May be I;m wrong...

    About https://issuetracker.unity3d.com/is...lash-readbytes-out-of-range-errors-in-clients issue, i checked fix report about this issue and it looks like user serialized object which he never deserialized. Means Message << Ser(ob1) << Ser(ob2) << Ser(ob3)... And opposite process ob1 = Message.Get(TypeOf(ob1)); ob3 = Message.Get(TypeOf(ob3)) NOT 2 - therefore crash happened. What are you prefer, add type supporting to protocol and probably double message size or do serialization/deserialization accurately (I don't know, but i'm sure that there will people with different opinion)...

    :)

    regards
    Alex
     
  49. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    1,674
    There is also positive feedback of course. UNET makes it possible for a single developer to work on multiplayer games without going crazy, that's a big deal.

    Your features sound good. I didn't mean that you specifically shouldn't add any new features, especially since some bugs aren't even your work.

    About the ReadString bug: yes it usually happens when we have a player with for example 10 NetworkBehaviours attached to it. Now if we decide that our 3rd NetworkBehaviour needs a custom OnSerialize/OnDeserialize function and accidentally make a mistake there, then the serialization of NetworkBehaviour 4-10 will be completely messed up, reading invalid values.

    There are two problems here exactly:
    • First of all, the 10 NetworkBehaviours should be completely safe from each other. If NetworkBehaviour 3 has a serialization error, then NetworkBehaviour 1,2, ,4,5,6,7,8,9,10 should still work fine, even if NetworkBehaviour 3 fails. For example:
      • Right now we have one big packet like: [NetworkBehaviour1.health, NetworkBehaviour1.mana, NetworkBehaviour2.position, ...] . If NetworkBehaviour1 never reads the mana properly, then NetworkBehaviour2 will read the mana, even though it expected the position, hence everything fails horribly.
      • Instead we should have one big packet like: [NetworkBehaviour1.data, NetworkBehaviour2.data], which is then used like: NetworkBehaviour1.OnDeserialize(NetworkBehaviour1.data); NetworkBehaviour2.OnDeserialize(NetworkBehaviour2.data). If NetworkBehaviour1 messes up and doesn't read the whole data, or reads too much data, it doesn't matter. NetworkBehaviour2 will still have it's own data that wasn't touched by anyone else.
      • In other words: before calling OnDeserialize, split the data into 10 independent datas. If one messes up, it doesn't matter.
    • The second problem: if we get an error in OnDeserialize, then we don't see it in the console, we never know that there was an error. For example, if we have an error in NetworkBehaviour3, we don't see "error in NetworkBehaviour 3.OnDeserialize". It fails silently, then the data for NetworkBehaviour4,5,6,7,8,9,10 get corrupt, and then we see an error like "NetworkBehaviour7: can't cast int to Vector3", even though the code in NetworkBehaviour7 is totally correct, it only got corrupted data. So any error in OnDeserialize or OnSerialize should immediately be shown in the Unity engine, so that we know that we made a mistake somewhere.

    About the 200KB/s problem from above:
    I tried it with only the LLAPI. I didn't get any errors, only the "no free events" message. I adjusted the bandwidth settings like you said, but that didn't make any difference. Then I adjusted the SendDelay to from 10 to 0, which worked perfectly:
    Screenshot at Dec 07 14-45-20 copy.png

    The "no free events" message does appear around the 25MB/s rate again though. But that's pretty good already.

    I was also able to reproduce the Unity crash. It happens when I set MinUpdateTimeout to 0 and then start the server. But I guess it doesn't matter if you want to remove that parameter anyway.

    In the end I used the same configs that allowed me to send 20MB/s for the HLAPI test. It still shows all kinds of errors when reaching the 200KB/s mark. So it works in the LLAPI, but not when sending over the HLAPI with the same configs. I sent you the project via PM.
     
  50. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    879
    @aabramychev
    Is there any estimate on when will the server DLL be released? Is it Unity 5.6? Will it also be opensource? As far as I understand, the server DLL is just a LLAPI implementation that could be used outside of Unity, is that correct? Will it be available for everyone, or only on a per-request basis?
    Sorry for a lot of questions, but server DLL is just something I was waiting for since UNet release :)

    Thanks beforehand.