Posts Tagged ‘Multicast’

Avahi thoughts

Tuesday, June 30th, 2009
Diagram of Streaming Multicast
Image via Wikipedia

First a short intro to avahi, basically it is a ZeroConf implementation for linux, to make a long story short through use of multicast it is able to discover services as they appear (as well as scan network for those services).

This is a tale of a hacker deciding to take a pydra ticket. After verifying that avahi has python bindings i headed to their home page looking for docs. There is a “ProgrammingDocs” which looked like a good sign, imagine my horror when i read on that page

Though no real documentation about the DBUS API is available, you may browse the DBUS introspection data online

OK, so they pretty much don’t have docs, it can’t be that bad to work with it, right? Their API is to f**** complicated :-) , this is supposed to be the simplest of the “client” examples, this is the simplest of the “publisher” examples, fortunately the publisher wrapper is very nice to work with, but the fact that it exists hints that there is something wrong with the API.

As far as the protocol goes, first thing that struck me is that you can’t really distinguish between server and client, both take an active role. “publisher” advertisizes it’s service, while the “client” (or however you wanna call it) initiates the glib event loop and waits for asynchronous callback to happen. If we ignore the fact that you are forced to use certain event loop having continuous discovery is not a bad thing, it provies you a way to do discovery even if certain involved parties are temporary down, as well as the ability to see them as they join the network. What i’m saying is that forcing people to use event loop is a bad thing (as it is big overkill in simple cases).

If we get to my code, i choose to make the master the one discovering nodes, the reason for this is that this way i don’t have to make the node tell the master “hey i’m alive use me” (and of course implement the appropriate extension to the protocol). So basically a master is looking for nodes, when a node is put on network it advertisizes itself and master finds it and add’s it to it’s Node list.

Reblog this post [with Zemanta]
Blog Widget by LinkWithin