pamoja for TypeScript - v0.1.17
    Preparing search index...

    Class Router

    One node routing table, learned from the traffic the node hears.

    The core table is generic over its size, which cannot cross the native boundary, so this one is sized when it is built.

    Index
    • Creates an empty routing table for a node.

      Parameters

      • address: number

        The address of this node, which is what a routing decision recognizes as a local delivery.

      • Optionalcapacity: number

        How many routes to make room for, defaulting to DEFAULT_CAPACITY. A capacity of 0 floods every unknown destination.

      Returns routing.Router

    • get address(): number

      The address this router answers for.

      Returns number

    • get capacity(): number

      How many routes the table can hold.

      Returns number

    • get isEmpty(): boolean

      Whether the table has learned nothing yet.

      Returns boolean

    • get size(): number

      How many routes the table currently holds.

      Returns number

    • Returns what the known route to a node costs.

      Parameters

      • dst: number

        The node to reach.

      Returns number | null

      The cost, or null when no route is known.

    • Forgets the route to a node, for example after it stops answering.

      Parameters

      • dst: number

        The node to forget.

      Returns void

    • Decides what to do with a packet bound for a node.

      Parameters

      • dst: number

        The node the packet is addressed to.

      Returns routing.ForwardDecision

      The decision, carrying a next hop only when it says to relay.

    • Returns the neighbour on the way to a node.

      Parameters

      • dst: number

        The node to reach.

      Returns number | null

      The next hop, or null when no route is known.

    • Learns a route from a packet that arrived.

      Parameters

      • origin: number

        The node the packet came from.

      • via: number

        The neighbour it arrived through.

      • cost: number

        What that path costs, usually a hop count.

      Returns boolean

      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.

    • Returns the whole route to a node.

      Parameters

      • dst: number

        The node to reach.

      Returns routing.Route | null

      The route, or null when no route is known.