AntHocNet 2.6.1
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 = 0x04
 On-wire format version, written at offset 0 of every frame and checked before any other field (ADR-0006).
 
constexpr std::uint8_t kKinematicsTag = 0x4B
 First byte of a hello's kinematics section ('K').
 
constexpr std::size_t kKinematicsSize = 1 + 6 * 4
 Tag + six float32 values.
 
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 ahn_web::antJson(), and deserialize().

◆ deserialize() [2/2]

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

Definition at line 63 of file ant_message_codec.h.

References deserialize().

Variable Documentation

◆ kWireVersion

constexpr std::uint8_t anthocnet::core::codec::kWireVersion = 0x04
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). 0x04: + optional trailing kinematics section on hellos (#573, ADR-0025): tag kKinematicsTag, then x y z vx vy vz as float32. Absent unless Config::shareKinematics is on, so default frames keep their length.

Definition at line 36 of file ant_message_codec.h.

◆ kKinematicsTag

constexpr std::uint8_t anthocnet::core::codec::kKinematicsTag = 0x4B
constexpr

First byte of a hello's kinematics section ('K').

Definition at line 39 of file ant_message_codec.h.

◆ kKinematicsSize

constexpr std::size_t anthocnet::core::codec::kKinematicsSize = 1 + 6 * 4
constexpr

Tag + six float32 values.

Definition at line 41 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 46 of file ant_message_codec.h.

◆ kMaxHistoryOnWire

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

retraced path ≤ path length

Definition at line 47 of file ant_message_codec.h.

◆ kMaxHelloOnWire

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

generous bound on adverts

Definition at line 48 of file ant_message_codec.h.