blob: bdce503e4a299f9c81f05e4ae16915663540252a [file] [log] [blame] [view]
Ashlesh Gawande4c0a7472018-08-08 12:20:33 -05001PSync examples
2==============
3
4By default, examples in `examples/` folder are not built. To enable them, use
5`--with-examples` configure option. For example:
6
7 ./waf configure --with-examples
8 ./waf
9
10Example binary can be found under `build/examples`:
11
12- Full sync : `psync-full-sync`
13- Partial sync : `psync-producer` and `psync-consumer`
14
15If the library is installed to the system using `./waf install` then the examples
16are also installed and can be executed directly.
17
18## Partial Sync Example
19
20Partial sync example of PSync has two parts: producer and consumer.
21These can be run on a machine after starting NFD:
22
23### Producer
24
25- Enable the logs for producer:
26
27```bash
28export NDN_LOG=examples.PartialSyncProducerApp=INFO
29```
30
31- Start the producer that will listen on /sync and publish 1 update for /a-0 ... /a-9 each.
32
33```bash
34psync-producer /sync /a 10 1
35```
36
37- Sample output:
38
39```
401546280442.096296 INFO: [examples.PartialSyncProducerApp] Publish: /a-1/1
411546280456.053138 INFO: [examples.PartialSyncProducerApp] Publish: /a-6/1
421546280458.210415 INFO: [examples.PartialSyncProducerApp] Publish: /a-8/1
431546280469.954134 INFO: [examples.PartialSyncProducerApp] Publish: /a-5/1
441546280472.487425 INFO: [examples.PartialSyncProducerApp] Publish: /a-2/1
451546280473.466515 INFO: [examples.PartialSyncProducerApp] Publish: /a-7/1
461546280481.882258 INFO: [examples.PartialSyncProducerApp] Publish: /a-0/1
471546280484.201229 INFO: [examples.PartialSyncProducerApp] Publish: /a-4/1
481546280489.348968 INFO: [examples.PartialSyncProducerApp] Publish: /a-9/1
491546280491.420391 INFO: [examples.PartialSyncProducerApp] Publish: /a-3/1
50```
51
52### Consumer
53
54- In a new terminal, enable the logs for consumer:
55
56```bash
57export NDN_LOG=examples.PartialSyncConsumerApp=INFO
58```
59
60- Run the consumer to subscribe to 5 random prefixes from the publisher on /sync
61
62```bash
63psync-consumer /sync 5
64```
65
66- Sample output from the consumer shows that it received updates only
67for the subscribed prefixes:
68
69```
701546280436.502769 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-7
711546280436.502888 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-9
721546280436.502911 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-8
731546280436.502934 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-4
741546280436.502956 INFO: [examples.PartialSyncConsumerApp] Subscribing to: /a-5
751546280458.211188 INFO: [examples.PartialSyncConsumerApp] Update: /a-8/1
761546280469.954886 INFO: [examples.PartialSyncConsumerApp] Update: /a-5/1
771546280473.467116 INFO: [examples.PartialSyncConsumerApp] Update: /a-7/1
781546280484.256181 INFO: [examples.PartialSyncConsumerApp] Update: /a-4/1
791546280489.349793 INFO: [examples.PartialSyncConsumerApp] Update: /a-9/1
80```
81
82## Full Sync Example
83
84To demonstrate full sync mode of PSync, ``psync-full-sync``
85can be run on a machine after starting NFD:
86
87- Enable the logs for full sync:
88
89```bash
90export NDN_LOG=examples.FullSyncApp=INFO
91```
92
93- Run the full sync example with sync prefix /sync, user prefix /a,
94and publish three updates for each user prefix: /a-0 and /a-1. This will simulate node a.
95
96```bash
97psync-full-sync /sync /a 2 3
98```
99
100- Repeat for another user prefix, to simulate node b:
101
102```bash
103psync-full-sync /sync /b 2 3
104```
105
106We should see that node a and node b have received each other's updates.
107
108- Sample output from node a shows that it received all updates
109from node b successfully:
110
111```
1121546282730.759387 INFO: [examples.FullSyncApp] Update /b-1/1
1131546282741.143225 INFO: [examples.FullSyncApp] Publish: /a-1/1
1141546282749.375854 INFO: [examples.FullSyncApp] Publish: /a-0/1
1151546282750.263246 INFO: [examples.FullSyncApp] Update /b-0/1
1161546282765.875118 INFO: [examples.FullSyncApp] Update /b-1/2
1171546282783.777807 INFO: [examples.FullSyncApp] Publish: /a-0/2
1181546282794.565507 INFO: [examples.FullSyncApp] Publish: /a-0/3
1191546282794.896895 INFO: [examples.FullSyncApp] Publish: /a-1/2
1201546282803.839416 INFO: [examples.FullSyncApp] Update /b-0/2
1211546282804.785867 INFO: [examples.FullSyncApp] Update /b-1/3
1221546282845.273772 INFO: [examples.FullSyncApp] Publish: /a-1/3
1231546282855.102790 INFO: [examples.FullSyncApp] Update /b-0/3
124```
125
126- Sample output from node b:
127
128```
1291546282730.758296 INFO: [examples.FullSyncApp] Publish: /b-1/1
1301546282741.144027 INFO: [examples.FullSyncApp] Update /a-1/1
1311546282749.376543 INFO: [examples.FullSyncApp] Update /a-0/1
1321546282750.262244 INFO: [examples.FullSyncApp] Publish: /b-0/1
1331546282765.296005 INFO: [examples.FullSyncApp] Publish: /b-1/2
1341546282783.778769 INFO: [examples.FullSyncApp] Update /a-0/2
1351546282794.566485 INFO: [examples.FullSyncApp] Update /a-0/3
1361546282795.374339 INFO: [examples.FullSyncApp] Update /a-1/2
1371546282803.838394 INFO: [examples.FullSyncApp] Publish: /b-0/2
1381546282804.033214 INFO: [examples.FullSyncApp] Publish: /b-1/3
1391546282845.274680 INFO: [examples.FullSyncApp] Update /a-1/3
1401546282855.101780 INFO: [examples.FullSyncApp] Publish: /b-0/3
141```