group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
net::FragmentReassembler Class Reference

#include <FragmentReassembler.hpp>

Collaboration diagram for net::FragmentReassembler:
[legend]

Classes

struct  ActiveSet
struct  OptionalSet

Public Types

enum class  Result { InProgress , Complete , Stale , Malformed }
 Result of addFragment. More...

Public Member Functions

Result addFragment (const PacketHeader &hdr, const uint8_t *payload, int payloadLen, std::vector< uint8_t > &assembled)
 Feed one received fragment into the reassembler.
void reset () noexcept
 Drop any in-progress reassembly.

Static Public Attributes

static constexpr int k_maxFragments = 255
 Maximum fragments per logical message — matches the 8-bit fragment-count field in the wire header.

Static Private Member Functions

static bool seqMoreRecent (std::uint32_t s1, std::uint32_t s2) noexcept
 Glenn-Fiedler "is s2 more recent than s1?" with 16-bit wrap.

Private Attributes

OptionalSet active_

Member Enumeration Documentation

◆ Result

Result of addFragment.

Enumerator
InProgress 

Fragment accepted into in-progress set, but more fragments are still needed before the message is complete.

Complete 

Fragment was the final missing piece — assembled is populated with the full logical message.

Stale 

Fragment was older than the in-progress set and got dropped (drop-stale semantics).

Malformed 

Header was malformed (bad fragment index/count).

Member Function Documentation

◆ addFragment()

Result net::FragmentReassembler::addFragment ( const PacketHeader & hdr,
const uint8_t * payload,
int payloadLen,
std::vector< uint8_t > & assembled )
inline

Feed one received fragment into the reassembler.

Parameters
hdrReceived PacketHeader. flags.0 must be set (caller pre-checks); fragmentInfo carries (index << 8) | count.
payloadFragment payload bytes (already stripped of the 16-byte PacketHeader by UdpEndpoint).
payloadLenLength of the fragment's payload (≤ k_maxPayloadBytes).
assembledOutput: filled with the full reassembled logical-message bytes when result == Complete.
Returns
See Result enum.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void net::FragmentReassembler::reset ( )
inlinenoexcept

Drop any in-progress reassembly.

Used on disconnect / connection reset.

◆ seqMoreRecent()

bool net::FragmentReassembler::seqMoreRecent ( std::uint32_t s1,
std::uint32_t s2 )
inlinestaticprivatenoexcept

Glenn-Fiedler "is s2 more recent than s1?" with 16-bit wrap.

Used for stale-fragment detection.

Here is the caller graph for this function:

Member Data Documentation

◆ active_

OptionalSet net::FragmentReassembler::active_
private

◆ k_maxFragments

int net::FragmentReassembler::k_maxFragments = 255
staticconstexpr

Maximum fragments per logical message — matches the 8-bit fragment-count field in the wire header.


The documentation for this class was generated from the following file: