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