Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by slingchilders · Dec 07, 2016 at 09:29 PM · networkingmultiplayermultiplayer-networking

Networking not sequenced, - ReliableSequenced Qos in Transport Layer API?

Hi there, I'm trying to build a simple server and client application using unity and Transport Layer API. I request QosType.ReliableSequenced for both the client and server app, open up the connection, etc. In my server Update method I increase an int called iClock by 1 every frame and then after that send a message to the client up with the value of iClock like so:

     public void SendPlayerClock(Player player)
     {
         Account account = player.account;
         byte[] buffer;
         byte error;
 
         MemoryStream writeStream = new MemoryStream();
         BinaryWriter writer = new BinaryWriter(writeStream);
         writer.Write(PackageType.Clock);
         writer.Write(iClock);
         buffer = writeStream.ToArray();
 
         NetworkTransport.Send(serverSocketId, player.iConnectionId, rsChannel, buffer, buffer.Length, out error);
     }

In the client I receive the event via NetworkTransport.Receive in its Update method and display the iClock value via OnGui. At first it goes in order, but here's what happens:

  1. At first the client sees the value increasing as it should

  2. After some time, every once in a while it skips to a lower value and continues, in time it's getting worse and worse

  3. If I move the focus away from the Editor, it seems to kind of display the same symptoms, but if I open an instance of a built client and focus on that one, the original one in the editor just stops, doesn't show any change in the counter, as soon as I put the focus back to it, it continues, but now it skips between high and low values.

What is going on? Both the client and the server have the runInBackground set to true. Am I misunderstanding the ReliableSequenced QoS or some threading stuff going on? It seems it's heavily reliable on the framerate of the application.

Here is how I open the socket:

     //Initialize the Unity Transport Layer API
     public void InitializeNetworkCode()
     {
         Debug.Log("Initializing Network Code");
         Application.runInBackground = true;
         // Init Transport using default values.
         NetworkTransport.Init();
        
         // Create a connection config and add a Channel.
         ConnectionConfig config = new ConnectionConfig();
         rsChannel = config.AddChannel(QosType.ReliableSequenced);
 
         // Create a topology based on the connection config.
         HostTopology topology = new HostTopology(config, serverSettings.MaxNumPlayers);
 
         int iChannel = 8801;
         // Create a host based on the topology we just created, and bind the socket to port 12345.
         serverSocketId = NetworkTransport.AddHost(topology, iChannel);
     }

Here is the receiving code:

                NetworkEventType evnt = NetworkTransport.Receive(out outHostId, out outConnectionId, out outChannelId, buffer, bufferSize, out receiveSize, out error);


Edit After some testing I can see that in this scenario, if I change the QoS, the behavior is as follows: Unreliable - least amount of skipping ReliableSequenced - moderate amount of skipping AllCostDelivery - completely crazy

Why is that? How can I have a truly reliable and sequenced way of delivering data?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by slingchilders · Dec 08, 2016 at 06:51 AM

I fell victim to my own poor reading comprehension, and misunderstood the QoS specs in the Unity Documentation. For what I needed I should have gone with StateUpdate I was really confused with the use of the word Sequenced in some of these - in what way is it sequenced if I was really clearly receiving older packets? Does that have to do with how I receive those fast messages inside Update?

So for anyone who has a similar problem, this goes to show that you should really think about what kind of information you are sending and how it should be treated logically within the game. Found this which shows what typical applications of each QoS are:

https://blogs.unity3d.com/2014/06/11/all-about-the-unity-networking-transport-layer/

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

119 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Error when using NetworkList "Don't know how to serialize List`1 " 0 Answers

local scale network 0 Answers

[UNet] Network Animator transition stutters 0 Answers

How to make my game multiplayer? 1 Answer

UDP Client receiving Disposed error 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges