Skip to content

Install AntHocNet

This repository ships two things you can install:

  • the algorithm core (core/), a simulator-free C++23 static library with the CMake package anthocnet-core (imported target anthocnet::core). It builds on swarm-core's core/ (package swarm-core, target swarm::core). Install it through vcpkg (below) or with CMake from a checkout (below);
  • the ns-3 module anthocnet (with the comparison modules aomdv, gpsr, oracle, adaptive and the routing-bench harness), which make install-ns3 copies into your ns-3 tree's contrib/ together with swarm-core's ns-3 module contrib/swarm-core (ns-3).

The browser adapter (the learn site) is not installed from here: it lives in swarm-routing.github.io.

Supported platforms

Part Platform Compiler, C++ standard CMake Simulator
core/ Linux x64 (Ubuntu 24.04, as CI) a C++23 compiler (CI: GCC 13.3) 3.20 or newer (CI: 3.28) none
ns-3 module Linux x64 the ns-3 release's (C++23 from ns-3.46) the ns-3 release's ns-3.49 on every PR; ns-3.46 to 3.48 on demand

ns-3.46 is the floor: the core is C++23, the standard ns-3 itself requires from 3.46 on. ns-3 maintains only its latest release, so CI builds every push and pull request on that one (ghcr.io/swarm-routing/ns3-dev:latest, ns-3.49 today); the older releases run when CI is dispatched with ns3-versions.

Linux through vcpkg (manifest mode)

The C++ core is published as the port anthocnet-core in the org's registry, swarm-routing/vcpkg-registry; every release opens its port PR (the vcpkg job of the release workflow; v2.9.0's is swarm-routing/vcpkg-registry#77). The port depends on the registry's swarm-core port. Install vcpkg once:

git clone https://github.com/microsoft/vcpkg.git "$HOME/vcpkg"
"$HOME/vcpkg/bootstrap-vcpkg.sh" -disableMetrics
export VCPKG_ROOT="$HOME/vcpkg"

Then, in your project, declare the dependency. vcpkg.json:

{
  "name": "my-simulation",
  "version": "0.1.0",
  "dependencies": ["anthocnet-core"]
}

vcpkg-configuration.json takes both ports from the org's registry and vcpkg's helper ports from the builtin one. Each baseline is a commit of that registry: for the builtin one, your vcpkg checkout's (git -C "$VCPKG_ROOT" rev-parse HEAD); for ours, the registry's main (git ls-remote https://github.com/swarm-routing/vcpkg-registry main). This script writes the file with both:

cat > vcpkg-configuration.json <<EOF
{
  "default-registry": {
    "kind": "builtin",
    "baseline": "$(git -C "$VCPKG_ROOT" rev-parse HEAD)"
  },
  "registries": [
    {
      "kind": "git",
      "repository": "https://github.com/swarm-routing/vcpkg-registry",
      "baseline": "$(git ls-remote https://github.com/swarm-routing/vcpkg-registry main | cut -f1)",
      "packages": ["swarm-core", "anthocnet-core"]
    }
  ]
}
EOF

CMakeLists.txt:

cmake_minimum_required(VERSION 3.20)
project(my-simulation CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(anthocnet-core CONFIG REQUIRED)
add_executable(my-simulation main.cc)
target_link_libraries(my-simulation PRIVATE anthocnet::core)

find_package(anthocnet-core) finds its swarm-core dependency itself; anthocnet::core brings swarm::core and the include path with it.

main.cc, a round trip of an ant through the canonical wire format (wire-format.md):

#include "anthocnet/core/ant_message_codec.h"

#include <cstdio>

int main() {
    anthocnet::core::AntMessage ant;
    const auto bytes = anthocnet::core::codec::serialize(ant);
    anthocnet::core::AntMessage back;
    const bool ok = anthocnet::core::codec::deserialize(bytes, back);
    std::printf("anthocnet-core: %zu-byte ant, round trip %s\n", bytes.size(), ok ? "ok" : "FAILED");
    return ok ? 0 : 1;
}

Configure with the vcpkg toolchain, which installs the manifest's ports first, then build and run:

cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
cmake --build build -j
./build/my-simulation

It prints:

anthocnet-core: 41-byte ant, round trip ok

Linux with CMake from a checkout

Without vcpkg, install swarm-core's core/ (the release swarm-core.lock names) and then this repository's core into one prefix. From a checkout, tools/swarm_core.py path downloads that release, checks its SHA256 and prints its core/ directory:

git clone --depth 1 https://github.com/swarm-routing/AntHocNet.git
cd AntHocNet
make test                                   # optional: the core's unit tests
prefix="$HOME/.local/anthocnet"
sc=$(python3 tools/swarm_core.py path)
cmake -S "$sc" -B build-swarm-core -DSWARM_CORE_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
cmake --build build-swarm-core -j && cmake --install build-swarm-core --prefix "$prefix"
cmake -S core -B build-anthocnet-core -DANTHOCNET_CORE_INSTALL=ON -DANTHOCNET_CORE_TESTS=OFF \
  -DCMAKE_PREFIX_PATH="$prefix" -DCMAKE_BUILD_TYPE=Release
cmake --build build-anthocnet-core -j && cmake --install build-anthocnet-core --prefix "$prefix"

SWARM_CORE_TESTS=OFF skips swarm-core's own tests, which do not build on GCC 13.3 in v2.2.0 (-Werror=stringop-overflow, swarm-routing/swarm-core#120); you only need its library. The prefix then holds lib/libanthocnet_core.a, the headers under include/anthocnet/core/ and the package in lib/cmake/anthocnet-core/. Build the project above with that prefix instead of the vcpkg toolchain:

cmake -S . -B build -DCMAKE_PREFIX_PATH="$HOME/.local/anthocnet"
cmake --build build -j && ./build/my-simulation

CI checks the same package on every PR: core/tests/consumer-package/ is built against an install of it.

ns-3

One subsection per ns-3 release CI builds on, newest first. The module is not cloned into contrib/ directly: make install-ns3 copies anthocnet (and, unless BASELINES=0, the comparison modules) into the tree and installs swarm-core's ns-3 module as contrib/swarm-core, at the swarm-adapter-ns3 release swarm-adapter-ns3.lock names (it keeps, with a warning, a contrib/swarm-core another installer put there at a different release). make ns3-doctor checks a tree before and after. Uninstall with make uninstall-ns3 NS3DIR=.... More in ns3/README.md.

ns-3.49

The release every push and pull request builds on.

  • Required tools: what ns-3's installation guide lists for 3.49 (a C++23 compiler, CMake, Python 3, Make or Ninja), plus Git and make. The installer downloads swarm-core's ns-3 module from GitHub (tools/swarm_core.py, Python 3), so it needs network access once.
  • Optional tools: Docker, for the ns3-dev and release images below (ns-3 preinstalled at /opt/ns-3); ccache speeds up rebuilds.
  • Install, from a clean machine to a run of the module's example (the ns-3 tag, then this repository's latest release tag):
git clone --branch ns-3.49 --depth 1 https://gitlab.com/nsnam/ns-3-dev.git ns-3
git clone --branch v2.9.0 --depth 1 https://github.com/swarm-routing/AntHocNet.git
cd AntHocNet
make ns3-doctor  NS3DIR="$PWD/../ns-3"
make install-ns3 NS3DIR="$PWD/../ns-3"      # BASELINES=0: AntHocNet alone, no comparison arms
cd ../ns-3
./ns3 configure --enable-tests --enable-examples \
  --filter-module-examples-and-tests='anthocnet;oracle;adaptive;routing-bench' \
  --enable-modules='anthocnet;aomdv;gpsr;oracle;adaptive;routing-bench;wifi;mobility;applications;csma;aodv;olsr;dsdv;flow-monitor;point-to-point;mesh'
./ns3 build
./test.py -s anthocnet
./ns3 run anthocnet-example

The --enable-modules list is CI's: it builds only what the modules need. Leave it out to build all of ns-3. With BASELINES=0, configure with --filter-module-examples-and-tests='anthocnet' and --enable-modules='anthocnet;wifi;mobility;applications;aodv;olsr;dsdv;flow-monitor;point-to-point;csma'. - Without a checkout: download anthocnet-ns3-modules-<version>.tar.gz from the latest release and tar -xzf it into ns-3/contrib; CI installs from this tarball on every PR. - Or the container: the release image has ns-3.49 with every module of the release already built and tested:

docker run --rm ghcr.io/swarm-routing/anthocnet:v2.9.0-optimized \
  ./ns3 run --no-build anthocnet-example

To build a checkout yourself, the plain ns-3 image is CI's:

docker run --rm -it -v "$PWD":/src -w /src ghcr.io/swarm-routing/ns3-dev:3.49 bash
make install-ns3 NS3DIR=/opt/ns-3
cd /opt/ns-3 && ./ns3 configure --enable-tests --enable-examples && ./ns3 build && ./ns3 run anthocnet-example
  • Known bugs on this release (table below): NS3-001 (stock AODV livelocks): AntHocNet is not affected; every AODV- and GPSR-family comparison arm runs behind routing-bench's ICMP guard. NS3-002 (AODV/DSDV socket order): routing-bench runs each stock arm in its own process. NS3-003 (DSDV on a null output device): isl-grid refuses dsdv on multi-interface topologies. NS3-004 and NS3-005 (AODV after an interface restart) touch only routing-bench --failures, which is opt-in.

ns-3.46, ns-3.47, ns-3.48

Built on demand (CI dispatched with ns3-versions, e.g. ["3.46","3.48"]), on the ghcr.io/swarm-routing/ns3-dev:<version> images.

  • Required and optional tools: as for ns-3.49, with that release's own requirements from its installation guide (C++23 from 3.46).
  • Install: the ns-3.49 commands with the release's tag, e.g. for 3.48:
git clone --branch ns-3.48 --depth 1 https://gitlab.com/nsnam/ns-3-dev.git ns-3
git clone --branch v2.9.0 --depth 1 https://github.com/swarm-routing/AntHocNet.git
cd AntHocNet
make ns3-doctor  NS3DIR="$PWD/../ns-3"
make install-ns3 NS3DIR="$PWD/../ns-3"
cd ../ns-3
./ns3 configure --enable-tests --enable-examples \
  --filter-module-examples-and-tests='anthocnet;oracle;adaptive;routing-bench'
./ns3 build
./test.py -s anthocnet
./ns3 run anthocnet-example

The satellite example isl-grid needs ns-3.48 or newer (the stock LEO model, ADR-0022). - Or the container: ghcr.io/swarm-routing/ns3-dev:3.48 (or :3.46, :3.47), with the same commands as for 3.49. - Known bugs on these releases: NS3-002 and NS3-003, handled as on 3.49. NS3-001 is not in 3.48.

OMNeT++

Not supported yet: swarm-adapter-omnet adds it. This section gets one subsection per OMNeT++ release once a release of this repository supports it.

Known simulator bugs

Upstream ns-3 defects our repositories meet, from the org's ns-3 bug register. Each ID links its RCAPA (the reproduction, the root cause, the upstream report).

ID What breaks ns-3 versions Status Our fix or workaround
NS3-001 AODV livelocks in a zero-time ICMP "net unreachable" storm 3.49 and ns-3-dev master 8ec9b4a1 (run); not 3.48 open upstream; reported, fix proposed (not ours); worked around AODV-family arms on ns3-dev:3.48 (AntHocNet CI) until the harness guard reaches them: routing-bench wraps the aodv arm in a guard (swarm-routing/sim-tools#322) applying nsnam/ns-3-dev!3101's rules (maintainer decision 2026-11-23, swarm-routing/sim-tools#238); strict XFAIL 3.49 sparse-aodv in swarm-routing/sim-containers test/known-failures.txt; the patch ns3/patches/NS3-001/ (nsnam/ns-3-dev!3101 at d3fbcacb; apply.sh applies it only to a source with the bug, swarm-routing/sim-tools#378), which the vcpkg ns3 port applies by the same rule (maintainer decision 2026-11-25, swarm-routing/vcpkg-registry#81; its own copy until it takes the released asset, swarm-routing/sim-tools#380)
NS3-002 AODV and DSDV order per-interface sockets by heap address 3.42, 3.48, 3.49 and ns-3-dev master 8ec9b4a1, a150de8f (run); 3.42, 3.48, 3.49 (read) open upstream; reported; worked around --isolateArms (default since v1.1.0); AntHocNet: its own maps ordered, stock aodv in its own process, the order gate on anthocnet rows only
NS3-003 DSDV sends on a route with a null output device (assert, or a silent SIGSEGV when optimized) 3.36–3.48 and ns-3-dev 2026-08 (run); 3.49 (read) open upstream; reported, fix proposed; worked around AntHocNet's isl-grid refuses dsdv on multi-interface topologies, checked by its satellite arm smoke
NS3-004 AODV never restarts its hello timer when an interface comes back up (a restarted node sends no HELLO for the rest of the run) 3.49 and ns-3-dev master 8a06b457 (run); 3.49, master (read) open upstream; draft ready none: --failures is opt-in; ns3/routing-bench/README.md "Scripted failures" names the limit (swarm-routing/sim-tools#361, open)
NS3-005 AODV route lifetime overflows int64 when an interface comes up after t=0 (GetMaximumSimulationTime() + Now(): UBSan aborts; undefined behaviour otherwise) 3.49 and ns-3-dev master d07400ba (run); 3.7–3.49, master (read) open upstream; reported; patch kept here and in the patched images the patch ns3/patches/NS3-005/ (apply.sh applies it only to a source with the bug), applied in swarm-routing/sim-containers ns3-dev:3.49-{debug,sanitized}-patched-5c58dfa (publish run 45712453689, the patch at sim-tools 1b36c739); --failures AODV restarts (swarm-routing/sim-tools#361) abort on sanitized stock builds: the suite leaves them out where the source has the bug and runs them on the patched sanitized image (ns3.yml failures-patched)

Fixed upstream, but present in an older ns-3 release you may still pin:

What breaks ns-3 versions Fixed in Our fix or workaround
802.11b HR/DSSS (5.5, 11 Mb/s) frames dropped as an unsupported modulation: GetModulationClassForStandard(WIFI_STANDARD_80211b) returns WIFI_MOD_CLASS_DSSS, and since 3.41 WifiPhy::StartReceivePreamble refuses any class above it 3.42 (run); 3.41, 3.42 (read); not 3.40 or earlier (no gate, read) 3.43 (da9fcebe) strict XFAIL 3.41/3.42 dsdv-manet, dense-{aodv,olsr,dsdv} (no-packets-delivered) in swarm-routing/sim-containers test/known-failures.txt (swarm-routing/sim-containers#250); swarm-routing/AntHocNet#923 to check for 802.11b above 2 Mb/s on 3.42
Four wifi unit suites (wifi-txop, wifi-mlo, wifi-gcr, wifi-emlsr-basic-exchanges) fail when test-runner is built without the test module: the tests match frames by packet UID, which needs packet metadata on, and 3.48 turns it on only through src/test's ns3tcp suites (a test bug; wifi-txop then reads past its frame list) 3.48 (run) 3.49 (the tests use the MPDU's own UID) strict XFAIL 3.48 unit:<suite> in swarm-routing/sim-containers test/known-failures.txt

Troubleshooting

  • vcpkg: no version database entry for anthocnet-core (or swarm-core) at the version you ask for: your registry baseline predates that release's port. Set it to the registry's current main (the script above); a release's port arrives with its feat(ports): anthocnet-core X.Y.Z PR in swarm-routing/vcpkg-registry.
  • Could not find a package configuration file provided by "swarm-core" when building against a CMake install: swarm-core is not on CMAKE_PREFIX_PATH. Install it into the same prefix (above), or pass both prefixes.
  • ANTHOCNET_CORE_INSTALL needs swarm-core from its package, not SWARM_CORE_DIR: the installed package links an installed swarm-core. Install swarm-core first, then configure with -DSWARM_CORE_DIR= (empty: the value is cached, so leaving the flag out of a reconfigure keeps it) or in a fresh build directory, e.g. cmake -S core -B build-anthocnet-core -DSWARM_CORE_DIR= -DANTHOCNET_CORE_INSTALL=ON -DANTHOCNET_CORE_TESTS=OFF -DCMAKE_PREFIX_PATH="$prefix". SWARM_CORE_DIR is for development against a local swarm-core checkout.
  • swarm-core's tests fail to compile on GCC 13.3 (-Werror=stringop-overflow in test/test-wire.cc): configure swarm-core with -DSWARM_CORE_TESTS=OFF (swarm-routing/swarm-core#120).
  • ns-3 configure or build fails on C++23 features: the tree is older than ns-3.46, the module's floor. make ns3-doctor NS3DIR=... prints the tree's version and its verdict on its ##DOCTOR## line.
  • contrib/swarm-core is X, AntHocNet installs Y: kept, not overwritten: another installer (another protocol's module) put a different swarm-core release there. AntHocNet is built and tested with Y; remove contrib/swarm-core and run make install-ns3 again to get it.