Send rate of OnSerializeNetworkView

I use OnSerializeNetworkView to send data from a server to clients. The GameObject involved has a NetworkView component attached to it, and everything works fine. But I noticed that the actual send rate of this OnSerializeNetworkView (mesured by counting function calls) does not match the value at Network.sendRate.
Examples:

Network.sendRate   OnSerializeNetworkView calls/s
 15                ~13
 20                ~17
 40                ~30
 60                ~40
100                ~60

It seems to be linear and actually capable of high rates, but not matching Network.sendRate for values over 10. Also, the type of “State Synchronization” of the attached NetworkView does not affect this behaviour in any way, which brings another question: Is OnSerializeNetworkView sent over UDP all the time?

The data to send is not large, about 300B per client, and the above values were pulled during tests with only one client. There is only one other NetworkView in the project, which synchronizes a Transform.

Any thoughts or explanations?

Some explanations:

  • Any data is send using UDP when you use the built-in network engine (RakNet).
  • Even RPCs are send via UDP. They use their own reliable layer for those.
  • How often OnSerializeNetworkView is called depens on the “State Synchronization” and whether you send data or receive data. When you’re the owner of the networkview (which means you only send), OnSerializeNetworkView should be called at sendRate.
  • When you are receiving OnSerializeNetworkView is only called when a packet has arrived. When delta compression is used, the sender might not send anything if not necessary.
  • With delta compression OnSerializeNetworkView is called at sendrate but that doesn’t mean it sends a packet each time. Only when there’s a change.

Personally i never measured the exact rate, but maybe it’s related to your framerate. Unity uses a single thread for scripting, so OnSerializeNetworkView has to be queued into the Update loop. At low framerates there might be some drops.

How did you measure the rate? Maybe post a code sample?