Davide Pesavento | 5118959 | 2021-10-02 22:34:34 -0400 | [diff] [blame] | 1 | Examples |
| 2 | ======== |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 3 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 4 | The example programs in the ``examples/`` subdirectory are not built by default. |
| 5 | To enable them, use the ``--with-examples`` configure option: |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 6 | |
| 7 | .. code-block:: bash |
| 8 | |
| 9 | ./waf configure --with-examples |
| 10 | ./waf |
| 11 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 12 | Once built, the example binaries can be found under ``build/examples/``: |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 13 | |
Davide Pesavento | 5118959 | 2021-10-02 22:34:34 -0400 | [diff] [blame] | 14 | * Full sync: ``psync-full-sync`` |
| 15 | * Partial sync: ``psync-producer`` and ``psync-consumer`` |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 16 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 17 | If the library is installed to the system using ``./waf install``, then the examples |
| 18 | will also be installed and can be executed directly. |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 19 | |
| 20 | Partial Sync Example |
| 21 | -------------------- |
| 22 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 23 | The partial sync example of PSync has two parts: producer and consumer. |
| 24 | These can be run on a machine after starting NFD. |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 25 | |
| 26 | Producer |
| 27 | ^^^^^^^^ |
| 28 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 29 | * Enable logging for the producer. |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 30 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 31 | .. code-block:: bash |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 32 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 33 | export NDN_LOG="examples.PartialSyncProducerApp=INFO" |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 34 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 35 | * Start the producer that will listen on ``/sync`` and publish one update for each |
| 36 | of ``/a-0`` ... ``/a-9``. |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 37 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 38 | .. code-block:: bash |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 39 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 40 | psync-producer /sync /a 10 1 |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 41 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 42 | * Sample output:: |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 43 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 44 | 1546280442.096296 INFO: [examples.PartialSyncProducerApp] Publish: /a-1/1 |
| 45 | 1546280456.053138 INFO: [examples.PartialSyncProducerApp] Publish: /a-6/1 |
| 46 | 1546280458.210415 INFO: [examples.PartialSyncProducerApp] Publish: /a-8/1 |
| 47 | 1546280469.954134 INFO: [examples.PartialSyncProducerApp] Publish: /a-5/1 |
| 48 | 1546280472.487425 INFO: [examples.PartialSyncProducerApp] Publish: /a-2/1 |
| 49 | 1546280473.466515 INFO: [examples.PartialSyncProducerApp] Publish: /a-7/1 |
| 50 | 1546280481.882258 INFO: [examples.PartialSyncProducerApp] Publish: /a-0/1 |
| 51 | 1546280484.201229 INFO: [examples.PartialSyncProducerApp] Publish: /a-4/1 |
| 52 | 1546280489.348968 INFO: [examples.PartialSyncProducerApp] Publish: /a-9/1 |
| 53 | 1546280491.420391 INFO: [examples.PartialSyncProducerApp] Publish: /a-3/1 |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 54 | |
| 55 | Consumer |
| 56 | ^^^^^^^^ |
| 57 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 58 | * In a new terminal, enable logging for the consumer. |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 59 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 60 | .. code-block:: bash |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 61 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 62 | export NDN_LOG="examples.PartialSyncConsumerApp=INFO" |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 63 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 64 | * Run the consumer to subscribe to 5 random prefixes from the publisher on ``/sync``. |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 65 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 66 | .. code-block:: bash |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 67 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 68 | psync-consumer /sync 5 |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 69 | |
| 70 | * Sample output from the consumer shows that it received updates only |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 71 | for the subscribed prefixes:: |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 72 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 73 | 1546280436.502769 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-7 |
| 74 | 1546280436.502888 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-9 |
| 75 | 1546280436.502911 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-8 |
| 76 | 1546280436.502934 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-4 |
| 77 | 1546280436.502956 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-5 |
| 78 | 1546280458.211188 INFO: [examples.PartialSyncConsumerApp] Update: /a-8/1 |
| 79 | 1546280469.954886 INFO: [examples.PartialSyncConsumerApp] Update: /a-5/1 |
| 80 | 1546280473.467116 INFO: [examples.PartialSyncConsumerApp] Update: /a-7/1 |
| 81 | 1546280484.256181 INFO: [examples.PartialSyncConsumerApp] Update: /a-4/1 |
| 82 | 1546280489.349793 INFO: [examples.PartialSyncConsumerApp] Update: /a-9/1 |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 83 | |
| 84 | Full Sync Example |
| 85 | ----------------- |
| 86 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 87 | To demonstrate the full sync mode of PSync, ``psync-full-sync`` can be run on a |
| 88 | machine after starting NFD. |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 89 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 90 | * Enable logging for the full sync demo app. |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 91 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 92 | .. code-block:: bash |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 93 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 94 | export NDN_LOG="examples.FullSyncApp=INFO" |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 95 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 96 | * Run the full sync example with sync prefix ``/sync``, user prefix ``/a``, |
| 97 | and publish three updates for each user prefix: ``/a-0`` and ``/a-1``. |
| 98 | This will simulate node *a*. |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 99 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 100 | .. code-block:: bash |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 101 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 102 | psync-full-sync /sync /a 2 3 |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 103 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 104 | * Repeat for another user prefix, to simulate node *b*. |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 105 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 106 | .. code-block:: bash |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 107 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 108 | psync-full-sync /sync /b 2 3 |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 109 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 110 | We should see that node *a* and node *b* have received each other's updates. |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 111 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 112 | * Sample output from node *a* shows that it received all updates from node *b* |
| 113 | successfully:: |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 114 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 115 | 1546282730.759387 INFO: [examples.FullSyncApp] Update /b-1/1 |
| 116 | 1546282741.143225 INFO: [examples.FullSyncApp] Publish: /a-1/1 |
| 117 | 1546282749.375854 INFO: [examples.FullSyncApp] Publish: /a-0/1 |
| 118 | 1546282750.263246 INFO: [examples.FullSyncApp] Update /b-0/1 |
| 119 | 1546282765.875118 INFO: [examples.FullSyncApp] Update /b-1/2 |
| 120 | 1546282783.777807 INFO: [examples.FullSyncApp] Publish: /a-0/2 |
| 121 | 1546282794.565507 INFO: [examples.FullSyncApp] Publish: /a-0/3 |
| 122 | 1546282794.896895 INFO: [examples.FullSyncApp] Publish: /a-1/2 |
| 123 | 1546282803.839416 INFO: [examples.FullSyncApp] Update /b-0/2 |
| 124 | 1546282804.785867 INFO: [examples.FullSyncApp] Update /b-1/3 |
| 125 | 1546282845.273772 INFO: [examples.FullSyncApp] Publish: /a-1/3 |
| 126 | 1546282855.102790 INFO: [examples.FullSyncApp] Update /b-0/3 |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 127 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 128 | * Sample output from node *b*:: |
Ashlesh Gawande | 465d149 | 2019-01-10 15:12:01 -0600 | [diff] [blame] | 129 | |
Davide Pesavento | 36651f1 | 2023-01-02 17:07:21 -0500 | [diff] [blame] | 130 | 1546282730.758296 INFO: [examples.FullSyncApp] Publish: /b-1/1 |
| 131 | 1546282741.144027 INFO: [examples.FullSyncApp] Update /a-1/1 |
| 132 | 1546282749.376543 INFO: [examples.FullSyncApp] Update /a-0/1 |
| 133 | 1546282750.262244 INFO: [examples.FullSyncApp] Publish: /b-0/1 |
| 134 | 1546282765.296005 INFO: [examples.FullSyncApp] Publish: /b-1/2 |
| 135 | 1546282783.778769 INFO: [examples.FullSyncApp] Update /a-0/2 |
| 136 | 1546282794.566485 INFO: [examples.FullSyncApp] Update /a-0/3 |
| 137 | 1546282795.374339 INFO: [examples.FullSyncApp] Update /a-1/2 |
| 138 | 1546282803.838394 INFO: [examples.FullSyncApp] Publish: /b-0/2 |
| 139 | 1546282804.033214 INFO: [examples.FullSyncApp] Publish: /b-1/3 |
| 140 | 1546282845.274680 INFO: [examples.FullSyncApp] Update /a-1/3 |
| 141 | 1546282855.101780 INFO: [examples.FullSyncApp] Publish: /b-0/3 |