Giter Site home page Giter Site logo

molderl's Introduction

molderl

Sending data via multicast allows an application to send a single packet to a large number of receivers. Unlike TCP where there is a connection to each receiver and a given message is sent to each receiver individually, multicast involves sending a single packet that is then received by every application who cares to listen for it. There are lots of other advantages too but there is one fairly severe disadvantage - multicast is not be nature a reliable protocol.

Often this doesn't matter. If you're streaming live video or audio, a few dropped packets here and there don't matter. If on the other hand you're sending data that absolutely must arrive (something you'd generally use TCP for) then you need something a little bit extra. You need reliable multicast.

There are a couple of well known solutions to this problem. The first is PGM or Pragmatic Multicast. This is one of the more advanced offerings but is fairly complex to implement. A much simpler approach with similar features is MOLDUDP64, a protocol designed by the NASDAQ for delivering price feed data. This protocol is very lightweight and only adds the bare essentials necessary to get reliable data transmission.

molderl is a simple server implementation that will allow Erlang applications to send data using this protocol.

Quick Start

Start the server:

> application:start(molderl).

Create a MOLD64 stream:

> {ok, StreamPID} = molderl:create_stream(mystream,{239,0,0,1},8888,8889).

or, using (optional) arguments:

> Options = [{ipaddresstosendfrom, {192,168,0,1}}, {filename, "/tmp/mystream"}, {timer,500}, {multicast_ttl, 2}, {max_recovery_count, 1000}].
> {ok, StreamPID} = molderl:create_stream(mystream,{239,0,0,1},8888,8889,Options).

Send a message:

> ok = molderl:send_message(StreamPID, <<"helloworld">>).

Unit tests how-to

$ rebar eunit

Randomized tests how to

$ cd molderl/
$ cp src/molderl.app.src ebin/molderl.app
$ erlc -o ebin/ -I deps/*/include/ deps/*/src/*.erl
$ erlc -pa ebin/ -o ebin/ -I include/ src/*.erl test/*.erl
$ erl -pa ebin/ -pa deps/*/ebin/ -eval 'molderl_integration_tests:launch(), init:stop().'

Note that given that packet drops is possible with UDP and the tests do not fully implement MOLDUDP64 recovery mechanics, the tests will fail intermittently without there necessarily being something wrong.

Instrumentation

If the statsderl app happens to be running, molderl will populate the following metrics:

Type Name
counter molderl.<stream_name>.packet.sent
timer molderl.<stream name>.packet.time_in*
timer molderl.<stream name>.packet.time_out*
counter molderl.<stream_name>.recovery_request.received
timer molderl.<stream_name>.recovery_request.latency

* You can supply an Erlang time 3-tuple {MacroSecs, Secs, MicroSecs} as the third argument to molderl:send_message/3 if you want latency to be measured from an earlier time than when a message enters molderl.

molderl's People

Contributors

pmembrey avatar viveshok avatar

Watchers

Barco Jie You avatar

Forkers

dasudian

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.