Code Monkey home page Code Monkey logo

datagramtunneler's Introduction

DatagramTunneler

Author License: GPL v3 GitHub last commit Stars

Simple cross-platform client/server program forwarding UDP datagrams through a TCP connection (aka tunnel). The client joins a multicast group and forwards the received datagrams to the server, which in turns multicasts them on its own subnet.

  • Designed with simplicity in mind
  • Tested on OSX 10.13.3, Ubuntu 16.04 and Centos 7.4
  • NOT Windows compatible

Content

Requirements
Installation
Synopsis
Examples
How does it work?
The DTEP Protocol
Licensing

  • A computer running a Linux or Mac OS distribution
  • A c++ compiler
  • Download or clone the repository.
  • Go into the repository:
cd <path_to_the_repo>/DatagramTunneler
  • Build the DatagramTunneler by simply running make:
make
  • You're ready to run the DatagramTunneler binary:
./bin/DatagramTunneler -h

For more info about how to run it, checkout the Synopsis below

In order to use the DatagramTunneler you need to start the server side first, then the client side. If you don't, the client will just fail to connect to the server and exit right away.

Server

  dgramtunneler --server -i <udp_iface_ip> -t <tcp_listen_port> [-u <udp_dst_ip>:<port>]
  • <udp_iface_ip>: interface used to publish the forwarded datagrams
  • <tcp_listen_port>: tcp port used to listen for client connections
  • <udp_dst_ip>:<port>: (optional) udp destination IP and port where the server is publishing the forwarded datagrams. If not provided, datagrams are published on the same channel joined by the client.

Client

  dgramtunneler --client -i <udp_iface_ip> -t <tcp_srv_ip>:<tcp_srv_port> -u <udp_dst_ip>:<port>
  • <udp_iface_ip>: interface used to join the multicast channel provided by -u
  • <tcp_srv_ip>:<port>: IP and port of the server to which the datagram will be forwarded
  • <udp_dst_ip>:<port>: udp destination IP and port of the channel we want to join

(Don't forget to give a little star if this tool is useful to you :]) server side:

./bin/datagramtunneler --server -i 192.168.0.104 -u 228.14.28.52:1234 -t 28052

client side:

./bin/datagramtunneler --client -i 192.168.0.105 -u 228.1.2.3:7437 -t 192.168.0.104:28052

The purpose of the DatagramTunneler is to transfer multicast data from one subnet A to another subnet B where that multicast channel is not available. To achieve this, the DatagramTunneler is split into 2 sides: a client side and a server side, as shown on the diagram below: Datagram Tunneler

The Client Side

The client side should run in the subnet where the multicast channel is joinable. Once started it will do the following:

  • connect to the DatagramListener Server (TCP)
  • join the multicast channel (UDP)
  • forward all the received datagrams to the server using the established TCP connection. Datagrams are transmitted throught TCP using the Datagram Tunneler Encapsulation Protocol (or DTEP).

The Server Side

The server side should run in the subnet where the multicast is not available. Once started it will do the following:

  • listen for a client connection (note that only one connection is accepted throughout the lifetime of the Server/Client instances. Once the tunnel is disconnected, both ends exit.
  • once a connection with a client is established, it will publish all the datagrams sent by the client to a multicast channel. That channel can be anything specified when launching the server, or if not specified, it will used the same multicast channel encoded with the datagram it received (c.f. DTEP).

The Datagram Tunneler Protocol or DTEP is a simple binary protocol, which is described by the following diagram:

A DTEP packet has a 1 byte header specifying the type of payload it contains.

Packet Type 0x00 = HEARTBEAT

This type of packet has no payload. It is sent by the client to the server and helps ensure both ends of the connection know if the other end is alive.

Packet Type 0x01 = DATAGRAM

This packet encapsulates the datagram observed by the client. Here is its complete description:

Although this diagram should be self explanatory, here is a break down of all the fields:

  • Datagram Length: number of bytes of the encapsulated datagram (the DTEP header length is NOT included)
  • UDP Channel Address: destination address of the multicast group which the client joined to receive that datagram
  • UDP Channel Port: destination port of the multicast group which the client joined to receive that datagram
  • Encapsulated UDP Datagram: actual datagram received by the client from the multicast channel

C.f. LICENSE

datagramtunneler's People

Contributors

markopaul0 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.