Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Packet Fragmentation implementation | DO NOT MERGE #22

Closed
wants to merge 13 commits into from
Closed

WIP: Packet Fragmentation implementation | DO NOT MERGE #22

wants to merge 13 commits into from

Conversation

TimonPost
Copy link
Collaborator

@TimonPost TimonPost commented Oct 1, 2018

This is an implementation of fragmentation (issue). Looks like it is working, but need to test it more still. So work in progress...

Note that I have looked at this libary which had some basic implementation of fragmentation. It is from the author of gafferongames blogs:

Things I changed:

  1. There are two headers:
  • PacketHeader
    This will contain all the header stuff we first had in RawPacket. This will be used for every packet.

  • Fragment Header
    Fragment header the information of the fragments a packet is divided into. The first fragment packet will have two headers. The standard PacketHeader and the Fragment header the following fragments only have the fragment header.

  1. Also, I have changed to using byteorder so that I can control more better how a header gets serialized an deserialized.
  2. I have a FragmentBuffer which will be used to store fragments temporarily
  3. Added a config ty[e for network settings.

Still, need to do:

  1. Tests
  2. Config file needs to be given by the user (for now the default is used).

@TimonPost TimonPost changed the title WIP: Large packet implementation | DO NOT MERGE WIP: Packet Fragmentation implementation | DO NOT MERGE Oct 1, 2018
Copy link
Owner

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great, lots of comments but mostly questions. Lets address my questions and then ill give this another review. Overall amazing work @TimonPost 👍 .

src/net/socket_state.rs Show resolved Hide resolved
src/net/socket_state.rs Show resolved Hide resolved
src/net/socket_state.rs Show resolved Hide resolved
src/net/socket_state.rs Show resolved Hide resolved
// get specific slice of data for fragment
let fragment_data = &payload[start_fragment_pos..end_fragment_pos];

packet_data.add_fragment(&fragment, fragment_data.to_vec());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think there might be a way to avoid this allocation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean .to_vec? If yes, I am going to try to make everything work with slices I am not happy yet because I do this for multiple places.

src/packet/packet_data.rs Show resolved Hide resolved
src/packet/packet_data.rs Show resolved Hide resolved
src/packet/packet_processor.rs Show resolved Hide resolved
src/packet/packet_processor.rs Show resolved Hide resolved
src/packet/packet_processor.rs Show resolved Hide resolved
@fhaynes
Copy link
Collaborator

fhaynes commented Oct 1, 2018

Very nice work, I mostly just had questions and a few nitpicks

@TimonPost
Copy link
Collaborator Author

See TimonPost/laminar#1

@TimonPost TimonPost closed this Oct 2, 2018
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.

3 participants