]> Cypherpunks.ru repositories - nncp.git/blob - doc/usecases.texi
e118da4ea8088858f4931b3c85de041e7e37a1c7
[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 @end menu
20
21 @node UsecaseMail
22 @section Occasional connection to mail server
23
24 Assume that you have got your own @url{http://www.postfix.org/, Postfix}
25 SMTP server connected to the Internet. But you read and write emails on
26 your notebook, that is connected to it just from time to time. How can
27 you flush buffered mail queues when your notebook is connected?
28
29 One possibility is to log in and run something like @command{postqueue
30 -f}, but by default you have got only several days so and sender will
31 receive notification emails that his messages still are not delivered
32 yet. Also you must have secure link (SSH, VPN, etc).
33
34 Another possibility is to use POP3/IMAP4 servers, but this is too
35 overcomplicated and bloated for the simple task. Not an option.
36 @url{https://en.wikipedia.org/wiki/KISS_principle, KISS}!
37
38 Just tell both of your Postfixes (on the server and notebook) to drop
39 email as a mail via NNCP (@ref{nncp-exec}) to specified node. This is
40 done similarly as with UUCP and as written in
41 @url{http://www.postfix.org/UUCP_README.html, Postfix documentation}.
42
43 Look @ref{Postfix, here} for further information. All mail will be
44 stored in NNCP @ref{Spool, spool}, that after exchanging and tossing
45 will call local @command{sendmail} command to deliver them just like
46 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 @node UsecaseAirgap
249 @section Highly secure isolated air-gap computers
250
251 If you worry much about security, then air-gapped computer could be the
252 only choice you can afford. Computer without any modems, wired and
253 wireless networks. Obviously the only possibility to exchange mail and
254 files is to use physically removable storage devices like CD-ROM, hard
255 drive, SD, tape and USB flash drives (@strong{worst} choice, due to
256 those devices complexity).
257
258 Presumably you have got another own hop before that computer: another
259 intermediate node which performs basic verification of retrieved storage
260 devices, possibly by rewriting the data from USB/hard drives to CD-RWs.
261
262 NNCP supports packets relying (transitioning) out-of-box.
263
264 @verbatim
265 neigh: {
266   bob: {
267     [...]
268     addrs: {
269       lan: "[fe80::5400%igb0]:5400"
270     }
271   }
272   bob-airgap:
273     [...]
274     via: ["bob"]
275   }
276 }
277 @end verbatim
278
279 That @ref{Configuration, configuration file} tells that we have got two
280 known neighbours: @emph{bob} and @emph{bob-airgap}. @emph{bob} can be
281 reached via online connection using @emph{lan} address.
282 @emph{bob-airgap} can be reached by sending intermediate relay packet
283 through the @emph{bob}.
284
285 Any command like @command{nncp-file myfile bob-airgap:} will
286 automatically create an encapsulated packet: one for the destination
287 endpoint, and other carrying it for intermediate relaying node.
288
289 Pay attention that relaying node knows nothing about the packet inside,
290 but just its size and priority. Transition packets are encrypted too:
291 using well-known @url{https://en.wikipedia.org/wiki/Onion_routing, onion
292 routing} technology. @emph{bob} can not read @emph{bob-airgap}'s packets.
293
294 @node UsecaseCensor
295 @section Network censorship bypassing, health
296
297 This is some kind of bad link too. Some governments tend to forbid
298 @strong{any} kind of private communication between people, allowing only
299 entertainment content delivering and popular social networks access
300 (that are already bloated with advertisements, locally executed
301 @url{https://www.gnu.org/philosophy/free-sw.html, proprietary}
302 JavaScript code (for spying on user activities, collect data on them),
303 shamelessly exploiting the very basic human need of communication).
304
305 This is their natural wish. But nobody forces you to obey huge
306 corporations like Apple, Google or Microsoft. It is your choice to
307 create an isolated friend-to-friend network with piles of harmless
308 content and private messaging. Only predators silently watch for their
309 victims in mammals world -- it harms your health being watched and
310 feeling that you are the victim that has already done something wrong.
311
312 @node UsecaseSpy
313 @section Reconnaissance, spying, intelligence, covert agents
314
315 Those guys know how Internet is a dangerous place incompatible with
316 privacy. They require quick, fast dropping and picking of data. No
317 possibility of many round-trips -- just drop the data, fire-and-forget.
318 It could be either removable media again and/or
319 @url{https://en.wikipedia.org/wiki/USB_dead_drop, USB dead drops},
320 @url{https://en.wikipedia.org/wiki/PirateBox, PirateBox}es,
321 @url{https://en.wikipedia.org/wiki/Short-range_agent_communications, SRAC}.
322 Short lived short range networks like Bluetooth and WiFi can also
323 be pretty fast, allowing to quickly fire chunks of queued packets.
324
325 Very important property is that compromising of those dead drops and
326 storages must be neither fatal nor even dangerous. Packets sent through
327 the network and exchanged via those devices are end-to-end
328 @ref{Encrypted, encrypted} (but unfortunately lacking forward secrecy).
329 No filenames, mail recipients are seen.
330
331 All node communications are done with so-called @ref{Spool, spool} area:
332 directory containing only those unprocessed encrypted packets. After
333 packet transfer you still can not read any of them: you have to run
334 another stage: @ref{nncp-toss, tossing}, that involves your private
335 cryptographic keys. So even if your loose your computer, storage devices
336 and so on -- it is not so bad, because you are not carrying private keys
337 with it (don't you?), you do not "toss" those packets immediately on the
338 same device. Tossing (reading those encrypted packets and extracting
339 transferred files and mail messages) could and should be done on a
340 separate computer (@ref{nncp-cfgmin} command could help creating
341 configuration file without private keys for that purpose).
342
343 If you really want to carry your private keys, then @ref{nncp-cfgenc}
344 command will be able to encrypt your configuration file. Passphrase you
345 enter is strengthened with both CPU and memory hard function.
346
347 @node UsecaseCaller
348 @section Cheap night transfers
349
350 Your Internet/telephone traffic price can vary, depending on daytime.
351 Night calls/connections could be twice as cheaper. You wish to send your
352 files at that time, but keep high priority email infrequently passing
353 through in anytime. Also you wish to pass any kind of traffic when the
354 node is available through the LAN.
355
356 You can easily set your preferences in @ref{Call, call
357 configurations} for @ref{nncp-caller} command used in online
358 communications.
359
360 @verbatim
361 neigh: {
362   [...]
363   some-node: {
364     [...]
365     addrs: {
366       lan: "[fe80::be5f:f4ff:fedd:2752%igb0]:5400"
367       wan: "some-node.com:5400"
368     }
369     calls: [
370       {
371         cron: "*/1 * * * *"
372         addr: lan
373         nice: MAX
374         onlinedeadline: 3600
375       },
376       {
377         cron: "*/10 * * * *"
378         addr: wan
379         nice: PRIORITY
380         xx: rx
381       },
382       {
383         cron: "*/1 0-7 * * *"
384         addr: wan
385         nice: BULK
386         onlinedeadline: 3600
387         maxonlinetime: 3600
388       },
389     ]
390   }
391 }
392 @end verbatim