Skip to main content

Decentralized Telemetry Transport (DecenTT)

Project description

DecenTT : Decentralized Telemetry Transport

By every single second passing, we are moving into a Decentralized world. As Richard Hendriks from Silicon Valley says, "The way it should have built in the first place".

But the transition is not very easy, since Centralization solves the Transaction Efficiency issues while introducing Single Point failure problems. Which the Decentralized protocols are proofed up of.

A very simple solution to this problem is making a hybrid protocol consisting of best of both worlds.

Wireless Sensor Networks have inspired an era of Ubiquitous IoT Devices. And one of the most crucial aspect of IoT systems is Indirect Communications.

Hence, here is the DecenTT initiative to combine such centralized and decentralized indirect communication protocol. DecenTT is a child of MQTT and IPFS.


Installation:

The installers are there within the package, but are under development phase. Follow the steps to install the dependencies.

  1. Install IPFS CLI,

  2. Initialize an IPFS Node: ipfs init

  3. Setup or Use an MQTT Server/Broker:

    • For the self hosted version the most popular implementation is Eclipse Mosquitto
    • For a cloud based service any provider would work.
  4. Install DecenTT Library: pip install DecenTT


Running IPFS Daemon :

from DecenTT.IPFS import Daemon

_daemon = Daemon(shell=False)
# _daemon.daemon.communicate()      # To run it in the attached mode
# _daemon.reload()                  # To reload
# _daemon.stop()                    # To stop the Daemon

In order to communicate with the network, an IPFS Daemon should be active.


Adding Bootstrap nodes

  • View Bootstrap nodes:

    ipfs bootstrap list
    /dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN
    /dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa
    /dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb
    /dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt
    /ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ
    

    These are the public bootstrap nodes provided from the IPFS community.

  • Removing the Bootstrap nodes:

    ipfs bootstrap rm all
    

    This removes all the bootstrap nodes.

  • If you wish to add a new bootstrap node you can do as follows:

    • Using IPFS CLI

      ipfs bootstrap add "your bootstrap node address"
      
    • Using IPFS HTTP API

    • Using DecenTT BStrapper:

      from DecenTT.IPFS.locales.bootstrap import BStrapper
      
      b = BStrapper()         # Loads default given Bootstrap Nodes
      b.load_all()
      

      If you have setup a private IPFS Network then you can specify the Bootstrap nodes in a .env file as follows:

      BOOTSTRAP_1=your-bootstrap1-address
      BOOTSTRAP_2=your-bootstrap2-address
      

      To load these newly added bootstrap nodes use following snippet:

      from DecenTT.IPFS.locales.bootstrap import BStrapper
      
      b = BStrapper(path="path-to-your-env-file")         # Loads default given Bootstrap Nodes
      b.load_all()
      

      If you want to add the bootstrap node dynamically, use:

      b.add(address="your-bootstrap-address")
      
      # OR
      b.record(address="your-bootstrap-address")
      b.load_all()
      _daemon.reload()
      

Usage:

Usage is similar to any other PubSub mechanism.

Switching support: Currently IPFS Supports only Topic Based Manual Switching. That means if your topic is flagged with a keyword such as secure/, the topic will be published via a more resilient channel. Default keyword is secure/. This keyword can be set by the keyword argument in the client.

For other switching mechanisms look into DecenTT/pages

Client

from DecenTT import Client


def sample_callback(client, userdata, msg):
    print(f"{msg} Object received : \t {msg.payload.decode()}")


if __name__ == '__main__':
    d_c = Client(
        host="your-mqtt-host-address",  # :str MQTT Server/Broker
        # port =1883,                    # :int MQTT Port
        # username = None,          # :str MQTT Username
        # password = None,          # :str MQTT Password
        # on_connect=None,          # :function MQTT on_connect
        # on_publish=None,          # :function MQTT on_publish
        # on_message=None,          # :function MQTT on_message
        # log_path=".",              # :str MQTT LogPath
        # keyword="secure/"         # :str Switching Keyword
    )
    # These arguments are specifically for MQTT Client, the IPFS client works as a self hosted node on a P2P network. Hence, it doesn't need any parameters to be set
    

Publish

from DecenTT import Client

cli = Client(
    host="your-mqtt-host"
)

cli.publish(
    topic="your-topic",             # :str Topic
    payload="your-payload-string"   # :str Payload
)

Subscribe:

from DecenTT import Client


def sample_callback(client, userdata, msg):
    print(f"{msg} Object received : \t {msg.payload.decode()}")


client = Client(
    host="your-mqtt-host"
)

client.subscribe(topic="ABC", callback=sample_callback)
client.subscribe(topic="secure/ABC", callback=sample_callback)  # This topic is more `resilient`, Hence, adding 'secure/' as a prefix makes use of a resilient topic

Changelog

New features in v0.0.2

  • Now you can subscribe to multiple topics, just as paho mqtt,
    topic_list=[
        ("topic1", 0),
        ("topic2", 1),
        # (<topic name>, <qos in integer>)
    ]
    

Minor bug fixes in v0.0.3

  • Standards mismatch bug in the Message Payload class

Minor bug fixes in v0.0.4

  • **kwargs bug resolved
  • DEFAULT_HOST bug resolved

Contributors

Feel Free to contribute to the DecenTT project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

DecenTT-0.0.6.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

DecenTT-0.0.6-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file DecenTT-0.0.6.tar.gz.

File metadata

  • Download URL: DecenTT-0.0.6.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for DecenTT-0.0.6.tar.gz
Algorithm Hash digest
SHA256 0f0c997d91ed9f519eb9f950e0f5a09c2e188d7888aa16c6ad805d42af4af6b3
MD5 5f043716d0dc5a32cdf5d7806174da53
BLAKE2b-256 fc35e1f6cdd0961f87f57ddbca8041c41b228a848cdae4d7d8653b3e3c49baf7

See more details on using hashes here.

File details

Details for the file DecenTT-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: DecenTT-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for DecenTT-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d8684670a5bb673a1332ce26d3348744100ee79fe24bee0249988ea44d54e533
MD5 af6572436b4df4aa34c57f211b7fa5b1
BLAKE2b-256 c42ea75e2b1e4bc486ddda38cab5f3a7c015568e60749255698ca15846506791

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page