- Hydra shall be a network of applications across one or more hosts
- Each individual application connected to the network shall be known as a node
- Nodes shall connect to each other by means of any pre-agreed data protocol
- Every node shall implement the baseline hydra protocol
- The hydra protocol shall provide a mechanism to determine a leader node
- Leaders are the nodes responsible for maintaining the Active Connection to IRC
- Events shall be relayed from the Leader, and replies sent to the Leader to be forwarded
- Nodes may be written in any language so long as they can implement a data protocol
- Nodes must connect to at least one other node in the network
- Nodes may connect to more than one node in the network
- Nodes shall be identified by a 32-bit ID (re-)generated on every connect attempt
- Nodes may also keep a friendly name (tag)
- Nodes must keep a record of all other nodes in the network, and the closest neighbour to them
- Nodes should endeavor to reply to pings ASAP, lest they timeout if the delay exceeds MAX_PING
- Nodes may reject any connection attempt as they see fit, e.g. on frequent disconnects
- Nodes must reject termtime messages from any unregistered node
A leader has been established, the network is in-term. Nodes should be transmitting data and keepalives
PING term val id
- Heartbeat broadcast by the leader only. Any other sender must be ignored.
- Cohort: All nodes should reply to it. Higher term takes priority.
- Leader: If this message is received from another id with same term, trigger an election.
term
(int
): Index of the current term. If this is greater than expected, update leader.val
(string
): Identifier for uniqueness. Nodes must not relay the same ping twiceid
(byte[4]
): NodeID of the Leader node, not modified when relayed by other nodes
PONG val id count [tag]
- Heartbeat reply broadcast from nodes. Iff
id
is the leader. - Cohort: All nodes must relay these messages once (modulo
val+id
). - Leader: Drop any node that doesn't respond in MAX_PING.
val
(string
): Identifier for identificationid
(byte[4]
): NodeID of the origin node, not modified when relayed by other nodescount
(int
): Hop counter. Initialized to 0, incremented by each relaytag
(string
): Optional, friendly name for the origin node
RECV idx line
- Data broadcast by the leader.
- Cohort: All nodes must relay this message once.
- Leader: Ignore.
idx
(int
): Monotonically increasing counter for record, initialised to 0 each termline
(string
): Unaltered full IRC message of types minimally enumerated by E_RECV
SEND id line
- Data message to leader from a node.
- Cohort: Ignore.
- Leader: Forward to IRC.
id
(byte[4]
): NodeID of the origin node, not modified when relayed by other nodesline
(string
): Full IRC message of types minimally enumerated by E_SEND
DROP id [reason]
- Broadcast to remove a node from the network.
- All: Comply instantly.
id
(byte[4]
): NodeID of the node to be removed.reason
(string
): Optional, reason for removal
A leader needs to be established, election messages only
NOMINATE term id
- Nominate node
id
(self) for election. - Cohort: Receiving this message in termtime signifies start of an election.
- Leader: Receiving this message terminates the term. Drop leader status, vote.
- Nominee: Take nominee status. Ignore any other nominations.
term
(int
): Index of the term in election. Ignore if less than expected.id
(byte[4]
): Nominee's nodeID
PLEDGE term nom id
- Pledge to vote for node
id
in electionterm
. - Cohort: All nodes must pledge to vote for the first nomination they see.
- Nominee: On recieving a quorum of pledges within MAX_VOTE, call the election.
term
(int
): Index of the term in election. Ignore if less than expected.nom
(byte[4]
): Nominee's nodeIDid
(byte[4]
): Sender's nodeID
CALL term
- Fetch votes for election
term
. - Cohort: Relay if not seen. Respond with pledged vote.
- Nominee: Reset timer, expect quorum of votes within MAX_VOTE.
term
(int
): Index of the term in election. Ignore if less than expected or no pledges.
ELECT term nom id
- Vote in election
term
. - Cohort: All nodes must relay this message once.
- Nominee: Take leader status upon quorum of votes within MAX_VOTE. Begin term with PING.
term
(int
): Index of the term in election. Ignore if less than expected.nom
(byte[4]
): Nominee's nodeIDid
(byte[4]
): Sender's nodeID
A server has requested to be a node, collectively decide whether to induct, if in-term
KNOCK ind [tag]
- Induction request sent by mediator on behalf of a newly linked server
- Cohort: If not seen recently, record this
ind
, send MEET and expect HELLO within MAX_MEET. - Mediator: Take mediator status. Ignore any other attempts to induct.
ind
(byte[4]
): Proposed NodeID generated by and for the new servertag
(string
): Optional, friendly name for the origin node
MEET ind id
- Induction response broadcast to mediator, if agreed on induction.
- Cohort: All nodes must relay this message once.
- Mediator: Send WELCOME if/once all nodes consent within MAX_MEET.
ind
(byte[4]
): Recieved NodeID. Must be ignored if conflicting or already met in the last MAX_MEETid
(byte[4]
): NodeID of the sender node
WELCOME ind
- Induction broadcast sent by mediator on reciept of all MEETs within MAX_MEET
- Inductee: Take node status.
- Mediator: Drop mediator status.
ind
(byte[4]
): Accepted NodeID
HELLO ind id
- Induction confirmation to the incoming node. Sent by all nodes on WELCOME.
- Cohort: Register node and relay if not already seen.
ind
(byte[4]
): Accepted NodeID. Must be ignored unlessind
has knockedid
(byte[4]
): NodeID of the sender node
E_RECV :
JOIN
, PART
, PRIVMSG
, NOTICE
, MODE
, TOPIC
, QUIT
or KICK
E_SEND :
JOIN
, PART
, PRIVMSG
, NOTICE
, MODE
, TOPIC
or KICK
MAX_PING :
10
seconds
MAX_VOTE :
Vary between 5
-15
seconds
MAX_MEET :
10
seconds
- TCP data over agreed port
- UDP data on agreed port
- IRC message (separate from the active connection)
- FIFO message-passing