Home > Distribution, erlang > Erlang Bitstring Operators

Erlang Bitstring Operators

After looking more deeply into what does a DHT like Kademlia does or not, I started to write some useful code in Erlang…

First it seems ( quite intuitive I must say ) that a DHT doesn’t say anything about connections… That is who am I connecting to at first, how to choose my endpoint, etc. Everything that is not enforced by the DHT mechanism is an opportunity to tune the system towards more special needs and features other than the DHT possibility set. Therefore I am making the intuitive assumption that a good way would be to connect to a very close node. BATMAN has an interesting and quite simple way of handling connection, so I decided to follow the example 😉

I just finished a UDP broadcaster in erlang, pretty simple, that basically advertise to his online neighbors itself came online, and register its neighbors’ replies.

Then comparing This and That I got a bit confused about some stuff…
For example : nodeID seems to be up to the user, provided a few conditions… is it really ?
But anyway it is sure that the nodeID is going to be a long binary. So I decided to start implementing a key scheme for what I had in mind for the dynamic vector clocks algorithms, that is a key based on the order of connection of the different node.

However, I was quite disappointed to *not find* any simple way to deal with bitstring operations in erlang… Binary operations work on integer only, and that would be 8bits for convenience with bitstring apparently… so I started writing my own module for that, with bs_and, bs_or, bs_not, and so on, that work on a bitstring of indefinite size. It s pretty basic and not optimized at all, but it works. Not sure if there is some interest out there for it, but let me know if there is, I can always put it on github somewhere 😉

Erlang Bitstring Operator test Screenshot

Erlang Bitstring Operator test Screenshot

Other than that, I keep working on my little portable SDL-based Game Engine, which now has OpenGL enabled by default if available on your machine.

SDLut_Refresh Test Screenshot

SDLut_Refresh Test Screenshot

It s working pretty nicely for simple bitmap display. Now the refresh is optimized ( I should display fps up there 🙂 ), and the user doesnt have to manage the list of rectangles to know what has changed on the screen or not ( which wasnt supported before in SDL render mode). Also openGL can be disabled if not needed, nothing changes on the interface for the user 🙂 pretty handy 😀 That was some work, but now the most troubling point is the “Font” part, that doesnt behave exaclyt as you would expect… more work to be done there.

Categories: Distribution, erlang Tags: ,
  1. 2010/03/24 at 01:52


    Good luck with the Kademlia implementation. I know you have looked at our dht project, but are writing an erlang version. We have found documentation pretty sparse and have had to use a great many papers and research info to get a good quality implementation (watch out for dead nodes, sybil and sparticus attacks). Anyway we found the area to be full of promises and little code that worked, we have had many discussions debates and failures getting an implementation. Whilst you may not want a c++ version please feel free to post kad questions on the getsatisfaction site of ours for the dht project and we can shoot the breeze with some kad nuances with you (the paper is very good but some things are not clear at all and need tested to see why).

    OSS needs some good DHT projects so best of luck and if we can help then we will whether with code or just questions.

    All the very best

    PS I know very little of Erlang so excuse any ignorance, but we are pretty heavily invested in boost which I think can provide a good link to Erlang code if it helps at all.

    • 2010/03/24 at 09:40

      Hi David,

      I am actually not trying to reimplement Kad itself. But more like trying some ideas I have to provide new services on top of it. Something that can be more than a key value storage…
      I choose erlang, because it’s very simple to write network code, server and clients quickly. so I can test and iterates on ideas. And there are already a few kad implementation in erlang that I can use to gain some detailed knowledge.

      Once I will find something interesting enough, then I ll go down the path of reimplementing it in C++, on top of an existing kad implementation, such as your Maidsafe-DHT project 😉
      I ll let you know when I have a prototype that works without kad, to check how we can mix it with kad algorithms…


  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: