This tutorial will show you how to set up two DTN2 daemons on two separate computers and make them talk to one another.
You'll be using server config files like the one from the first tutorial. Follow these instructions on both servers, making each refer to the other one.
route local_eid dtn://name.dtn
Name can be anything you want it to be, provided it is unique for each daemon. e.g. dtn://bob.dtn. EID stands for Endpoint identifier. These are used to identify the sender and the final destination of the bundles.
We need to modify the interfaces a little. An interface looks for bundles directed to that specific daemon. It is also used for routing bundles onwards that are not intended for that specific daemon. The interface command has the following format:
interface add name_of_interface type_of_interface local_addr = local address local_port = local port number
For example:
interface add tcp0 tcp local_port=5000
tcp0 is merely the name of the interface. It doesn't matter what you choose as it's just used to refer back to the interface later on. TCP is the type of interface being used. TCP stands for Transmission Control Protocol. It is the transport layer protocol we will be using to send our bundles on. There are other transport layer protocols we can use but for now we are going to use TCP. The local_addr is the address of the computer. It can be an IP address or a name. We won't be using the name as we will be using the default IP address on the machine. Finally the local_port is the port of the machine that the daemon will listen for incoming bundles on. We have changed it to 5000 so that the Daemon will know incoming traffic will be going to port 5000
Next we have to set up a link between our computers. A link allows the daemons to communicate to one another via the correct IP addresses and ports. It points the bundles in the direction of the distant computer. Go down to the link section in the conf file. Add the following:
link add link_name ip address:port number ONDEMAND tcp
For example:
link add link_tcp 131.12.45.192:5000 ONDEMAND tcp
The link_name is what the link will be called and referenced to. It may be called anything. The ip address is the IP address of the computer running the other DTN daemon. The computer name on the network can be used, for instance if DHCP is in use and we don't know the IP address of the machine. We will stick with IP addresses for now. The port number should be the port number that the other DTN daemon will listen on.
Lastly, add a route for the end point of the daemon. This locates the daemon on the other computer. Without it the bundles will not be sent.
route add name link_name
For example:
Don't forget to add the star. The asterisk is there to make all bundles match this route, instead of being mistaken as administrative bundles to be processed on the local node.route add dtn://george.dtn/* link_tcp
./dtnsend -s name of sender -d name of destination -t type of message to be sent -p name of file being sent/message being sent
The -t argument can have three values (m, f, or d) for message, file, or date.
Use dtnsend to send to one of the daemons. In this example, we'll make bob send to george:
./dtnsend -s dtn://bob.dtn/b -d dtn://george.dtn/g -t m -p "Hello george"
Notice how I have added an extra part to the daemon's EID in the source and destination parameters of the dtnsend command. The g and b are merely there to add a path for the bundle. Without the path the receiving daemon will interpret the bundle as an administrative bundle. The bundles will still go to the daemon indicated by the EID. The name of the extra part to the EID doesn't matter. It can be whatever you want it to be. Type bundle list into bob's daemon. We should see no bundles there! Then type bundle list into george's daemon. A bundle should be waiting there to be retrieved.
To retrieve the bundle, use dtnrecv. It collects the bundles and delivers the message/file/date. The dtnrecv program will wait indefinitely for new bundles to arrive from the DTN daemon. To get out of dtnrecv hit Control-C.
dtn2/apps/dtnrecv/dtnrecv dtn://george.dtn/g
The message "Hello george" should be displayed. Success!