Code Monkey home page Code Monkey logo

kdt's Introduction

A Kademlia System

This repository contains a partially implemented node for a DHT based on Kademlia. It uses LMDB for file storage and OpenSSL for generating safe random numbers. The code should compile on any POSIX compatible system on which the mentioned dependencies are available.

The purpose of this application was originally to serve as foundation for various kinds of peer-to-peer network experiments. Its future is, however, currently not certain.

Building and Running

Building requires CMAKE 3.8 or later, git, the OpenSSL development headers, and the LMDB development headers. If on Ubuntu, the following commands should install all required dependencies:

$ sudo apt install cmake git libssl-dev liblmdb-dev

On a POSIX system, the following commands should be enough to download and build the project, assuming all dependencies are installed.

$ git clone https://github.com/emanuelpalm/kdt.git
$ cd kdt
$ mkdir build
$ cd build
$ cmake ../
$ make

Two binaries are produced: namely, kdt-test and kdt. The former runs a unit test suite, while the latter starts the application. No command line arguments are read, so any configuration data has to be provided via environment variables. The two most significant such are KDT_INTERFACE and KDT_PEER. The former selects which local network interface to use, what port, as well as what internet and transport protocols to use. The latter variable determines what node, if any, to use for joining the network after the application has started.

The following example, also assuming a POSIX environment, could be suitable for joining a local KDT network:

KDT_INTERFACE="IPv4/TCP 0.0.0.0:39882" KDT_PEER="IPv4/TCP 192.168.0.4" ./kdt

Implementation Details

The only communication method currently implemented uses TCP for reliable datagram transmission. Both IPv4 and IPv6 are supported, but not at once. To improve performance, all message buffers are pre-allocated. Custom allocators are provided for allocating memory for outgoing and ingoing messages, respectively.

Repository Organization

The cmake/ folder contains CMAKE modules.

The src/main/ folder contains the application code. Significantly, it contains the following entries:

Entry Description
kdm/ Actual peer implementation, based on the pnet module.
pnet/ Peer-to-peer network layer.
def.h Global definitions, affecting memory allocations, timings, etc.
err.h Error type.
kint.h Kademlia integer type, with various utility functions.
kvs.h Key/value store.
mem.h Memory buffer stream implementation.

Each folder and .c/.h file pair in the src/main/kdt folder is considered as being a module. Folders contain a .h file with the same name as the folder serving as entry-point for the module. If a module folder contains a folder named internal/, the contents of that folder must only be accessed directly from within the module.

The src/test/ folder contains a unit test library called unit as well as unit tests for some of the main folder modules.

Contributions

Contributions may be considered from any source.

If you are interested in finishing the implementation, a good start could be to search for TODO statements. The following command should list them, if executed from the project root folder via a POSIX terminal:

grep -irn --include="*.c" TODO .

kdt's People

Stargazers

Gravis avatar fa11ing1eaf avatar

Watchers

James Cloos avatar Emanuel Palm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.