Skip to content

fix!: MTT-1425 Resolving overflow issue with UTP Adapter#1300

Merged
JesseOlmer merged 9 commits intodevelopfrom
fix/utp-adapter-fixes
Oct 15, 2021
Merged

fix!: MTT-1425 Resolving overflow issue with UTP Adapter#1300
JesseOlmer merged 9 commits intodevelopfrom
fix/utp-adapter-fixes

Conversation

@andrews-unity
Copy link
Copy Markdown
Contributor

So this is doing some cleanup and fixing several issues the UTP Adapter was having with regards to queued packets, as well as fragmentation. Also cleaned up the public properties to make more sense since what was there before just lead to a lot of confusion. Also we report back a string for an error code now which should make it easier to understand what is going on.

MTT-1425

Changelog

com.unity.adapter.utp

  • Fixed: Possible Editor crash when trying to read a batched packet where the size of the packet was larger than the max packet size.
  • Fixed: Removed the requirement that MaxPacketSize needs to be the same size as the batched/fragmentation buffer size.
  • Changed: Consolidated the Send/Recv queue properties as they always needed to be the same.
  • Changed: Consolidated the Fragmentation/Queue size as they always needed to be the same.
  • Added: New SetConnectionData function that takes in a NetworkEndpoint
  • Removed: Removed m_MessageBuffer as it was no longer needed and we just do a temp allocation and copy the packet when we call InvokeOnTransportEvent

Testing and Documentation

  • Testing is already covered by the current transport tests.

NetworkEndPoint.Parse(d.Address, (ushort)d.Port);

public static implicit operator ConnectionAddressData(NetworkEndPoint d) =>
new ConnectionAddressData() { Address = d.Address.Split(':')[0], Port = d.Port };
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I do not like this but its the way NetworkEndpoint encodes the address. If there is no ':' then it will just return nothing or whatever is before it.

Debug.Assert(sizeof(ulong) == UnsafeUtility.SizeOf<NetworkConnection>(),
"Netcode connection id size does not match UTP connection id size");
Debug.Assert(m_MessageBufferSize > 5, "Message buffer size must be greater than 5");
Debug.Assert(m_MaximumPacketSize > 5, "Message buffer size must be greater than 5");
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.

where this magical 5 is coming from and should it be a k_ constant value?

private void Awake()
{
var maxCap = UnityTransport.MaximumMessageLength + 128;
var maxCap = UnityTransport.InitialBatchQueueSize + 128;
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.

another magic number here too...

Copy link
Copy Markdown
Contributor

@0xFA11 0xFA11 left a comment

Choose a reason for hiding this comment

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

some minor nits but LGTM

Copy link
Copy Markdown
Contributor

@Cosmin-B Cosmin-B left a comment

Choose a reason for hiding this comment

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

It also looks all good to me besides the little magic numbers.

@JesseOlmer JesseOlmer changed the title fix: MTT-1425 Resolving overflow issue with UTP Adapter fix!: MTT-1425 Resolving overflow issue with UTP Adapter Oct 15, 2021
@JesseOlmer JesseOlmer merged commit 20f8f45 into develop Oct 15, 2021
@JesseOlmer JesseOlmer deleted the fix/utp-adapter-fixes branch October 15, 2021 14:12
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.

5 participants