|
1 <html> |
|
2 <head> |
|
3 <title> DTN2 Manual: Starting dtnd and sending a ping </title> |
|
4 <link rel="stylesheet" type="text/css" href="manual.css" /> |
|
5 </head> |
|
6 <body> |
|
7 <h1>Starting dtnd and sending a ping |
|
8 </h1> |
|
9 |
|
10 <p> |
|
11 In this tutorial, you'll learn how to configure and start an instance |
|
12 of dtnd, then make it answer a ping. |
|
13 |
|
14 <h2> Configuration </h2> |
|
15 |
|
16 <p> |
|
17 In this section, we'll prepare an appropriate <tt>dtn.conf</tt> |
|
18 file for our instance of dtnd. |
|
19 |
|
20 <h3> Directories </h3> |
|
21 |
|
22 <p> |
|
23 First, you need to choose a directory that will hold the files dtnd |
|
24 needs. For the purposes of this tutorial, we'll assume your username |
|
25 is <tt>fred</tt> and that you want dtnd to write into |
|
26 <tt>/home/fred/dtn</tt>. |
|
27 |
|
28 <p> Make the <tt>/home/fred/dtn</tt> directory, then copy the example |
|
29 <tt>dtn.conf</tt> file from <tt>DTN2/daemon/dtn.conf</tt> to |
|
30 <tt>/home/fred/dtn/dtn.conf</tt>. Edit the <tt>dtn.conf</tt> file. For |
|
31 this tutorial, we'll use the simplest database to configure, |
|
32 BerkeleyDB. Leave the <i>storage set type berkeleydb</i> line alone. |
|
33 Set the <i>payloaddir</i> to <tt>/home/fred/dtn/bundles</tt> and set |
|
34 the <i>dbdir</i> to <tt>/home/fred/dtn/db</tt>. |
|
35 |
|
36 <p> The <i>dbdir</i> directory is where persistent objects that DTN2 uses to |
|
37 manage its internal state live. This database will remain fairly small. It |
|
38 needs to be preserved between invocations of the DTN2 daemon, because |
|
39 the data in it lets DTN2 know the status of registrations with |
|
40 clients, and bundles which are in flight in the network. One of the |
|
41 "disruptions" that a DTN is tolerant of is the failure of a node. |
|
42 Using the data in the database, a new DTN2 daemon can carry on the |
|
43 work the previous one was doing. But note that if the contents of the |
|
44 database are lost, it is as if this node never existed, and there will |
|
45 be repercussions in the DTN (like retransmissions of bundles) as a |
|
46 result. |
|
47 |
|
48 <p> The <i>payload</i> directory is where bundles which are in-flight |
|
49 live. In general, the bundles in this directory are ones which this |
|
50 DTN2 instance has custody of. That means that if they disappear out of |
|
51 this directory, they will be lost forever, since there are no other |
|
52 authoritative copies of the bundle in the network. DTN2 and the DTN |
|
53 protocols are designed to maintain the files in this directory without |
|
54 leaving old ones lying around. If you see an old file there, it's |
|
55 likely due to a bug. Please help us get to the bottom of what's causing it. |
|
56 Unlike packets, which are typically quite small (from 50 to 64,000 |
|
57 bytes), a single bundle can be very large (over 2 gigabytes). |
|
58 On a server dedicated to |
|
59 running DTN2, your payload directory should have access to the largest |
|
60 partition on your server. As an analogy, on a mail server the mail |
|
61 spool is usually on /var, and has access to the majority of the extra |
|
62 disk space on a machine. The same should be true for the payload |
|
63 directory. |
|
64 |
|
65 <h3>Using TCL in the Config File</h3> |
|
66 |
|
67 <p> You don't need to make any changes in the <i>local_eid</i>, but |
|
68 scroll down and take a look at it anyway. In the defualt |
|
69 configuration, it looks like this: <i>route local_eid |
|
70 "dtn://[info hostname].dtn"</i>. Note the square |
|
71 brackets. To understand what's happening here, you need to know that |
|
72 this configuration file is not simply a file of settings for dtnd, but |
|
73 an actual <a href="http://www.tcl.tk">TCL</a> script. It is interpreted by |
|
74 the TCL interpreter that is built in to dtnd. In TCL, square brackets |
|
75 mean "interpret this first, and replace the brackets with the result". |
|
76 So before dtnd sees a <i>route local_eid ...</i> command, TCL |
|
77 processes the <i>info hostname</i> command. As you might be able to |
|
78 guess by now, the entire line results in the <i>local_eid</i> being |
|
79 set to a custom string based on your hostname. |
|
80 |
|
81 <p> This is the only place in this particular configuration file where |
|
82 we will use TCL features like the square brackets. However, you should |
|
83 remember that all the power of TCL is available to you as you write |
|
84 your own configuration files, should you desire it. For an example of |
|
85 this, see <a href="configuration.html#rotate">the example showing how |
|
86 to rotate logs</a> from within dtnd. |
|
87 |
|
88 <p> So the local EID is set, but what is it? From the |
|
89 <a href="arch.html">Architecture</a> section, you should recall |
|
90 that nodes in the DTN are identified by EIDs. The local EID |
|
91 is simply the way our DTN node will refer to itself. Without this |
|
92 setting, it would not recognize bundles intended for it, and might |
|
93 just pass them on ad infinitum! People who have configured Internet |
|
94 email systems like Postfix or Sendmail might recognize this setting, |
|
95 as mail routers need to know their own name for the same reason. |
|
96 |
|
97 <p> |
|
98 And EID is a string that is used throughout the DTN to identify |
|
99 an endpoint. That leaves you considerable latitude on how to set |
|
100 it. We recommend for now that you set it according to the |
|
101 machine name where the DTN node is running, as the example does. |
|
102 |
|
103 <p> |
|
104 At this time, one dtnd can have only one local EID. This |
|
105 limitation might disappear in future versions if it proves to be a |
|
106 problem. |
|
107 |
|
108 <h3> Interfaces </h3> |
|
109 |
|
110 <p> |
|
111 Take a look at the <i>interface add</i> commands a few lines |
|
112 down. The command <i>interface add tcp0 tcp</i> adds a |
|
113 TCP convergence layer named <i>tcp0</i> to the server. This |
|
114 means that the daemon will start listening on port 4556 for incoming |
|
115 connections from other servers in the DTN. |
|
116 |
|
117 <p>Usually DTN nodes that are communicating via |
|
118 TCP listen on port 4556, based on the IANA port assignment. |
|
119 If you have another application on the same server listening on |
|
120 port 4556, you'll need to choose a different port for your dtnd |
|
121 to use. |
|
122 |
|
123 <p> The <i>interface add</i> command can take convergence layer |
|
124 specific arguments to customize the behavior of the interface. |
|
125 For the purposes of this tutorial, |
|
126 we will be using the defaults. For more information on these arguments |
|
127 see the reference pages on the <a href="configuration.html#cls">various |
|
128 convergence layers</a>. |
|
129 |
|
130 <p> In some security contexts, and with some virtual interface |
|
131 configurations, it is desirable to have dtnd listen only on a certain |
|
132 interface, for instance "listen to internal connections only". |
|
133 You can do this by adding <i>local_addr=desired-ip</i> to the end of |
|
134 the <i>interface add</i> command. The default <i>local_addr</i> |
|
135 is 0.0.0.0, meaning "listen on all interfaces". |
|
136 For this tutorial, we will allow dtnd to listen on all |
|
137 interfaces, so leave the <i>interface add</i> command as it is. |
|
138 |
|
139 <p> Note that we are adding an interface of type TCP. There are other |
|
140 ways that DTN nodes can communicate, including via UDP, raw |
|
141 ethernet frames, and across a filesystem |
|
142 (where some external activity, like a messenger with a USB keychain |
|
143 drive, is responsible for moving the files). A server that is |
|
144 using multiple convergence layers |
|
145 has other <i>interface add</i> lines in the configuration file. |
|
146 |
|
147 <p> |
|
148 In fact, below the <i>interface add</i> line for the TCP convergence |
|
149 layer is one for the UDP covergence layer. Because we are setting up |
|
150 a standalone server in this tutorial, neither <i>udp0</i> nor |
|
151 <i>tcp0</i> will end up getting used to move bundles at this point. |
|
152 |
|
153 <h3> Links and Routes </h3> |
|
154 |
|
155 <p> |
|
156 Because in this tutorial, we are setting up a standalone dtnd, |
|
157 we will not need any <tt>link</tt> or <tt>route</tt> statements. |
|
158 You'll end up with a Disruption Tolerant Network made up of |
|
159 only one daemon. Not much to brag about, but out of simple |
|
160 beginnings come great things! |
|
161 |
|
162 <h2> Initializing the Database </h2> |
|
163 |
|
164 <p> |
|
165 Before dtnd can use the database to keep track of runtime state, |
|
166 it needs to initialize it. This is a simple matter of starting |
|
167 the daemon once with the <tt>--init-db</tt> argument. You'll |
|
168 also want to give it the location of the configuration file, so |
|
169 that dtnd can find the correct database directory. Put that together |
|
170 and you have: |
|
171 |
|
172 <blockquote><pre>$ <font color=blue>daemon/dtnd -c /home/fred/dtn/dtn.conf --init-db </font> |
|
173 [1178218919.248562 /dtnd notice] random seed is 248552 |
|
174 [1178218919.248660 /dtnd notice] DTN daemon starting up... (pid 3268) |
|
175 [1178218919.263195 /dtnd notice] initializing persistent data store |
|
176 [1178218919.263343 /dtn/storage notice] creating new database directory /var/tmp/dtn/db |
|
177 [1178218921.130742 /dtnd notice] closing persistent data store |
|
178 </pre> |
|
179 </blockquote> |
|
180 |
|
181 <h2> Running the Daemon </h2> |
|
182 |
|
183 <p> |
|
184 For now, you start dtnd from the commandline, like any other |
|
185 Unix command. By default, the TCL interpreter takes input from |
|
186 standard in, so you will need to leave it running in the foreground. While |
|
187 you are learning the ins and outs of dtnd, it is best to run it |
|
188 this way, so that you can interact with it. Use the <tt>-c</tt> |
|
189 argument to tell it where to find the configuration file. |
|
190 For information on other arguments you can give dtnd, see |
|
191 the <a href="man/dtnd.html">dtnd man page</a>. |
|
192 |
|
193 <p> |
|
194 Once you start dtnd with a command like <tt>DTN2/daemon/dtnd -c |
|
195 /home/fred/dtn/dtn.conf</tt>, it will put out some messages, then |
|
196 give you the <tt>dtn%</tt> prompt. This means the server is up |
|
197 and running, awaiting commands from you. Things you type at the |
|
198 prompt are interpreted by the same TCL interpreter that just parsed |
|
199 the configuration file. In a way, you can consider the configuration |
|
200 file a list of commands that will be issued for you |
|
201 each time you start the server. |
|
202 |
|
203 <p> |
|
204 Here's an example of starting up the server: |
|
205 |
|
206 <blockquote><pre>$ <font color=blue>daemon/dtnd -c /home/fred/dtn/dtn.conf</font> |
|
207 [1178218965.919630 /dtnd notice] random seed is 919621 |
|
208 [1178218965.919725 /dtnd notice] DTN daemon starting up... (pid 3271) |
|
209 [1178218965.943359 /dtn/bundle/daemon notice] loading bundles from data store |
|
210 zabar dtn% |
|
211 </pre></blockquote> |
|
212 |
|
213 <p> |
|
214 You get a bit more info if you start up with the '-l info argument': |
|
215 |
|
216 <blockquote><pre>$ <font color=blue>daemon/dtnd -c /home/fred/dtn/dtn.conf -l info</font> |
|
217 [1178219015.034268 /dtnd notice] random seed is 34259 |
|
218 [1178219015.034621 /dtnd notice] DTN daemon starting up... (pid 3272) |
|
219 [1178219015.046752 /dtnd info] parsing configuration file daemon/dtn.conf... |
|
220 [1178219015.047142 /dtnd info] dtnd parsing configuration... |
|
221 [1178219015.047716 /dtn/interface/table info] adding interface tcp0 (tcp) |
|
222 [1178219015.048082 /dtn/interface/table info] adding interface udp0 (udp) |
|
223 [1178219015.048606 /dtnd info] dtnd configuration parsing complete |
|
224 [1178219015.048853 /dtn/storage info] initializing db name=DTN (not shared), dir=/var/tmp/dtn/db |
|
225 [1178219015.054478 /dtn/storage info] datastore /var/tmp/dtn/db was cleanly shut down |
|
226 [1178219015.057959 /dtn/bundle/daemon info] REGISTRATION_ADDED 0 dtn://zabar.research.intel-research.net.dtn |
|
227 [1178219015.058144 /dtn/bundle/daemon info] REGISTRATION_ADDED 2 dtn://zabar.research.intel-research.net.dtn/ping |
|
228 [1178219015.058309 /dtn/bundle/daemon notice] loading bundles from data store |
|
229 [1178219015.557741 /dtnd info] starting console on 127.0.0.1:5050 |
|
230 zabar dtn% |
|
231 </pre></blockquote> |
|
232 |
|
233 <p> |
|
234 Use the online help system to learn what you can do from here. Type |
|
235 <b>help</b>. For help on a specific command, type <b>help |
|
236 <i>command</i></b>. For now, though, you don't need to use any |
|
237 commands. Just let dtnd run in its own window. When we start talking |
|
238 to dtnd with an application you'll see log messages in the window |
|
239 where dtnd is running. |
|
240 |
|
241 <h2> Pinging the daemon </h2> |
|
242 |
|
243 <p> |
|
244 A Disruption Tolerant Network is made up of a number of |
|
245 servers whose job is to move bundles through the system. |
|
246 But where do the bundles come from? They come from applications. |
|
247 In the future, you can expect to see applications to move |
|
248 scientific data, web pages, e-mail, and other data that |
|
249 needs to traverse a network region prone to disruption. |
|
250 For now though, the best way to see your new DTN (consisting |
|
251 of just your one server) operate is to send a ping bundle into |
|
252 to it, and see what comes back out! |
|
253 |
|
254 <p> |
|
255 To ping your server, run the <tt>dtnping</tt> command. It lives |
|
256 in the <tt>DTN2/apps/dtnping</tt> directory. You'll need to give it |
|
257 one argument, which is the EID address of the endpoint that you |
|
258 want to ping. Since there is only one server in your DTN, the |
|
259 choice should be simple. You need to use the local EID |
|
260 that you set in the configuration file. If you'd like to |
|
261 check what dtnd thinks it's local EID name is, use the |
|
262 <tt>registration list</tt> command in the window where dtnd is running. |
|
263 The first registration is always the server registering it's own |
|
264 EID with itself, so that it can handle administrative bundles, like |
|
265 the ping bundle we are about to send. |
|
266 |
|
267 <p> |
|
268 Alternatively, <tt>dtnping</tt> contains a convenience shortcut |
|
269 whereby the string 'localhost' is interpreted as the local EID |
|
270 of the daemon. |
|
271 |
|
272 <p> |
|
273 Here's an example of how to ping a server who's local EID |
|
274 is <i>dtn://dtn-a.dtn</i>: |
|
275 |
|
276 <blockquote><pre>$ <font color=blue>./dtnping localhost</font> |
|
277 source_eid [dtn://zabar.research.intel-research.net.dtn/ping.3310] |
|
278 dtn_register succeeded, regid 10 |
|
279 PING [dtn://zabar.research.intel-research.net.dtn/ping]... |
|
280 20 bytes from [dtn://zabar.research.intel-research.net.dtn/ping]: 'dtnping!' seqno=0, time=212 ms |
|
281 20 bytes from [dtn://zabar.research.intel-research.net.dtn/ping]: 'dtnping!' seqno=1, time=297 ms |
|
282 <font color=blue>Ctrl-C</font></pre></blockquote> |
|
283 |
|
284 <h2> What next? </h2> |
|
285 |
|
286 <p> |
|
287 You've set up a standalone dtnd and pinged it. From here, you |
|
288 can explore two directions. In the <a href="tutorial-2.html"> |
|
289 DTN2 applications</a> tutorial, you can learn how to use the other |
|
290 applications that come with DTN2 to interact with your new little |
|
291 DTN. In the <a href="tutorial-3.html">building a bigger DTN</a> |
|
292 tutorial, you can see how to use links to make several nodes work |
|
293 together as part of a bigger DTN. |
|
294 |
|
295 </body> |
|
296 </html> |
|
297 |