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

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
 

Detailed Description

The whole simulation: nodes, radio, mobility, traffic and the event queue.

Definition at line 242 of file sim.h.

Constructor & Destructor Documentation

◆ World()

ahn_web::World::World ( std::uint64_t  seed)
explicit

An empty world; seed derives every random stream in it.

Member Function Documentation

◆ setArea()

void ahn_web::World::setArea ( double  x,
double  y,
double  z 
)

Field size in metres (z > 0 enables altitude).

◆ setDiskChannel()

void ahn_web::World::setDiskChannel ( double  range)

Unit-disk links of radius range metres.

◆ setUrbanChannel()

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.

◆ setIslChannel()

void ahn_web::World::setIslChannel ( )

Links only where addIslLink() says, delay tracking distance.

◆ addIslLink()

void ahn_web::World::addIslLink ( int  a,
int  b 
)

Add an inter-satellite link (ChannelKind::Isl, Mixed).

◆ setMixedChannel()

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.

◆ setSatellite()

void ahn_web::World::setSatellite ( int  node)

#582: mark node as a satellite on the Mixed channel.

◆ setBitrate()

void ahn_web::World::setBitrate ( double  bps)
inline

Transmitter bit rate (default 2 Mbit/s).

Definition at line 269 of file sim.h.

◆ setLossProbability()

void ahn_web::World::setLossProbability ( double  p)
inline

Independent per-reception loss probability (default 0).

Definition at line 271 of file sim.h.

◆ addNode()

int ahn_web::World::addNode ( double  x,
double  y,
double  z 
)

Add a node at (x, y, z); returns its address.

◆ setNodeRange()

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.

◆ setMobility()

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).

◆ addAttenuationZone()

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.

◆ setBattery()

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.

◆ batteryLeft()

double ahn_web::World::batteryLeft ( int  node)

#575: energy left in node's battery (J), or -1 without one.

◆ setGroundStation()

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).

◆ addJammingZone()

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.

◆ scheduleNodeUp()

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.

◆ addFlow()

int ahn_web::World::addFlow ( int  src,
int  dst,
double  rate,
double  start,
double  stop 
)

Add a CBR flow; returns its index.

◆ setLinkMetric()

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.

◆ config()

anthocnet::core::Config & ahn_web::World::config ( )
inline

The protocol Config every node is built with – the core defaults.

Worlds never change it (ADR-0019); a mission's labelled knob may.

Definition at line 316 of file sim.h.

◆ start()

void ahn_web::World::start ( )

Build the nodes' core logic and arm their timers and the flows.

◆ advanceTo()

void ahn_web::World::advanceTo ( double  t)

Process every event up to simulated time t (starts if needed).

◆ now()

double ahn_web::World::now ( ) const
inline

Current simulated time (s).

Definition at line 325 of file sim.h.

◆ seed()

std::uint64_t ahn_web::World::seed ( ) const
inline

The seed this world was built from.

Definition at line 327 of file sim.h.

◆ moveNode()

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).

◆ setNodeUp()

void ahn_web::World::setNodeUp ( int  node,
bool  up 
)

Switch node off (its held packets are dropped) or back on.

◆ cutIslLink()

void ahn_web::World::cutIslLink ( int  a,
int  b 
)

Remove an inter-satellite link.

◆ nodeCount()

int ahn_web::World::nodeCount ( ) const
inline

Number of nodes.

Definition at line 339 of file sim.h.

◆ position()

Vec3 ahn_web::World::position ( int  node) const
inline

Where node is now.

Definition at line 341 of file sim.h.

References node().

◆ nodeUp()

bool ahn_web::World::nodeUp ( int  node) const
inline

Whether node is switched on.

Definition at line 343 of file sim.h.

References node().

◆ linkUp()

bool ahn_web::World::linkUp ( int  a,
int  b 
) const
inline

Whether a and b can hear each other now.

Definition at line 345 of file sim.h.

◆ node()

const Node & ahn_web::World::node ( int  i) const
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().

◆ flows()

const std::vector< Flow > & ahn_web::World::flows ( ) const
inline

The flows and their running totals.

Definition at line 349 of file sim.h.

◆ pendingCount()

int ahn_web::World::pendingCount ( int  node) const
inline

Data packets node holds waiting for a route.

Definition at line 351 of file sim.h.

References node().

◆ log()

const std::vector< LogEvent > & ahn_web::World::log ( ) const
inline

Events since the last clearLog().

Definition at line 353 of file sim.h.

◆ clearLog()

void ahn_web::World::clearLog ( )
inline

Forget the logged events (the front end drains them every frame).

Definition at line 355 of file sim.h.

◆ antTransmissions()

std::uint64_t ahn_web::World::antTransmissions ( ) const
inline

Ant transmissions so far (control overhead).

Definition at line 357 of file sim.h.

◆ antBytes()

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.

◆ urbanBlocksX()

int ahn_web::World::urbanBlocksX ( ) const
inline

Street grid blocks along x (Urban).

Definition at line 365 of file sim.h.

◆ urbanBlocksY()

int ahn_web::World::urbanBlocksY ( ) const
inline

Street grid blocks along y (Urban).

Definition at line 367 of file sim.h.

◆ streetWidth()

double ahn_web::World::streetWidth ( ) const
inline

Street width in metres (Urban).

Definition at line 369 of file sim.h.

◆ range()

double ahn_web::World::range ( ) const
inline

Radio range in metres (Disk, Urban).

Definition at line 371 of file sim.h.

◆ nodeRange()

double ahn_web::World::nodeRange ( int  node) const

◆ channel()

ChannelKind ahn_web::World::channel ( ) const
inline

The link rule in use.

Definition at line 374 of file sim.h.

◆ zonesFlat()

std::vector< double > ahn_web::World::zonesFlat ( ) const

#575: the attenuation zones as [factor, n, x0, y0, ... x(n-1), y(n-1), ...].

◆ jamZonesFlat()

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), ...].

◆ area()

Vec3 ahn_web::World::area ( ) const
inline

Field size in metres.

Definition at line 381 of file sim.h.

◆ formatEvent()

static std::string ahn_web::World::formatEvent ( const LogEvent &  e)
static

One trace line per logged event (the parity format).

Friends And Related Symbol Documentation

◆ Node

friend class Node
friend

Definition at line 387 of file sim.h.

Member Data Documentation

◆ kXrayRing

constexpr std::size_t ahn_web::World::kXrayRing = 512
staticconstexpr

X-ray (#637): how many ant transmissions the ring keeps.

Definition at line 359 of file sim.h.


The documentation for this class was generated from the following file: