Getting two Daemons to communicate to one another

advertisement

Getting two Daemons to communicate to one another via two computers

This paper attempts to help people set up two DTN2 daemons on two separate computers and make them talk to one another.

Setting up the config files

To begin with we will need to alter the dtn.conf file for each daemon. This is located in the daemon folder. Go into the daemon folder located in the DTN2 folder and find the config file dtn.conf of your first daemon and open it up. The dtn.conf file runs every time the daemon starts up so any changes made in it will affect the daemon itself. It is basically a set up file for the daemon each time it starts. Scroll down till you find the area called “Routing configuration”. Under the sub area called “route local_eid <eid>”, create an EID for each daemon like this:

Route local_eid “dtn://<name>.dtn” where name is anything you want it to be provided it is unique for each daemon. e.g. – dtn://bob.dtn.

An EID stands for Endpoint identifiers. These are used to identify the sender and the final destination of the bundles.

Interface

We need to modify the interfaces a little. An interface helps by looking for bundles directed to that specific daemon. It is also used for routing bundles onwards that are not intended for that specific daemon. Under interface change the TCP interface to the following:

Interface add <name_of_interface> <type_of_interface> local_addr = <local address> local_port = <local port number> e.g. :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

Links

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 which the daemon is located but not at the

daemon itself. (That’s what the route section discussed next is for. ) Go down to the link section in the conf file. Add the following: link add <link_name> <ip address>:<port number> ONDEMAND tcp e.q.- 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 in lieu, for instance if DHCP is in use and we don’t know the IP address of the machines. We will stick with IP addresses for now. The <port number> should be the port number that the other DTN daemon will listen on. (we will set this later by editing the “interface” part of the other computers dtn.conf)

Route

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> e.g. – route add dtn://george.dtn/* link_tcp

Don’t forget to add the star. This will allow you to receive correctly. The * is there to make sure the receiver correctly receives the bundle. This insures that the bundle is directed to the receiver. Without the “path” (with a “path” being the section of the EID after the host (with the host being “george.dtn” for example)) the receiver interprets the bundles as administrative bundles. If this happens you will get errors and the Daemon may shut down.

“and repeat”

Now repeat the situation on the other daemon conf file. Give it a name (ie-

“dtn://george.dtn”), a link and a route(route add dtn://bob.dtn/*).

Don’t forget to save your two dtn.conf files. Loading without saving will mean that the changes we have made will not be loaded into the Daemon.

Communication and dtnsend

Now you’re ready to send bundles to and from daemons! Load both daemons up. Open a terminal up and go into the dtn2/apps/dtnsend folder or find the dtnsend executable. The dtnsend command has a number of options that need to be filled in as follows: dtnsend is a function of DTN2 that creates bundles and passes them to a daemon on the local machine. It also allows you to set options for each bundle you wish to create. The dtnsend program communicates with a DTN daemon through port 5010 on the local machine.

Note that this port number may be changed in the configuration of the DTN daemon.

./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 –s stands for sender. –d stands for destination. –t stands for type and –p stands for payload data. –t can have three values= m,f,d(message,file,date). Here is what we will do.

Add the sender and receiver names. Under –t put m for message and then under –p place a message to be sent.

Use dtnsend to send to one of the daemons. In this case I’m going to 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 extra arbitrary 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. dtnrecv

To retrieve the bundle, type the following to retrieve the bundle’s contents. drnrecv collects the bundles and delivers the message/file/date. The dtnsend program communicates with a DTN daemon through port 5010 on the local machine. Note that this port number may be changed in the configuration of the DTN daemon. The dtnrecv program will wait indefinitely for new bundles to arrive from the DTN daemon. To get out of dtnrecv hit ctrl c. dtn2/apps/dtnrecv/dtnrecv dtn://george.dtn/g.

The message “Hello george” should be displayed. Success!

Download