AntHocNet 2.0.0
Paper-faithful ant-colony ad hoc routing: the shared core and its adapters
Loading...
Searching...
No Matches
route_decision.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (C) 2026 Daniel Henrique Joppi
3
4/**
5 * RouteDecision: the verb the algorithm hands back to an adapter.
6 *
7 * AntRouterLogic is pure: it never sends a packet or schedules a timer
8 * itself. It returns RouteDecisions and the adapter carries them out against
9 * its simulator (unicast to nextHop, link-layer broadcast, enqueue pending,
10 * deliver to the local transport, or drop).
11 */
12#ifndef ANTHOCNET_CORE_ROUTE_DECISION_H
13#define ANTHOCNET_CORE_ROUTE_DECISION_H
14
17
18namespace anthocnet {
19namespace core {
20
21enum class RouteAction {
22 None, ///< Nothing to do.
23 Unicast, ///< Send `message` to `nextHop`.
24 Broadcast, ///< Link-layer broadcast `message`.
25 Queue, ///< Hold the data packet pending a route to `nextHop`/dst.
26 Deliver, ///< Destination reached: hand to the local transport.
27 Drop, ///< Discard (loop, TTL, no route).
28 DiscardPending, ///< Local repair timed out ([1] §3.5, D6): discard the
29 ///< data packets queued for destination `nextHop`.
30};
31
35 bool hasMessage = false; ///< Whether `message` is populated.
36 AntMessage message; ///< Ant to emit (Unicast/Broadcast).
37
38 static RouteDecision drop() { return {RouteAction::Drop, kInvalidAddress, false, {}}; }
39 static RouteDecision none() { return {RouteAction::None, kInvalidAddress, false, {}}; }
40 static RouteDecision deliver() { return {RouteAction::Deliver, kInvalidAddress, false, {}}; }
41};
42
43} // namespace core
44} // namespace anthocnet
45
46#endif // ANTHOCNET_CORE_ROUTE_DECISION_H
constexpr NodeAddress kInvalidAddress
"No such node / no route" sentinel, mirroring the legacy use of -1.
Definition types.h:27
std::int32_t NodeAddress
Network-layer node address.
Definition types.h:21
@ Unicast
Send message to nextHop.
@ Drop
Discard (loop, TTL, no route).
@ Deliver
Destination reached: hand to the local transport.
@ Queue
Hold the data packet pending a route to nextHop/dst.
@ DiscardPending
Local repair timed out ([1] §3.5, D6): discard the data packets queued for destination nextHop.
@ Broadcast
Link-layer broadcast message.
AntHistoryTracker: (src, seqNum) duplicate detection.
Definition ant_history.h:24
Complete, copyable description of an ant packet.
Definition ant_message.h:48
AntMessage message
Ant to emit (Unicast/Broadcast).
static RouteDecision deliver()
bool hasMessage
Whether message is populated.
static RouteDecision drop()
static RouteDecision none()