|
AntHocNet 2.6.1
Paper-faithful ant-colony ad hoc routing: the shared core and its adapters
|
The whole simulation: nodes, radio, mobility, traffic and the event queue. More...
#include <ahn_web/sim.h>
Public Member Functions | |
| World (std::uint64_t seed) | |
An empty world; seed derives every random stream in it. | |
| void | setArea (double x, double y, double z) |
| Field size in metres (z > 0 enables altitude). | |
| void | setDiskChannel (double range) |
Unit-disk links of radius range metres. | |
| void | setUrbanChannel (double range, int blocksX, int blocksY, double streetWidth) |
| Unit disk cut by the buildings of a blocksX x blocksY street grid. | |
| void | setIslChannel () |
| Links only where addIslLink() says, delay tracking distance. | |
| void | addIslLink (int a, int b) |
| Add an inter-satellite link (ChannelKind::Isl, Mixed). | |
| void | setMixedChannel (double range) |
| #582: ground, air and space nodes in one world. | |
| void | setSatellite (int node) |
#582: mark node as a satellite on the Mixed channel. | |
| void | setBitrate (double bps) |
| Transmitter bit rate (default 2 Mbit/s). | |
| void | setLossProbability (double p) |
| Independent per-reception loss probability (default 0). | |
| int | addNode (double x, double y, double z) |
| Add a node at (x, y, z); returns its address. | |
| void | setNodeRange (int node, double range) |
Give node its own radio range in metres (#568: a device class). | |
| void | setMobility (int node, const Mobility &m) |
node's radio range: its own, else the world range(). | |
| void | addAttenuationZone (const std::vector< double > &xy, double factor, double top=30) |
#575: inside the polygon xy (x0, y0, x1, y1, ...) and below top metres, radio range is scaled by factor (a canopy, rubble: a drone above the trees is not in it). | |
| void | setBattery (int node, double joules) |
#575: give node a battery of joules. | |
| double | batteryLeft (int node) |
#575: energy left in node's battery (J), or -1 without one. | |
| void | setGroundStation (int node, double minElevationDeg) |
#575: make node a ground station on the satellite (Isl) channel. | |
| void | addJammingZone (const std::vector< double > &xy, double from, double until, double vx=0, double vy=0) |
| #582: a jamming zone. | |
| void | scheduleNodeUp (int node, double t, bool up) |
#582: a scripted event – switch node off (up = false) or back on at simulated time t (an aftershock, a device restored), as setNodeUp. | |
| int | addFlow (int src, int dst, double rate, double start, double stop) |
| Add a CBR flow; returns its index. | |
| bool | setLinkMetric (const std::string &name) |
| #579: the link metric every node is built with, by registry name ("classic", "sinr", "energy"); false if unknown. | |
| anthocnet::core::Config & | config () |
| The protocol Config every node is built with – the core defaults. | |
| void | start () |
| Build the nodes' core logic and arm their timers and the flows. | |
| void | advanceTo (double t) |
Process every event up to simulated time t (starts if needed). | |
| double | now () const |
| Current simulated time (s). | |
| std::uint64_t | seed () const |
| The seed this world was built from. | |
| void | moveNode (int node, double x, double y, double z) |
Drag node to (x, y, z) and pin it there (it stops moving). | |
| void | setNodeUp (int node, bool up) |
Switch node off (its held packets are dropped) or back on. | |
| void | cutIslLink (int a, int b) |
| Remove an inter-satellite link. | |
| int | nodeCount () const |
| Number of nodes. | |
| Vec3 | position (int node) const |
Where node is now. | |
| bool | nodeUp (int node) const |
Whether node is switched on. | |
| bool | linkUp (int a, int b) const |
| Whether a and b can hear each other now. | |
| const Node & | node (int i) const |
Node i (for read-only inspection of its core state). | |
| const std::vector< Flow > & | flows () const |
| The flows and their running totals. | |
| int | pendingCount (int node) const |
Data packets node holds waiting for a route. | |
| const std::vector< LogEvent > & | log () const |
| Events since the last clearLog(). | |
| void | clearLog () |
| Forget the logged events (the front end drains them every frame). | |
| std::uint64_t | antTransmissions () const |
| Ant transmissions so far (control overhead). | |
| const std::vector< std::uint8_t > & | antBytes (std::uint64_t id) const |
X-ray (#637): the serialized bytes of ant transmission id – the id-th TxAnt event since start(), from 0 – if it is among the last kXrayRing; else empty. | |
| int | urbanBlocksX () const |
| Street grid blocks along x (Urban). | |
| int | urbanBlocksY () const |
| Street grid blocks along y (Urban). | |
| double | streetWidth () const |
| Street width in metres (Urban). | |
| double | range () const |
| Radio range in metres (Disk, Urban). | |
| double | nodeRange (int node) const |
| ChannelKind | channel () const |
| The link rule in use. | |
| std::vector< double > | zonesFlat () const |
| #575: the attenuation zones as [factor, n, x0, y0, ... x(n-1), y(n-1), ...]. | |
| std::vector< double > | jamZonesFlat () const |
| #582: the jamming zones active now, where they are now, as [n, x0, y0, ... x(n-1), y(n-1), ...]. | |
| Vec3 | area () const |
| Field size in metres. | |
Static Public Member Functions | |
| static std::string | formatEvent (const LogEvent &e) |
| One trace line per logged event (the parity format). | |
Static Public Attributes | |
| static constexpr std::size_t | kXrayRing = 512 |
| X-ray (#637): how many ant transmissions the ring keeps. | |
Friends | |
| class | Node |
The whole simulation: nodes, radio, mobility, traffic and the event queue.
|
explicit |
An empty world; seed derives every random stream in it.
| void ahn_web::World::setArea | ( | double | x, |
| double | y, | ||
| double | z | ||
| ) |
Field size in metres (z > 0 enables altitude).
| void ahn_web::World::setDiskChannel | ( | double | range | ) |
Unit-disk links of radius range metres.
| void ahn_web::World::setUrbanChannel | ( | double | range, |
| int | blocksX, | ||
| int | blocksY, | ||
| double | streetWidth | ||
| ) |
Unit disk cut by the buildings of a blocksX x blocksY street grid.
| void ahn_web::World::setIslChannel | ( | ) |
Links only where addIslLink() says, delay tracking distance.
| void ahn_web::World::addIslLink | ( | int | a, |
| int | b | ||
| ) |
Add an inter-satellite link (ChannelKind::Isl, Mixed).
| void ahn_web::World::setMixedChannel | ( | double | range | ) |
#582: ground, air and space nodes in one world.
Satellites (see setSatellite) link only by their ISLs and to the ground stations that see them; every other pair links by the disk rule, in 3-D, with the world range range for nodes without their own. Unlike the Isl channel, a ground station also links to its neighbours by the disk rule (a HAPS holds both its ring and its uplink). Every link's delay is its length at the speed of light.
| void ahn_web::World::setSatellite | ( | int | node | ) |
#582: mark node as a satellite on the Mixed channel.
|
inline |
|
inline |
| int ahn_web::World::addNode | ( | double | x, |
| double | y, | ||
| double | z | ||
| ) |
Add a node at (x, y, z); returns its address.
| void ahn_web::World::setNodeRange | ( | int | node, |
| double | range | ||
| ) |
Give node its own radio range in metres (#568: a device class).
On the disk and urban channels two nodes link iff they are within min(range_a, range_b). A node never given one uses the world range(), so every existing world is unchanged.
| void ahn_web::World::setMobility | ( | int | node, |
| const Mobility & | m | ||
| ) |
node's radio range: its own, else the world range().
Give node a mobility model (Manhattan snaps it to an intersection).
| void ahn_web::World::addAttenuationZone | ( | const std::vector< double > & | xy, |
| double | factor, | ||
| double | top = 30 |
||
| ) |
#575: inside the polygon xy (x0, y0, x1, y1, ...) and below top metres, radio range is scaled by factor (a canopy, rubble: a drone above the trees is not in it).
A link uses each end's own scaled range; where zones overlap the smallest factor applies.
| void ahn_web::World::setBattery | ( | int | node, |
| double | joules | ||
| ) |
#575: give node a battery of joules.
It drains at kIdleW all the time and kTxW while transmitting, and the node switches off when it is empty. Accounting only: it never touches a routing decision.
| double ahn_web::World::batteryLeft | ( | int | node | ) |
#575: energy left in node's battery (J), or -1 without one.
| void ahn_web::World::setGroundStation | ( | int | node, |
| double | minElevationDeg | ||
| ) |
#575: make node a ground station on the satellite (Isl) channel.
It links to any satellite at least minElevationDeg above its horizon, the horizon being the plane normal to the Earth's radius through it (the Earth's centre is the field's centre, as for orbits).
| void ahn_web::World::addJammingZone | ( | const std::vector< double > & | xy, |
| double | from, | ||
| double | until, | ||
| double | vx = 0, |
||
| double | vy = 0 |
||
| ) |
#582: a jamming zone.
While from <= t < until, any disk or urban link with an end inside the polygon xy (x0, y0, x1, y1, ...), or crossing it, fails. The polygon moves at (vx, vy) m/s from from on (a fire front); (0, 0) holds it still (a jammer). It covers every altitude. Satellite links are never jammed.
| void ahn_web::World::scheduleNodeUp | ( | int | node, |
| double | t, | ||
| bool | up | ||
| ) |
#582: a scripted event – switch node off (up = false) or back on at simulated time t (an aftershock, a device restored), as setNodeUp.
| int ahn_web::World::addFlow | ( | int | src, |
| int | dst, | ||
| double | rate, | ||
| double | start, | ||
| double | stop | ||
| ) |
Add a CBR flow; returns its index.
| bool ahn_web::World::setLinkMetric | ( | const std::string & | name | ) |
#579: the link metric every node is built with, by registry name ("classic", "sinr", "energy"); false if unknown.
Before start() only: an upgrade, like a mission knob, never a world's default.
|
inline |
| void ahn_web::World::start | ( | ) |
Build the nodes' core logic and arm their timers and the flows.
| void ahn_web::World::advanceTo | ( | double | t | ) |
Process every event up to simulated time t (starts if needed).
|
inline |
|
inline |
| void ahn_web::World::moveNode | ( | int | node, |
| double | x, | ||
| double | y, | ||
| double | z | ||
| ) |
Drag node to (x, y, z) and pin it there (it stops moving).
| void ahn_web::World::setNodeUp | ( | int | node, |
| bool | up | ||
| ) |
Switch node off (its held packets are dropped) or back on.
| void ahn_web::World::cutIslLink | ( | int | a, |
| int | b | ||
| ) |
Remove an inter-satellite link.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Node i (for read-only inspection of its core state).
Definition at line 347 of file sim.h.
Referenced by nodeUp(), pendingCount(), and position().
|
inline |
|
inline |
|
inline |
Events since the last clearLog().
|
inline |
|
inline |
| const std::vector< std::uint8_t > & ahn_web::World::antBytes | ( | std::uint64_t | id | ) | const |
X-ray (#637): the serialized bytes of ant transmission id – the id-th TxAnt event since start(), from 0 – if it is among the last kXrayRing; else empty.
A copy kept for inspection: no decision reads it.
|
inline |
|
inline |
|
inline |
|
inline |
| double ahn_web::World::nodeRange | ( | int | node | ) | const |
|
inline |
| std::vector< double > ahn_web::World::zonesFlat | ( | ) | const |
#575: the attenuation zones as [factor, n, x0, y0, ... x(n-1), y(n-1), ...].
| std::vector< double > ahn_web::World::jamZonesFlat | ( | ) | const |
#582: the jamming zones active now, where they are now, as [n, x0, y0, ... x(n-1), y(n-1), ...].
|
inline |
|
static |
One trace line per logged event (the parity format).
|
staticconstexpr |