Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Showcase RakNet Networking

Discussion in 'Multiplayer' started by ep1s0de, Jun 25, 2019.

?

Did you like the demo?

  1. Yes

    34 vote(s)
    91.9%
  2. No

    3 vote(s)
    8.1%
Multiple votes are allowed.
  1. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168


    Hello. When developing the game, I was faced with the problem of using network solutions from third-party developers, somewhere there were bugs, somewhere there was not enough functionality, and then I remembered the times when unity had a stable (albeit outdated) the RakNet network engine. It had all the simple functionality: sending/receiving, RPC calls, master server, etc. But the developers have deprived us of this miracle in the new versions of unity. And then I came up with the idea of integrating the RakNet network engine back into Unity. As you can see, I succeeded.

    Features:
    - Fast and reliable encryption
    - Partitioning/Merge packets when sending/receiving
    - Packet priorities
    - Server Queries Support
    - Detailed statistics for each connection
    - Bandwidth control
    - Password for the connection (for servers)


    Under the spoiler you can see what was implemented using the network engine










    Attention! I have published only a basic set of scripts (client and server), all the rest of the logic you have to write yourself, the scripts have all the functionality for this.

    (Stable version): https://github.com/redheadgektor/RakNet_Networking (x86, x64)
    (Deprecated old version): https://github.com/redheadgektor/RakNet_Networking_Old (x86, x64)
     
    Last edited: Oct 15, 2021
    PutridEx, akuno and TiToMoskito like this.
  2. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    Wow! Watch video :)
     
  3. Dareheim

    Dareheim

    Joined:
    Oct 12, 2013
    Posts:
    7
    So what? Let's source:D
     
  4. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    I am still adding code to make it convenient and understandable to use in your projects ... I will post it when end writting:) (in a couple of days)
     
  5. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
  6. TiToMoskito

    TiToMoskito

    Joined:
    Jan 28, 2014
    Posts:
    66
    Thank you very much, would you share the server console part?
     
  7. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168

    I am still writing my project, when I finish with it I will lay out the source code on github
     
  8. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    456
    Nice job. I wonder why was RakNet deprecated.
     
    ep1s0de and akuno like this.
  9. OndrejP

    OndrejP

    Joined:
    Jul 19, 2017
    Posts:
    303
    I wish Unity stopped "experimenting" with their networking tech and properly integrated latest RakNet as "basic" networking level. Then build the rest (HLAPI) on top of that.

    RakNet is high-performance, stable networking library, which powers a lot of games. It's reliable and proven by time. I consider it industry standard.

    I don't like current "void", UNet is depracated, LLAPI will be depracated and current state of new tech is unusable (e.g. more than 32 packets waiting = silent dropping them - new Unity Transport). Couldn't they keep HLAPI and LLAPI little longer, fixing bugs until new tech is ready?

    We have successful product on Steam Early Access and currently facing decision what tech to use to implement multiplayer (we postponed the decision as long as we could). I've tested UNet few years ago and wasn't happy with it. We want something which can be deployed on demand by us and by community (dedicated servers) - no hosted solution. Also we're likely to write our own high-level tech on top of whatever we end up using.

    I'm slowly starting to think that best solution for us will be what author of this topic did (with Linux / Mac support)

    EDIT: There's one interesting thing, Valve open-sourced their API and networking library they are using for DOTA and CS:GO. It's part of SteamSDK, which we already integrated (but can be also used without it and works well with dedicated servers). The bonus feature is that non-steam version (GOG, Discord store, other platforms) of your game can use it and connect to Steam version of your game.

    More info:
    https://partner.steamgames.com/doc/api/ISteamNetworkingSockets
     
    Last edited: Jul 8, 2019
    ep1s0de likes this.
  10. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    because the developers of the engine supposedly made a new network called uNet in 2014 or 2015, and deleted RakNet which was part of Unity3D ... And now there is nothing at all, neither RakNet nor uNet ...
     
  11. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
  12. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
    Hey guys im trying to send an image from the server back to the client but it wont be received if its above some certain threshold, i tried increase the maxbandwitth but im never actually to receive these packets on the client


    Okay never-mind I was sending it wrong. Thats what we need a low level library that we can actually use to do various things, I spent a few days trying to get photon to send/receive images from and to the server for the purpose of "streaming content" and couldnt do it because its too overegineered for 1 thing

    Okay I was having some problems getting to run as an exe but fixed the problem by looking at the logs and determing you had to select x86_64
     
    Last edited: Jul 12, 2019
  13. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    So large arrays of bytes need to be sent not entirely but in parts, otherwise the network stream will be suspended until the whole array is transferred ... And by the way, it is recommended to send such arrays not over one channel but over several ...
     
  14. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    Watch my new videos... :);)










    I rewrote most of the network code and now there are fewer lags. everything is done not in a while loop but in the FixedUpdate method



    As you may have noticed, I create false delays and network packet loss ... The Clumsy 0.2 program helped me in this.
     
    Dareheim likes this.
  15. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
    I came up with a better method, instead of sending back images which was nonsense instead im going to actually stream video -- which might be better
     
  16. Litwin

    Litwin

    Joined:
    Aug 15, 2013
    Posts:
    70
    Amazing!! :p

    Are you using SLikeNet or original RakNet from github of the Oculos VR? You plan to release in github with features interpolation, predictions and etc?

    Thanks.
     
    Last edited: Jul 21, 2019
    ep1s0de likes this.
  17. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168

    I use the original RakNet

    In the near future I will lay out the entire source code of the project on the github ... I can not say the exact date
     
    Litwin likes this.
  18. Litwin

    Litwin

    Joined:
    Aug 15, 2013
    Posts:
    70
    Oh great, I'm glad to hear that. Have you had any further progress?
     
  19. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    There is progress, but the fact is that I do not use ECS and the Job System, and all operations take place in one thread (main thread unity), I write code so that there are minimal processing costs ....
     
    Litwin likes this.
  20. ixdeveloper

    ixdeveloper

    Joined:
    Jan 5, 2016
    Posts:
    14
    Nice to see someone else picking up RakNet! We have been using it for two years in a cross platform application (iOS and HoloLens), and it's been very stable and performant. Are you planning to look into the network layer as well? Ideally, I'd like to see something that is not sensitive to firewall settings etc. Maybe run the traffic as TLS over port 443?
     
    Joe-Censored likes this.
  21. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168

    Before I started using RakNet, I tried to make a prototype of a multiplayer game using a new transport level, but then I realized that there was no documentation for it and I also took RakNet as an example
     
    Joe-Censored likes this.
  22. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    456
    @warfaredev, @ixdeveloper Have you tried using Dark Rift 2? If you have, how would you compare these 2 frameworks?
     
  23. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    I have not used Dark Rift 2
     
  24. ostermannjan

    ostermannjan

    Joined:
    Apr 11, 2019
    Posts:
    1
    @warfaredev nice job, I am currently playing around with raknet :D Can I ask, how do you instantiate gameobjects over the network? Or does everyone spawn everything locally and you sync them by unique ids, or something like that?
     
    ep1s0de likes this.
  25. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    I create the objects first on the server, set the properties for it, and then send the client information about the created object (asset id, network id, position, rotation)
     
  26. ixdeveloper

    ixdeveloper

    Joined:
    Jan 5, 2016
    Posts:
    14
    ep1s0de likes this.
  27. ixdeveloper

    ixdeveloper

    Joined:
    Jan 5, 2016
    Posts:
    14
    Haven't tried it either. Looks quite promising - although in our case we do like the ability to tweak the server ourselves with RakNet.
     
    ep1s0de likes this.
  28. ixdeveloper

    ixdeveloper

    Joined:
    Jan 5, 2016
    Posts:
    14
  29. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    This is almost the same, but only I cut out the unnecessary functions ...
     
    Litwin likes this.
  30. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    Watch new videos


     
    ixdeveloper, Litwin and Wattosan like this.
  31. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    Watch my "new" video :)
    I forgot to post a link to a video in this thread
     
  32. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    Watch stress-test video (with comments)

     
  33. Maqsoom123

    Maqsoom123

    Joined:
    Dec 7, 2016
    Posts:
    10
    @ep1s0de Hey documentation is missing please make a demo how to send data from "Client to server then server to other clients", and how to send data client to client without involving server..!

    A chat demo with this can really help!
     
  34. Maqsoom123

    Maqsoom123

    Joined:
    Dec 7, 2016
    Posts:
    10
    Please make a discord server for us, so we can take some help from you!
     
  35. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    A client cannot join other clients, it can only communicate with others through a server ...

    There is an example on the github on how to establish a connection between a client and a server
     
  36. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    I made server-side lag compensation :)

     
  37. Maqsoom123

    Maqsoom123

    Joined:
    Dec 7, 2016
    Posts:
    10
    Can u plz make a chat demo? and lag compensation seems awesome or atleast a simple example which help us to structure code in server and client part!!!! , and u also said u will release the source of client side prediction and server reconsillation stuff
     
    Last edited: Jun 28, 2020
    ep1s0de likes this.
  38. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    I'm sorry, but I don't spend much time on development, I will open access to the source code as soon as it is ready...
     
  39. Maqsoom123

    Maqsoom123

    Joined:
    Dec 7, 2016
    Posts:
    10
    Hello, lucky i got the chat working, and thnx for the github, i have a question i send a message from client1 to server and then server to all client how to ignore the message on client1(owner), right now what i am doing is to ignore owner i write the guid in packet and in foreach loop i use != against connections(list) in server_demo
     
  40. Maqsoom123

    Maqsoom123

    Joined:
    Dec 7, 2016
    Posts:
    10
    ok i just solved it, its peer.IncomingGUID
     
  41. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    Comrades! Soon I will post the updated code on github
     
  42. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Hey @ep1s0de nice work.
    Did you do any stress tests, e.g. how many packets per second can be sent between server and client?
    Also, could you add a license file to the repo to indicate what people can/can't do with it?
    Also, could you add notes on how you compiled RakNet.dll and which version it is?

    I wanted to add a RakNet transport to Mirror/DOTSNET for a while now. Very interesting.
     
    akuno likes this.
  43. Maqsoom123

    Maqsoom123

    Joined:
    Dec 7, 2016
    Posts:
    10
    @vis2k i am goin to w8 for the raknet transport for mirror :)
     
  44. Xitanos

    Xitanos

    Joined:
    Jul 23, 2020
    Posts:
    3
    You can post in GitHub the Client Demo? The Same of Videos?
     
  45. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    Unfortunately I have lost most of these sources. Lightning struck my house and my hard drive failed. Soon I will post the updated code on the github with examples.

    I may have some sources left on google drive, if I find them I will definitely post them in this topic
     
  46. Maqsoom123

    Maqsoom123

    Joined:
    Dec 7, 2016
    Posts:
    10
    @ep1so0de iTs gOiN tO bE aWeSoMe, i daily check this forum specially!!!!!! will be w8iNg dUdE
     
  47. Xitanos

    Xitanos

    Joined:
    Jul 23, 2020
    Posts:
    3
    Wonderful! I'm waiting ... Very Grateful!
     
  48. Xitanos

    Xitanos

    Joined:
    Jul 23, 2020
    Posts:
    3
    I'm sorry for your HD. it has happened to me a couple of times. If you need it, I have a dedicated server with Git installed. I usually keep my projects in sync with my server so I never lose
     
  49. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
  50. Litwin

    Litwin

    Joined:
    Aug 15, 2013
    Posts:
    70
    You posted only the example of the RakNet? Do you intend to commit example of the techniques used in the videos (lag compensation, prediction and etc)?

    Thanks!