Skip to content

cyphyhouse/directoryd

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

directoryd
==========

This is a software package that provides service directory support for
the HoTDeC testbed. It uses a decentralized architecture to
automatically discover services on other nodes.

I (Daniel) edited this so that we could use this for the quadcopter for device discovery.

Requirements
------------

* czmq              (sudo apt-get install libczmq-dev)
* Avahi             (sudo apt-get install libavahi-client-dev)
* Protocol Buffers  (sudo apt-get install libprotobuf-dev)
* Protocol Compiler (sudo apt-get install protobuf-compiler)
* cmake

Build & Installation
--------------------
First make sure to look at ddclient/test_query.cpp on your laptop in order
to fill out the field for your wifi interface marked by a comment

Then add all the vehicles that you are using to the vehicles.txt file. For
example, if you have 2 quadcopters and 1 car you write:
    quadcopter 2
    car 1
    
Then make sure to look at ddclient/test_register.cpp on the vehicles in order
to change the vehicle type and ids marked by the comments. By the previous
example, one quadcopter would have "quadcopter1" and the second "quadcopter2"
and the car would have "car1". "quadcopter1" would have "stop 1" and 
"quadcopter2" would have "stop 2" and "car1" would have "stop 1" again.

Make sure that protoc and your libprotobuf libraries are the same version.
Then make sure you have the protobuf compiler installed so that you can do

    protoc --cpp_out=protobuf Services.proto
    
Then in the directoryd directory do

    mkdir build
    cd build
    cmake ..
    make

When running directoryd, make sure that avahi has started. If you're using
systemctl just run:

    sudo systemctl start avahi-daemon
    
The quadcopters already run this when they start by default.

On your laptop: run ./query_script.sh
On the vehicles run ./register_script.sh

Not really important:
You can change the installation location by changing the
CMAKE_INSTALL_PREFIX:

    cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..

You can create an installer using cpack in the build directory:

    cpack

You can install either using `make install` or using one of the
cpack-created installers.

Usage
-----

    directoryd [-dh]
        -d      launch as daemon
        -h      help
        -D      dump protobuf messages as TextFormat

directoryd should be used as a daemon that runs in the background. It
creates a zeromq ipc socket in /tmp/directoryd.

API
---

See `Services.proto`. You can `Register` or `Unregister` your services, or
you can `Find` services.

* Registration requires a `name`, which is unique to each instance of
  your service. You can provide one or more `location`s for your
  service, which require a `type` (what kind of services this is --
  vision, controller, something new, etc), and either
  a `port` or a `resource`. It is assumed that the service you're
  registering is local -- that is, on the same machine as the directoryd
  node. `resource` registration is not supported yet. Finally, you can
  provide `txt` entries -- these are key-value pairs of meta-data about
  your service. For example, you can provide version information or
  other useful data to client services.

* Unregister simply requires a `name`.

* Finding a service is flexible. You need to specify a `type` of service
  to look for, but in addition, you can filter by `name` and/or by `txt`
  entries.

Your service must send a `heartbeat` message once per second in order to
maintain its registration. Any other message (`find`, `register`,
`unregister`) also counts for the heartbeat. You will not receive a
notification if you have been disconnected in this way.

Everything else will receive a reply. A reply to a `find` will include a
`findresult`; otherwise, you will get back the same `type` of request.
On a failure result, you will also receive a `result` string.

A client library is provided that supports all of the above
functionality. See the `ddclient` directory for more information.
`query.hpp` provides find functionality, and `register.hpp` provides
registration and lifetime management. Example usage is provided in
`test_query.cpp` and `test_register.cpp`.

Copying/License
---------------

See COPYING.

About

Richard Otap's thesis code http://goo.gl/uB8orO , rewritten for CZMQ

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 78.7%
  • Java 10.5%
  • Shell 5.4%
  • CMake 5.4%