Skip to content

fix: Packet loss now returns the value of the current frame instead of connection lifetime#2004

Merged
0xFA11 merged 7 commits intodevelopfrom
bugfix/MTT-3389_packet-loss-amortized
Jun 8, 2022
Merged

fix: Packet loss now returns the value of the current frame instead of connection lifetime#2004
0xFA11 merged 7 commits intodevelopfrom
bugfix/MTT-3389_packet-loss-amortized

Conversation

@Rosme
Copy link
Copy Markdown

@Rosme Rosme commented Jun 8, 2022

Fix the way the packet loss was calculated where it was over a connection lifetime instead of a frame.

MTT-3389

Changelog

  • Fixed issue where PacketLoss would return the packet loss over a connection lifetime instead of a single frame.

Testing and Documentation

  • Includes integration tests.

@Rosme Rosme requested review from a team as code owners June 8, 2022 14:53
@Rosme Rosme requested a review from a team as a code owner June 8, 2022 14:53
Comment thread com.unity.netcode.gameobjects/CHANGELOG.md Outdated
JS Fauteux added 2 commits June 8, 2022 11:12
…ity-Technologies/com.unity.netcode.gameobjects into bugfix/MTT-3389_packet-loss-amortized
@Rosme Rosme changed the title bugifx: Packet loss now returns the value of the current frame instead of connection lifetime fix: Packet loss now returns the value of the current frame instead of connection lifetime Jun 8, 2022
@simon-lemay-unity
Copy link
Copy Markdown
Contributor

I understand the benefit of tracking packet loss on a smaller time scale, but I'm worried that a frame is too small a scale. I don't think we see enough packets per frame to gather a good metric of packet loss on the network. For example, if 10 packets are received per frame (which would be a consequent volume of traffic), then packet loss can't be lower than 10% for any frame. Users are only likely to see long periods of 0% packet loss, interspersed with spikes of 10%-20%. That's not practical to figure out packet loss on the network, since you then have to count the total number of frames between these spikes (e.g. a 10% spike every 10 frame means 1% packet loss on the network, which is a more realistic and useful figure). I think tracking packet loss over periods of say a second might be more useful and accurate.

@Rosme
Copy link
Copy Markdown
Author

Rosme commented Jun 8, 2022

I understand the benefit of tracking packet loss on a smaller time scale, but I'm worried that a frame is too small a scale. I don't think we see enough packets per frame to gather a good metric of packet loss on the network. For example, if 10 packets are received per frame (which would be a consequent volume of traffic), then packet loss can't be lower than 10% for any frame. Users are only likely to see long periods of 0% packet loss, interspersed with spikes of 10%-20%. That's not practical to figure out packet loss on the network, since you then have to count the total number of frames between these spikes (e.g. a 10% spike every 10 frame means 1% packet loss on the network, which is a more realistic and useful figure). I think tracking packet loss over periods of say a second might be more useful and accurate.

We decided to go this route as RNSM actually allow you to configure over how many samples and how long you want the packet loss to be. Since this is used by the tools, it's an easy way to get the value and leave in the end of the user how much precision and flexibility they want.

Comment thread com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs Outdated
Copy link
Copy Markdown
Member

@NoelStephensUnity NoelStephensUnity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the very minor whitespace issue, it looks good to me.

// In those situation we want to return the last packet loss value instead of 0 to avoid invalid swings
if (packetDroppedDelta == 0 && packetReceivedDelta == 0)
{
return m_PacketLossCache.PacketLoss;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to return 0 in this case? It would mean that you don't need to store the previous value 🤔

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question, maybe what you have is already the best approach

Copy link
Copy Markdown
Contributor

@ian-m-unity ian-m-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with one suggestion :)

@0xFA11 0xFA11 enabled auto-merge (squash) June 8, 2022 20:13
@0xFA11 0xFA11 merged commit 7f5dc1c into develop Jun 8, 2022
@0xFA11 0xFA11 deleted the bugfix/MTT-3389_packet-loss-amortized branch June 8, 2022 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants