This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
[Question] Can yo chain modems to deliver messages?
Started by micspam, 11 August 2012 - 08:36 AMPosted 11 August 2012 - 10:36 AM
I'm trying to set up a internet system where I can brodcast a message to computers w/modems outside of 64 blocks. Is that possible?
Posted 11 August 2012 - 03:42 PM
Yes, you would use a relay method which would be fairly simple to make.
Computer A sends a message to Computer B, which passes the message on to Computer C.
Computer A sends a message to Computer B, which passes the message on to Computer C.
Posted 11 August 2012 - 03:55 PM
Here is an example or a extremely Basic Router
Spoiler
local tArgs = {...}
if #tArgs ~= 2 then
print("Error Usage : <computer one ID> <computer two ID>")
return
end
local function openRednet()
local listOfSides = rs.getSides()
for i = 1,6 do
if peripheral.isPresent(listOfSides[i]) and peripheral.getType(listOfSides[i]) == "modem" then
rednet.open(listOfSides[i])
return listOfSides[i]
end
end
end
modemOn = openRednet()
if not modemOn then
print("No WIFI ModemnPress any key to return to menu.")
os.pullEvent("key")
return
else
print("Opened wifi on "..modemOn.." side")
end
local comp1 = tonumber(tArgs[1])
local comp2 = tonumber(tArgs[2])
if comp1 == nil or comp2 == nil then
print("Error Usage : <computer one ID> <computer two ID>")
return
end
while true do
local e,e1,e2,e3,e4,e5 = os.pullEvent()
if e == "rednet_message" then
if e1 == comp1 then
rednet.send(comp2,e2)
elseif e1 == comp2 then
rednet.send(comp1,e2)
end
end
end
Posted 12 August 2012 - 08:07 AM
interesting function, thing is you have to set up every computer individually, I designed a function for this but it needs fine tuning
Posted 12 August 2012 - 08:26 AM
Thanks. I designed it as a simple system. When you start getting into packet routing in a more hardcore scene things become huge and complex quickly. So it has one simple job send packets from a to b and packets from b to a. If I started adding other stuff like routing tables, IP's ,TCP and Internet it would become several hundred lines long. Yes the added complexity means added functional But I find in most cases this simple little script running on a satellite will do all I need.interesting function, thing is you have to set up every computer individually, I designed a function for this but it needs fine tuning
Posted 12 August 2012 - 09:10 AM
yeah, I would use serialized tables to contain the message, the relay PC would check it its ID is in a list and if not it would broadcast the message and then the table with its ID added in so each PC could only send it once. I suddenly realised that I would end up with duplicate messages if the following happened:
C=the main computer sending the messages
O=a relay PC
P=the relay computer where the problem starts
arrows are message transfer
so basically you now have a computer with 3 copies of the same message with different ID lists
PS I really hope this font has fixed width chars
C=the main computer sending the messages
O=a relay PC
P=the relay computer where the problem starts
arrows are message transfer
O->O->P<-O<-O
^ ^ ^
| | |
O<-O<-C->O->O
so basically you now have a computer with 3 copies of the same message with different ID lists
PS I really hope this font has fixed width chars
Posted 12 August 2012 - 09:21 AM
yep the message would be duplicated many many time also when scaled up It would scale the amount of duplication. I gave up on that concept and went with something else In the routing system I am developing currently.Packet routing in a mesh net is a problem that has still no fixed answer in the real world. The Internet only functions because a dedicated group of individuals maintain it. They manual add routing tables and tell the system how to function.yeah, I would use serialized tables to contain the message, the relay PC would check it its ID is in a list and if not it would broadcast the message and then the table with its ID added in so each PC could only send it once. I suddenly realised that I would end up with duplicate messages if the following happened:
– snip –
so basically you now have a computer with 3 copies of the same message with different ID lists
PS I really hope this font has fixed width chars
Example a packet from America goes to the neared under sea cable because It was told to be a Technion in a routing table. Then when arriving in the other country goes to the local exchange for the user because IP address ranging from 000,000,020 to 000,000,030 are given from that exchange.then the exchange sends it to the user because when the user connected to it it asked for a IP and the exchange used one from its allocated range again a Technion installed this range. The Inter net only works because the routing tables are maintained. when this stops so will the Internet. Unless adaptive mesh net systems are created that can rout based on other characteristics.
So the problem is a lot bigger that it first seams. In CC we can work around this quite simple By managing our own routing tables.But that is quite complex. so making a user friendly system will always be a challenge.
Posted 12 August 2012 - 09:45 AM
yeah, tell me about it, I'm only just out of school, no programming experience other than a little fiddling in vbs… making such complicated systems still takes me a while… but I will get it right
Posted 12 August 2012 - 12:09 PM
I actually built a turtle deployment system that will put a computer every 16 blocks, hidden underground. With 1.4, though, I might want to have it put the computers high up…
Nonetheless, all I need to do is just get the turtle to run a program on the computer. The only viable method I can think of is to edit the server/global startup.
Nonetheless, all I need to do is just get the turtle to run a program on the computer. The only viable method I can think of is to edit the server/global startup.