aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorng0 <ng0@infotropique.org>2017-08-24 13:20:39 +0000
committerng0 <ng0@infotropique.org>2017-08-24 13:20:39 +0000
commit834f1ec8209254fb66dc2908d39852761f015c8f (patch)
treee2cab1f02106812a3c46d19fb9cd775b49d0ded1 /doc
parent4c4d52c50cca5ff22ec12839ba6c629f705fef00 (diff)
downloadgnunet-834f1ec8209254fb66dc2908d39852761f015c8f.tar.gz
gnunet-834f1ec8209254fb66dc2908d39852761f015c8f.zip
doc: Start of half-manual conversion from LaTeX to Texinfo for gnunet-c-tutorial.
Diffstat (limited to 'doc')
-rw-r--r--doc/gnunet-c-tutorial.texi (renamed from doc/gnunet-c-tutorial.tex)408
1 files changed, 184 insertions, 224 deletions
diff --git a/doc/gnunet-c-tutorial.tex b/doc/gnunet-c-tutorial.texi
index 13c975567..0c01cceab 100644
--- a/doc/gnunet-c-tutorial.tex
+++ b/doc/gnunet-c-tutorial.texi
@@ -1,73 +1,65 @@
1\documentclass[10pt]{article} 1\input texinfo
2\usepackage[ansinew]{inputenc} 2@c %**start of header
3\usepackage{makeidx,amsmath,amssymb,exscale,multicol,epsfig,graphics,verbatim,ulem} 3@setfilename gnunet-c-tutorial.info
4\usepackage{epsfig,geometry,url,listings,subcaption} 4@documentencoding UTF-8
5\usepackage{boxedminipage} 5@settitle GNUnet C Tutorial
6\usepackage[T1]{fontenc}%required 6@c %**end of header
7\usepackage{textcomp}
8\geometry{headsep=3ex,hscale=0.9}
9\usepackage{hyperref}
10\usepackage{color}
11\hypersetup{pdftitle={GNUnet C Tutorial},
12 pdfsubject={GNUnet},
13 pdfauthor={Christian Grothoff <christian@grothoff.org>},
14 pdfkeywords={p2p,search,gnunet,tutorial}
15 %,pdfpagemode={FullScreen}
16 }
17
18
19\lstset{
20language=bash,
21basicstyle=\ttfamily,
22upquote=true,
23columns=fullflexible,
24literate={*}{{\char42}}1
25 {-}{{\char45}}1
26}
27 7
28\newcommand{\exercise}[1]{\noindent\begin{boxedminipage}{\textwidth}{\bf Exercise:} #1 \end{boxedminipage}} 8@copying
29 9Copyright @copyright{} 2001-2017 GNUnet e.V.
30\begin{document} 10
31 11Permission is granted to copy, distribute and/or modify this document
32\lstset{ % 12under the terms of the GNU Free Documentation License, Version 1.3 or
33language=C, % choose the language of the code 13any later version published by the Free Software Foundation; with no
34basicstyle=\footnotesize, % the size of the fonts that are used for the code 14Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
35numbers=left, % where to put the line-numbers 15copy of the license is included in the section entitled ``GNU Free
36numberstyle=\footnotesize, % the size of the fonts that are used for the line-numbers 16Documentation License''.
37stepnumber=1, % the step between two line-numbers. If it is 1 each line will be numbered 17
38numbersep=5pt, % how far the line-numbers are from the code 18A copy of the license is also available from the Free Software
39backgroundcolor=\color{white}, % choose the background color. You must add \usepackage{color} 19Foundation Web site at @url{http://www.gnu.org/licenses/fdl.html}.
40showspaces=false, % show spaces adding particular underscores 20
41showstringspaces=false, % underline spaces within strings 21Alternately, this document is also available under the General
42showtabs=false, % show tabs within strings adding particular underscores 22Public License, version 3 or later, as published by the Free Software
43frame=single, % adds a frame around the code 23Foundation. A copy of the license is included in the section entitled
44tabsize=2, % sets default tabsize to 2 spaces 24``GNU General Public License''.
45captionpos=b, % sets the caption-position to bottom 25
46breaklines=true, % sets automatic line breaking 26A copy of the license is also available from the Free Software
47breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace 27Foundation Web site at @url{http://www.gnu.org/licenses/gpl.html}.
48escapeinside={\%*}{*)} % if you want to add a comment within your code 28@end copying
49}
50 29
30@titlepage
31@title GNUnet C Tutorial
32@subtitle A Tutorial for GNUnet 0.10.x (C version)
33@author The GNUnet Developers
51 34
52\begin{center} 35@page
53\large {A Tutorial for GNUnet 0.10.x (C version)} 36@vskip 0pt plus 1filll
54 37
55Christian Grothoff $\qquad$ Bart Polot $\qquad$ Matthias Wachs 38@insertcopying
39@end titlepage
40
41@contents
42
43@c **** TODO
44@c 1. Update content?
45@c 2. Either reference main documentation or
46@c 3. Merge this into main documentation
47
48@node Top
49@top Introduction
56 50
57\today
58\end{center}
59This tutorials explains how to install GNUnet on a GNU/Linux system and gives an introduction on how 51This tutorials explains how to install GNUnet on a GNU/Linux system and gives an introduction on how
60GNUnet can be used to develop a Peer-to-Peer application. Detailed installation instructions for 52GNUnet can be used to develop a Peer-to-Peer application. Detailed installation instructions for
61various operating systems and a detailed list of all dependencies can be found on our website at 53various operating systems and a detailed list of all dependencies can be found on our website at
62\url{https://gnunet.org/installation}. 54@uref{https://gnunet.org/installation}.
63 55
64\textbf{Please read this tutorial carefully since every single step is 56Please read this tutorial carefully since every single step is
65 important and do not hesitate to contact the GNUnet team if you have 57important and do not hesitate to contact the GNUnet team if you have
66 any questions or problems! Check here how to contact the GNUnet 58any questions or problems! Check here how to contact the GNUnet
67 team: \url{https://gnunet.org/contact_information}} 59team: @uref{https://gnunet.org/contact_information}
68 60
69 61
70\section{Installing GNUnet} 62@section Installing GNUnet
71 63
72First of all you have to install a current version of GNUnet. You can download a 64First of all you have to install a current version of GNUnet. You can download a
73tarball of a stable version from GNU FTP mirrors or obtain the latest development 65tarball of a stable version from GNU FTP mirrors or obtain the latest development
@@ -78,162 +70,142 @@ latest development version things can be broken, functionality can be changed or
78can fail. You should only use the development version if you know that you require a 70can fail. You should only use the development version if you know that you require a
79certain feature or a certain issue has been fixed since the last release. 71certain feature or a certain issue has been fixed since the last release.
80 72
81\subsection{Obtaining a stable version} 73@subsection Obtaining a stable version
82 74
83You can download the latest stable version of GNUnet from GNU FTP mirrors: 75You can download the latest stable version of GNUnet from GNU FTP mirrors:
84\begin{center} 76@uref{ftp://ftp.gnu.org/gnu/gnunet/gnunet-0.10.x.tar.gz}
85\url{ftp://ftp.gnu.org/gnu/gnunet/gnunet-0.10.x.tar.gz}
86\end{center}
87You should also download the signature file and verify the integrity of the tarball. 77You should also download the signature file and verify the integrity of the tarball.
88\begin{center} 78@uref{ftp://ftp.gnu.org/gnu/gnunet/gnunet-0.10.x.tar.gz.sig}
89\url{ftp://ftp.gnu.org/gnu/gnunet/gnunet-0.10.x.tar.gz.sig}
90\end{center}
91To verify the signature you should first import the GPG key used to sign the tarball 79To verify the signature you should first import the GPG key used to sign the tarball
92\lstset{language=bash} 80@example
93\begin{lstlisting}
94$ gpg --keyserver keys.gnupg.net --recv-keys 48426C7E 81$ gpg --keyserver keys.gnupg.net --recv-keys 48426C7E
95\end{lstlisting} 82@end example
96And use this key to verify the tarball's signature 83And use this key to verify the tarball's signature
97\lstset{language=bash} 84@example
98\begin{lstlisting}
99$ gpg --verify gnunet-0.10.x.tar.gz.sig gnunet-0.10.x.tar.gz 85$ gpg --verify gnunet-0.10.x.tar.gz.sig gnunet-0.10.x.tar.gz
100\end{lstlisting} 86@end example
101After successfully verifying the integrity you can extract the tarball using 87After successfully verifying the integrity you can extract the tarball using
102\lstset{language=bash} 88@example
103\begin{lstlisting}
104$ tar xvzf gnunet-0.10.x.tar.gz 89$ tar xvzf gnunet-0.10.x.tar.gz
105$ mv gnunet-0.10.x gnunet # we will use the directory "gnunet" in the remainder of this document 90## we will use the directory "gnunet" in the remainder of this document
91$ mv gnunet-0.10.x gnunet
106$ cd gnunet 92$ cd gnunet
107\end{lstlisting} 93@end example
108 94
109However, please note that stable versions can be very outdated, as a developer 95However, please note that stable versions can be very outdated, as a developer
110you are strongly encouraged to use the version from \url{https://gnunet.org/git/}. 96you are strongly encouraged to use the version from @uref{https://gnunet.org/git/}.
111 97
112\subsection{Installing Build Tool Chain and Dependencies} 98@subsection Installing Build Tool Chain and Dependencies
113 99
114To successfully compile GNUnet you need the tools to build GNUnet and the required dependencies. 100To successfully compile GNUnet you need the tools to build GNUnet and the required dependencies.
115Please have a look at \url{https://gnunet.org/dependencies} for a list of required dependencies 101Please have a look at @uref{https://gnunet.org/dependencies} for a list of required dependencies
116and \url{https://gnunet.org/generic_installation} for specific instructions for your operating system. 102and @uref{https://gnunet.org/generic_installation} for specific instructions for your operating system.
117 103
118Please check the notes at the end of the configure process about required dependencies. 104Please check the notes at the end of the configure process about required dependencies.
119 105
120For GNUnet bootstrapping support and the http(s) plugin you should install \texttt{libgnurl}. 106For GNUnet bootstrapping support and the http(s) plugin you should install libgnurl.
121For the filesharing service you should install at least one of the datastore backends \texttt{mysql}, 107For the filesharing service you should install at least one of the datastore backends mysql,
122\texttt{sqlite} or \texttt{postgresql}. 108sqlite or postgresql.
123 109
124\subsection{Obtaining the latest version from Git} 110@subsection Obtaining the latest version from Git
125 111
126The latest development version can obtained from our Git repository. To obtain 112The latest development version can obtained from our Git repository. To obtain
127the code you need Git installed and checkout the repository using: 113the code you need Git installed and checkout the repository using:
128\lstset{language=bash} 114@example
129\begin{lstlisting}
130$ git clone https://gnunet.org/git/gnunet 115$ git clone https://gnunet.org/git/gnunet
131\end{lstlisting} 116@end example
132After cloning the repository you have to execute 117After cloning the repository you have to execute
133\lstset{language=bash} 118@example
134\begin{lstlisting}
135$ cd gnunet 119$ cd gnunet
136$ ./bootstrap 120$ ./bootstrap
137\end{lstlisting} 121@end example
138 122
139The remainder of this tutorial assumes that you have Git Master checked out. 123The remainder of this tutorial assumes that you have Git Master checked out.
140 124
125@subsection Compiling and Installing GNUnet
141 126
142\subsection{Compiling and Installing GNUnet} 127First, you need to install at least libgnupgerror version 1.27
128@uref{ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.27.tar.bz2}
129and libgcrypt version 1.7.6 @uref{ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.7.6.tar.bz2}.
143 130
144First, you need to install at least {\tt libgnupgerror} version 131@example
1451.27\footnote{\url{ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.27.tar.bz2}}
146and {\tt libgcrypt} version
1471.7.6\footnote{\url{ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.7.6.tar.bz2}}.
148
149\lstset{language=bash}
150\begin{lstlisting}
151$ wget ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.27.tar.bz2 132$ wget ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.27.tar.bz2
152$ tar xf libgpg-error-1.27.tar.bz2 133$ tar xf libgpg-error-1.27.tar.bz2
153$ cd libgpg-error-1.27 134$ cd libgpg-error-1.27
154$ ./configure 135$ ./configure
155$ sudo make install 136$ sudo make install
156$ cd .. 137$ cd ..
157\end{lstlisting} 138@end example
158 139
159\lstset{language=bash} 140@example
160\begin{lstlisting}
161$ wget ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.7.6.tar.bz2 141$ wget ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.7.6.tar.bz2
162$ tar xf libgcrypt-1.7.6.tar.bz2 142$ tar xf libgcrypt-1.7.6.tar.bz2
163$ cd libgcrypt-1.7.6 143$ cd libgcrypt-1.7.6
164$ ./configure 144$ ./configure
165$ sudo make install 145$ sudo make install
166$ cd .. 146$ cd ..
167\end{lstlisting} 147@end example
168 148
169\label{sub:install} 149@c sub:install
170Assuming all dependencies are installed, the following commands will 150Assuming all dependencies are installed, the following commands will
171compile and install GNUnet in your home directory. You can specify the 151compile and install GNUnet in your home directory. You can specify the
172directory where GNUnet will be installed by changing the 152directory where GNUnet will be installed by changing the
173\lstinline|--prefix| value when calling \lstinline|./configure|. If 153--prefix value when calling ./configure. If
174you do not specifiy a prefix, GNUnet is installed in the directory 154you do not specifiy a prefix, GNUnet is installed in the directory
175\lstinline|/usr/local|. When developing new applications you may want 155/usr/local. When developing new applications you may want
176to enable verbose logging by adding 156to enable verbose logging by adding --enable-logging=verbose:
177\lstinline|--enable-logging=verbose|:
178 157
179\lstset{language=bash} 158@example
180\begin{lstlisting}
181$ ./configure --prefix=$PREFIX --enable-logging 159$ ./configure --prefix=$PREFIX --enable-logging
182$ make 160$ make
183$ make install 161$ make install
184\end{lstlisting} 162@end example
185 163
186After installing GNUnet you have to add your GNUnet installation to your path 164After installing GNUnet you have to add your GNUnet installation to your path
187environmental variable. In addition you have to create the \lstinline|.config| 165environmental variable. In addition you have to create the .config
188directory in your home directory where GNUnet stores its data and an empty 166directory in your home directory where GNUnet stores its data and an empty
189GNUnet configuration file: 167GNUnet configuration file:
190 168
191\lstset{language=bash} 169@example
192\begin{lstlisting}
193$ export PATH=$PATH:$PREFIX/bin 170$ export PATH=$PATH:$PREFIX/bin
194$ echo export PATH=$PREFIX/bin:\\$PATH >> ~/.bashrc 171$ echo export PATH=$PREFIX/bin:\\$PATH >> ~/.bashrc
195$ mkdir ~/.config/ 172$ mkdir ~/.config/
196$ touch ~/.config/gnunet.conf 173$ touch ~/.config/gnunet.conf
197\end{lstlisting} 174@example
198% $
199 175
200\subsection{Common Issues - Check your GNUnet installation} 176@subsection Common Issues - Check your GNUnet installation
201 177
202You should check your installation to ensure that installing GNUnet 178You should check your installation to ensure that installing GNUnet
203was successful up to this point. You should be able to access GNUnet's 179was successful up to this point. You should be able to access GNUnet's
204binaries and run GNUnet's self check. 180binaries and run GNUnet's self check.
205\lstset{language=bash} 181@example
206\begin{lstlisting}
207$ which gnunet-arm 182$ which gnunet-arm
208\end{lstlisting} 183@end example
209should return \lstinline|$PREFIX/bin/gnunet-arm|. It should be 184should return $PREFIX/bin/gnunet-arm. It should be
210located in your GNUnet installation and the output should not be 185located in your GNUnet installation and the output should not be
211empty. If you see an output like: 186empty. If you see an output like:
212\lstset{language=bash} 187@example
213\begin{lstlisting}
214$ which gnunet-arm 188$ which gnunet-arm
215$ 189@end example
216\end{lstlisting} 190check your PATH variable to ensure GNUnet's bin directory is included.
217check your {\tt PATH} variable to ensure GNUnet's {\tt bin} directory is included.
218 191
219GNUnet provides tests for all of its subcomponents. Run 192GNUnet provides tests for all of its subcomponents. Run
220\lstset{language=bash} 193@example
221\begin{lstlisting}
222$ make check 194$ make check
223\end{lstlisting} 195@end example
224to execute tests for all components. {\tt make check} traverses all subdirectories in {\tt src}. 196to execute tests for all components. make check traverses all subdirectories in src.
225For every subdirectory you should get a message like this: 197For every subdirectory you should get a message like this:
226 198
227\begin{verbatim} 199@example
228make[2]: Entering directory `/home/$USER/gnunet/contrib' 200make[2]: Entering directory `/home/$USER/gnunet/contrib'
229PASS: test_gnunet_prefix 201PASS: test_gnunet_prefix
230============= 202=============
2311 test passed 2031 test passed
232============= 204=============
233\end{verbatim} 205@example
234 206
235 207
236\section{Background: GNUnet Architecture} 208@section Background: GNUnet Architecture
237 209
238GNUnet is organized in layers and services. Each service is composed of a 210GNUnet is organized in layers and services. Each service is composed of a
239main service implementation and a client library for other programs to use 211main service implementation and a client library for other programs to use
@@ -273,112 +245,102 @@ clients communicate via a message protocol to be defined and implemented by
273the programmer. 245the programmer.
274 246
275 247
276\section{First Steps with GNUnet} 248@section First Steps with GNUnet
277 249
278\subsection{Configure your peer} 250@subsection Configure your peer
279 251
280First of all we need to configure your peer. Each peer is started with a configuration containing settings for GNUnet itself and its services. This configuration is based on the default configuration shipped with GNUnet and can be modified. The default configuration is located in the {\tt \$PREFIX/share/gnunet/config.d} directory. When starting a peer, you can specify a customized configuration using the the {\tt$-c$} command line switch when starting the ARM service and all other services. When using a modified configuration the default values are loaded and only values specified in the configuration file will replace the default values. 252First of all we need to configure your peer. Each peer is started with a configuration containing settings for GNUnet itself and its services. This configuration is based on the default configuration shipped with GNUnet and can be modified. The default configuration is located in the $PREFIX/share/gnunet/config.d directory. When starting a peer, you can specify a customized configuration using the the $-c$ command line switch when starting the ARM service and all other services. When using a modified configuration the default values are loaded and only values specified in the configuration file will replace the default values.
281 253
282Since we want to start additional peers later, we need 254Since we want to start additional peers later, we need
283some modifications from the default configuration. We need to create a separate service home and a file containing our modifications for this peer: 255some modifications from the default configuration. We need to create a separate service home and a file containing our modifications for this peer:
284\lstset{language=bash} 256@example
285\begin{lstlisting}
286$ mkdir ~/gnunet1/ 257$ mkdir ~/gnunet1/
287$ touch peer1.conf 258$ touch peer1.conf
288\end{lstlisting} 259@end example
289 260
290Now add the following lines to peer1.conf to use this directory. For 261Now add the following lines to peer1.conf to use this directory. For
291simplified usage we want to prevent the peer to connect to the GNUnet 262simplified usage we want to prevent the peer to connect to the GNUnet
292network since this could lead to confusing output. This modifications 263network since this could lead to confusing output. This modifications
293will replace the default settings: 264will replace the default settings:
294\begin{verbatim} 265@example
295[PATHS] 266[PATHS]
296GNUNET_HOME = ~/gnunet1/ # Use this directory to store GNUnet data 267GNUNET_HOME = ~/gnunet1/ # Use this directory to store GNUnet data
297[hostlist] 268[hostlist]
298SERVERS = # prevent bootstrapping 269SERVERS = # prevent bootstrapping
299\end{verbatim} 270@end example
300 271
301 272@subsection Start a peer
302\subsection{Start a peer} 273Each GNUnet instance (called peer) has an identity (peer ID) based on a
303Each GNUnet instance (called peer) has an identity (\textit{peer ID}) based on a
304cryptographic public private key pair. The peer ID is the printable hash of the 274cryptographic public private key pair. The peer ID is the printable hash of the
305public key. 275public key.
306 276
307GNUnet services are controlled by a master service the so called \textit{Automatic Restart Manager} (ARM). 277GNUnet services are controlled by a master service the so called Automatic Restart Manager (ARM).
308ARM starts, stops and even restarts services automatically or on demand when a client connects. 278ARM starts, stops and even restarts services automatically or on demand when a client connects.
309You interact with the ARM service using the \lstinline|gnunet-arm| tool. 279You interact with the ARM service using the gnunet-arm tool.
310GNUnet can then be started with \lstinline|gnunet-arm -s| and stopped with 280GNUnet can then be started with gnunet-arm -s and stopped with
311\lstinline|gnunet-arm -e|. An additional service not automatically started 281gnunet-arm -e. An additional service not automatically started
312can be started using \lstinline|gnunet-arm -i <service name>| and stopped 282can be started using gnunet-arm -i <service name> and stopped
313using \lstinline|gnunet-arm -k <servicename>|. 283using gnunet-arm -k <servicename>.
314 284
315Once you have started your peer, you can use many other GNUnet commands 285Once you have started your peer, you can use many other GNUnet commands
316to interact with it. For example, you can run: 286to interact with it. For example, you can run:
317\lstset{language=bash} 287@example
318\begin{lstlisting}
319$ gnunet-peerinfo -s 288$ gnunet-peerinfo -s
320\end{lstlisting} 289@end example
321to obtain the public key of your peer. 290to obtain the public key of your peer.
322You should see an output containing the peer ID similar to: 291You should see an output containing the peer ID similar to:
323\lstset{language=bash} 292@example
324\begin{lstlisting}
325I am peer `0PA02UVRKQTS2C .. JL5Q78F6H0B1ACPV1CJI59MEQUMQCC5G'. 293I am peer `0PA02UVRKQTS2C .. JL5Q78F6H0B1ACPV1CJI59MEQUMQCC5G'.
326\end{lstlisting} 294@end example
327 295
328 296
329\subsection{Monitor a peer} 297@subsection Monitor a peer
330 298
331In this section, we will monitor the behaviour of our peer's DHT service with respect to a 299In this section, we will monitor the behaviour of our peer's DHT service with respect to a
332specific key. First we will start GNUnet and then start the DHT service and use the DHT monitor tool 300specific key. First we will start GNUnet and then start the DHT service and use the DHT monitor tool
333to monitor the PUT and GET commands we issue ussing the \lstinline|gnunet-dht-put| and 301to monitor the PUT and GET commands we issue ussing the gnunet-dht-put and
334\lstinline|gnunet-dht-get| commands. Using the ``monitor'' line given below, you can observe the behavior of 302gnunet-dht-get commands. Using the ``monitor'' line given below, you can observe the behavior of
335your own peer's DHT with respect to the specified KEY: 303your own peer's DHT with respect to the specified KEY:
336 304
337\lstset{language=bash} 305@example
338\begin{lstlisting}
339$ gnunet-arm -c ~/peer1.conf -s # start gnunet with all default services 306$ gnunet-arm -c ~/peer1.conf -s # start gnunet with all default services
340$ gnunet-arm -c ~/peer1.conf -i dht # start DHT service 307$ gnunet-arm -c ~/peer1.conf -i dht # start DHT service
341$ cd ~/gnunet/src/dht; 308$ cd ~/gnunet/src/dht;
342$ ./gnunet-dht-monitor -c ~/peer1.conf -k KEY 309$ ./gnunet-dht-monitor -c ~/peer1.conf -k KEY
343\end{lstlisting} 310@end example
344Now open a separate terminal and change again to the \lstinline|gnunet/src/dht| directory: 311Now open a separate terminal and change again to the gnunet/src/dht directory:
345\lstset{language=bash} 312@example
346\begin{lstlisting}
347$ cd ~/gnunet/src/dht 313$ cd ~/gnunet/src/dht
348$ ./gnunet-dht-put -c ~/peer1.conf -k KEY -d VALUE # put VALUE under KEY in the DHT 314$ ./gnunet-dht-put -c ~/peer1.conf -k KEY -d VALUE # put VALUE under KEY in the DHT
349$ ./gnunet/src/dht/gnunet-dht-get -c ~/peer1.conf -k KEY # get key KEY from the DHT 315$ ./gnunet/src/dht/gnunet-dht-get -c ~/peer1.conf -k KEY # get key KEY from the DHT
350$ gnunet-statistics -c ~/peer1.conf # print statistics about current GNUnet state 316$ gnunet-statistics -c ~/peer1.conf # print statistics about current GNUnet state
351$ gnunet-statistics -c ~/peer1.conf -s dht # print statistics about DHT service 317$ gnunet-statistics -c ~/peer1.conf -s dht # print statistics about DHT service
352\end{lstlisting} 318@end example
353% $
354 319
355 320
356\subsection{Starting Two Peers by Hand} 321@subsection Starting Two Peers by Hand}
357 322
358This section describes how to start two peers on the same machine by hand. 323This section describes how to start two peers on the same machine by hand.
359The process is rather painful, but the description is somewhat instructive. 324The process is rather painful, but the description is somewhat instructive.
360In practice, you might prefer the automated method described in 325In practice, you might prefer the automated method described in
361Section~\ref{sec:testbed}. 326Section sec:testbed.
362 327
363\subsubsection{Setup a second peer} 328@subsubsection Setup a second peer
364We will now start a second peer on your machine. 329We will now start a second peer on your machine.
365For the second peer, you will need to manually create a modified 330For the second peer, you will need to manually create a modified
366configuration file to avoid conflicts with ports and directories. 331configuration file to avoid conflicts with ports and directories.
367A peers configuration file is by default located in {\tt ~/.gnunet/gnunet.conf}. 332A peers configuration file is by default located in ~/.gnunet/gnunet.conf.
368This file is typically very short or even empty as only the differences to the 333This file is typically very short or even empty as only the differences to the
369defaults need to be specified. The defaults are located in 334defaults need to be specified. The defaults are located in
370many files in the {\tt \$PREFIX/share/gnunet/config.d} directory. 335many files in the $PREFIX/share/gnunet/config.d directory.
371 336
372To configure the second peer, use the files {\tt 337To configure the second peer, use the files
373 \$PREFIX/share/gnunet/config.d} as a template for your main 338$PREFIX/share/gnunet/config.d as a template for your main
374configuration file: 339configuration file:
375% 340@example
376\lstset{language=bash}
377\lstset{language=bash}
378\begin{lstlisting}
379$ cat $PREFIX/share/gnunet/config.d/*.conf > peer2.conf 341$ cat $PREFIX/share/gnunet/config.d/*.conf > peer2.conf
380\end{lstlisting} 342@end example
381Now you have to edit {\tt peer2.conf} and change: 343Now you have to edit peer2.conf and change:
382\begin{itemize} 344\begin{itemize}
383 \itemsep0em 345 \itemsep0em
384 \item{\texttt{GNUNET\_TEST\_HOME} under \texttt{PATHS}} 346 \item{\texttt{GNUNET\_TEST\_HOME} under \texttt{PATHS}}
@@ -388,25 +350,23 @@ Now you have to edit {\tt peer2.conf} and change:
388 and the PORT option does not need to be touched) } 350 and the PORT option does not need to be touched) }
389 \item{Every value for ``\texttt{UNIXPATH}'' in any section (e.g. by adding a "-p2" suffix)} 351 \item{Every value for ``\texttt{UNIXPATH}'' in any section (e.g. by adding a "-p2" suffix)}
390\end{itemize} 352\end{itemize}
391to a fresh, unique value. Make sure that the \texttt{PORT} numbers stay 353to a fresh, unique value. Make sure that the PORT numbers stay
392below 65536. From now on, whenever you interact with the second 354below 65536. From now on, whenever you interact with the second
393peer, you need to specify {\tt -c peer2.conf} as an additional 355peer, you need to specify -c peer2.conf as an additional
394command line argument. 356command line argument.
395 357
396Now, generate the 2nd peer's private key: 358Now, generate the 2nd peer's private key:
397 359
398\lstset{language=bash} 360@example
399\begin{lstlisting}
400$ gnunet-peerinfo -s -c peer2.conf 361$ gnunet-peerinfo -s -c peer2.conf
401\end{lstlisting} 362@end example
402% $
403 363
404This may take a while, generate entropy using your keyboard or mouse 364This may take a while, generate entropy using your keyboard or mouse
405as needed. Also, make sure the output is different from the {\tt 365as needed. Also, make sure the output is different from the
406 gnunet-peerinfo} output for the first peer (otherwise you made an 366gnunet-peerinfo output for the first peer (otherwise you made an
407error in the configuration). 367error in the configuration).
408 368
409\subsubsection{Start the second peer and connect the peers} 369@subsubsection Start the second peer and connect the peers
410 370
411Then, you can start a second peer using: 371Then, you can start a second peer using:
412\lstset{language=bash} 372\lstset{language=bash}
@@ -433,11 +393,11 @@ OPTIONS = -p
433 393
434Then change {\tt peer2.conf} and replace the ``\texttt{SERVERS}'' line in the ``\texttt{[hostlist]}'' section with 394Then change {\tt peer2.conf} and replace the ``\texttt{SERVERS}'' line in the ``\texttt{[hostlist]}'' section with
435``\texttt{http://localhost:8080/}''. Restart both peers using: 395``\texttt{http://localhost:8080/}''. Restart both peers using:
436\begin{lstlisting} 396@example
437$ gnunet-arm -c peer1.conf -e # stop first peer 397$ gnunet-arm -c peer1.conf -e # stop first peer
438$ gnunet-arm -c peer1.conf -s # start first peer 398$ gnunet-arm -c peer1.conf -s # start first peer
439$ gnunet-arm -c peer2.conf -s # start second peer 399$ gnunet-arm -c peer2.conf -s # start second peer
440\end{lstlisting} 400@end example
441 401
442Note that if you start your peers without changing these settings, they 402Note that if you start your peers without changing these settings, they
443will use the ``global'' hostlist servers of the GNUnet P2P network and 403will use the ``global'' hostlist servers of the GNUnet P2P network and
@@ -446,7 +406,7 @@ tricky as you're going to be connected to many more peers and would
446likely observe traffic and behaviors that are not explicitly controlled 406likely observe traffic and behaviors that are not explicitly controlled
447by you. 407by you.
448 408
449\subsubsection{How to connect manually} 409@subsubsection How to connect manually
450 410
451If you want to use the \texttt{peerinfo} tool to connect your peers, you should: 411If you want to use the \texttt{peerinfo} tool to connect your peers, you should:
452\begin{itemize} 412\begin{itemize}
@@ -459,13 +419,13 @@ If you want to use the \texttt{peerinfo} tool to connect your peers, you should:
459 419
460Check that they are connected using {\tt gnunet-core -c peer1.conf}, which should give you the other peer's 420Check that they are connected using {\tt gnunet-core -c peer1.conf}, which should give you the other peer's
461peer identity: 421peer identity:
462\lstset{language=bash} 422@example
463\begin{lstlisting}
464$ gnunet-core -c peer1.conf 423$ gnunet-core -c peer1.conf
465Peer `9TVUCS8P5A7ILLBGO6 [...shortened...] 1KNBJ4NGCHP3JPVULDG' 424Peer `9TVUCS8P5A7ILLBGO6 [...shortened...] 1KNBJ4NGCHP3JPVULDG'
466\end{lstlisting} 425@end example
467 426
468\subsection{Starting Peers Using the Testbed Service} \label{sec:testbed} 427@subsection Starting Peers Using the Testbed Service
428@c \label{sec:testbed}
469 429
470GNUnet's testbed service is used for testing scenarios where a number of peers 430GNUnet's testbed service is used for testing scenarios where a number of peers
471are to be started. The testbed can manage peers on a single host or on multiple 431are to be started. The testbed can manage peers on a single host or on multiple
@@ -494,7 +454,7 @@ With the testbed API, a sample test case can be structured as follows:
494\lstset{language=C} 454\lstset{language=C}
495\lstinputlisting{testbed_test.c} 455\lstinputlisting{testbed_test.c}
496The source code for the above listing can be found at 456The source code for the above listing can be found at
497\url{https://gnunet.org/git/gnunet.git/tree/doc/testbed_test.c} 457@uref{https://gnunet.org/git/gnunet.git/tree/doc/testbed_test.c}
498or in the {\tt doc/} folder of your repository check-out. 458or in the {\tt doc/} folder of your repository check-out.
499After installing GNUnet, the above source code can be compiled as: 459After installing GNUnet, the above source code can be compiled as:
500\lstset{language=bash} 460\lstset{language=bash}
@@ -549,14 +509,14 @@ disconnect from the service with the provided service handle (\texttt{op\_result
549\exercise{Find out how many peers you can run on your system.} 509\exercise{Find out how many peers you can run on your system.}
550 510
551\exercise{Find out how to create a 2D torus topology by changing the 511\exercise{Find out how to create a 2D torus topology by changing the
552 options in the configuration file.\footnote{See \url{https://gnunet.org/supported-topologies}} 512 options in the configuration file.\footnote{See @uref{https://gnunet.org/supported-topologies}}
553 Then use the DHT API to store and retrieve values in the 513 Then use the DHT API to store and retrieve values in the
554 network.} 514 network.}
555 515
556 516
557\section{Developing Applications} 517@section Developing Applications
558 518
559\subsection{gnunet-ext} 519@subsection gnunet-ext}
560To develop a new peer-to-peer application or to extend GNUnet we provide 520To develop a new peer-to-peer application or to extend GNUnet we provide
561a template build system for writing GNUnet extensions in C. It can be 521a template build system for writing GNUnet extensions in C. It can be
562obtained as follows: 522obtained as follows:
@@ -603,7 +563,7 @@ In addition the \texttt{ext} systems provides:
603\end{itemize} 563\end{itemize}
604 564
605 565
606\subsection{Adapting the Template} 566@subsection Adapting the Template}
607 567
608The first step for writing any extension with a new service is to 568The first step for writing any extension with a new service is to
609ensure that the {\tt ext.conf.in} file contains entries for the 569ensure that the {\tt ext.conf.in} file contains entries for the
@@ -614,7 +574,7 @@ If you want to adapt the template rename the {\tt ext.conf.in} to match your
614services name, you have to modify the \texttt{AC\_OUTPUT} section in {\tt configure.ac} 574services name, you have to modify the \texttt{AC\_OUTPUT} section in {\tt configure.ac}
615in the \texttt{gnunet-ext} root. 575in the \texttt{gnunet-ext} root.
616 576
617\section{Writing a Client Application} 577@section Writing a Client Application
618 578
619When writing any client application (for example, a command-line 579When writing any client application (for example, a command-line
620tool), the basic structure is to start with the {\tt 580tool), the basic structure is to start with the {\tt
@@ -656,7 +616,7 @@ main (int argc, char *const *argv)
656} 616}
657\end{lstlisting} 617\end{lstlisting}
658 618
659\subsection{Handling command-line options} 619@subsection Handling command-line options}
660 620
661Options can then be added easily by adding global variables and 621Options can then be added easily by adding global variables and
662expanding the {\tt options} array. For example, the following would 622expanding the {\tt options} array. For example, the following would
@@ -702,7 +662,7 @@ more persistent P2P functions.
702\exercise{Add a few command-line options and print them inside 662\exercise{Add a few command-line options and print them inside
703of {\tt run}. What happens if the user gives invalid arguments?} 663of {\tt run}. What happens if the user gives invalid arguments?}
704 664
705\subsection{Writing a Client Library} 665@subsection Writing a Client Library}
706 666
707The first and most important step in writing a client library is to 667The first and most important step in writing a client library is to
708decide on an API for the library. Typical API calls include 668decide on an API for the library. Typical API calls include
@@ -848,7 +808,7 @@ struct GNUNET_MQ_MessageHandler handlers[] = {
848\exercise{Figure out where you can pass values to the closures ({\tt cls}).} 808\exercise{Figure out where you can pass values to the closures ({\tt cls}).}
849 809
850 810
851\subsection{Writing a user interface} 811@subsection Writing a user interface}
852 812
853Given a client library, all it takes to access a service now is to 813Given a client library, all it takes to access a service now is to
854combine calls to the client library with parsing command-line 814combine calls to the client library with parsing command-line
@@ -861,13 +821,13 @@ options.
861 821
862 822
863 823
864\section{Writing a Service} 824@section Writing a Service
865 825
866Before you can test the client you've written so far, you'll need to also 826Before you can test the client you've written so far, you'll need to also
867implement the corresponding service. 827implement the corresponding service.
868 828
869 829
870\subsection{Code Placement} 830@subsection Code Placement}
871 831
872New services are placed in their own subdirectory under {\tt gnunet/src}. 832New services are placed in their own subdirectory under {\tt gnunet/src}.
873This subdirectory should contain the API implementation file {\tt SERVICE\_api.c}, 833This subdirectory should contain the API implementation file {\tt SERVICE\_api.c},
@@ -876,7 +836,7 @@ the description of the client-service protocol {\tt SERVICE.h} and P2P protocol
876{\tt gnunet-service-SERVICE.h} and several files for tests, including test code 836{\tt gnunet-service-SERVICE.h} and several files for tests, including test code
877and configuration files. 837and configuration files.
878 838
879\subsection{Starting a Service} 839@subsection Starting a Service}
880 840
881The key API definition for creating a service is the {\tt GNUNET\_SERVICE\_MAIN} macro: 841The key API definition for creating a service is the {\tt GNUNET\_SERVICE\_MAIN} macro:
882\lstset{language=C} 842\lstset{language=C}
@@ -949,7 +909,7 @@ from the same client.
949 forget to call {\tt GNUNET\_SERVICE\_client\_continue()}?} 909 forget to call {\tt GNUNET\_SERVICE\_client\_continue()}?}
950 910
951 911
952\section{Interacting directly with other Peers using the CORE Service} 912@section Interacting directly with other Peers using the CORE Service
953 913
954FIXME: This section still needs to be updated to the lastest API! 914FIXME: This section still needs to be updated to the lastest API!
955 915
@@ -972,7 +932,7 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
972 const struct GNUNET_MQ_MessageHandler *handlers); 932 const struct GNUNET_MQ_MessageHandler *handlers);
973\end{lstlisting} 933\end{lstlisting}
974 934
975\subsection{New P2P connections} 935@subsection New P2P connections}
976 936
977Before any traffic with a different peer can be exchanged, the peer must be 937Before any traffic with a different peer can be exchanged, the peer must be
978known to the service. This is notified by the \texttt{CORE} {\tt connects} callback, 938known to the service. This is notified by the \texttt{CORE} {\tt connects} callback,
@@ -997,7 +957,7 @@ the respective peer.
997start (and connect) two peers and print a message once your connect 957start (and connect) two peers and print a message once your connect
998callback is invoked.} 958callback is invoked.}
999 959
1000\subsection{Receiving P2P Messages} 960@subsection Receiving P2P Messages}
1001 961
1002To receive messages from \texttt{CORE}, you pass the desired 962To receive messages from \texttt{CORE}, you pass the desired
1003{\em handlers} to the {\tt GNUNET\_CORE\_connect()} function, 963{\em handlers} to the {\tt GNUNET\_CORE\_connect()} function,
@@ -1014,7 +974,7 @@ without message handlers. Which ``connect'' handlers are invoked when
1014the two peers are connected? Why?} 974the two peers are connected? Why?}
1015 975
1016 976
1017\subsection{Sending P2P Messages} 977@subsection Sending P2P Messages}
1018 978
1019You can transmit messages to other peers using the {\it mq} you were 979You can transmit messages to other peers using the {\it mq} you were
1020given during the {\tt connect} callback. Note that the {\it mq} 980given during the {\tt connect} callback. Note that the {\it mq}
@@ -1032,7 +992,7 @@ messages lost? How can you transmit messages faster? What happens if
1032you stop the peer that is receiving your messages?} 992you stop the peer that is receiving your messages?}
1033 993
1034 994
1035\subsection{End of P2P connections} 995@subsection End of P2P connections}
1036 996
1037If a message handler returns {\tt GNUNET\_SYSERR}, the remote peer shuts down or 997If a message handler returns {\tt GNUNET\_SYSERR}, the remote peer shuts down or
1038there is an unrecoverable network disconnection, CORE notifies the service that 998there is an unrecoverable network disconnection, CORE notifies the service that
@@ -1053,7 +1013,7 @@ disconnects (void *cls,
1053 1013
1054\exercise{Fix your service to handle peer disconnects.} 1014\exercise{Fix your service to handle peer disconnects.}
1055 1015
1056\section{Storing peer-specific data using the PEERSTORE service} 1016@section Storing peer-specific data using the PEERSTORE service
1057 1017
1058GNUnet's PEERSTORE service offers a persistorage for arbitrary peer-specific data. 1018GNUnet's PEERSTORE service offers a persistorage for arbitrary peer-specific data.
1059Other GNUnet services can use the PEERSTORE to store, retrieve and monitor data records. 1019Other GNUnet services can use the PEERSTORE to store, retrieve and monitor data records.
@@ -1077,7 +1037,7 @@ peerstore_handle = GNUNET_PEERSTORE_connect (cfg);
1077The service handle \lstinline|peerstore_handle| will be needed for all subsequent 1037The service handle \lstinline|peerstore_handle| will be needed for all subsequent
1078PEERSTORE operations. 1038PEERSTORE operations.
1079 1039
1080\subsection{Storing records} 1040@subsection Storing records}
1081 1041
1082To store a new record, use the following function: 1042To store a new record, use the following function:
1083\begin{lstlisting} 1043\begin{lstlisting}
@@ -1110,7 +1070,7 @@ void
1110GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc); 1070GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc);
1111\end{lstlisting} 1071\end{lstlisting}
1112 1072
1113\subsection{Retrieving records} 1073@subsection Retrieving records}
1114 1074
1115To retrieve stored records, use the following function: 1075To retrieve stored records, use the following function:
1116\begin{lstlisting} 1076\begin{lstlisting}
@@ -1140,7 +1100,7 @@ The \lstinline|GNUNET_PEERSTORE_iterate| function returns a handle to the iterat
1140handle can be used to cancel the iterate operation only before the callback function is called with 1100handle can be used to cancel the iterate operation only before the callback function is called with
1141a \lstinline|NULL| record. 1101a \lstinline|NULL| record.
1142 1102
1143\subsection{Monitoring records} 1103@subsection Monitoring records}
1144 1104
1145PEERSTORE offers the functionality of monitoring for new records stored under a specific key 1105PEERSTORE offers the functionality of monitoring for new records stored under a specific key
1146combination (subsystem, peerid, key). To start the monitoring, use the following function: 1106combination (subsystem, peerid, key). To start the monitoring, use the following function:
@@ -1162,7 +1122,7 @@ void
1162GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc); 1122GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc);
1163\end{lstlisting} 1123\end{lstlisting}
1164 1124
1165\subsection{Disconnecting from PEERSTORE} 1125@subsection Disconnecting from PEERSTORE}
1166 1126
1167When the connection to the PEERSTORE service is no longer needed, disconnect using the following 1127When the connection to the PEERSTORE service is no longer needed, disconnect using the following
1168function: 1128function:
@@ -1176,7 +1136,7 @@ disconnection until all store requests are received by the PEERSTORE service. Ot
1176it will disconnect immediately. 1136it will disconnect immediately.
1177 1137
1178 1138
1179\section{Using the DHT} 1139@section Using the DHT
1180 1140
1181The DHT allows to store data so other peers in the P2P network can 1141The DHT allows to store data so other peers in the P2P network can
1182access it and retrieve data stored by any peers in the network. 1142access it and retrieve data stored by any peers in the network.
@@ -1190,7 +1150,7 @@ The second parameter indicates how many requests in parallel to expect.
1190It is not a hard limit, but a good approximation will make the DHT more 1150It is not a hard limit, but a good approximation will make the DHT more
1191efficient. 1151efficient.
1192 1152
1193\subsection{Storing data in the DHT} 1153@subsection Storing data in the DHT}
1194Since the DHT is a dynamic environment (peers join and leave frequently) 1154Since the DHT is a dynamic environment (peers join and leave frequently)
1195the data that we put in the DHT does not stay there indefinitely. It is 1155the data that we put in the DHT does not stay there indefinitely. It is
1196important to ``refresh'' the data periodically by simply storing it again, 1156important to ``refresh'' the data periodically by simply storing it again,
@@ -1229,7 +1189,7 @@ over time. You might consider using the function GNUNET\_SCHEDULER\_add\_delayed
1229call GNUNET\_DHT\_put from inside a helper function.} 1189call GNUNET\_DHT\_put from inside a helper function.}
1230 1190
1231 1191
1232\subsection{Obtaining data from the DHT} 1192@subsection Obtaining data from the DHT}
1233As we saw in the previous example, the DHT works in an asynchronous mode. 1193As we saw in the previous example, the DHT works in an asynchronous mode.
1234Each request to the DHT is executed ``in the background'' and the API 1194Each request to the DHT is executed ``in the background'' and the API
1235calls return immediately. In order to receive results from the DHT, the 1195calls return immediately. In order to receive results from the DHT, the
@@ -1273,7 +1233,7 @@ get_handle =
1273the peers the requests have gone through. In order to convert a peer ID to a string, use 1233the peers the requests have gone through. In order to convert a peer ID to a string, use
1274the function GNUNET\_i2s. Pay attention to the route option parameters in both calls!} 1234the function GNUNET\_i2s. Pay attention to the route option parameters in both calls!}
1275 1235
1276\subsection{Implementing a block plugin} 1236@subsection Implementing a block plugin}
1277 1237
1278In order to store data in the DHT, it is necessary to provide a block 1238In order to store data in the DHT, it is necessary to provide a block
1279plugin. The DHT uses the block plugin to ensure that only well-formed 1239plugin. The DHT uses the block plugin to ensure that only well-formed
@@ -1417,7 +1377,7 @@ when the respective validation hooks are called.}
1417 1377
1418 1378
1419 1379
1420\subsection{Monitoring the DHT} 1380@subsection Monitoring the DHT
1421It is possible to monitor the functioning of the local DHT service. When monitoring 1381It is possible to monitor the functioning of the local DHT service. When monitoring
1422the DHT, the service will alert the monitoring program of any events, 1382the DHT, the service will alert the monitoring program of any events,
1423both started locally or received for routing from another peer. The are three different 1383both started locally or received for routing from another peer. The are three different
@@ -1484,7 +1444,7 @@ monitor_handle = GNUNET_DHT_monitor_start (dht_handle,
1484\end{lstlisting} 1444\end{lstlisting}
1485 1445
1486 1446
1487\section{Debugging with {\tt gnunet-arm}} 1447@section Debugging with gnunet-arm
1488 1448
1489Even if services are managed by {\tt gnunet-arm}, you can start them with 1449Even if services are managed by {\tt gnunet-arm}, you can start them with
1490{\tt gdb} or {\tt valgrind}. For example, you could add the following lines 1450{\tt gdb} or {\tt valgrind}. For example, you could add the following lines
@@ -1514,7 +1474,7 @@ GNUnet provides a powerful logging mechanism providing log levels \texttt{ERROR}
1514configured using the \lstinline|$GNUNET_FORCE_LOG| environmental variable. 1474configured using the \lstinline|$GNUNET_FORCE_LOG| environmental variable.
1515The \texttt{DEBUG} level is only available if \lstinline|--enable-logging=verbose| was used when 1475The \texttt{DEBUG} level is only available if \lstinline|--enable-logging=verbose| was used when
1516running \texttt{configure}. More details about logging can be found under 1476running \texttt{configure}. More details about logging can be found under
1517\url{https://gnunet.org/logging}. 1477@uref{https://gnunet.org/logging}.
1518 1478
1519You should also probably enable the creation of core files, by setting 1479You should also probably enable the creation of core files, by setting
1520{\tt ulimit}, and echo'ing 1 into {\tt /proc/sys/kernel/core\_uses\_pid}. 1480{\tt ulimit}, and echo'ing 1 into {\tt /proc/sys/kernel/core\_uses\_pid}.