I have a pretty simple UDP client/server going - the client sends updates to the server every 30 milliseconds, so 33.333 times per second. Nothing else is being sent anywhere else in the code (except for an initial connection message and then a disconnection message)
These updates are always 19 bytes, and Packet.getDataSize() confirms this. So 19 bytes 33 times per seconds should be sending out roughly 627 bytes per second.
However Windows resource monitor says my program is consistently sending out 4,000 to 5,000 bytes per second.
Is this some kind of bug, or is sf::Packet actually much much larger than Packet.getDataSize()?
Here is the code that gets called in the game loop:
void Client::sendUpdate()
{
elapsedTime = elapsedTime + clock.getElapsedTime();
if (elapsedTime.asMilliseconds() >= tickrate.asMilliseconds()) //tickrate = sf::milliseconds(30) set elsewhere
{
elapsedTime = clock.restart();
sf::Packet sendPacket;
sf::Uint32 protocolID = 1885697825;
sf::Uint8 action = UPDATE;
sendPacket << protocolID << action << localPlayer.id << localPlayer.positionX << localPlayer.positionY << localPlayer.rotation;
cout << "sendPacket: " << sendPacket.getDataSize() << endl;
if (socket.send(sendPacket, serverAddress, serverPort) != sf::Socket::Done)
{
cerr << "Error sending player input." << endl;
}
}
}
It's entirely possible of course that I'm just not seeing something I've done wrong, but I've been trying to figure this out for a while now so I thought I'd ask for help.
Also here's a screen cap of the resource monitor and the debug/console outputting the data size of the packet