Class Router
One node routing table, learned from the traffic the node hears.
public sealed class Router : IDisposable
- Inheritance
-
Router
- Implements
- Inherited Members
Remarks
Flooding always works but costs every node airtime and power on every packet. A node that remembers the way can forward to one neighbour instead, and falls back to flooding rather than failing whenever it does not know the way. The core table is generic over its size, which cannot cross the C ABI, so this one is sized when it is built.
Constructors
Router(uint, int)
Creates an empty routing table for a node.
public Router(uint address, int capacity = 64)
Parameters
addressuintThe address of this node, which is what a routing decision recognises as a local delivery.
capacityintHow many routes to make room for. A capacity of 0 floods every unknown destination, which is the behaviour with no table at all.
Exceptions
- PamojaException
The native table could not be created.
Properties
Address
The address this router answers for.
public uint Address { get; }
Property Value
Capacity
How many routes the table can hold.
public int Capacity { get; }
Property Value
Count
How many routes the table currently holds.
public int Count { get; }
Property Value
Methods
Cost(uint)
Returns what the known route to a node costs.
public ushort? Cost(uint dst)
Parameters
dstuintThe node to reach.
Returns
- ushort?
The cost, or
nullwhen no route is known.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Forget(uint)
Forgets the route to a node, for example after it stops answering.
public void Forget(uint dst)
Parameters
dstuintThe node to forget.
Forward(uint)
Decides what to do with a packet bound for a node.
public ForwardDecision Forward(uint dst)
Parameters
dstuintThe node the packet is addressed to.
Returns
- ForwardDecision
The decision, carrying a next hop only when it says to relay.
NextHop(uint)
Returns the neighbour on the way to a node.
public uint? NextHop(uint dst)
Parameters
dstuintThe node to reach.
Returns
- uint?
The next hop, or
nullwhen no route is known.
Observe(uint, uint, ushort)
Learns a route from a packet that arrived.
public bool Observe(uint origin, uint via, ushort cost)
Parameters
originuintThe node the packet came from.
viauintThe neighbour it arrived through.
costushortWhat that path costs, usually a hop count.
Returns
- bool
Whether the table changed. It keeps the cheapest way it knows to each node, and when full gives up the most expensive route to make room for a cheaper one.
RouteTo(uint)
Returns the whole route to a node.
public Route? RouteTo(uint dst)
Parameters
dstuintThe node to reach.
Returns
- Route?
The route, or
nullwhen no route is known.