This post is intended to be a hub for general discussion and planning of a complete networking framework (a set of programs).
It was created hoping that the several members of the CC community that showed interest in this subject over the last few days post their opinions and findings here, and that eventually this may result in collaborative project.
I will try to complete this post with anything interesting about the problem; I also will attempt to establish vocabulary in order to improve communication between developers.
Preliminary Research:
By searching Wikipedia, I first came across the Communication Protocol page, and from there to one of the models for a communication protocol, the OSI model page. Here they describe several layers on which a protocol depends, and IMO the first one counting from down that ComputerCraft doesn't has is the network layer. For building such a layer, we already have unique identifiers for computers, so all we need is a routing protocol.
However, different situations demand different protocols; e.g. a crew of turtles is a dynamic network while stationary high altitude computers would form a static network. Respectively, a geographic routing greedy-random-greedy protocol and the Babel routing protocol IMO are the basic solutions for those problems, but I'm still not sure. For more about routing protocols, Wikipedia is a good place; I've just found this paper that studies the case of mobile networks.
Also, while real-life networks suffer of radio interference and unpredictable movements of nodes, in Minecraft, with some basic setting up and tracking, nodes know exactly when they will go out of range (except in case of storms). So a routing protocol which uses this fact could end up being more lightweight.
In any case, I suggest that we (whoever is interested) try to develop a general framework to allow communication between protocols.
Basic vocabulary:
-interface: a mechanism through which two computers can communicate directly,e.g. rednet, redstone, LAN cables, http.
-node: a computer with the capability of communicating with other computers, regardless of interface.
-neighbors of a node A regarding an interface I: any computer that A can communicate with directly by using interface I. When the interface is not specified, assume that it is to all interfaces we refer.
-path: a sequence of nodes, each in range of the next one.
-network: a tuple (networkID, nodes, protocol) where the protocol is a set of rules that enables the nodes to communicate;
Network ID's allow to separate systems as wanted.
About protocols:
-the protocol may use several interfaces;
-the protocol must expose the following functionality:
–association of aliases to a computer ID
–at each node:
set an alias to the node, that will be always go with the node ID.
a data structure representing tuples (nodeID, aliases, cost) where nodeID goes through all the nodes it knows can reach inside the network (Note that some protocols don't even know who they can reach)
a messaging function(target,message); no conditions are on this function, which may fail even if the there is a path between the emitter and the target.
A node can belong to several networks..
In addition to that, there are gateways: nodes that provide a link between specifiable networks to which they belong (an exception will soon appear). Gateways (may?) must provide an alias to the networks they use that identifies them as a gateway.
Until now, i haven't mentioned how does a 'normal' node accesses networks and uses them. In this language, there would be a parasite protocol, which would be able to message direct neighbors which were either
-other parasites from the same network;
-gateways allowed to communicate with that parasite network;
This breaks the rule of gateways belonging to the networks they communicate with (shrug).
Gateways can then forward messages to the networks they belong to, or directly to other connected parasites.
For each networking case, one would decide how, if any, gateways announced their presence, or, if parasites announced their presence; if gateways send through the network info about which parasites are connected to them (that's the reason for aliases: identification of gateways spread across a network). Based on these needs, helper functions and what I'm going to call gateway protocols could be written.
Helper Programs:
I use CC-emulator for debugging, and some improvements would ease it:
- a scroll-able shell, for reading lengthy output, possibly an upgrade of this one by Espen;
- a replacement for the rednet API that would enable setting computers' positions and simulate rednet based on those;
FAQ:
-Isn't rednet enough?
Direct connections by rednet have range limitations.
-Why not using the http API to channel signals through the internet and back to Minecraft:
lame because it breaks the 4th wall and not everyone can use http.
-Hasn't someone solved this already?
Some partial solutions (do not get me wrong, the may be partial but some are fantastic) are:
-LyqydNet: a solution that lacks dynamic behavior, such as node recovery.
Loose thoughts:
-storms: (maybe) we don't want to have networks reset themselves just because 'a wild storm has appeared' and suddenly no-one is in reach . Ideas?