Posted 30 December 2012 - 05:30 AM
If this can be used in turtles, what do you think about allowing the modem to listen to 2 frequencies? That way, turtles could connect two networks (each with a different frequency).
This makes more sense in the context of changing rednet to use frequencies (e.g. not send(id,msg) ). Since it's related, I post here what I think would be a complete solution for rednet frequencies (which is based of many ideas of the rednet frequencies suggestion thread):
setListenFreq(freq,n), where n is 1,2,3, or 4, and freq is something out of a very larger set of things, e.g. all Lua numbers, or strings of limited size.
Sets frequency slot n to freq.
Frequencies could initially be:
1st slot - the computer id;
2,3, and 4th slot: _default = a default frequency that wouldn't match any computer id;
All frequencies could also be a default value, in case there is the need to get rid of id's; which is an entirely diferent problem btw, how would people access their respective computer folders, ect. Plus, that wouldn't be backwards compatible.
send(freq,msg)
For all computers listening to the frequency freq, that are in rednet range, queues a rednet event ('rednet',freq,msg,distance,side) (side, why not? that way we can differentiate between modems). This is consequently backwards compatible with send(id,msg)
For backward compatibility, one can still implement broadcast(msg) as send(_default,msg). Backwards compatibility fails when people rely on send(_id,msg) only reaching the computer whose id is _id, because it would reach anyone listening to the frequency _id.
Why 4 frequencies to listen on? Because, in the context of a network, that is, a set of computers which wish to communicate efficiently among themselves, without interfering with others, and a turtle A of that network:
-1 frequency slot only, wouldn't allow listening to both the network's internal broadcasts and messages forwarded directly to A. The only solution would be filtering messages based on a target descriptor, e.g. send(net_freq,'target:A|msg'), but that would wake up every computer of the network in range of A, unnecessarily.
-2 frequency slots are better; but in networks there may be the need to have nodes linking 2 different networks, for instance the server network and a turtle fleet network, that one wants to keep with different frequencies, which are kept private and effectively serve as a secure channel (so that blacklisting a sub-network does not need to set a new frequency in the server network). Consequently, 4 channels are fine for this.
A computer can currently make this work with 4 advanced modems, but a turtle would need a modem with 4 channels. Personnaly, I would prefer a modem with 4 listening frequencies for all computers, because ease of use and turtle auto-servers and whatnot.
Btw, I now I've been talking a lot about networking, and I don't have anything completely ready yet, but I've already coded a routing protocol (github anyone interested, osi repository). I'm in the process of adpating cc-emu to simulate broken connections, and would like to use something like this to compare efficiency of normal broadcast with using channels. As it is now, it will work with the normal broadcast, but it would be more efficient either with the advanced modem as it is or the rednet frequencies described above.
Edited on 30 December 2012 - 06:20 AM