1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. Unity 2017.1 beta is now available for download.
    Dismiss Notice
  5. Unity 5.6 is now released.
    Dismiss Notice
  6. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  8. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice

Unity Multiplayer New multiplayer transport release

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

  1. larus

    larus

    Unity Technologies

    Joined:
    Oct 12, 2007
    Posts:
    242
    • There is no estimate for release right now, not with 5.6, but it could be release outside the Unity release cycle
    • It's not planned to make it open source (we could do it but will need to discuss)
    • Right now it's just the network transport yes
    • Licensing details have not been determined (if it will be free for all or something else)
    A beta version is available for people who would like to give it a serious try and give us feedback on it. You can contact me or Alexey if interested.
     
  2. r-valeev

    r-valeev

    Joined:
    Nov 6, 2016
    Posts:
    3
    @aabramychev, @larus Hello.

    Could you say please, is there any upcoming in near future updates that will allow using secure websocket connection by the uNet. While searching solution on forum we found that many users share same problem and don't know how to solve it.

    In our case, we developing game for kongregate with dedicated server (based on unity also) and we can't initiate secure wss connection between client-server-kongregate
     
  3. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    @r-valeev , technically yes, but i lost with platforms, self signed and root certificates :( and cannot find the best way for managing this stuff. If you have ideas how it should be implemented (api and so on on server end) you are wellcome. So far all ideas which i have looks too ugly to implement :(
     
  4. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    @ZimM as Larus said, the publshing status of server dll has not decided yet. If you really need this product, ask your regional support first...
     
  5. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    829
    About the new features.
    Replay is simply great for finding bugs and profiling, specially if we want to implement a priority feature and see how that works when users play that is simply the most awesome feature one can have in his arsenal to attack these issues. Anyone who wants to know more, look at the video "I shot you first" from the halo team on GDC vault (it is free).

    The simulation, I think external tools are good enough but this can not hurt.
    About stats, definitely it is great to have them.

    I am not sure how this can be done yet since I did not give enough thoughts to it but I would like to have a system to prioritize messages to be sent based on external factors so having stats like how many bytes have been sent and how much is the guessed bandwidth of a connection helps a lot when writing those kinds of stuff so the congestion control should be transparent in LLAPI.

    Thanks for all of the hard and great work. Soonish I'll test a few projects using the build to see how it works.
     
  6. VeryCrushed

    VeryCrushed

    Joined:
    Dec 13, 2016
    Posts:
    1
    Contacted both @larus and unity support a week ago about getting the server library and have yet to hear a response, would really like to get this for my project. @aabramychev any help on this? Or anyone from Unity that can assist it would be appreciated.
     
  7. r-valeev

    r-valeev

    Joined:
    Nov 6, 2016
    Posts:
    3
    Same for us. Waiting for answer by our request on wss support.

    As we replied on personal message, we could advice some ideas how it may be impemented, but we'll need to discuss it via skype\mail and see source code that is responsible for that part of unet.
     
  8. tvirus06

    tvirus06

    Joined:
    Apr 21, 2013
    Posts:
    153
    Any update on the Standalone Simulation Server?
     
  9. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    829
    I've tested the latest build with the new transport the 5.4.3f1 and the UDP setup worked flawlessly on windows but on WebGL, first client connected then server kinda got hanged and second client could not connect and when i close the server, it thinks it crashed (probably due to the hanged state). I have the dump files, will file a report and then will email Alexey :)

    @other guys here, it has been holidays , they'll answer you when they come back.
     
  10. Carti

    Carti

    Tier 1 Support Unity Technologies

    Joined:
    Mar 16, 2016
    Posts:
    76
    Hi folks,

    I just dealt with a support ticket regarding access to the new server DLL that was discussed on the 12/13th December.

    Free support aren't able to give access ourselves. Having discussed with the Multiplayer team, we would suggest forwarding your request for access to multiplayer@unity3d.com alongside information of your project and your full intentions for the DLL.
     
    Last edited: Jan 11, 2017
  11. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    Sorry for delaying with answers. Just returned back to regular work...

    ok step by step
    @vis2k thanks a lot for your research. I did talk with hlapi guys and received very interesting answer - it is by design :) Anyway we will investigate this and (hope) will improve (25 mb through loopback probable is not good enough will check too) .
    @Ashkan_gc yes man... my fault web gl will be fixed shortly (hope i will be able to publish new version on this week or early next week)
    @r-valeev wss has been almost done, so i will publish this too (with new build) then we can discuss what should be added to this. ok?
    @Carti, @VeryCrushed , just talked with Larus :) Yes he will update shortly, just want personally ask you before we will publish new version...

    Do i forget somebody?
     
    tvirus06, Jouni-Mannonen and vis2k like this.
  12. tvirus06

    tvirus06

    Joined:
    Apr 21, 2013
    Posts:
    153
    But what about the Simulation Server? Any updates?
     
  13. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    uff, it is hard question to answer :( (and btw wrong thread to ask :)) Correct answer - I really don't know. Some points about this: 1. we decided move our efforts to make unet more stable. (i hope new transport has been already more stable then before and we work on hlapi too) 2. Simulation server (roughly speaking) is unity player without unnecessary modules, but unity itself has not support modules so far... 3. Personally, I cannot define by myself what simulation server means :)
    So far, I can say that it is in the plans, but when - i do not have clean information :( Sorry for disappointing...
     
  14. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    46
    Why does the signature of NetworkTransport.Receive

    Code (CSharp):
    1. public static Networking.NetworkEventType Receive(out int hostId, out int connectionId, out int channelId, byte[] buffer, int bufferSize, out int receivedSize, out byte error);
    take bufferSize as a parameter? Arrays _do_ have a length in C#. The entire LLAPI feels like it was designed to be a C-API not a C# API. Returning errors as `out byte error` for example.
     
    Last edited: Jan 12, 2017
  15. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    @pragmascript yes you are right ... There are couple of reason for this:
    There is a c++ api too and llapi on c# is similar to c++ api, and c++ api can be used too in server.dll
    For Send(); we need to put buffer length because data serialized in buffer can occupy only part of them.
    For error code, if you take a look on api you will see that there are a lot of function which return value + error code too:
    int rtt = GetRtt(..., error);
    in this case I thought that would be better if I add error status to all function as out parameter. In this case all function will have signature like func(..., error), regardless of return value.

    Probably I was wrong:( but now is to late to change API.
    For sure, you always have option to encapsulate LLAPI call in your function.
    Anyway, I'm really sorry for this
    Alex
     
  16. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    46
    Hey thanks for your answer,

    I think the API is nicely designed overall. It just feels a bit C/C++ish.
    Maybe it would be possible to have function overloads that directly return an NetworkError enum as an out parameter without breaking the API. But I don't think its super important.

    Thanks
    Pragma
     
    Last edited: Jan 13, 2017
  17. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    heh :) We are working on this right now
     
    pragmascript and Zullar like this.
  18. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    829
    About the API my IMHO is that since the code that you write using LLAPI is Cish anyways, you manage buffers and do things like that, It is ok for that too be Cish unless you are using new .NET stuff like Span<T> and similar constructs which make it possible to write the low level code in C# and on .NET itself like the new ASP.NET core's framework which is mostly on managed code.

    In our situation I actually prefer it to be C like when it acts like C and sounds like C, to me it is good that it looks like C to remind you about all things which you should care about when you are modifying that part of code.
     
  19. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    46
    Hey,
    I'm sorry if that has been answered before but:
    Is it safe to call NetworkTransport.Receive and NetworkTransport.Send
    from a thread that is not the unity main thread?
     
  20. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    @pragmascript : short answer no (for now), for long answer I need more time :( it is "almost" threadsafe but there are couple of places where race condition can happened and I need to review these places again... I will create dedicated post about tread-safe coding. But if you always send/receive from thread which not main thread - yes you can do this
     
    pragmascript and Zullar like this.
  21. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    Hi folks
    1. New transport version have been published - see first message in this thread (short description - ack buffer has been configurable up to 128 bits and wss: support)

    2. Server code is ready too, send me please PM who tested it before or I promised to deliver and I will send ref to binaries

    thanks
    Alex
     
    isidro02139 likes this.
  22. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    1,476
    Nice work alex, web sockets via SSL sounds very interesting.

    I am curious, does that mean that SSL is or will be usable for non-websocket connections some day? This would be very useful for any game that uses passwords (or other sensitive data).
     
  23. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    We are thinking about this but haven't got final decision yet :( DTLS? probably something lighter? From other hand we are going to port web sockets to mobile platform soon, probably t will be enough?
     
  24. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    1,476
    Was just curiosity. SHA should probably be good enough to send around passwords.
     
    Last edited: Jan 20, 2017
  25. TheWesselGames

    TheWesselGames

    Joined:
    Aug 31, 2016
    Posts:
    23
    Is the new transport also going to be in a version of Unity 5.5?
     
  26. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
  27. EvilDingo

    EvilDingo

    Joined:
    May 7, 2011
    Posts:
    179
    Unity appears to ignore general UDP packets. I need to send data from my server to a Unity client, but unless the message originates from Unity, it's ignored. Could you tell me the format of the packets sent from Unity so I can decode them and send messages in the proper format? Is there a struct or something I can use to format my custom packets?
     
  28. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    Dear @EvilDingo this thread about new transport only, please, Please, PLEASE, do not put here messages related to other area. You always have a option to create new theme or ping me directly.
    With best regards
    Alex
     
  29. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    284
    Just noticed the new NetworkTransport is in 5.6b8. Good job guys, seems very promising
     
    isidro02139 likes this.
  30. Paul-Kirby

    Paul-Kirby

    Joined:
    Jul 27, 2013
    Posts:
    58
    I am currently using Unity 5.5 along with NetworkTransport for may Dedicated Server and Client code and was wondering about SSL due to I will be sending usernames and passwords when they log in, which ends up being sent over UDP Packets via NetworkTransport, so this would need to be encrypted.

    So how in Unity beta 5.6 would I be able to use SSL with NetworkTransport?

    I know in .NET I had to use System.Net.Security.SslStream along with AuthenticateAsServer and AuthenticateAsClient and use the private and public RSA Keys.

    So basically the server had access to both Public and Private Keys and the server would pass its Public Key to the client to use and it all worked fine.

    I am currently not too sure if Unity is able to use the above classes due to I have not tried it in Unity yet.

    So is this similar to what we have to do here, or is the new way different ?

    An example or link would be nice :)

    Thanks

    Paul
     
  31. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    @Paul-Kirby it is difficult question. Short answer - we have not decided yet. ssl is a tcp related protocol. We strongly don't want to re-invent wheels here. I personally do not want implement wpa :) DTLS could be option, but I don't know any good implementation of this...

    Sorry for late answer
     
  32. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    46
    Hello :)

    what is the maximum number of connections that are supported for a single machine acting as a server.
    the release notes of 5.6b11 say
    Is this the maximum number of connections a single node can handle?
     
  33. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    it is maximum hosts which you can use, 65535 connection per host (theoretically, as you can occupy your ram)
     
  34. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    284
    ok so for example, 128 would be the max amount of "servers" (in the broad sense of the word) that you could start on a single machine, and each one of them could have a theoretical maximum of 65535 connections?
     
    Last edited: Mar 9, 2017
  35. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
  36. Paul-Kirby

    Paul-Kirby

    Joined:
    Jul 27, 2013
    Posts:
    58
    That's fine, I ended up writing my own Threaded TCP Library specifically for my games which uses Threads, Queues, Handlers etc behind the scenes.

    I didn't really want to use NetworkTransport for the UDP side and have to use WebRequest or equivalent to request a HTTPS page to handle the secure side of things, which nearly everyone seems to keep saying to do.

    Paul
     
  37. Paul-Kirby

    Paul-Kirby

    Joined:
    Jul 27, 2013
    Posts:
    58
    That's good to know, that would make Stress Testing Tools easier to make, its not fun having to run 64 clients (over multiple machines) each opening up 16 connections totalling 1,024 connections on the server.

    So in theory I could have all 8 clients each open up 128 connections totalling 1,024 connections on the server.
    That would be some stress test on both sides :p

    Paul
     
    aabramychev likes this.
  38. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    52
    Hello here.
    There is something that i do not understand for the moment.
    I read about Http, and websocket and how it work.

    But i do not understand how the NetworkTransport work when it is not in the websocket mode...
    Have you some references for learning the technology behind it ? That will help me to do game/optimize them. :)

    Best regard, a french student who want to learn. =)
     
  39. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
  40. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    52
    That was i don't understand, you use UDP, unreliable transport so... but Unet has a reliable channel ( like TCP ? so why not use TCP ... :( )...
    And if you use a similar way as web socket, why have you web socket option ? what the benefit of the two approachs ?

    I will strongly read again gafferOnGame. References i used for sync position =).
    Thx you.
     
  41. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    284
    Using UDP instead of TCP for game networking is common knowlegde.

    TCP is already reliable, but comes with all sorts of delays and overheads that would make it a terrible solution for fast-paced online games. We need more fine-grained control than that.

    So the key is to take UDP as a foundation and implement everything you want on top of it. In games, you'll sometimes need unreliable channels for non-critical stuff to save on performance. So you'll use basic UDP for that. Then, sometimes you'll need different flavors of reliable channels (orderer/unordered, fragmented, only-latest-msg-matters, etc...), so you are free to implement all of these specific things on top of UDP.

    In short; UDP lets you do exactly what you need for your game, while TCP is just one big slow thing
     
    Last edited: Mar 25, 2017
    aabramychev likes this.
  42. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    Second question first:)
    -using websocket is (almost) only way to support multiplayer game in web browser (yes I know about webRTC and we will probably support them but not now).
    -websocket is a backup protocol in case when firewall block other traffic.

    First question:
    tcp is reliable and ordered protocol, designed and tuned for file delivering. It means (for example) if your peer sent packets p1, p2, p3, p4, while you received only p4 you will need to wait delivering of p1,p2,p3. and only after that you will receive all packets together (strongly saying segments).

    Then question to you: If each packet defined movement of different objects (o1, .., o4) why do you need to receive p1, to update o4? :)

    Other question, you persistently update position of object1 bt sending (x1,y1, x2,y2, xn,yn) where 1,2,...n time slots... If you receive x10, y10, you don't need to receive x1, y1, as You've already know the position of object in time = 10. Correct?
     
  43. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    52
    Yes ok that what i actually do for movement. But i thank you could use differents protocols for a same connection. That is, i suppose .. not possible.

    I will strongly study network. Unet give me the motivation.

    (You know, my teachers said that you can use TCP for games network......... Poor France :( )

    Thank a lot guys for these clarifications :) .


    Final question : If my channel is reliable sequenced (so NOT TCP HAHAHAHAHAHA ... :( ), if i send differents messages/RPC of differents objects in it and imagine i have 2 objects o1 and o2.
    o1 send p1 and after o2 send p2.
    o2 don't need p1 but need p2. If the same reliable sequenced channel is used : o2 will wait p1 to have p2 ?

    If it's the case, i can refactor my game for more efficiency ^^ .
     
    Last edited: Mar 26, 2017
  44. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    >If the same reliable sequenced channel is used : o2 will wait p1 to have p2 ?
    yes, again reliable sequenced works like stream (or tcp) hence, if you compare performance of reliable sequenced and tcp, reliable sequenced will be slower, as ack algorithm is generic (should work for all qos) and not tuned to deliver stream.

    BTW, your teacher is not wrong, you still can use tcp for games if you take into account tcp drawbacks. (The reason is easy, tcp much easy to program and it is heavily tested + i always can do http tunneling with tcp so it much more firewall friendly) So, the first question which I will ask myself - why not tcp? :)
     
  45. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    156
    You can use TCP for games, it is just more appropriate for games that don't depend on fast network response, or games where you need every packet in order. Turn based games, board games, card games, all of those TCP would be perfectly fine. TCP on a fast paced first person shooter though would make no sense, for example.
     
    aabramychev likes this.
  46. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    829
    Also if anybody is interested to study, there are multiple implementations of reliable protocols on top of UDP , ENet and lidgren are two of them in C/C++ and C#

    @aabramychev great job man! I'm really liking the new 5.6 just because of the new transport layer. You simply rock \m/
     
  47. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    46
    Hey one question regarding QosType.StateUpdate:

    As far as I understand StateUpdate only sends the most recent message in a given channel.
    What do I do if I have multiple objects that I want to send state updates for?
    Do i have to combine all the state updates into one message and only send one message so the earlier ones don't get skipped? What is the recommended way of doing this?
     
  48. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    @pragmascript Yes you are right + you can use multiple channels. (We have got feature request to support multiply state update sub channels like you want(need) but now we do not have any good design for this feature)
     
  49. mafff

    mafff

    Joined:
    Jan 16, 2015
    Posts:
    2
    @aabramychev I just updated my multiplayer game from 5.5 to 5.6.1 and I have a two questions about the new NetworkTransport.
    1. NetworkTransport.GetCurrentRtt was deprecated, but I don't see any other replacement API. What is the preferred why to query the ping for a connection?
    2. Both ConnectionConfig.SendDelay and ConnectionConfig.MinUpdateTimeout seem to do a very similar thing. What is the difference? My understanding is that MinUpdateTimeout defines how long the thread sleeps before sending the next batch of packets and can be changed by flow control, while SendDelay is an additional delay that allows subsequent messages to be grouped together. I think the addition of a send delay makes MinUpdateTimeout superfluous. You could just use one delay and also use it for flow control.
     
  50. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    363
    @maff
    1. use GetCurrentRTT (TT are capital)
    2. MinUpdateTimeout left to be compatible with old parameters, the only use of this parameter right now is if you set this parameter up and no set Bandwidth parameter, that parameter will use to calculate allowed bandwidth by formula MinUpdateTimeout*PacketSize = Allowed Bandwidth. SendDelay will not send message immediately but will wait for SendDelay timeout which allow to combine different messages in one packet