Skip to content

Commit 3425643

Browse files
committed
fw: Readvertise documentation
1 parent b09aee6 commit 3425643

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

pkg/fw/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,52 @@ The main differences from a full forwarder include:
3838
* Forwarding hint is not stripped even if it matches a configured node name.
3939

4040
These are subject to change.
41+
42+
## Prefix Registration / Readvertisement
43+
44+
Unlike many other NDN libraries, NDNts does not hard-wire prefix registration toward a particular forwarder.
45+
Instead, the prefix registration functionality is structured more like a router:
46+
47+
* `FwFace` can *announce* a prefix into the NDNts logical forwarder.
48+
* The logical forwarder can then *readvertise* the prefix into a *destination* such as a remote forwarder.
49+
50+
NDNts includes several `ReadvertiseDestination` implementation compatible with other forwarders:
51+
52+
* `@ndn/nfdmgmt` implements the NFD Management protocol, compatible with NFD and NDNd.
53+
* `@ndn/dpdkmgmt` implements the NDN-DPDK GraphQL protocol, compatible with NDN-DPDK.
54+
55+
After loading either package and attaching to the logical forwarder, prefix registration commands would be transmitted toward the connected forwarder.
56+
In contrast, if no `ReadvertiseDestination` is attached to a logical forwarder, the producer prefixes from a `FwFace` are visible within the logical forwarder and no prefix registration commands would be sent.
57+
58+
A `FwFace` may prevent its prefixes from being readvertised by setting `advertiseFrom: false` attribute.
59+
If this attribute is set, the prefixes announced by this `FwFace` are only visible within the logical forwarder but ignored by `Readvertise` module.
60+
This attribute is normally set on a `FwFace` that represents an uplink to a remote forwarder, so that its prefixes (often the default route `/`) do not leak to another uplink that you may be connecting.
61+
In contrast, having `advertiseFrom: true` attribute (the default) does not magically enable prefix registration commands if you do not have a `ReadvertiseDestination` attached.
62+
63+
### Readvertise Module Architecture
64+
65+
The readvertise module consists of:
66+
67+
* One `Readvertise` class instance integrated with the logical forwarder.
68+
* One or more `ReadvertiseDestination` subclass instances attached to the `Readvertise` instance.
69+
70+
The `Readvertise` class is responsible for:
71+
72+
* When a prefix is announced by the first `FwFace`, send an advertise (register) command to each destination.
73+
* When a prefix is unannounced by the last `FwFace`, send a withdraw (unregister) command to each destination.
74+
* If the same prefix is announced by multiple `FwFace`s or by the same `FwFace` more than once, it is deduplicated automatically and would not cause duplicate advertise commands or premature withdraw commands.
75+
76+
The `ReadvertiseDestination` base class is responsible for:
77+
78+
* Maintain a queue of pending advertise and withdraw commands to be processed by the subclass.
79+
* Maintain a state of each prefix, with one of four statuses: ADVERTISING, ADVERTISED, WITHDRAWING, WITHDRAWN.
80+
* If an advertise or withdraw command fails, automatically retry the command.
81+
* If the prefix is withdrawn while an advertise command is being executed, immediately send a withdraw command afterward, to ensure state consistency.
82+
83+
Each `ReadvertiseDestination` subclass is responsible for:
84+
85+
* Implement the prefix registration protocol understood by the connected forwarder.
86+
* Actually transmit the advertise and withdraw commands, and inform the base class of the success/failure outcome.
87+
* If the commands require NDN signatures, manage the signing and certificate publishing.
88+
* Refresh the advertised prefixes (i.e. schedule resending advertise commands) in case of connectivity change.
89+
* For example, if `TcpTransport` reconnects to NFD, it would be seen by NFD as a new face, so that every prefix must be registered again to maintain connectivity.

pkg/fw/src/face.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ export namespace FwFace {
101101
* - `true`: same as route name.
102102
* - number: n-component prefix of route name.
103103
* - {@link Name} or string: specified name.
104+
* - {@link PrefixAnnouncementObj}: enclosed name, using the pre-encoded Prefix Announcement
105+
* object if it's supported by the readvertise destination.
104106
*/
105107
export type RouteAnnouncement = boolean | number | PrefixAnnouncement;
106108

pkg/fw/src/readvertise.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class Readvertise {
4141
*
4242
* Outer key is the FwFace.
4343
* Inner key is the announced name in hex.
44-
* Inner key is the announced name.
44+
* Inner value is the announced name.
4545
*
4646
* This is for deleting all announcements from a FwFace.
4747
*/

0 commit comments

Comments
 (0)