Search Unity

Unity Multiplayer New multiplayer transport release

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

  1. mafff

    mafff

    Joined:
    Jan 16, 2015
    Posts:
    15
    @aabramychev thanks for the quick reply. For my game low latency is crucial and I'd happily sacrifice bandwidth. I set SendDelay to 1ms because of this reason. As per documentation MinUpdateTimeout "defines minimum time in milliseconds between sending packets. [...] Default value = 10". Can you confirm this doesn't apply anymore? Can I rest assured MinUpdateTimeout won't add any delay?

    Also, are there any other parameters I can tweak to reduce the client-server latency?
     
  2. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    @mafff you can set them to 0 if you want, in this case your delay will be defined by GlobalConfig.threadawaketmeout only. (but i still would recommend to leave them 1 or better 2 ms)

    yes i can confirm that minUpdateTmeout won't affect performance
     
  3. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    90
    Hey,
    I am trying to log statistics about the server networking. Specifically I want to log incoming and outgoing bandwidth.
    I know you can get to the outgoing bandwidth via NetworkTransport.GetOutgoingFullBytesCount, how do I measure the incoming bandwidth on the server? Or are there other functions to get to network statistics of the running game?

    ps. Any updates on the state of the standalone server dll?
     
  4. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    @pragmascript Thanks for this message. You don't have this function because i just forget to implement them. Will definitely do, but a little bit later, I did taka a look on our stat functions and possible they will need to be re-factored again :(

    Server.dll is still in "alpha" phase, that means we still do not have any decision how we are going to distribute them. Before this decision has been done, you can use them as you want :) If you need them (windows build) pm me
    =Alex
     
  5. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    90
    @aabramychev thanks for the quick answer :)
    I have one more question if you don't mind: In our game we get a "NoResources" error message in the transport layer from time to time. The manual is not very clear about which resources are missing. Maybe you could clarify which resources are missing and maybe have an idea how to avoid it? (We are using 5.6.2 atm)
     
  6. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    most probably message buffer waiting for to be acknowledged, is full. Try to change ack buffer length (by default it is 32) to bigger value. ConnectionConfig.AcksType ...
     
  7. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    @pragmascript - it was for you. Another reason could be you send reliable messages to fast :) In this case, you need to reconsider how do you send your messages...
     
  8. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    90
    Thanks I will try to bump ConnectionConfig.AcksType to 64 and see what happens :)
     
  9. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    151
    hello,

    How to set client not ready with ClientScene ?
    In your repository you have the function ClientScene.SetNotReady(); but it's not defined in all Unity version :s
     
  10. JMax

    JMax

    Joined:
    Apr 10, 2015
    Posts:
    4
    When i set SSLCertFilePath and SSLPrivateKeyFilePath
    i got: libwebsocket init failed

    What i do wrong? Unity 5.6.1p1
     

    Attached Files:

    Last edited: Aug 7, 2017
  11. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    @JMax, please do not use this thread for bug reporting next time.
    1. Check please / delimiter instead \\
    2. Report bug if this won't help
     
  12. VeryCrushed

    VeryCrushed

    Joined:
    Dec 13, 2016
    Posts:
    2
    @aabramychev

    How often do you guys update the Server DLL? Currently using the DLL from January, and am wondering how support is for new versions of Unity such as 2017.1 and 2017.2.
     
  13. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    Heh, it is still in beta phase. So, there is no official support, except my personal support. It is bad news. Good news, just yesterday we discussed about creating regular builds of server.dll for all 3 platforms. So probably it will change in the near future.

    btw, we allow customers to use them but we will ask customers for feedback? :) What about this? (joke)

    Alex
     
    gamevanilla likes this.
  14. yackson-cc

    yackson-cc

    Joined:
    May 14, 2016
    Posts:
    23
    Hi aabramychev how are you?

    I have a Dudes/Questions
    -Is the TransportLayer full UDP? or UPD combine with TCP?
    -Is the TransportLayer a possible robust server for a mmorpg with autoritative server?
    -TransportLayer suport listeners, some how this "TransportLayer.OnConnect += meOnConnectedToServer"? the documentation is little.

    -This guy made this library using and pass version of UNET, he implements a server autoritative that runs 4000 instances perfectly sync and without lag, i can get better result using the new TransportLayer?
    https://forum.unity.com/threads/ope...-networking-library-for-massive-games.273348/

    Thanks a lot for your support in this thread :D
    Cheers!
     
  15. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    1. udp, tcp has been limited support via web sockets
    2. never stressed than for mmorpg, depends how many data and how often do you send. difficult to answer
    3. No you need to add them by yourself, I published example here, where I show how OnConnect function can be created
    4. No Idea :) sorry. It again depends of the game, as usual, network MUST be tested first, before or in parallel with the main game. For example, I'm creating MMO game which has 1000000 player, but all of them just staying and do nothing :) Without lag sounds a little bit unclean for me. Where is the network lag? Is it supposed to be the same lag for players between NY and Beijing and guys between NY and Boston?

    ps. I'm not sales person :) sorry. If you want to try, i will happy to help, and fix problem if/when you will find them, but unfortunately I cannot promise more than that, we are not making silver bullets :)
     
    leopripos and yackson-cc like this.
  16. yackson-cc

    yackson-cc

    Joined:
    May 14, 2016
    Posts:
    23
    Thanks for your response, i am confuse with your first answer, please can you explainme a little bit?
    i understand that is UDP and TCP both via web sockets.

    sorry, my main idiom is spanish, because is hard for me understand these first response, and the google traductor not helpme xD

    thanks again
     
  17. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    1. udp
    2. web sockets :)
     
    yackson-cc likes this.
  18. TheUKDude

    TheUKDude

    Joined:
    Jul 27, 2013
    Posts:
    72
    #1:
    Basically NetworkTransport is coded around UDP Sockets.

    #2:
    Not being nasty or anything, but in my views I don't think NetworkTransport would be good enough for a MMORPG game where the server is running as an authoritative server.
    The most CCU I could get out of it was about 128 connections where it become a bit sluggish, maybe I was doing something wrong, I don't know.

    #3:
    The "OnConnect" type of Events / Callbacks you would have to implement yourself, its not that hard to do.

    #4:
    Its possible to do if you know what you are doing to handle thousands of connected users, its just a matter of how you segregate them.
    You could split areas up into Zones and have Zone Cluster Servers, or you could have Instance Servers which can overlap your whole world.
    Both have their own issues along with good and bad points and both require server to server communications as well.

    My views on
    NetworkTransport...

    TBH, I was originally going to use NetworkTransport for my game, but due to the server having to also use NetworkTransport it became an issue, especially when you needed to stress test stuff.

    I then looked into Photon and wasn't that happy with the price plan so went back trying

    NetworkTransport
    .

    Maybe NetworkTransport has gotten better since I last tried it, but back then it was ok, but not for the amount of connections I really wanted it to handle.

    I ended up trying to created my own Network Library using TCP Sockets which uses Threads for the Network Loop, Message Queues and Handlers, I have simulated it with 1K to 5K users easy, granted it was only sending basic messages (ping / pong type of messages) but it handled it fine.

    Now at the end of the day, is my code better than using

    NetworkTransport , probably not due to I have to do everything where as
    NetworkTransport does most of the stuff behind the scenes.


    Now if my game was going to be a Multiplayer Game with a maximum of say 32 to 64 players then I might of used Unity's
    NetworkTransport.

    Paul
     
  19. yackson-cc

    yackson-cc

    Joined:
    May 14, 2016
    Posts:
    23
    @Paul-Kirby & @aabramychev thanks for your responses :D

    I have another question, in this fragment of code :

    Code (CSharp):
    1. private void ReciveDataTCPChannel()
    2.         {
    3.             var tmpNetworkReader = new NetworkReader(receivedDataBuffer);
    4.             var tmpSizePacket = tmpNetworkReader.ReadUInt16();//(reference)
    5.             var tmpPacketID = tmpNetworkReader.ReadInt16();
    6. }
    (reference) : the first read function ReadUInt16() get always what value? is the packet size how i write there ? o that value contains? the example and documentation not expose this well. thanks
     
  20. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
  21. yackson-cc

    yackson-cc

    Joined:
    May 14, 2016
    Posts:
    23
    I want more simple:

    this code is extracted from el example proyect tha you made for us (thanks!)

    Code (CSharp):
    1.  
    2. void OnData(int connectionId)
    3. {
    4.         NetworkReader reader = new NetworkReader(m_ReceivedDataBuffer);
    5.         ushort sz = reader.ReadUInt16();//WHAT is that? size of packet?
    6.         short msgType = reader.ReadInt16();
    7.  
    8.         switch (msgType)
    9.         {
    10.             case MessageTypes.CSObjectUpdate:
    11.                 OnObjectUpdate(connectionId, reader);
    12.                 break;
    13.             default:
    14.                 Debug.AssertFormat(false, "wrong msgType {0}", msgType);
    15.                 break;
    16.         }
    17. }
    18.  
     
  22. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    I just don't remeber, check how I use this sz :)
     
  23. yackson-cc

    yackson-cc

    Joined:
    May 14, 2016
    Posts:
    23
    yep, i check that you would doing, and because the dude appears

    this is the serialize object:

    Code (CSharp):
    1.  
    2. public class CSObjectUpdate : MessageBase
    3. {
    4.     public Vector3 forces;
    5.  
    6.     public override void Deserialize(NetworkReader reader)
    7.     {
    8.         forces = reader.ReadVector3();
    9.     }
    10.  
    11.     public override void Serialize(NetworkWriter writer)
    12.     {//HERE must be your ushort "sz = reader.ReadUInt16();" but is not here, all the packets that you build, are the same, not have write.Write(ushort) before the next line, but you always read the ushort sz = reader.ReadUInt16()
    13.         writer.StartMessage(MessageTypes.CSObjectUpdate);//the packet ID
    14.         writer.Write(forces);//The content of packet
    15.         writer.FinishMessage();
    16.     }
    17. }
    18.  
     
  24. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    I guess it is something with HLAPI serializer which I used here :( do not remember, check please hlapi code. I did use this serialzer just for simplicity, nobody prevent you just use protobuf instead or something else which better fit you.
     
    yackson-cc likes this.
  25. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    151
    Hello here.

    I have a very important question.
    For the moment we have connection.maxSendDelay for setting a delay for sending message.
    This delay is 100 ms by default and pack all messages for bandwidht optimization which is great.

    BUT ( :) )

    Is there a way to force the sending by code ? I have a position synchronization which have to be sent very very quickly and I want to force the networkBehaviour to send the commands / Rpc . Can I do this ?


    In an ideal situation I only want command/rpc of this networkBehaviour to be sent, not all messages in my game.
     
  26. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    647
    Unsure if this will be a solution for you, but take a look at MessageBase.
     
  27. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    151
    Message base and writer / send works with the same system as networkBehaviour.

    NetworkBehaviour use that, it's just an extension to keep track of what command on which gameObject it's called =/
     
  28. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    647
    Oh not sure then. I've switched over from UNET to Steamworks and they way it works is you send messages (which get buffered for up to 200ms or max packet size I believe). To force everything buffered to send sooner than the automatic send you can call a different method which unloads the buffer sends the packet immediately. Unsure if UNET has a similar feature.
     
  29. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    @Driiades, Heh your case was unexpected :( We have got the plan to add priority sending in the future, but looks like still procrastinating this due more urgent task need to be solved. How critical is this for you? If yes, how urgent this task is? PM me directly if I can help you
     
  30. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    @Driiades hmm, there is another way to do it right now, just create two connection from the client to server one with delay and another with no delay :) (SendDelay == 0) and send you high priority data using second connection
     
  31. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    151
    Hello, Actually it's a server and client problem, not just client. In fact I become to have a very good position synchronization. But I unexpected that the packaging of messages will delay so much the algorithm and it's a very critical function in a game (the most important in some games ?).

    For example the position sync was very bad when MaxDelay was at 100 ms. And became very good with 10 ms. But also I get 10 ms of delay on something that require maximum 100 ms or 150 ms of latency. I think we can't work on position sync algorithm if we take 10% of delay by design.

    What I need is very simple : The packaging system in all case and maybe an extra unreliable channel which send message soon as possible (maybe at the end of frame ?)

    In fact the most flexible things will be configurable channels with delay for each ( Hahahahahah it will be so nice no ? :p )

    @aabramychev It's not urgent at all. I'm just a student who doesn't work on online game on my company for the moment.I just try to make an API for better using Unet, and was working on position sync. It's just... well if you can improve this part ok it will be nice, if no .. I will stay with my 10 ms delay and will cry in my room in France no problem :( .
     
    Last edited: Nov 17, 2017
    aabramychev likes this.
  32. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    ok will try to help, cannot promise to do this fast but will try :) by adding high priority flag to message
     
    shamsfk likes this.
  33. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
  34. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    730
    Last edited: Dec 24, 2017
  35. uweenukr

    uweenukr

    Joined:
    Jan 17, 2011
    Posts:
    53
    Were Unity Server updates removed from the whole roadmap?
     
    pragmascript and KevinHGS like this.
  36. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    @aabramychev Hi there! Is there a separate LLAPI releases log somewhere? It's really hard to pick what changed in LLAPI from official Unity3D release logs.
     
  37. fdsagizi2

    fdsagizi2

    Joined:
    Nov 4, 2013
    Posts:
    70
    Hi, How we can get stack of messages in this case - to understand, percent of usage some rpc functions witch fill that stack?

    And what about reliable but overridet data, like player live?

    if some one hit player - live become 90 hp, after another hit become 80hp, it must be reliable and ordered, but we want use only last message as reliable. If we lose 90 hp - unity will re send that, but we don’t actually need it, because recently we send 80 hp. And namy cases can use that: user live, press mapping, animator data, some positions witch changes unusually
     
  38. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    "Hi, How we can get stack of messages in this case - to understand, percent of usage some rpc functions witch fill that stack?"
    I'm sorry, I do not understand the question :(
    "And what about reliable but overridet data, like player live?"
    Take a look on reliable state update qos
     
  39. fdsagizi2

    fdsagizi2

    Joined:
    Nov 4, 2013
    Posts:
    70
    Reliable state update qos - thats awesome, thanks!

    About stack, when server get message "NoResources":

    for me, big problem is: Understand, where we spend more resources than we can? In our game, we have tons of Rpc and TargetRpc methods, witch is full of send stack ??? How i can to know, who fill it, TargetRpc_SendPosistion or TargetRpc_SendSomeAnother or maybe some else rpc...? Will be nice, get all packets - witch in stack, and go trough all, and dig it( may be too many calls, or may be too fat data in some rpc)

    expect code like this:

    Code (CSharp):
    1.     struct DataInfo{
    2.         public int sendData;
    3.         public int sendCount;
    4.     }
    5.  
    6.     override void OnErrorNoResource(int channel){
    7.  
    8.         var pakets = NetworkTransport.GetAllOutgouingPacketsByChanel (channel);
    9.         var map_func_data = new Dictionary<string,DataInfo> ();
    10.  
    11.         foreach (var p in pakets) {
    12.             map_func_data[p.rpc_function_name].sendData += p.data_size;
    13.             map_func_data [p.rpc_function_name].sendCount++;
    14.         }
    15.  
    16.         foreach (var it in map_func_data)
    17.             Debug.Log (it.Key + " dataSize " + it.Value.sendData + " callTimes: " + it.Value.sendCount);
    18.     }
    if you know Russian:

    Привет, когда мы получаем эту ошибку, очень сложно понять, кто же заполнил весь стек данных, что не осталось места для отправки новых. И было бы супер, иметь возможность пройтись по всем пакетам которые ожидают отправки, и узнать - где у нас слишком часто идут вызовы, или возможно не очень часто - но данные слишком толстые к примеру.
     
    Last edited: May 14, 2018
  40. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    @fdsagizi2 I guess it is wrong place to discuss your problem. Send me pm please, and Yes I can speak russian
     
  41. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    90
    Hi,

    Since LLAPI will be deprecated soon, how will the new Transport Layer API compare to LLAPI.
    Is it a similar lowlevel API that we can switch to?
    Are there any scenarios that we can do with LLAPI but will no longer be able to handle with the upcoming API?
     
  42. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    4,000
    Upcoming LLAPI won't have reliable messages
     
  43. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    90
    So its basically a thin wrapper around UDP? Or what are features added on top of UDP?
     
  44. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    So anyone wanting to use the new LLAPI will have to write a reliable layer for it. Pointless 1000s of people having to reinvent the wheel every time, Unity should include it as standard.
     
    Kirsche likes this.
  45. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    730
    I would expect unity to provide a reliable algorithm on top of UDP.

    LLAPI supposedly does that, but I have been struggling with silently dropped packages for months using reliable channels. For me it is not working.
     
    Last edited: Aug 15, 2018
  46. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,070
    How do you know that? In comments of the uNet post they said it would be very similar to the current one and conversion between them should be easy
     
  47. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,731
    Unity has said the base replacement won't have reliable messages, but they may include that as an add on package. The way they are currently phrasing it though I wouldn't count on reliable messages being there.

     
unityunity