Skip to content

Conversation

@JonathSpirit
Copy link
Owner

This pull request introduces several improvements and refactors to the networking code, focusing on packet handling, debugging, and the client-server protocol. The most significant changes are the introduction of more granular packet counters for both host and peer targets, enhanced debugging options, and a refactor of the packet reordering and caching mechanisms to support these changes. These updates improve the clarity, flexibility, and robustness of the networking stack.

Networking Protocol and Client Refactor:

  • Added a Targets enum to Client, allowing separate tracking of packet counters and reordered counters for PEER and HOST, and refactored related methods and member variables to use these new counters. This enables more precise packet tracking and management. [1] [2] [3]
  • Updated the PacketReorderer and related protocol logic to use the new reordered counter, including changes to method signatures and member variables, ensuring correct handling and ordering of packets per target. [1] [2] [3]
  • Refactored ProtocolPacket to replace the concept of "last counter" with "reordered counter" throughout, aligning with the new tracking system. [1] [2] [3] [4] [5] [6]

Debugging and Build Options:

  • Added a new CMake option FGE_ENABLE_PACKET_DEBUG_VERBOSE to enable verbose packet debug printing, with a warning if enabled without debug mode. [1] [2]

Packet Cache and Reordering Improvements:

  • Enhanced PacketCache with an alarm state, a new processing method, and internal refactoring for better packet retransmission and tracking. [1] [2] [3] [4]
  • Increased the packet cache delay factor from 1.2 to 2.2 for improved reliability in high-latency scenarios.

API and Example Updates:

  • Updated example client and server code to use the new packet counter APIs and improved output for debugging, reflecting the new separation of host and peer counters. [1] [2] [3]
  • Improved the Packet class with proper assignment operators and minor cleanups.

Other Protocol and Infrastructure Changes:

  • Added forward declaration for NetFluxUdp in the protocol header to support new method signatures.

These changes collectively modernize the networking internals, making the system more maintainable and robust for future development.

- Not an circular buffer anymore
- Add a try count to packets inside the cache
- Currently there is now a problem with the client reorder WIP
- Client: add isReadyToAcceptMorePendingPackets() it should now be used instead of isPendingPacketsEmpty()
… client context

- Also cleanup debug printing
- WIP There is still a issue where not acknowledged packet is not correctly re-sent in certain situation
… (openssl) for now

- This fix the transmission for big packets
- Also add more debug printing
@JonathSpirit JonathSpirit added this to the v0.9.5 milestone Jan 24, 2026
@JonathSpirit JonathSpirit self-assigned this Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants