diff options
author | ng0 <ng0@infotropique.org> | 2017-08-24 13:20:39 +0000 |
---|---|---|
committer | ng0 <ng0@infotropique.org> | 2017-08-24 13:20:39 +0000 |
commit | 834f1ec8209254fb66dc2908d39852761f015c8f (patch) | |
tree | e2cab1f02106812a3c46d19fb9cd775b49d0ded1 /doc | |
parent | 4c4d52c50cca5ff22ec12839ba6c629f705fef00 (diff) | |
download | gnunet-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{ | ||
20 | language=bash, | ||
21 | basicstyle=\ttfamily, | ||
22 | upquote=true, | ||
23 | columns=fullflexible, | ||
24 | literate={*}{{\char42}}1 | ||
25 | {-}{{\char45}}1 | ||
26 | } | ||
27 | 7 | ||
28 | \newcommand{\exercise}[1]{\noindent\begin{boxedminipage}{\textwidth}{\bf Exercise:} #1 \end{boxedminipage}} | 8 | @copying |
29 | 9 | Copyright @copyright{} 2001-2017 GNUnet e.V. | |
30 | \begin{document} | 10 | |
31 | 11 | Permission is granted to copy, distribute and/or modify this document | |
32 | \lstset{ % | 12 | under the terms of the GNU Free Documentation License, Version 1.3 or |
33 | language=C, % choose the language of the code | 13 | any later version published by the Free Software Foundation; with no |
34 | basicstyle=\footnotesize, % the size of the fonts that are used for the code | 14 | Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A |
35 | numbers=left, % where to put the line-numbers | 15 | copy of the license is included in the section entitled ``GNU Free |
36 | numberstyle=\footnotesize, % the size of the fonts that are used for the line-numbers | 16 | Documentation License''. |
37 | stepnumber=1, % the step between two line-numbers. If it is 1 each line will be numbered | 17 | |
38 | numbersep=5pt, % how far the line-numbers are from the code | 18 | A copy of the license is also available from the Free Software |
39 | backgroundcolor=\color{white}, % choose the background color. You must add \usepackage{color} | 19 | Foundation Web site at @url{http://www.gnu.org/licenses/fdl.html}. |
40 | showspaces=false, % show spaces adding particular underscores | 20 | |
41 | showstringspaces=false, % underline spaces within strings | 21 | Alternately, this document is also available under the General |
42 | showtabs=false, % show tabs within strings adding particular underscores | 22 | Public License, version 3 or later, as published by the Free Software |
43 | frame=single, % adds a frame around the code | 23 | Foundation. A copy of the license is included in the section entitled |
44 | tabsize=2, % sets default tabsize to 2 spaces | 24 | ``GNU General Public License''. |
45 | captionpos=b, % sets the caption-position to bottom | 25 | |
46 | breaklines=true, % sets automatic line breaking | 26 | A copy of the license is also available from the Free Software |
47 | breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace | 27 | Foundation Web site at @url{http://www.gnu.org/licenses/gpl.html}. |
48 | escapeinside={\%*}{*)} % 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 | ||
55 | Christian 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} | ||
59 | This tutorials explains how to install GNUnet on a GNU/Linux system and gives an introduction on how | 51 | This tutorials explains how to install GNUnet on a GNU/Linux system and gives an introduction on how |
60 | GNUnet can be used to develop a Peer-to-Peer application. Detailed installation instructions for | 52 | GNUnet can be used to develop a Peer-to-Peer application. Detailed installation instructions for |
61 | various operating systems and a detailed list of all dependencies can be found on our website at | 53 | various 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 | 56 | Please read this tutorial carefully since every single step is |
65 | important and do not hesitate to contact the GNUnet team if you have | 57 | important and do not hesitate to contact the GNUnet team if you have |
66 | any questions or problems! Check here how to contact the GNUnet | 58 | any questions or problems! Check here how to contact the GNUnet |
67 | team: \url{https://gnunet.org/contact_information}} | 59 | team: @uref{https://gnunet.org/contact_information} |
68 | 60 | ||
69 | 61 | ||
70 | \section{Installing GNUnet} | 62 | @section Installing GNUnet |
71 | 63 | ||
72 | First of all you have to install a current version of GNUnet. You can download a | 64 | First of all you have to install a current version of GNUnet. You can download a |
73 | tarball of a stable version from GNU FTP mirrors or obtain the latest development | 65 | tarball 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 | |||
78 | can fail. You should only use the development version if you know that you require a | 70 | can fail. You should only use the development version if you know that you require a |
79 | certain feature or a certain issue has been fixed since the last release. | 71 | certain 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 | ||
83 | You can download the latest stable version of GNUnet from GNU FTP mirrors: | 75 | You 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} | ||
87 | You should also download the signature file and verify the integrity of the tarball. | 77 | You 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} | ||
91 | To verify the signature you should first import the GPG key used to sign the tarball | 79 | To 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 |
96 | And use this key to verify the tarball's signature | 83 | And 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 |
101 | After successfully verifying the integrity you can extract the tarball using | 87 | After 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 | ||
109 | However, please note that stable versions can be very outdated, as a developer | 95 | However, please note that stable versions can be very outdated, as a developer |
110 | you are strongly encouraged to use the version from \url{https://gnunet.org/git/}. | 96 | you 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 | ||
114 | To successfully compile GNUnet you need the tools to build GNUnet and the required dependencies. | 100 | To successfully compile GNUnet you need the tools to build GNUnet and the required dependencies. |
115 | Please have a look at \url{https://gnunet.org/dependencies} for a list of required dependencies | 101 | Please have a look at @uref{https://gnunet.org/dependencies} for a list of required dependencies |
116 | and \url{https://gnunet.org/generic_installation} for specific instructions for your operating system. | 102 | and @uref{https://gnunet.org/generic_installation} for specific instructions for your operating system. |
117 | 103 | ||
118 | Please check the notes at the end of the configure process about required dependencies. | 104 | Please check the notes at the end of the configure process about required dependencies. |
119 | 105 | ||
120 | For GNUnet bootstrapping support and the http(s) plugin you should install \texttt{libgnurl}. | 106 | For GNUnet bootstrapping support and the http(s) plugin you should install libgnurl. |
121 | For the filesharing service you should install at least one of the datastore backends \texttt{mysql}, | 107 | For the filesharing service you should install at least one of the datastore backends mysql, |
122 | \texttt{sqlite} or \texttt{postgresql}. | 108 | sqlite or postgresql. |
123 | 109 | ||
124 | \subsection{Obtaining the latest version from Git} | 110 | @subsection Obtaining the latest version from Git |
125 | 111 | ||
126 | The latest development version can obtained from our Git repository. To obtain | 112 | The latest development version can obtained from our Git repository. To obtain |
127 | the code you need Git installed and checkout the repository using: | 113 | the 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 |
132 | After cloning the repository you have to execute | 117 | After 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 | ||
139 | The remainder of this tutorial assumes that you have Git Master checked out. | 123 | The 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} | 127 | First, 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} | ||
129 | and libgcrypt version 1.7.6 @uref{ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.7.6.tar.bz2}. | ||
143 | 130 | ||
144 | First, you need to install at least {\tt libgnupgerror} version | 131 | @example |
145 | 1.27\footnote{\url{ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.27.tar.bz2}} | ||
146 | and {\tt libgcrypt} version | ||
147 | 1.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 |
170 | Assuming all dependencies are installed, the following commands will | 150 | Assuming all dependencies are installed, the following commands will |
171 | compile and install GNUnet in your home directory. You can specify the | 151 | compile and install GNUnet in your home directory. You can specify the |
172 | directory where GNUnet will be installed by changing the | 152 | directory where GNUnet will be installed by changing the |
173 | \lstinline|--prefix| value when calling \lstinline|./configure|. If | 153 | --prefix value when calling ./configure. If |
174 | you do not specifiy a prefix, GNUnet is installed in the directory | 154 | you 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 |
176 | to enable verbose logging by adding | 156 | to 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 | ||
186 | After installing GNUnet you have to add your GNUnet installation to your path | 164 | After installing GNUnet you have to add your GNUnet installation to your path |
187 | environmental variable. In addition you have to create the \lstinline|.config| | 165 | environmental variable. In addition you have to create the .config |
188 | directory in your home directory where GNUnet stores its data and an empty | 166 | directory in your home directory where GNUnet stores its data and an empty |
189 | GNUnet configuration file: | 167 | GNUnet 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 | ||
202 | You should check your installation to ensure that installing GNUnet | 178 | You should check your installation to ensure that installing GNUnet |
203 | was successful up to this point. You should be able to access GNUnet's | 179 | was successful up to this point. You should be able to access GNUnet's |
204 | binaries and run GNUnet's self check. | 180 | binaries 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 |
209 | should return \lstinline|$PREFIX/bin/gnunet-arm|. It should be | 184 | should return $PREFIX/bin/gnunet-arm. It should be |
210 | located in your GNUnet installation and the output should not be | 185 | located in your GNUnet installation and the output should not be |
211 | empty. If you see an output like: | 186 | empty. 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} | 190 | check your PATH variable to ensure GNUnet's bin directory is included. |
217 | check your {\tt PATH} variable to ensure GNUnet's {\tt bin} directory is included. | ||
218 | 191 | ||
219 | GNUnet provides tests for all of its subcomponents. Run | 192 | GNUnet 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 |
224 | to execute tests for all components. {\tt make check} traverses all subdirectories in {\tt src}. | 196 | to execute tests for all components. make check traverses all subdirectories in src. |
225 | For every subdirectory you should get a message like this: | 197 | For every subdirectory you should get a message like this: |
226 | 198 | ||
227 | \begin{verbatim} | 199 | @example |
228 | make[2]: Entering directory `/home/$USER/gnunet/contrib' | 200 | make[2]: Entering directory `/home/$USER/gnunet/contrib' |
229 | PASS: test_gnunet_prefix | 201 | PASS: test_gnunet_prefix |
230 | ============= | 202 | ============= |
231 | 1 test passed | 203 | 1 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 | ||
238 | GNUnet is organized in layers and services. Each service is composed of a | 210 | GNUnet is organized in layers and services. Each service is composed of a |
239 | main service implementation and a client library for other programs to use | 211 | main 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 | |||
273 | the programmer. | 245 | the 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 | ||
280 | First 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. | 252 | First 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 | ||
282 | Since we want to start additional peers later, we need | 254 | Since we want to start additional peers later, we need |
283 | some modifications from the default configuration. We need to create a separate service home and a file containing our modifications for this peer: | 255 | some 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 | ||
290 | Now add the following lines to peer1.conf to use this directory. For | 261 | Now add the following lines to peer1.conf to use this directory. For |
291 | simplified usage we want to prevent the peer to connect to the GNUnet | 262 | simplified usage we want to prevent the peer to connect to the GNUnet |
292 | network since this could lead to confusing output. This modifications | 263 | network since this could lead to confusing output. This modifications |
293 | will replace the default settings: | 264 | will replace the default settings: |
294 | \begin{verbatim} | 265 | @example |
295 | [PATHS] | 266 | [PATHS] |
296 | GNUNET_HOME = ~/gnunet1/ # Use this directory to store GNUnet data | 267 | GNUNET_HOME = ~/gnunet1/ # Use this directory to store GNUnet data |
297 | [hostlist] | 268 | [hostlist] |
298 | SERVERS = # prevent bootstrapping | 269 | SERVERS = # prevent bootstrapping |
299 | \end{verbatim} | 270 | @end example |
300 | 271 | ||
301 | 272 | @subsection Start a peer | |
302 | \subsection{Start a peer} | 273 | Each GNUnet instance (called peer) has an identity (peer ID) based on a |
303 | Each GNUnet instance (called peer) has an identity (\textit{peer ID}) based on a | ||
304 | cryptographic public private key pair. The peer ID is the printable hash of the | 274 | cryptographic public private key pair. The peer ID is the printable hash of the |
305 | public key. | 275 | public key. |
306 | 276 | ||
307 | GNUnet services are controlled by a master service the so called \textit{Automatic Restart Manager} (ARM). | 277 | GNUnet services are controlled by a master service the so called Automatic Restart Manager (ARM). |
308 | ARM starts, stops and even restarts services automatically or on demand when a client connects. | 278 | ARM starts, stops and even restarts services automatically or on demand when a client connects. |
309 | You interact with the ARM service using the \lstinline|gnunet-arm| tool. | 279 | You interact with the ARM service using the gnunet-arm tool. |
310 | GNUnet can then be started with \lstinline|gnunet-arm -s| and stopped with | 280 | GNUnet can then be started with gnunet-arm -s and stopped with |
311 | \lstinline|gnunet-arm -e|. An additional service not automatically started | 281 | gnunet-arm -e. An additional service not automatically started |
312 | can be started using \lstinline|gnunet-arm -i <service name>| and stopped | 282 | can be started using gnunet-arm -i <service name> and stopped |
313 | using \lstinline|gnunet-arm -k <servicename>|. | 283 | using gnunet-arm -k <servicename>. |
314 | 284 | ||
315 | Once you have started your peer, you can use many other GNUnet commands | 285 | Once you have started your peer, you can use many other GNUnet commands |
316 | to interact with it. For example, you can run: | 286 | to 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 |
321 | to obtain the public key of your peer. | 290 | to obtain the public key of your peer. |
322 | You should see an output containing the peer ID similar to: | 291 | You should see an output containing the peer ID similar to: |
323 | \lstset{language=bash} | 292 | @example |
324 | \begin{lstlisting} | ||
325 | I am peer `0PA02UVRKQTS2C .. JL5Q78F6H0B1ACPV1CJI59MEQUMQCC5G'. | 293 | I 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 | ||
331 | In this section, we will monitor the behaviour of our peer's DHT service with respect to a | 299 | In this section, we will monitor the behaviour of our peer's DHT service with respect to a |
332 | specific key. First we will start GNUnet and then start the DHT service and use the DHT monitor tool | 300 | specific key. First we will start GNUnet and then start the DHT service and use the DHT monitor tool |
333 | to monitor the PUT and GET commands we issue ussing the \lstinline|gnunet-dht-put| and | 301 | to 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 | 302 | gnunet-dht-get commands. Using the ``monitor'' line given below, you can observe the behavior of |
335 | your own peer's DHT with respect to the specified KEY: | 303 | your 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 |
344 | Now open a separate terminal and change again to the \lstinline|gnunet/src/dht| directory: | 311 | Now 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 | ||
358 | This section describes how to start two peers on the same machine by hand. | 323 | This section describes how to start two peers on the same machine by hand. |
359 | The process is rather painful, but the description is somewhat instructive. | 324 | The process is rather painful, but the description is somewhat instructive. |
360 | In practice, you might prefer the automated method described in | 325 | In practice, you might prefer the automated method described in |
361 | Section~\ref{sec:testbed}. | 326 | Section sec:testbed. |
362 | 327 | ||
363 | \subsubsection{Setup a second peer} | 328 | @subsubsection Setup a second peer |
364 | We will now start a second peer on your machine. | 329 | We will now start a second peer on your machine. |
365 | For the second peer, you will need to manually create a modified | 330 | For the second peer, you will need to manually create a modified |
366 | configuration file to avoid conflicts with ports and directories. | 331 | configuration file to avoid conflicts with ports and directories. |
367 | A peers configuration file is by default located in {\tt ~/.gnunet/gnunet.conf}. | 332 | A peers configuration file is by default located in ~/.gnunet/gnunet.conf. |
368 | This file is typically very short or even empty as only the differences to the | 333 | This file is typically very short or even empty as only the differences to the |
369 | defaults need to be specified. The defaults are located in | 334 | defaults need to be specified. The defaults are located in |
370 | many files in the {\tt \$PREFIX/share/gnunet/config.d} directory. | 335 | many files in the $PREFIX/share/gnunet/config.d directory. |
371 | 336 | ||
372 | To configure the second peer, use the files {\tt | 337 | To 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 |
374 | configuration file: | 339 | configuration 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 |
381 | Now you have to edit {\tt peer2.conf} and change: | 343 | Now 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} |
391 | to a fresh, unique value. Make sure that the \texttt{PORT} numbers stay | 353 | to a fresh, unique value. Make sure that the PORT numbers stay |
392 | below 65536. From now on, whenever you interact with the second | 354 | below 65536. From now on, whenever you interact with the second |
393 | peer, you need to specify {\tt -c peer2.conf} as an additional | 355 | peer, you need to specify -c peer2.conf as an additional |
394 | command line argument. | 356 | command line argument. |
395 | 357 | ||
396 | Now, generate the 2nd peer's private key: | 358 | Now, 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 | ||
404 | This may take a while, generate entropy using your keyboard or mouse | 364 | This may take a while, generate entropy using your keyboard or mouse |
405 | as needed. Also, make sure the output is different from the {\tt | 365 | as needed. Also, make sure the output is different from the |
406 | gnunet-peerinfo} output for the first peer (otherwise you made an | 366 | gnunet-peerinfo output for the first peer (otherwise you made an |
407 | error in the configuration). | 367 | error 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 | ||
411 | Then, you can start a second peer using: | 371 | Then, you can start a second peer using: |
412 | \lstset{language=bash} | 372 | \lstset{language=bash} |
@@ -433,11 +393,11 @@ OPTIONS = -p | |||
433 | 393 | ||
434 | Then change {\tt peer2.conf} and replace the ``\texttt{SERVERS}'' line in the ``\texttt{[hostlist]}'' section with | 394 | Then 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 | ||
442 | Note that if you start your peers without changing these settings, they | 402 | Note that if you start your peers without changing these settings, they |
443 | will use the ``global'' hostlist servers of the GNUnet P2P network and | 403 | will 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 | |||
446 | likely observe traffic and behaviors that are not explicitly controlled | 406 | likely observe traffic and behaviors that are not explicitly controlled |
447 | by you. | 407 | by you. |
448 | 408 | ||
449 | \subsubsection{How to connect manually} | 409 | @subsubsection How to connect manually |
450 | 410 | ||
451 | If you want to use the \texttt{peerinfo} tool to connect your peers, you should: | 411 | If 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 | ||
460 | Check that they are connected using {\tt gnunet-core -c peer1.conf}, which should give you the other peer's | 420 | Check that they are connected using {\tt gnunet-core -c peer1.conf}, which should give you the other peer's |
461 | peer identity: | 421 | peer identity: |
462 | \lstset{language=bash} | 422 | @example |
463 | \begin{lstlisting} | ||
464 | $ gnunet-core -c peer1.conf | 423 | $ gnunet-core -c peer1.conf |
465 | Peer `9TVUCS8P5A7ILLBGO6 [...shortened...] 1KNBJ4NGCHP3JPVULDG' | 424 | Peer `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 | ||
470 | GNUnet's testbed service is used for testing scenarios where a number of peers | 430 | GNUnet's testbed service is used for testing scenarios where a number of peers |
471 | are to be started. The testbed can manage peers on a single host or on multiple | 431 | are 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} |
496 | The source code for the above listing can be found at | 456 | The 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} |
498 | or in the {\tt doc/} folder of your repository check-out. | 458 | or in the {\tt doc/} folder of your repository check-out. |
499 | After installing GNUnet, the above source code can be compiled as: | 459 | After 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} |
560 | To develop a new peer-to-peer application or to extend GNUnet we provide | 520 | To develop a new peer-to-peer application or to extend GNUnet we provide |
561 | a template build system for writing GNUnet extensions in C. It can be | 521 | a template build system for writing GNUnet extensions in C. It can be |
562 | obtained as follows: | 522 | obtained 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 | ||
608 | The first step for writing any extension with a new service is to | 568 | The first step for writing any extension with a new service is to |
609 | ensure that the {\tt ext.conf.in} file contains entries for the | 569 | ensure 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 | |||
614 | services name, you have to modify the \texttt{AC\_OUTPUT} section in {\tt configure.ac} | 574 | services name, you have to modify the \texttt{AC\_OUTPUT} section in {\tt configure.ac} |
615 | in the \texttt{gnunet-ext} root. | 575 | in the \texttt{gnunet-ext} root. |
616 | 576 | ||
617 | \section{Writing a Client Application} | 577 | @section Writing a Client Application |
618 | 578 | ||
619 | When writing any client application (for example, a command-line | 579 | When writing any client application (for example, a command-line |
620 | tool), the basic structure is to start with the {\tt | 580 | tool), 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 | ||
661 | Options can then be added easily by adding global variables and | 621 | Options can then be added easily by adding global variables and |
662 | expanding the {\tt options} array. For example, the following would | 622 | expanding 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 |
703 | of {\tt run}. What happens if the user gives invalid arguments?} | 663 | of {\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 | ||
707 | The first and most important step in writing a client library is to | 667 | The first and most important step in writing a client library is to |
708 | decide on an API for the library. Typical API calls include | 668 | decide 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 | ||
853 | Given a client library, all it takes to access a service now is to | 813 | Given a client library, all it takes to access a service now is to |
854 | combine calls to the client library with parsing command-line | 814 | combine 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 | ||
866 | Before you can test the client you've written so far, you'll need to also | 826 | Before you can test the client you've written so far, you'll need to also |
867 | implement the corresponding service. | 827 | implement the corresponding service. |
868 | 828 | ||
869 | 829 | ||
870 | \subsection{Code Placement} | 830 | @subsection Code Placement} |
871 | 831 | ||
872 | New services are placed in their own subdirectory under {\tt gnunet/src}. | 832 | New services are placed in their own subdirectory under {\tt gnunet/src}. |
873 | This subdirectory should contain the API implementation file {\tt SERVICE\_api.c}, | 833 | This 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 |
877 | and configuration files. | 837 | and configuration files. |
878 | 838 | ||
879 | \subsection{Starting a Service} | 839 | @subsection Starting a Service} |
880 | 840 | ||
881 | The key API definition for creating a service is the {\tt GNUNET\_SERVICE\_MAIN} macro: | 841 | The 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 | ||
954 | FIXME: This section still needs to be updated to the lastest API! | 914 | FIXME: 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 | ||
977 | Before any traffic with a different peer can be exchanged, the peer must be | 937 | Before any traffic with a different peer can be exchanged, the peer must be |
978 | known to the service. This is notified by the \texttt{CORE} {\tt connects} callback, | 938 | known to the service. This is notified by the \texttt{CORE} {\tt connects} callback, |
@@ -997,7 +957,7 @@ the respective peer. | |||
997 | start (and connect) two peers and print a message once your connect | 957 | start (and connect) two peers and print a message once your connect |
998 | callback is invoked.} | 958 | callback is invoked.} |
999 | 959 | ||
1000 | \subsection{Receiving P2P Messages} | 960 | @subsection Receiving P2P Messages} |
1001 | 961 | ||
1002 | To receive messages from \texttt{CORE}, you pass the desired | 962 | To 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 | |||
1014 | the two peers are connected? Why?} | 974 | the two peers are connected? Why?} |
1015 | 975 | ||
1016 | 976 | ||
1017 | \subsection{Sending P2P Messages} | 977 | @subsection Sending P2P Messages} |
1018 | 978 | ||
1019 | You can transmit messages to other peers using the {\it mq} you were | 979 | You can transmit messages to other peers using the {\it mq} you were |
1020 | given during the {\tt connect} callback. Note that the {\it mq} | 980 | given 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 | |||
1032 | you stop the peer that is receiving your messages?} | 992 | you 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 | ||
1037 | If a message handler returns {\tt GNUNET\_SYSERR}, the remote peer shuts down or | 997 | If a message handler returns {\tt GNUNET\_SYSERR}, the remote peer shuts down or |
1038 | there is an unrecoverable network disconnection, CORE notifies the service that | 998 | there 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 | ||
1058 | GNUnet's PEERSTORE service offers a persistorage for arbitrary peer-specific data. | 1018 | GNUnet's PEERSTORE service offers a persistorage for arbitrary peer-specific data. |
1059 | Other GNUnet services can use the PEERSTORE to store, retrieve and monitor data records. | 1019 | Other GNUnet services can use the PEERSTORE to store, retrieve and monitor data records. |
@@ -1077,7 +1037,7 @@ peerstore_handle = GNUNET_PEERSTORE_connect (cfg); | |||
1077 | The service handle \lstinline|peerstore_handle| will be needed for all subsequent | 1037 | The service handle \lstinline|peerstore_handle| will be needed for all subsequent |
1078 | PEERSTORE operations. | 1038 | PEERSTORE operations. |
1079 | 1039 | ||
1080 | \subsection{Storing records} | 1040 | @subsection Storing records} |
1081 | 1041 | ||
1082 | To store a new record, use the following function: | 1042 | To store a new record, use the following function: |
1083 | \begin{lstlisting} | 1043 | \begin{lstlisting} |
@@ -1110,7 +1070,7 @@ void | |||
1110 | GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc); | 1070 | GNUNET_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 | ||
1115 | To retrieve stored records, use the following function: | 1075 | To 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 | |||
1140 | handle can be used to cancel the iterate operation only before the callback function is called with | 1100 | handle can be used to cancel the iterate operation only before the callback function is called with |
1141 | a \lstinline|NULL| record. | 1101 | a \lstinline|NULL| record. |
1142 | 1102 | ||
1143 | \subsection{Monitoring records} | 1103 | @subsection Monitoring records} |
1144 | 1104 | ||
1145 | PEERSTORE offers the functionality of monitoring for new records stored under a specific key | 1105 | PEERSTORE offers the functionality of monitoring for new records stored under a specific key |
1146 | combination (subsystem, peerid, key). To start the monitoring, use the following function: | 1106 | combination (subsystem, peerid, key). To start the monitoring, use the following function: |
@@ -1162,7 +1122,7 @@ void | |||
1162 | GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc); | 1122 | GNUNET_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 | ||
1167 | When the connection to the PEERSTORE service is no longer needed, disconnect using the following | 1127 | When the connection to the PEERSTORE service is no longer needed, disconnect using the following |
1168 | function: | 1128 | function: |
@@ -1176,7 +1136,7 @@ disconnection until all store requests are received by the PEERSTORE service. Ot | |||
1176 | it will disconnect immediately. | 1136 | it will disconnect immediately. |
1177 | 1137 | ||
1178 | 1138 | ||
1179 | \section{Using the DHT} | 1139 | @section Using the DHT |
1180 | 1140 | ||
1181 | The DHT allows to store data so other peers in the P2P network can | 1141 | The DHT allows to store data so other peers in the P2P network can |
1182 | access it and retrieve data stored by any peers in the network. | 1142 | access 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. | |||
1190 | It is not a hard limit, but a good approximation will make the DHT more | 1150 | It is not a hard limit, but a good approximation will make the DHT more |
1191 | efficient. | 1151 | efficient. |
1192 | 1152 | ||
1193 | \subsection{Storing data in the DHT} | 1153 | @subsection Storing data in the DHT} |
1194 | Since the DHT is a dynamic environment (peers join and leave frequently) | 1154 | Since the DHT is a dynamic environment (peers join and leave frequently) |
1195 | the data that we put in the DHT does not stay there indefinitely. It is | 1155 | the data that we put in the DHT does not stay there indefinitely. It is |
1196 | important to ``refresh'' the data periodically by simply storing it again, | 1156 | important 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 | |||
1229 | call GNUNET\_DHT\_put from inside a helper function.} | 1189 | call 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} |
1233 | As we saw in the previous example, the DHT works in an asynchronous mode. | 1193 | As we saw in the previous example, the DHT works in an asynchronous mode. |
1234 | Each request to the DHT is executed ``in the background'' and the API | 1194 | Each request to the DHT is executed ``in the background'' and the API |
1235 | calls return immediately. In order to receive results from the DHT, the | 1195 | calls return immediately. In order to receive results from the DHT, the |
@@ -1273,7 +1233,7 @@ get_handle = | |||
1273 | the peers the requests have gone through. In order to convert a peer ID to a string, use | 1233 | the peers the requests have gone through. In order to convert a peer ID to a string, use |
1274 | the function GNUNET\_i2s. Pay attention to the route option parameters in both calls!} | 1234 | the 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 | ||
1278 | In order to store data in the DHT, it is necessary to provide a block | 1238 | In order to store data in the DHT, it is necessary to provide a block |
1279 | plugin. The DHT uses the block plugin to ensure that only well-formed | 1239 | plugin. 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 |
1421 | It is possible to monitor the functioning of the local DHT service. When monitoring | 1381 | It is possible to monitor the functioning of the local DHT service. When monitoring |
1422 | the DHT, the service will alert the monitoring program of any events, | 1382 | the DHT, the service will alert the monitoring program of any events, |
1423 | both started locally or received for routing from another peer. The are three different | 1383 | both 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 | ||
1489 | Even if services are managed by {\tt gnunet-arm}, you can start them with | 1449 | Even 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} | |||
1514 | configured using the \lstinline|$GNUNET_FORCE_LOG| environmental variable. | 1474 | configured using the \lstinline|$GNUNET_FORCE_LOG| environmental variable. |
1515 | The \texttt{DEBUG} level is only available if \lstinline|--enable-logging=verbose| was used when | 1475 | The \texttt{DEBUG} level is only available if \lstinline|--enable-logging=verbose| was used when |
1516 | running \texttt{configure}. More details about logging can be found under | 1476 | running \texttt{configure}. More details about logging can be found under |
1517 | \url{https://gnunet.org/logging}. | 1477 | @uref{https://gnunet.org/logging}. |
1518 | 1478 | ||
1519 | You should also probably enable the creation of core files, by setting | 1479 | You 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}. |