AntHocNet 2.0.0
Paper-faithful ant-colony ad hoc routing: the shared core and its adapters
Loading...
Searching...
No Matches
anthocnet::core::codec Namespace Reference

Functions

std::size_t serializedSize (const AntMessage &msg)
 Number of bytes serialize() will produce for msg.
 
std::vector< std::uint8_t > serialize (const AntMessage &msg)
 Encode msg into a fresh byte buffer.
 
void serialize (const AntMessage &msg, std::vector< std::uint8_t > &out)
 Encode msg into out (resized to serializedSize(msg)).
 
bool deserialize (const std::uint8_t *bytes, std::size_t len, AntMessage &msg)
 Decode bytes into msg.
 
bool deserialize (const std::vector< std::uint8_t > &bytes, AntMessage &msg)
 

Variables

constexpr std::uint8_t kWireVersion = 0x03
 On-wire format version, written at offset 0 of every frame and checked before any other field (ADR-0006).
 
constexpr std::uint16_t kMaxVisitedOnWire = 100
 Protocol bounds enforced on decode of untrusted input, mirroring the Config defaults so the codec stays standalone (golden rule #5).
 
constexpr std::uint16_t kMaxHistoryOnWire = 100
 retraced path ≤ path length
 
constexpr std::uint16_t kMaxHelloOnWire = 64
 generous bound on adverts
 

Function Documentation

◆ serializedSize()

std::size_t anthocnet::core::codec::serializedSize ( const AntMessage &  msg)

Number of bytes serialize() will produce for msg.

◆ serialize() [1/2]

std::vector< std::uint8_t > anthocnet::core::codec::serialize ( const AntMessage &  msg)

Encode msg into a fresh byte buffer.

◆ serialize() [2/2]

void anthocnet::core::codec::serialize ( const AntMessage &  msg,
std::vector< std::uint8_t > &  out 
)

Encode msg into out (resized to serializedSize(msg)).

◆ deserialize() [1/2]

bool anthocnet::core::codec::deserialize ( const std::uint8_t *  bytes,
std::size_t  len,
AntMessage &  msg 
)

Decode bytes into msg.

Returns false if the buffer is truncated or internally inconsistent; on failure msg is left in an unspecified state.

Referenced by deserialize().

◆ deserialize() [2/2]

bool anthocnet::core::codec::deserialize ( const std::vector< std::uint8_t > &  bytes,
AntMessage &  msg 
)
inline

Definition at line 55 of file ant_message_codec.h.

References deserialize().

Variable Documentation

◆ kWireVersion

constexpr std::uint8_t anthocnet::core::codec::kWireVersion = 0x03
constexpr

On-wire format version, written at offset 0 of every frame and checked before any other field (ADR-0006).

Bump on any layout/semantic change. Both adapter headers must serialize this same value. 0x01: version byte + bounds/enum enforcement (item 12). 0x02: + AntMessage::broadcastBudget field, AntType::LinkFail (item 05). 0x03: backward-ant slim — prevHop/hops/pathTime/pheromone off the wire, reconstructed locally from history (item 02, ADR-0009).

Definition at line 33 of file ant_message_codec.h.

◆ kMaxVisitedOnWire

constexpr std::uint16_t anthocnet::core::codec::kMaxVisitedOnWire = 100
constexpr

Protocol bounds enforced on decode of untrusted input, mirroring the Config defaults so the codec stays standalone (golden rule #5).

A frame declaring more elements than these is rejected, not just buffer-checked. == Config::maxPathLength

Definition at line 38 of file ant_message_codec.h.

◆ kMaxHistoryOnWire

constexpr std::uint16_t anthocnet::core::codec::kMaxHistoryOnWire = 100
constexpr

retraced path ≤ path length

Definition at line 39 of file ant_message_codec.h.

◆ kMaxHelloOnWire

constexpr std::uint16_t anthocnet::core::codec::kMaxHelloOnWire = 64
constexpr

generous bound on adverts

Definition at line 40 of file ant_message_codec.h.