Skip to content
joshtwo edited this page Mar 3, 2013 · 4 revisions

Arsenic v. 0.4

This is a Haskell bot for dAmn (deviantART Messaging Network). It is a bot distributed between many different processes; an event dispatcher (the core process) and many nodes which send and recieve events through it (the processes that constitute the rest of the bot's functionality). While the bot's de facto language is Haskell, it is perfectly possible to create modules in other languages which use the Arsenic protocol (the format of the messages used to communicate between nodes in order to trigger events).

Installation instructions and further documentation pending. Ideally, you can simply clone this repo and run cabal install to download the dependencies and compile the individual binaries and libraries that constitute Arsenic.

Arsenic Protocol

The current draft of the format used to communicate between nodes of the bot is below:

This protocol is called the Arsenic protocol. Packets of this format constitute all of the events fired within this bot, and are sent between individual nodes of the bot. Arsenic uses the ZMQ library, which would mean that this is built on top of the ZMQ protocol, but this protocol could also be feasibly implemented without it; as it is currently listed here in this draft, the protocol only refers to the format of the strings sent over the ZMQ sockets themselves. ZMQ level details will be added later.

Basic Format

An Arsenic packet is composed of a series of length delimited strings of characters. The length of each of these strings is specified in two consecutive bytes which form a single 16 bit binary number (big endian). The length for the string comes directly before the string itself. Example:

1    2    3    4    5    6    7    8    9    
0000 0111 0100 0101 0011 0100 1001 1110 0111
0    7    116  101  115  116  105  110  103  
LENGTH    t    e    s    t    i    n    g   

In this diagram, the first row is which byte in the packet the current column is. The second is its value in binary. The third is its value in decimal. The fourth is the plaintext, excluding the two bytes specifying length.

In order to specify lengths greater than 1111 1111 (or 255 bytes) for a single string, you can specify multiple consecutive ones with lengths of 0000 0000 (each "0 length" string meaning "a 255 character segment of the current string"). For example, if you had a string that was 300 characters long, it would work like this:

1    2    3    4    5    6    7    8    9    10   11   12   13   ...
0000 1101 0010 1100 0001 1000 0010 1100 0001 1000 0010 1100 0001
0    13   98   108  97   104  98   108  97   104  98   108  97
LENGTH    b    l    a    h    b    l    a    h    b    l    a 

 ... continued at byte 220 ...

220  221  222  223  224  225  226  227  228  229  230  231  232  ... 
0000 1110 1000 0010 1100 0001 0010 1110 1100 0001 1000 0010 1100
0    14   104  98   108  97   2    14   108  97   104  98   108   
LENGTH    h    b    l    a    LENGTH    l    a    h    b    l

You can see that starting at bytes 226 and 227, the remaining part of the 300 character string is specified as an entirely new one.

Clone this wiki locally