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

Built-in teaching scenarios: one per network family, shaped like the repo's presets but scaled down to what reads well on a screen. More...

Classes

struct  Flow
 A constant-bit-rate data flow and its running totals. More...
 
struct  Leg
 One straight leg of a node's trajectory: p0 at t0 to p1 at t1. More...
 
struct  LogEvent
 One entry of the event log (see Ev for what each field means per kind). More...
 
struct  Mobility
 A node's mobility model and its parameters. More...
 
class  Node
 One AntHocNet node: the core logic plus the adapter state around it. More...
 
class  SplitMix64
 SplitMix64: tiny, portable, and bit-identical on every platform (integer arithmetic only; the double is an exact 53-bit scaling). More...
 
struct  Vec3
 A position in metres (z = altitude; 0 on planar worlds). More...
 
class  World
 The whole simulation: nodes, radio, mobility, traffic and the event queue. More...
 

Enumerations

enum class  MobilityKind {
  Static , RandomWaypoint , GaussMarkov , Manhattan ,
  Orbit
}
 How a node moves. Values are part of the JS API (setMobility's kind). More...
 
enum class  ChannelKind { Disk , Urban , Isl }
 Which link rule the teaching radio uses. More...
 
enum class  Ev : int {
  TxAnt = 1 , RxAnt = 2 , TxData = 3 , Deliver = 4 ,
  Drop = 5 , RouteAdd = 6 , RouteDel = 7 , Queue = 8 ,
  TxFail = 9 , NodeDown = 10 , NodeUp = 11
}
 Event kinds of the log the front end animates and the parity test diffs. More...
 
enum class  DropReason : int {
  Ttl = 1 , QueueTimeout = 2 , HoldCap = 3 , RepairDiscard = 4 ,
  NodeOff = 5
}
 Why a data packet was lost (the peer field of an Ev::Drop event). More...
 

Functions

std::vector< std::string > scenarioNames ()
 Names accepted by buildScenario(), in display order.
 
bool buildScenario (World &w, const std::string &name)
 Populate an empty World with the named scenario. Returns false if unknown.
 
double detSin (double x)
 sin / cos from arithmetic only (range reduction + Taylor series), so the native and WASM builds compute bit-identical orbits: libm's transcendental functions are not guaranteed to round the same on both.
 
double detCos (double x)
 
Vec3 orbitPosition (const Mobility &m, const Vec3 &centre, double t)
 Where an Orbit puts a node at time t (centre = the field's centre, z = 0).
 

Detailed Description

Built-in teaching scenarios: one per network family, shaped like the repo's presets but scaled down to what reads well on a screen.

The browser adapter (#544, ADR-0021): an adapter for the shared AntHocNet core, next to the ns-3 one (and NS-2's, through v1.9.0).

They change the scenario only – mobility, channel, size, traffic – never the protocol Config (ADR-0019). The parity test runs every one of them.

It owns what an adapter owns – the clock, the RNGs, the timers, the pending-packet queue, a radio – and carries out the RouteDecisions the core returns. It never decides a route.

The radio is a teaching model: unit disk (optionally cut by buildings, or a fixed ISL adjacency), a FIFO transmitter per node with a fixed bit rate, and a MAC transmit-failure report when a unicast's receiver is out of range. It is not ns-3 and nothing measured on it is a benchmark number.

Everything here is plain C++14 on top of core/, so the same sources build natively and with Emscripten; the native-vs-WASM decision-trace parity test (web/test/parity.sh) holds the two builds byte-identical.

Enumeration Type Documentation

◆ MobilityKind

enum class ahn_web::MobilityKind
strong

How a node moves. Values are part of the JS API (setMobility's kind).

Enumerator
Static 

never moves (until dragged)

RandomWaypoint 

straight legs to uniform waypoints, optional pause

GaussMarkov 

correlated speed and heading, 1 s steps, optionally 3-D

Manhattan 

street grid: straight 0.5, left/right 0.25 at each corner

Orbit 

circular orbit around the field's centre (satellites)

Definition at line 75 of file sim.h.

◆ ChannelKind

enum class ahn_web::ChannelKind
strong

Which link rule the teaching radio uses.

Enumerator
Disk 

linked iff within range()

Urban 

within range() and no building on the line of sight

Isl 

linked iff an inter-satellite link was added (and not cut)

Definition at line 109 of file sim.h.

◆ Ev

enum class ahn_web::Ev : int
strong

Event kinds of the log the front end animates and the parity test diffs.

Append only: the JS front end and the trace format index these numerically.

Enumerator
TxAnt 

node -> peer (-1 = broadcast); a=AntType, b=dir, v=arrival time

RxAnt 

node received from peer; a=AntType, b=dir

TxData 

node -> peer; a=flow, b=seq, v=arrival time

Deliver 

node = destination; a=flow, b=seq, v=end-to-end delay

Drop 

node; a=flow, b=seq, peer=DropReason

RouteAdd 

node; peer=next hop, a=destination

RouteDel 

node; peer=next hop, a=destination

Queue 

node; a=flow, b=seq, peer=destination

TxFail 

node -> peer unicast failed (out of range)

NodeDown 

node switched off

NodeUp 

node switched on

Definition at line 117 of file sim.h.

◆ DropReason

enum class ahn_web::DropReason : int
strong

Why a data packet was lost (the peer field of an Ev::Drop event).

Enumerator
Ttl 

hop limit reached (a loop)

QueueTimeout 

waited QueueTimeout (3 s) for a route, or queue full

HoldCap 

a reconvergence hold outlived ReconvHoldCap (200 ms)

RepairDiscard 

a local repair expired: the core's DiscardPending

NodeOff 

the holding or receiving node was switched off

Definition at line 132 of file sim.h.

Function Documentation

◆ scenarioNames()

std::vector< std::string > ahn_web::scenarioNames ( )

Names accepted by buildScenario(), in display order.

◆ buildScenario()

bool ahn_web::buildScenario ( World &  w,
const std::string &  name 
)

Populate an empty World with the named scenario. Returns false if unknown.

◆ detSin()

double ahn_web::detSin ( double  x)

sin / cos from arithmetic only (range reduction + Taylor series), so the native and WASM builds compute bit-identical orbits: libm's transcendental functions are not guaranteed to round the same on both.

◆ detCos()

double ahn_web::detCos ( double  x)

◆ orbitPosition()

Vec3 ahn_web::orbitPosition ( const Mobility &  m,
const Vec3 &  centre,
double  t 
)

Where an Orbit puts a node at time t (centre = the field's centre, z = 0).