[1.0.0 pre.65] Where do I limit packet sizes without editing MTU?

NetCode has a maximum hardcoded packet size of 1400 bytes but my custom network interface (Epic Online Services) has a limit of 1140 bytes because the backend adds their own header data.

How do I reduce the packet sizes NetCode produces?

I’ve localized the Transport package and manually edited the MTU constant to 1140 and it works. But the problem is I’ll have to do that manually for every single update and anyone else who wants to try using my prototype interface which is annoying.

A̶l̶t̶e̶r̶n̶a̶t̶i̶v̶e̶l̶y̶ ̶I̶ ̶c̶o̶u̶l̶d̶ ̶c̶o̶p̶y̶ ̶p̶a̶s̶t̶e̶ ̶t̶h̶e̶ ̶f̶r̶a̶g̶m̶e̶n̶t̶a̶t̶i̶o̶n̶ ̶p̶i̶p̶e̶l̶i̶n̶e̶ ̶s̶t̶a̶g̶e̶ ̶t̶h̶e̶n̶ ̶c̶h̶a̶n̶g̶e̶ ̶t̶h̶e̶ ̶o̶n̶e̶ ̶l̶i̶n̶e̶ ̶i̶n̶d̶i̶c̶a̶t̶i̶n̶g̶ ̶m̶a̶x̶i̶m̶u̶m̶ ̶p̶a̶c̶k̶e̶t̶ ̶s̶i̶z̶e̶ ̶b̶u̶t̶ ̶t̶h̶a̶t̶ ̶d̶o̶e̶s̶n̶’̶t̶ ̶a̶l̶t̶e̶r̶ ̶t̶h̶e̶ ̶o̶t̶h̶e̶r̶ ̶p̶a̶r̶t̶s̶ ̶o̶f̶ ̶n̶e̶t̶c̶o̶d̶e̶ ̶w̶h̶i̶c̶h̶ ̶a̶s̶s̶u̶m̶e̶ ̶t̶h̶e̶ ̶s̶a̶m̶e̶ ̶M̶T̶U̶ ̶s̶i̶z̶e̶.̶

Making a custom frag stage and then appending it to the end does not work.

Reading Transport code in general, it seems like making MTU size dynamic will be an impossible task at this point.

Way too many functions and logical operators are built on the assumption that MTU is a constant variable.

It seems like the solution is thus editing Unity Editor package cache (not the one in the project) to skip the need to localize the package for a single constant change. Either automatically via script or manually.

As you have figured out, right now the only option is unfortunately to modify the package with a custom constant. However, it is on our short-term list of priorities to provide a way to modify it through the NetworkSettings API. This is important not only for custom network interfaces, but also for some networks that sometimes have issues with IP fragmentation (we’ve had reports of issues with some VPNs for example). I can’t commit to timelines, but ideally this would be available soon (we’re working on this right now).

2 Likes