Jump to content

Packet Performance Questions - Multiple Single Packets to one batch


Go to solution Solved by Gurgarath,

Recommended Posts

Dear Community,

I'm currently working on a small personal project and i am stuck.
Right now, I’m sending small packets of information from the client to the game, and while the data transfer works fine, I’d like to improve performance.
At the moment, I'm sending multiple small packets one by one specifically, for example, I send inventory item information using a loop that sends 10 separate packets, one for each inventory cell.
What I’d like to do instead is send one larger packet that contains all 10 inventory cells at once. I’ve tried a few different approaches, but I’m not quite sure how to structure and process the combined data correctly on the receiving end.
If anyone has experience with this kind of optimization or advice on how to properly serialize and handle a batch of data in one packet, I’d really appreciate your input!
Thanks in advance!


Best Regards,
DevOverflow

  • Bot

 You not mentioned if  your actual batch of packest are static or dynamic ? Try compress packets using lz4 and a use dynamic packet.

Edited by Metin2 Dev

english_banner.gif

  • Forum Moderator
  • Solution
6 hours ago, Punszz said:

 You not mentioned if  your actual batch of packest are static or dynamic ? Try compress packets using lz4 and a use dynamic packet.

If he sends a batch it is more likely dynamic. Unless he likes, defer sending and spams static packets all at once which could be considered bad practice. Compressing LZ4 packets is more often than not not useful, as the compression / decompression overhead on a 20 bytes packet is way worse than just sending the packet raw. Only packets worth compressing are probably the biggest one and they are often DG packets or custom CG / GC big packets like a ranking or stuff like that.

On the part where I kept the default networking, I usually prefer to send dynamic packets of large data (using a "vector", that we can send if we make it an array or data or reconstruct it on the server) where it makes sense, rather than sending multiple small packets, this at least removes stuttering on the client (and risk to get kicked out because you send too many burst packets). But if you really go for a new approach, there are thousands of better options than what we have now, like msquic, a modern TCP implementation, packet serialization and so on. But it requires extensive work and sometimes multi-threading if you want to do it right, which is something that will lead you to hours of TSAN.

Edited by Gurgarath
  • Good 1

Gurgarath
coming soon
My Services

  • Active Member

Based on what you’ve written, it’s unlikely to make much of a difference. The ::Send(...) function simply writes data into a buffer to be sent on the next tick, so from the server’s perspective, it doesn’t change much. It really depends on what you're trying to achieve. For example, take a look at how opening a shop via a bundle works. In that case, the server needs complete information about all items, so sending each item in a separate packet wouldn’t make much sense.

Edited by Endymion
9 hours ago, Gurgarath said:

If he sends a batch it is more likely dynamic. Unless he likes, defer sending and spams static packets all at once which could be considered bad practice. Compressing LZ4 packets is more often than not not useful, as the compression / decompression overhead on a 20 bytes packet is way worse than just sending the packet raw. Only packets worth compressing are probably the biggest one and they are often DG packets or custom CG / GC big packets like a ranking or stuff like that.

On the part where I kept the default networking, I usually prefer to send dynamic packets of large data (using a "vector", that we can send if we make it an array or data or reconstruct it on the server) where it makes sense, rather than sending multiple small packets, this at least removes stuttering on the client (and risk to get kicked out because you send too many burst packets). But if you really go for a new approach, there are thousands of better options than what we have now, like msquic, a modern TCP implementation, packet serialization and so on. But it requires extensive work and sometimes multi-threading if you want to do it right, which is something that will lead you to hours of TSAN.

Thank you for your Answer. I will try it out!

  • Metin2 Dev 1
  • Bot
17 hours ago, Gurgarath said:

If he sends a batch it is more likely dynamic. Unless he likes, defer sending and spams static packets all at once which could be considered bad practice. Compressing LZ4 packets is more often than not not useful, as the compression / decompression overhead on a 20 bytes packet is way worse than just sending the packet raw. Only packets worth compressing are probably the biggest one and they are often DG packets or custom CG / GC big packets like a ranking or stuff like that.

On the part where I kept the default networking, I usually prefer to send dynamic packets of large data (using a "vector", that we can send if we make it an array or data or reconstruct it on the server) where it makes sense, rather than sending multiple small packets, this at least removes stuttering on the client (and risk to get kicked out because you send too many burst packets). But if you really go for a new approach, there are thousands of better options than what we have now, like msquic, a modern TCP implementation, packet serialization and so on. But it requires extensive work and sometimes multi-threading if you want to do it right, which is something that will lead you to hours of TSAN.

Aand what i said? Sending a compressed vector and reconstruct on client.. Compression is really worth..  i

english_banner.gif

  • 2 weeks later...
On 4/13/2025 at 8:08 AM, Gurgarath said:

If he sends a batch it is more likely dynamic. Unless he likes, defer sending and spams static packets all at once which could be considered bad practice. Compressing LZ4 packets is more often than not not useful, as the compression / decompression overhead on a 20 bytes packet is way worse than just sending the packet raw. Only packets worth compressing are probably the biggest one and they are often DG packets or custom CG / GC big packets like a ranking or stuff like that.

On the part where I kept the default networking, I usually prefer to send dynamic packets of large data (using a "vector", that we can send if we make it an array or data or reconstruct it on the server) where it makes sense, rather than sending multiple small packets, this at least removes stuttering on the client (and risk to get kicked out because you send too many burst packets). But if you really go for a new approach, there are thousands of better options than what we have now, like msquic, a modern TCP implementation, packet serialization and so on. But it requires extensive work and sometimes multi-threading if you want to do it right, which is something that will lead you to hours of TSAN.

Thank you for your answer. Your answer worked perfectly and solved my problem. I really appreciate your help!

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.