16#ifndef ANTHOCNET_CORE_ANT_ROUTER_LOGIC_H
17#define ANTHOCNET_CORE_ANT_ROUTER_LOGIC_H
188 std::uint32_t nextSeq() {
return seqNum_++; }
203 void computeBackAntState(
AntMessage& ant)
const;
222 std::uint32_t seqNum_ = 0;
223 std::map<NodeAddress, double> activeSessions_;
224 std::map<NodeAddress, double> lastSeen_;
229 std::map<std::pair<NodeAddress, NodeAddress>,
double> hopEstimate_;
230 std::map<NodeAddress, double> lastReactive_;
231 std::map<NodeAddress, double> lastRepair_;
232 std::map<NodeAddress, double> repairDeadline_;
233 std::map<NodeAddress, int> txFailures_;
234 double lastEvaporation_ = 0.0;
237 std::map<AntType, std::uint64_t> antsSent_;
238 std::map<AntType, std::uint64_t> antsReceived_;
239 std::uint64_t linkfailPropagations_ = 0;
240 std::uint64_t linkfailBudgetDrops_ = 0;
241 std::uint64_t linkfailOriginsSuppressed_ = 0;
242 std::uint64_t repairDiscards_ = 0;
243 std::uint64_t directedSteers_ = 0;
244 std::map<NodeAddress, double> lastLinkfailNotify_;
AntMessage createHelloAnt(std::size_t maxAdverts)
NodeAddress selectNextHop(NodeAddress dest, bool proactive)
Stochastic next hop for dest using the ant exponent betaAnts (kInvalidAddress if no route).
void stampForward(AntMessage &ant, NodeAddress nextHop) const
Append this node to a forward ant's visited stack, recording this hop's cost (congestion-aware MAC es...
void setObserver(IRouterObserver *observer)
Attach an optional observer for ant/route events (nullptr to detach).
AntMessage createBackAnt(const AntMessage &forward)
Build the backward ant for a forward ant that reached this node (this == dst).
std::uint64_t repairDiscards() const
Local repairs that expired without a backward ant and therefore released the data buffered for their ...
void reinforceFromBackAnt(const AntMessage &ant)
Update the regular pheromone table from a backward ant that arrived here (reinforce the link it came ...
std::vector< RouteDecision > reportTxFailure(NodeAddress next, NodeAddress dataDest=kInvalidAddress)
Adapter MAC transmit-failure hook (ADR-0008 detector D): a failed unicast to next means the link is d...
std::uint64_t antsSent(AntType type) const
Ants of type this node has put on the medium (origination + forward).
NodeAddress advanceBackAnt(AntMessage &ant) const
Advance a backward ant by one hop: move this node from the visited stack onto history and return the ...
std::vector< RouteDecision > reportNeighborLoss(NodeAddress n)
Remove neighbour n and, for every destination whose best path it carried, broadcast a LinkFail notifi...
const PheromoneTable & table() const
bool shouldSendProactive(NodeAddress dest) const
The thesis's emission gate, re-derived per-link (#180, ADR-0018): true when some neighbour's virtual ...
std::uint64_t controlPacketsSent() const
Total ant control packets sent across all types (routing overhead).
std::vector< NodeAddress > activeDestinations() const
Destinations with data sent within config_.sessionTtl (const query).
AntRouterLogic(NodeAddress address, const Config &config, IClock &clock, IRng &rng, const ILinkMetric *metric=nullptr, const ILinkState *linkState=nullptr)
metric selects the pheromone formula (item 16); nullptr uses the canonical ClassicMetric.
AntMessage createHelloAnt()
void learnNeighbor(NodeAddress neighbor)
Record that neighbor is reachable (link-layer detection / hello), seeding an equal-weight regular phe...
void noteDataSession(NodeAddress dest)
Record that this node just originated data for dest, making it an active session that proactive ants ...
void loseNeighbor(NodeAddress neighbor)
std::vector< RouteDecision > onReceiveAnt(const AntMessage &ant, NodeAddress prevHop)
Process a received ant arriving from prevHop.
std::uint64_t linkfailPropagations() const
LinkFail notes this node re-broadcast on another reporter's behalf (issue #20: origins = antsSent(Lin...
std::vector< RouteDecision > onDataPacket(NodeAddress dest, NodeAddress prevHop=kInvalidAddress)
Decide what to do with a locally-originated or in-transit data packet destined for dest: route it (Un...
const Config & config() const
double backAntPheromone(const AntMessage &ant) const
Pheromone this back ant would deposit at the current node, reconstructed from its history (hops + sum...
std::vector< AntMessage > createProactiveAnts()
One proactive forward ant per active destination (empty if none or if !config_.enableProactive),...
NodeAddress randomDestination()
Pick a random known destination for a proactive ant (or kInvalidAddress).
std::uint64_t linkfailBudgetDrops() const
LinkFail propagations suppressed by an exhausted inherited broadcastBudget — how often the depth boun...
AntMessage createForwardAnt(AntType type, NodeAddress dest)
std::vector< RouteDecision > onMaintenanceTick()
Periodic liveness/maintenance tick (driven by the adapter hello timer): expire neighbours not heard f...
PheromoneEngine & engine()
std::uint64_t antsReceived(AntType type) const
Non-duplicate ants of type this node has received and processed.
NodeAddress address() const
std::uint64_t directedSteers() const
Reactive forward ants steered along the diffusion gradient instead of being broadcast (config....
std::uint64_t linkfailOriginsSuppressed() const
Per-destination advertisements dropped by the origin cooldown (config.linkfailNotifyInterval,...
NodeAddress nextHopForData(NodeAddress dest, NodeAddress prevHop=kInvalidAddress)
Stochastic next hop for a data packet, using the greedier data exponent betaData (kInvalidAddress if ...
Multipath acceptance filter for reactive forward ants ([1] §3.1, issue #96).
Source of simulation time (seconds).
Node-local MAC-layer signals for the congestion-aware per-hop metric (item 10/A2, [1] §3....
Optional observer the core notifies of routing events (item 15).
constexpr NodeAddress kInvalidAddress
"No such node / no route" sentinel, mirroring the legacy use of -1.
std::int32_t NodeAddress
Network-layer node address.
AntHistoryTracker: (src, seqNum) duplicate detection.
Complete, copyable description of an ant packet.
The canonical AntHocNet metric (Eq.2): blend the path-time estimate with the hop-count estimate and i...
Maps an observation to a pheromone (goodness; higher == better).