-
Notifications
You must be signed in to change notification settings - Fork 71
/
switchfun.txt
294 lines (270 loc) · 8.87 KB
/
switchfun.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
## Walking all peers manually on a node using the common 3x5x8 switch scheme.
## We're exclusively using the 8 form because it's easier to stick to one form
## The node is 0015 to us, therefor all paths end in 5.
## The first entry in the 8 form is 0400
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/splice.js 0000.0000.0000.0400 0000.0000.0000.0015
0000.0000.0000.4005
## After splicing that with the path to our peer, we clearly see that everything
## will have a 5 added to the end.
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4005", 3000, 1)'
{
"data": "",
"key": "xp2f7m98uw24664ngwl47k8uyx59sblgp8qsbpk24sh10ppu9fz0.k",
"ms": "382",
"path": "0000.0000.0000.4005",
"result": "pong",
"txid": "824920922",
"version": "8"
}
## 0400 is analogus to 0013 (the first peer)
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.0135", 3000, 1)'
{
"data": "",
"key": "xp2f7m98uw24664ngwl47k8uyx59sblgp8qsbpk24sh10ppu9fz0.k",
"ms": "407",
"path": "0000.0000.0000.0135",
"result": "pong",
"txid": "1322201729",
"version": "8"
}
## Since the lowest 2 bits are reserved for specifying the encoding form (they're both 0)
## numbers count 400, 404, 408, 40c, 410, 414, 418, 41c, 420 ...
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4045", 3000, 1)'
{
"data": "",
"key": "2v6dt6f841hzhq2wsqwt263w2dswkt6fz82vcyxqptk88mtp8y50.k",
"ms": "897",
"path": "0000.0000.0000.4045",
"result": "pong",
"txid": "3621711461",
"version": "8"
}
## This is us, wow, we have slot 3, what luck!
## the shortest version of this route is 0017
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4085", 3000, 1)'
{
"data": "",
"key": "b8xn6kv9279k7mjdmg08ut6yc4n3d2lp3s3juq39qz83z9bzxgz0.k",
"ms": "638",
"path": "0000.0000.0000.4085",
"result": "pong",
"txid": "1345867629",
"version": "8"
}
## Oops! If you use a number which is not in the sequence you get a
## switch error (or perhaps it will be interpreted and end up at another node)
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.40d5", 3000, 1)'
{
"data": "",
"ms": "539",
"path": "0000.0000.0000.40d5",
"result": "err_switch",
"txid": "3599763113",
"version": "0"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.40c5", 3000, 1)'
{
"data": "",
"key": "lpcvt3u85q837u402dlu3rfg107x92j5xlzd77tftsjy88zx0yf0.k",
"ms": "408",
"path": "0000.0000.0000.40c5",
"result": "pong",
"txid": "259944377",
"version": "7"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4105", 3000, 1)'
{
"data": "",
"key": "wb0hdx8vu6khpfj32qzhvykjk7gq8bc691czhx3yp7zn04bh5gy0.k",
"ms": "363",
"path": "0000.0000.0000.4105",
"result": "pong",
"txid": "1099356221",
"version": "8"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4145", 3000, 1)'
{
"data": "",
"key": "6q09l149vz0bqtx51jy557juj39wxmupmfd52h9w5xsdnsns1qj0.k",
"ms": "223",
"path": "0000.0000.0000.4145",
"result": "pong",
"txid": "542004376",
"version": "7"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4185", 3000, 1)'
{
"data": "",
"key": "1cgrz7hmc4wzg7pu284u5b77y2mdzt261tr0rj0qf7j2vsqf5150.k",
"ms": "312",
"path": "0000.0000.0000.4185",
"result": "pong",
"txid": "87763052",
"version": "7"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.41c5", 3000, 1)'
{
"data": "",
"key": "w7xvbpmgwuwkv8x9wrpfmydtfxv6ydfmpktgc6tt8v8d3c9bn580.k",
"ms": "394",
"path": "0000.0000.0000.41c5",
"result": "pong",
"txid": "1682459805",
"version": "8"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4205", 3000, 1)'
{
"data": "",
"key": "11sfkq2clbv4dgzgx8hm47p4ld9pwy82y7jluvjh91cyl1n7bwf0.k",
"ms": "329",
"path": "0000.0000.0000.4205",
"result": "pong",
"txid": "3712296271",
"version": "7"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4245", 3000, 1)'
{
"data": "",
"key": "c94sls20x5shql6r4z4nvqlrs9pcppgj2h41m1bntzk60j5wrs40.k",
"ms": "362",
"path": "0000.0000.0000.4245",
"result": "pong",
"txid": "1883792007",
"version": "7"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4285", 3000, 1)'
{
"data": "",
"key": "08pdl5mbcpx2b0uh6wj6wktq5v47kv9gpy40rnqr52t1ugctr430.k",
"ms": "252",
"path": "0000.0000.0000.4285",
"result": "pong",
"txid": "711411764",
"version": "7"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.42c5", 3000, 1)'
{
"data": "",
"key": "r5tmqf72mjzht1grqm34l1ldrx9tdubyzw33ucng6bfqp1y0mux0.k",
"ms": "452",
"path": "0000.0000.0000.42c5",
"result": "pong",
"txid": "2970256056",
"version": "7"
}
## This seems to be a node which is supposed to be connected but is not responding.
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4305", 3000, 1)'
{
"ms": "3003",
"path": "0000.0000.0000.4305",
"result": "timeout",
"txid": "1014318430",
"version": "7"
}
## Try again for good measure
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4305", 3000, 1)'
{
"ms": "3002",
"path": "0000.0000.0000.4305",
"result": "timeout",
"txid": "2282909610",
"version": "7"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.42c5", 3000, 1)'
{
"data": "",
"key": "r5tmqf72mjzht1grqm34l1ldrx9tdubyzw33ucng6bfqp1y0mux0.k",
"ms": "181",
"path": "0000.0000.0000.42c5",
"result": "pong",
"txid": "2432582962",
"version": "7"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4345", 3000, 1)'
{
"data": "",
"key": "fj9q4s6fg8mjdjfks8lc8bp7ly05qm11z54crlb7tz1pl01fg3r0.k",
"ms": "329",
"path": "0000.0000.0000.4345",
"result": "pong",
"txid": "1698617630",
"version": "7"
}
## We have either reached the top of the list or there is an empty slot left by a node which
## disconnected, we can't know for sure so lets ping a few more nodes in order to check.
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4385", 3000, 1)'
{
"data": "",
"ms": "158",
"path": "0000.0000.0000.4385",
"result": "err_switch",
"txid": "880013604",
"version": "0"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.43c5", 3000, 1)'
{
"data": "",
"ms": "444",
"path": "0000.0000.0000.43c5",
"result": "err_switch",
"txid": "1175469204",
"version": "0"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4405", 3000, 1)'
{
"data": "",
"ms": "347",
"path": "0000.0000.0000.4405",
"result": "err_switch",
"txid": "3258844093",
"version": "0"
}
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.4445", 3000, 1)'
{
"data": "",
"ms": "321",
"path": "0000.0000.0000.4445",
"result": "err_switch",
"txid": "869243597",
"version": "0"
}
user@toshitba:~/wrk/cjdns$
## Recall from above that we're 0408 aka 0017 (because we can be represented using the small encoding)
## ping selves
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.0175", 3000, 1)'{
"data": "",
"key": "b8xn6kv9279k7mjdmg08ut6yc4n3d2lp3s3juq39qz83z9bzxgz0.k",
"ms": "619",
"path": "0000.0000.0000.0175",
"result": "pong",
"txid": "1099734707",
"version": "8"
}
## just to verify that it's working, we'll create a loop packet
## us->them->us->them and it works.
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0000.0000.1575", 3000, 1)'
{
"data": "",
"key": "nx6k81p1nxw1b5ry8ub5u63hu0tlskp1t2fytcbrbf1709xh11g0.k",
"ms": "1251",
"path": "0000.0000.0000.1575",
"result": "pong",
"txid": "3109463617",
"version": "8"
}
## We can make it loop more but the latency gets very big!
user@toshitba:~/wrk/cjdns$ ./contrib/nodejs/tools/cexec.js 'SwitchPinger_ping("0000.0001.7575.7575", 3000, 1)'
{
"data": "",
"key": "b8xn6kv9279k7mjdmg08ut6yc4n3d2lp3s3juq39qz83z9bzxgz0.k",
"ms": "1900",
"path": "0000.0001.7575.7575",
"result": "pong",
"txid": "2807636566",
"version": "8"
}
## This only works because we and our peer are both using 3x5x8 encoding, if they were using
## something different, it would still be possible but more complex to craft paths.
## nodes describe their encoding schemes to one another so even the most complex encoding
## schemes are supported by cjdns which has to craft paths through the network much like
## we did here.