Determining the data size that is sent

Options
liortal53
liortal53
edited October 2013 in Native
Hi,

We're using photon to send messages using UDP.

I'd like to know if it's possible to calculate the amount of data (in bytes) that gets sent over the wire.

I can calculate the size of each message i'm sending, however i am not sure what overhead Photon (and UDP) adds on top of that.


Thanks
Lior

Comments

  • Kaiserludi
    Options
    Hi Lior.

    PhotonPeer.getBytesOut() and PhotonPeer.getBytesIn() return the amount of bytes that has been sent / received since the last call to Connect(). These values are about the data that is passed to / received from the UDP socket, so its including all overhead, that's added by Photon.
    You could check those values (and make sure that your outgoing queue is empty), then queue your operations, call service() and afterwards check again and depending on which operations you have queued and/or received in your callbacks, the difference between the return values of these functions before and after the service call is you operation size. This isn't 100% accurate as Photon may send or receive acks just inside that timeframe.

    If you want to know the overall data including the overhead that's added by UDP, then you could use the program Wireshark to see whats going in and out on port 5055 (assuming you are using Photons standard udp-port). You would therefor have to run the client on a desktop OS (Linux, OS X, Windows, either directly with a version of your client for that OS or by running a simulator or emulator build of a mobile OS version).
    Wireshark also gives you the info about the payload of a udp packet without any UDP overhead.

    If you want to know the size of just the operation payload after serialization but without any overhead added by Photon then you could serialize your payload with class ExitGames::Common::Serializer, which is what Photon also uses for Serialization internally . You would then just check the size of the resulting byte-array that contains the serialized version of your data.