Skip to content

feat: Implement GetCurrentRtt in the adapter #1755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 28, 2022

Conversation

simon-lemay-unity
Copy link
Contributor

MTT-2683

Implement GetCurrentRtt in the adapter, using the code already used for the metrics gathering. Had to make a few adjustments to ExtractRtt to make it easier to use in GetCurrentRtt.

Note that the returned value only reflects RTT for reliable traffic, but this should be a good approximation of RTT for any kind of traffic (and with NGO sending most things reliably currently, the limitation is a bit moot).

Changelog

com.unity.netcode.adapter.utp

  • Added: GetCurrentRtt is now properly implemented.

Testing and Documentation

  • Includes unit/integration test.
  • No documentation changes or additions were necessary.

@simon-lemay-unity simon-lemay-unity requested a review from a team as a code owner February 28, 2022 19:41
Copy link
Contributor

@Rosme Rosme left a comment

Choose a reason for hiding this comment

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

Looks good. Good change.

@@ -773,25 +773,23 @@ private void ExtractNetworkMetricsFromPipeline(NetworkPipeline pipeline, Network

private int ExtractRtt(NetworkConnection networkConnection)
{
if (NetworkManager.IsServer)
if (m_Driver.GetConnectionState(networkConnection) != NetworkConnection.State.Connected)
Copy link
Contributor

Choose a reason for hiding this comment

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

Detail but why is the NetworkManager.IsServer check out of the method instead of adding it to the if(m_Driver.GetConnectionState(networkConnection) != NetworkConnection.State.Connected) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we want ExtractRtt to work on servers too. Metrics want 0 for the RTT on servers, but GetCurrentRtt must work on servers too. So moving the check out of the method allows ExtractRtt to be used more widely.

@simon-lemay-unity simon-lemay-unity merged commit 98fbfbf into develop Feb 28, 2022
@simon-lemay-unity simon-lemay-unity deleted the feat/adapter-getcurrentrtt branch February 28, 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.

4 participants