blob: 64f34a7c316b270db4c95bf945f8f656b1528dd8 [file] [log] [blame] [view]
Davide Pesaventob60398c2020-12-18 00:02:25 -05001# PSync examples
Ashlesh Gawande4c0a7472018-08-08 12:20:33 -05002
Davide Pesaventob60398c2020-12-18 00:02:25 -05003By default, the examples in this folder are not built. To enable them, use the
Ashlesh Gawande4c0a7472018-08-08 12:20:33 -05004`--with-examples` configure option. For example:
5
Davide Pesaventob60398c2020-12-18 00:02:25 -05006```bash
7./waf configure --with-examples
8./waf
9```
Ashlesh Gawande4c0a7472018-08-08 12:20:33 -050010
Davide Pesaventob60398c2020-12-18 00:02:25 -050011The example binaries can be found in `build/examples`:
Ashlesh Gawande4c0a7472018-08-08 12:20:33 -050012
Davide Pesaventob60398c2020-12-18 00:02:25 -050013- Full sync: `psync-full-sync`
14- Partial sync: `psync-producer` and `psync-consumer`
Ashlesh Gawande4c0a7472018-08-08 12:20:33 -050015
16If the library is installed to the system using `./waf install` then the examples
17are also installed and can be executed directly.
18
Davide Pesaventob60398c2020-12-18 00:02:25 -050019## Partial Sync example
Ashlesh Gawande4c0a7472018-08-08 12:20:33 -050020
21Partial sync example of PSync has two parts: producer and consumer.
Davide Pesaventob60398c2020-12-18 00:02:25 -050022These can be run on a machine after starting NFD.
Ashlesh Gawande4c0a7472018-08-08 12:20:33 -050023
24### Producer
25
26- Enable the logs for producer:
27
28```bash
29export NDN_LOG=examples.PartialSyncProducerApp=INFO
30```
31
Davide Pesaventob60398c2020-12-18 00:02:25 -050032- Start the producer that will listen on `/sync` and publish 1 update for
33`/a-0` ... `/a-9` each.
Ashlesh Gawande4c0a7472018-08-08 12:20:33 -050034
35```bash
36psync-producer /sync /a 10 1
37```
38
39- Sample output:
40
41```
421546280442.096296 INFO: [examples.PartialSyncProducerApp] Publish: /a-1/1
431546280456.053138 INFO: [examples.PartialSyncProducerApp] Publish: /a-6/1
441546280458.210415 INFO: [examples.PartialSyncProducerApp] Publish: /a-8/1
451546280469.954134 INFO: [examples.PartialSyncProducerApp] Publish: /a-5/1
461546280472.487425 INFO: [examples.PartialSyncProducerApp] Publish: /a-2/1
471546280473.466515 INFO: [examples.PartialSyncProducerApp] Publish: /a-7/1
481546280481.882258 INFO: [examples.PartialSyncProducerApp] Publish: /a-0/1
491546280484.201229 INFO: [examples.PartialSyncProducerApp] Publish: /a-4/1
501546280489.348968 INFO: [examples.PartialSyncProducerApp] Publish: /a-9/1
511546280491.420391 INFO: [examples.PartialSyncProducerApp] Publish: /a-3/1
52```
53
54### Consumer
55
56- In a new terminal, enable the logs for consumer:
57
58```bash
59export NDN_LOG=examples.PartialSyncConsumerApp=INFO
60```
61
Davide Pesaventob60398c2020-12-18 00:02:25 -050062- Run the consumer to subscribe to 5 random prefixes from the publisher on `/sync`
Ashlesh Gawande4c0a7472018-08-08 12:20:33 -050063
64```bash
65psync-consumer /sync 5
66```
67
68- Sample output from the consumer shows that it received updates only
69for the subscribed prefixes:
70
71```
721546280436.502769 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-7
731546280436.502888 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-9
741546280436.502911 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-8
751546280436.502934 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-4
761546280436.502956 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-5
771546280458.211188 INFO: [examples.PartialSyncConsumerApp] Update: /a-8/1
781546280469.954886 INFO: [examples.PartialSyncConsumerApp] Update: /a-5/1
791546280473.467116 INFO: [examples.PartialSyncConsumerApp] Update: /a-7/1
801546280484.256181 INFO: [examples.PartialSyncConsumerApp] Update: /a-4/1
811546280489.349793 INFO: [examples.PartialSyncConsumerApp] Update: /a-9/1
82```
83
Davide Pesaventob60398c2020-12-18 00:02:25 -050084## Full Sync example
Ashlesh Gawande4c0a7472018-08-08 12:20:33 -050085
Davide Pesaventob60398c2020-12-18 00:02:25 -050086To demonstrate full sync mode of PSync, `psync-full-sync`
Ashlesh Gawande4c0a7472018-08-08 12:20:33 -050087can be run on a machine after starting NFD:
88
89- Enable the logs for full sync:
90
91```bash
92export NDN_LOG=examples.FullSyncApp=INFO
93```
94
Davide Pesaventob60398c2020-12-18 00:02:25 -050095- Run the full sync example with sync prefix `/sync`, user prefix `/a`,
96and publish three updates for each user prefix: `/a-0` and `/a-1`. This will simulate node a.
Ashlesh Gawande4c0a7472018-08-08 12:20:33 -050097
98```bash
99psync-full-sync /sync /a 2 3
100```
101
102- Repeat for another user prefix, to simulate node b:
103
104```bash
105psync-full-sync /sync /b 2 3
106```
107
108We should see that node a and node b have received each other's updates.
109
110- Sample output from node a shows that it received all updates
111from node b successfully:
112
113```
1141546282730.759387 INFO: [examples.FullSyncApp] Update /b-1/1
1151546282741.143225 INFO: [examples.FullSyncApp] Publish: /a-1/1
1161546282749.375854 INFO: [examples.FullSyncApp] Publish: /a-0/1
1171546282750.263246 INFO: [examples.FullSyncApp] Update /b-0/1
1181546282765.875118 INFO: [examples.FullSyncApp] Update /b-1/2
1191546282783.777807 INFO: [examples.FullSyncApp] Publish: /a-0/2
1201546282794.565507 INFO: [examples.FullSyncApp] Publish: /a-0/3
1211546282794.896895 INFO: [examples.FullSyncApp] Publish: /a-1/2
1221546282803.839416 INFO: [examples.FullSyncApp] Update /b-0/2
1231546282804.785867 INFO: [examples.FullSyncApp] Update /b-1/3
1241546282845.273772 INFO: [examples.FullSyncApp] Publish: /a-1/3
1251546282855.102790 INFO: [examples.FullSyncApp] Update /b-0/3
126```
127
128- Sample output from node b:
129
130```
1311546282730.758296 INFO: [examples.FullSyncApp] Publish: /b-1/1
1321546282741.144027 INFO: [examples.FullSyncApp] Update /a-1/1
1331546282749.376543 INFO: [examples.FullSyncApp] Update /a-0/1
1341546282750.262244 INFO: [examples.FullSyncApp] Publish: /b-0/1
1351546282765.296005 INFO: [examples.FullSyncApp] Publish: /b-1/2
1361546282783.778769 INFO: [examples.FullSyncApp] Update /a-0/2
1371546282794.566485 INFO: [examples.FullSyncApp] Update /a-0/3
1381546282795.374339 INFO: [examples.FullSyncApp] Update /a-1/2
1391546282803.838394 INFO: [examples.FullSyncApp] Publish: /b-0/2
1401546282804.033214 INFO: [examples.FullSyncApp] Publish: /b-1/3
1411546282845.274680 INFO: [examples.FullSyncApp] Update /a-1/3
1421546282855.101780 INFO: [examples.FullSyncApp] Publish: /b-0/3
Davide Pesaventob60398c2020-12-18 00:02:25 -0500143```