]> Cypherpunks.ru repositories - nncp.git/blob - doc/usecases.texi
f5b30e377f0b7112c441b22c2d99004b70837b29
[nncp.git] / doc / usecases.texi
1 @node Use cases
2 @unnumbered Use cases
3
4 See also this page @ref{Сценарии, on russian}.
5
6 @menu
7 * Occasional connection to mail server: UsecaseMail
8 * Lightweight fast POP3/IMAP4 replacement: UsecasePOP
9 * Unreliable/expensive communication link: UsecaseUnreliable
10 * Slow/expensive link for high-volume data, bad QoS: UsecaseQoS
11 * Extreme terrestrial environments, no link: UsecaseNoLink
12 * One-way broadcasting communications: UsecaseBroadcast
13 * Satellite links: UsecaseSatelliteLinks
14 * Private, isolated MitM/Sybil-resistant networks: UsecaseF2F
15 * Highly secure isolated air-gap computers: UsecaseAirgap
16 * Network censorship bypassing, health: UsecaseCensor
17 * Reconnaissance, spying, intelligence, covert agents: UsecaseSpy
18 * Cheap night transfers: UsecaseCaller
19 * Multicast flooding transmission: UsecaseMulticast
20 @end menu
21
22 @node UsecaseMail
23 @section Occasional connection to mail server
24
25 Assume that you have got your own @url{http://www.postfix.org/,
26 Postfix}/@url{http://www.exim.org/, Exim} SMTP server connected to the
27 Internet. But you read and write emails on your notebook, that is
28 connected to it just from time to time. How can you flush buffered mail
29 queues when your notebook is connected?
30
31 One possibility is to log in and run something like @command{postqueue
32 -f}, but by default you have got only several days so and sender will
33 receive notification emails that his messages still are not delivered
34 yet. Also you must have secure link (SSH, VPN, etc).
35
36 Another possibility is to use POP3/IMAP4 servers, but this is too
37 overcomplicated and bloated for the simple task. Not an option.
38 @url{https://en.wikipedia.org/wiki/KISS_principle, KISS}!
39
40 Just tell both of your Postfix/Exim (on the server and notebook) to drop
41 email as a mail via NNCP (@ref{nncp-exec}) to specified node.
42
43 More information for Postfix is @ref{Postfix, here} and for Exim is
44 @ref{Exim, here}. All mail will be stored in NNCP @ref{Spool, spool},
45 that after exchanging and tossing will call local @command{sendmail}
46 command to deliver them just like that happened on the same machine.
47
48 @node UsecasePOP
49 @section Lightweight fast POP3/IMAP4 replacement
50
51 @ref{nncp-daemon} can be connected with @ref{nncp-caller} for a long
52 time -- it can create TCP connection that lasts for many hours. When
53 SMTP server receives mail, it will call @ref{nncp-exec} creating an
54 outbound encrypted packet. Daemon checks outbound directory each second
55 and immediately sends notification about undelivered packets to remote
56 side, that also downloads it at once.
57
58 There are only dozens of bytes notifying about incoming packets, dozens
59 of bytes telling to download those packets. Mail packets are compressed
60 (POP3 and IMAP4 as a rule do not). You have lightweight, compressed,
61 low-delay, reliable link for the mail with strong encryption and mutual
62 sides authentication!
63
64 @node UsecaseUnreliable
65 @section Unreliable/expensive communication link
66
67 Assume that you have got slow modem/radio/cellular link that frequently
68 disconnects and causes TCP timeouts. Not all HTTP servers support file
69 download continuation. SMTP does not support resuming at all and heavy
70 messages is problematic to retrieve. Moreover, each disconnect leads to
71 the same data retransmission again, that can not be afforded sometimes.
72
73 Just send your @ref{nncp-exec, mail} and @ref{nncp-file, files} through
74 NNCP. You can use either offline delivery methods -- read about them in
75 the next section, or you can use included NNCP @ref{nncp-daemon, TCP
76 daemon}.
77
78 The command:
79
80 @example
81 $ nncp-file file_i_want_to_send bob:
82 $ nncp-file another_file bob:movie.avi
83 @end example
84
85 will queue two files for sending to @emph{bob} node. Fire and forget!
86 Now this is daemon's job (or offline transfer) to send this files part
87 by part to remote system when it is available.
88
89 @node UsecaseQoS
90 @section Slow/expensive link for high-volume data, bad QoS
91
92 Assume that you can give your relatively cheap 2 TiB removable hard
93 drive to someone each day at the morning (and take it back at the
94 evening). This equals to 185 Mbps good quality (without any speed
95 degradation) link in single direction. What about more and bigger hard
96 drives? This type of data exchange is called
97 @url{https://en.wikipedia.org/wiki/Sneakernet, sneakernet}/floppynet.
98
99 NNCP allows traffic @ref{Niceness, prioritizing}: each packet has
100 niceness level, that will guarantee that it will be processed earlier or
101 later than the other ones. Nearly all commands has corresponding option:
102
103 @example
104 $ nncp-file -nice FLASH myfile node:dst
105 $ nncp-xfer -nice PRIORITY /mnt/shared
106 $ nncp-call -nice NORMAL bob
107 [...]
108 @end example
109
110 Huge files could be split on smaller @ref{Chunked, chunks}, giving
111 possibility to transfer virtually any volumes using small capacity
112 storages.
113
114 You can also use CD-ROM and tape drives:
115
116 @example
117 $ nncp-bundle -tx bob | cdrecord -tao -
118 $ nncp-bundle -tx bob | dd of=/dev/sa0 bs=10240
119 @end example
120
121 @node UsecaseNoLink
122 @section Extreme terrestrial environments, no link
123
124 This is some kind of too slow link. Offline delivery methods is the only
125 choice. Just send files as shown in previous section, but use removable
126 media for transferring packets to other nodes.
127
128 Assume that you send two files to @emph{bob} node. Insert USB storage
129 device (SD is preferable!), mount it and run @ref{nncp-xfer}:
130
131 @example
132 $ nncp-xfer -node bob /media/usbstick
133 @end example
134
135 to copy all outbound packets related to @emph{bob}. Use @option{-mkdir}
136 option to create related directory on USB/SD storage if they are missing
137 (for example when running for the first time).
138
139 If you use single storage device to transfer data both to @emph{bob} and
140 @emph{alice}, then just omit @option{-node} option to copy all available
141 outgoing packets.
142
143 @example
144 $ nncp-xfer /media/usbstick
145 @end example
146
147 Unmount it and transfer storage to Bob and Alice. When they will insert
148 it in their computers, they will use exactly the same command:
149
150 @example
151 $ nncp-xfer /media/usbstick
152 @end example
153
154 to find all packets related to their node and copy them locally for
155 further processing. @command{nncp-xfer} is the only command used with
156 removable devices.
157
158 @node UsecaseBroadcast
159 @section One-way broadcasting communications
160
161 Sometimes you have got high-bandwidth but unidirectional link, for
162 example, satellite's broadcasting signal. You are not able to use online
163 @ref{Sync, synchronization protocol} because it requires mutual interaction.
164
165 You can use @ref{Bundles, bundles} and stream them above. They are just
166 a sequence of @ref{Encrypted, encrypted packets} you can catch on.
167
168 @example
169 $ nncp-bundle -tx alice bob eve ... | command to send broadcast
170 $ command to receive broadcast | nncp-bundle -rx
171 @end example
172
173 With built-in packet duplicates detection ability, you can retransmit
174 your broadcasts from time to time, to increase chances the recipient
175 will catch them by regular stream listening.
176
177 @node UsecaseSatelliteLinks
178 @section Satellite links
179
180 Satellite links have @strong{very} high delays together with high
181 bandwidths. You can send several megabits of data per second, but they
182 will reach the remote side only after half a second!
183 Most file sharing protocols like
184 @url{https://en.wikipedia.org/wiki/Files_transferred_over_shell_protocol, FISH},
185 @url{https://en.wikipedia.org/wiki/FTP, FTP},
186 @url{https://en.wikipedia.org/wiki/Secure_copy, scp},
187 @url{https://en.wikipedia.org/wiki/XMODEM, XMODEM}
188 will perform very badly because of round-trips quantity. Each file
189 transmission explicitly generates request and acknowledgement packets
190 that are send over the link. Remote side won't do anything until it
191 receives them. Moreover not all protocols allow duplex data
192 transmission (when both sides are sending data simultaneously).
193
194 NNCP's @ref{Sync, synchronization protocol} (SP) tries to mitigate all
195 that issues by reducing number of round-trips, number of packets passing
196 through. All file lists, file download requests are grouped together
197 (pipelined) in one huge packet. Only transmission halt and successful
198 file download acknowledgements are sent explicitly. SP could be asked
199 only either to upload or download packets for our node. SP could ignore
200 files with low priority. Full files listing is passing even during the
201 handshake procedure.
202
203 @node UsecaseF2F
204 @section Private, isolated MitM/Sybil-resistant networks
205
206 All Internet connections can be eavesdropped and forged. You
207 @strong{have to} to use encryption and authentication for securing them.
208 But it is very hard to secure metadata, that leaks during each online
209 session. When you start your shiny new software server be sure that
210 there could be huge quantity of bogus peers trying to perform
211 @url{https://en.wikipedia.org/wiki/Sybil_attack, Sybil attack}. Opennet
212 peer-to-peer networking is dangerous thing to do.
213
214 The most popular cryptographic protocol in Internet is
215 @url{https://en.wikipedia.org/wiki/Transport_Layer_Security, TLS} that
216 is very hard to implement correctly and hard to configure for mutual
217 participants authentication. Not all TLS configurations and related
218 protocols provide @url{https://en.wikipedia.org/wiki/Forward_secrecy,
219 forward secrecy} property -- all previously intercepted packets could be
220 read if private keys are compromised.
221
222 Friend-to-friend networks, darknets can mitigate risks related to fake
223 and forged nodes. However they are harder to support and require more
224 time to be done right.
225
226 NNCP's @ref{nncp-daemon, TCP daemon} uses
227 @url{http://noiseprotocol.org/, Noise-IK} protocol to mutually
228 authenticate peers and provide effective (both participants send payload
229 in the very first packet) secure transport with forward secrecy
230 property.
231
232 @example
233 $ nncp-daemon -bind "[::]":5400
234 @end example
235
236 will start TCP daemon listening on all interfaces for incoming
237 connections.
238
239 @example
240 $ nncp-call bob
241 @end example
242
243 will try to connect to @emph{bob}'s node known TCP addresses (taken from
244 configuration file) and send all related outbound packets and retrieve
245 those the Bob has. All interrupted transfers will be automatically
246 resumed.
247
248 Ability to do @ref{MCD, multicast nodes discovery} of participant in
249 IPv6 networks allows complete ignorance of network addresses specifying.
250
251 @node UsecaseAirgap
252 @section Highly secure isolated air-gap computers
253
254 If you worry much about security, then air-gapped computer could be the
255 only choice you can afford. Computer without any modems, wired and
256 wireless networks. Obviously the only possibility to exchange mail and
257 files is to use physically removable storage devices like CD-ROM, hard
258 drive, SD, tape and USB flash drives (@strong{worst} choice, due to
259 those devices complexity).
260
261 Presumably you have got another own hop before that computer: another
262 intermediate node which performs basic verification of retrieved storage
263 devices, possibly by rewriting the data from USB/hard drives to CD-RWs.
264
265 NNCP supports packets relying (transitioning) out-of-box.
266
267 @verbatim
268 neigh: {
269   bob: {
270     [...]
271     addrs: {
272       lan: "[fe80::5400%igb0]:5400"
273     }
274   }
275   bob-airgap:
276     [...]
277     via: ["bob"]
278   }
279 }
280 @end verbatim
281
282 That @ref{Configuration, configuration file} tells that we have got two
283 known neighbours: @emph{bob} and @emph{bob-airgap}. @emph{bob} can be
284 reached via online connection using @emph{lan} address.
285 @emph{bob-airgap} can be reached by sending intermediate relay packet
286 through the @emph{bob}.
287
288 Any command like @command{nncp-file myfile bob-airgap:} will
289 automatically create an encapsulated packet: one for the destination
290 endpoint, and other carrying it for intermediate relaying node.
291
292 Pay attention that relaying node knows nothing about the packet inside,
293 but just its size and priority. Transition packets are encrypted too:
294 using well-known @url{https://en.wikipedia.org/wiki/Onion_routing, onion
295 routing} technology. @emph{bob} can not read @emph{bob-airgap}'s packets.
296
297 @node UsecaseCensor
298 @section Network censorship bypassing, health
299
300 This is some kind of bad link too. Some governments tend to forbid
301 @strong{any} kind of private communication between people, allowing only
302 entertainment content delivering and popular social networks access
303 (that are already bloated with advertisements, locally executed
304 @url{https://www.gnu.org/philosophy/free-sw.html, proprietary}
305 JavaScript code (for spying on user activities, collect data on them),
306 shamelessly exploiting the very basic human need of communication).
307
308 This is their natural wish. But nobody forces you to obey huge
309 corporations like Apple, Google or Microsoft. It is your choice to
310 create an isolated friend-to-friend network with piles of harmless
311 content and private messaging. Only predators silently watch for their
312 victims in mammals world -- it harms your health being watched and
313 feeling that you are the victim that has already done something wrong.
314
315 @node UsecaseSpy
316 @section Reconnaissance, spying, intelligence, covert agents
317
318 Those guys know how Internet is a dangerous place incompatible with
319 privacy. They require quick, fast dropping and picking of data. No
320 possibility of many round-trips -- just drop the data, fire-and-forget.
321 It could be either removable media again and/or
322 @url{https://en.wikipedia.org/wiki/USB_dead_drop, USB dead drops},
323 @url{https://en.wikipedia.org/wiki/PirateBox, PirateBox}es,
324 @url{https://en.wikipedia.org/wiki/Short-range_agent_communications, SRAC}.
325 Short lived short range networks like Bluetooth and WiFi can also
326 be pretty fast, allowing to quickly fire chunks of queued packets.
327
328 Very important property is that compromising of those dead drops and
329 storages must be neither fatal nor even dangerous. Packets sent through
330 the network and exchanged via those devices are end-to-end
331 @ref{Encrypted, encrypted} (but unfortunately lacking forward secrecy).
332 No filenames, mail recipients are seen.
333
334 All node communications are done with so-called @ref{Spool, spool} area:
335 directory containing only those unprocessed encrypted packets. After
336 packet transfer you still can not read any of them: you have to run
337 another stage: @ref{nncp-toss, tossing}, that involves your private
338 cryptographic keys. So even if your loose your computer, storage devices
339 and so on -- it is not so bad, because you are not carrying private keys
340 with it (don't you?), you do not "toss" those packets immediately on the
341 same device. Tossing (reading those encrypted packets and extracting
342 transferred files and mail messages) could and should be done on a
343 separate computer (@ref{nncp-cfgmin} command could help creating
344 configuration file without private keys for that purpose).
345
346 If you really want to carry your private keys, then @ref{nncp-cfgenc}
347 command will be able to encrypt your configuration file. Passphrase you
348 enter is strengthened with both CPU and memory hard function.
349
350 @node UsecaseCaller
351 @section Cheap night transfers
352
353 Your Internet/telephone traffic price can vary, depending on daytime.
354 Night calls/connections could be twice as cheaper. You wish to send your
355 files at that time, but keep high priority email infrequently passing
356 through in anytime. Also you wish to pass any kind of traffic when the
357 node is available through the LAN.
358
359 You can easily set your preferences in @ref{Call, call
360 configurations} for @ref{nncp-caller} command used in online
361 communications.
362
363 @verbatim
364 neigh: {
365   [...]
366   some-node: {
367     [...]
368     addrs: {
369       lan: "[fe80::be5f:f4ff:fedd:2752%igb0]:5400"
370       wan: "some-node.com:5400"
371     }
372     calls: [
373       {
374         cron: "*/1 * * * *"
375         addr: lan
376         nice: MAX
377         onlinedeadline: 3600
378       },
379       {
380         cron: "*/10 * * * *"
381         addr: wan
382         nice: PRIORITY
383         xx: rx
384       },
385       {
386         cron: "*/1 0-7 * * *"
387         addr: wan
388         nice: BULK
389         onlinedeadline: 3600
390         maxonlinetime: 3600
391       },
392     ]
393   }
394 }
395 @end verbatim
396
397 @node UsecaseMulticast
398 @section Multicast flooding transmission
399
400 Do you need to send single mail message or file to many recipients at
401 once? For example an update of some program, network participants list
402 or available files for freqing? But you are not connected directly to
403 each of them?
404
405 @verbatim
406    A-------->E---->F    A -> B C E
407   / \        |\    ^    C -> H J
408  /   \       |  \  |    E -> D F G
409 v     v      v    \v    D -> G
410 B     C      D---->G    J -> K
411      / \     ^    /     K -> D G
412     /   \    |   /
413    v     v   v  /
414    H     J<->K<-
415 @end verbatim
416
417 NNCP has @ref{Multicast, multicast} packets format, allowing you to
418 flood transmission of the single packet to multiple recipients.
419 @strong{A} sends packet to three destinations. @strong{C} sends it to
420 the two nodes next. @strong{E} sends it to three. Some participants may
421 receive multiple copies of the same packet, like @strong{D}, @strong{J},
422 @strong{G}, @strong{F}, but that copies will be just ignored. If
423 @strong{B} sends packet to single known to him @strong{A}, then that
424 packet will be distributed among all other multicast area subscribers.
425
426 Moreover those multicast packets are encrypted and require key knowledge
427 for reading. But that does not prevent their relaying! Also you are not
428 required to know sender's public keys. That way you can easily create
429 echo-conferences for files or commands (like mail message delivering)
430 transmission.
431
432 Let's create keys for the new multicast area:
433
434 @example
435 $ nncp-cfgnew -area filelists -nocomments
436 areas: @{
437   filelists: @{
438     id: TOU5TKOW4JBIZJBX63D4776C72FMWDAUAUSZNJX4DFOITVYQ5ZQA
439     pub: DSHL5O6BK2R3QKJAIJ7BC4UIGE73EC2LJPOV3VTS44KYOTUQYZLA
440     prv: AYD5FAA4GDDSAD5N65NJLLFS6TG2NSPQ46KAQO5U722JLVG34SOQ
441   @}
442 @}
443 @end example
444
445 and send that keypair everybody who wants to read that area.
446 For intermediaries willing to relay packets on, but that should not read
447 them, you just need to send area's identity. For example @strong{A} adds
448 to his configuration:
449
450 @example
451 areas: @{
452   filelists: @{
453     id: TOU...
454     pub: DSH...
455     prv: AYD...
456     subs: ["B", "C", "E"]
457     incoming: /home/A/areas/filelists
458   @}
459 @end example
460
461 and @strong{E}, that will be relaying intermediary (as we decided):
462
463 @example
464 areas: @{
465   filelists: @{
466     id: TOU...
467     subs: ["D", "F", "G"]
468   @}
469 @end example
470
471 After you distributed the knowledge about @code{nodelist} multicast
472 area, you can share @ref{FreqIndex, file lists}:
473
474 @example
475 $ nncp-file tree-of-A-20210715.txt.zst area:filelists:
476 $ nncp-toss -node self
477 @end example