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