This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Ivegon's profile picture

RedNet Alternative Question

Started by Ivegon, 12 September 2012 - 09:52 PM
Ivegon #1
Posted 12 September 2012 - 11:52 PM
Hello, I'm currently building a nuclear power plant. And, I'm currently at the stage of coding the whole system. Though, I tend to stray from RedNet because of it's insecure and limited capabilities. Thus, I had to find an alternative to communicate between the computers managing all of the systems.

The system uses bundled cables. Essentially, I'm still ironing out the specifics of the program. Though, there's one Mainframe computer which sends all of the commands via the cables. Since bundled cables are essentially a 16-channel redstone cable. A certain combination of colors would automatically send a command throughout the whole network. The other computers are constantly waiting for said commands. If it doesn't recognize a command, then, it ignores it. In a limited context, like, when a computer sends a command to another computer. It works. Though, when we have multiple computers, the receiver computers activates when it's not supposed to. So, automatically, it breaks the concept. Though, I prefer this system over RedNet because of it's local-capabilities. So, everything is closed. We are talking about a nuclear reactor. So, it's like an Ethernet cable over wifi.

Anywho, here's some code:

Mainframe Computer:
Spoiler

shell.run("clear")
function rsreset(sSide)
	redstone.setBundledOutput(sSide, 0)
end
print("Welcome to the MainFrame")
print("You may control any systems in the power plant")
print("Here are the available commands:")
print("   cbd - Close Blast Doors")
print("   obd - Open Blast Doors")
print("   oed - Open Elevator Doors")
print("   ced - Close Elevator Doors")
print("   rme - Raise Main Elevator to Entrance Level")
print("   lme - Lower Main Elevator to Reactor Level")
while true do
  event = os.pullEvent()
input = read()
cdb = "cbd"
odb = "obd"
oed = "oed"
ced = "ced"
rme = "rme"
lme = "lme"
shutdown = "shutdown"
if input == "cbd" then
print("Closing Blast Doors...")
rs.setBundledOutput("bottom" , colors.lightBlue+colors.white)
sleep(1)
rsreset("bottom")
sleep(0.1)
print("Waiting for Confirmation")
os.pullEvent("redstone")
print("Confirmation Received")

else if input == "obd" then
print("Opening Blast Doors...")
rs.setBundledOutput("bottom" , colors.lightBlue+colors.orange)
sleep(1)
rsreset("bottom")
sleep(0.1)
print("Waiting for Confirmation...")
os.pullEvent("redstone")
print("Confirmation Received...")
else if input == "oed" then
print("Override - Opening Elevator Door...")
rs.setBundledOutput("bottom" , colors.lightBlue+colors.magenta)
sleep(1)
rsreset("bottom")
sleep(0.1)
print("Waiting for Confirmation")
os.pullEvent("redstone")
print("Confirmation Received")
else if input == "ced" then
print("Override - Closing Elevator Door...")
rs.setBundledOutput("bottom" , colors.lightBlue+colors.yellow)
sleep(1)
rsreset("bottom")
sleep(0.1)
print("Waiting for Confirmation")
os.pullEvent("redstone")
print("Confirmation Received")
else if input == "rme" then
print("Raising Elevator to Entrance Level...")
rs.setBundledOutput("bottom" , colors.white+colors.orange+colors.magenta)
sleep(1)
rsreset("bottom")
sleep(0.1)
print("Waiting for Confirmation...")
os.pullEvent("redstone")
print("Confirmation Received...")
else if input == "lme" then
print("Raising Elevator to Reactor Level...")
rs.setBundledOutput("bottom" , colors.white+colors.orange+colors.lightBlue)
sleep(1)
rsreset("bottom")
sleep(0.1)
print("Waiting for Confirmation...")
os.pullEvent("redstone")
print("Confirmation Received...")
else if input == "shutdown" then
print("Exiting...")
shell.run("shutdown")
else
print("Input Not Recognized")
end
end
end
end
end
end
end
end
Blastdoor Computer:
Spoiler

shell.run("clear")
function rsreset(sSide)
	redstone.setBundledOutput(sSide, 0)
end
print("Welcome to Blast Doors and Elevator Controls")
print("Waiting for Command from MainFrame...")
while true do
  event = os.pullEvent()
if colors.test(rs.getBundledInput("top"), colors.lightBlue+colors.white) == true then
print("Closing Blast Doors...")
rs.setBundledOutput("bottom" , colors.magenta)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.orange)
sleep(0.5)
rs.setBundledOutput("bottom" , colors.magenta)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.orange)
sleep(0.5)
rs.setBundledOutput("bottom" , colors.magenta)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.orange)
sleep(0.5)
rs.setBundledOutput("bottom" , colors.magenta)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.orange)
sleep(0.5)
rs.setBundledOutput("bottom" , colors.white)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.white)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.white)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.white)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
print("Door Closed")
rs.setBundledOutput("top" , colors.lightBlue+colors.black)
sleep(0.5)
rsreset("top")
end
end
if colors.test(rs.getBundledInput("top"), colors.lightBlue+colors.orange) == true then
print("Opening Blast Doors...")
rs.setBundledOutput("bottom" , colors.lime)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.yellow)
sleep(0.5)
rs.setBundledOutput("bottom" , colors.lime)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.yellow)
sleep(0.5)
rs.setBundledOutput("bottom" , colors.lime)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.yellow)
sleep(0.5)
rs.setBundledOutput("bottom" , colors.lime)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.yellow)
sleep(0.5)
rs.setBundledOutput("bottom" , colors.lightBlue)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.lightBlue)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.lightBlue)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
rs.setBundledOutput("bottom" , colors.lightBlue)
sleep(0.5)
rsreset("bottom")
sleep(0.5)
print("Door Opened")
rs.setBundledOutput("top" , colors.lightBlue+colors.black)
sleep(0.5)
rsreset("top")
end
end
if colors.test(rs.getBundledInput("top"), colors.lightBlue+colors.magenta) == true then
else if colors.test(rs.getBundledInput("top"), colors.white+colors.orange+colors.yellow+colors.lime+colors.pink+colors.gray+colors.lightGray+colors.cyan+colors.purple+colors.blue+colors.brown+colors.green+colors.red+colors.black) == false then
print("Override - Opening Elevator Door...")
rs.setBundledOutput("bottom" , colors.pink)
sleep(3)
rsreset("bottom")
print("Override Complete...")
rs.setBundledOutput("top" , colors.lightBlue+colors.black)
sleep(0.5)
rsreset("top")
end
end
if colors.test(rs.getBundledInput("top"), colors.lightBlue+colors.yellow) == true then
print("Override - Closing Elevator Door...")
rs.setBundledOutput("bottom" , colors.gray)
sleep(3)
rsreset("bottom")
print("Override Complete...")
rs.setBundledOutput("top" , colors.lightBlue+colors.black)
sleep(0.5)
rsreset("top")
end
end
end
Elevator Controls:
Spoiler

shell.run("clear")
function rsreset(sSide)
	redstone.setBundledOutput(sSide, 0)
end
print("Welcome to Raw Elevator CTRL")
print("Waiting for Command from MainFrame...")
while true do
  event = os.pullEvent()
if colors.test(rs.getBundledInput("top"), colors.white+colors.orange+colors.magenta) == true then
print("Lifting Elevator")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.white)
sleep(1)
rsreset("bottom")
print("Elevator at Entrance Level")
rs.setBundledOutput("top" , colors.white+colors.orange+colors.black)
sleep(0.5)
rsreset("top")
end
end
if colors.test(rs.getBundledInput("top"), colors.white+colors.orange+colors.lightBlue) == true then
print("Lowering Elevator")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleep(1)
rsreset("bottom")
rs.setBundledOutput("bottom" , colors.orange)
sleeep(1)
rsreset("bottom")
print("Elevator at Reactor Level")
rs.setBundledOutput("top" , colors.white+colors.orange+colors.black)
sleep(0.5)
rsreset("top")
end
end
end
To me, the issue resides in this line of code:
if colors.test(rs.getBundledInput("top"), colors.white+colors.orange+colors.lightBlue) == true then
It checks of colors.white+colors.orange+colors.lightBlue is active. Though, if the main frame activates the exact command. A command with a line of code like this:
if colors.test(rs.getBundledInput("top"), colors.white+colors.orange) == true then
Would automatically activate that commands while activating the command up-top. Causing issues. I've tried a few options that did this:
if colors.test(colors.combine(colors.white+colors.orange+colors.magenta) == true) and (colors.test(rs.getBundledInput("right"), colors.lightBlue+colors.yellow+colors.lime+colors.pink+colors.gray+colors.lightGray+colors.cyan+colors.purple+colors.blue+colors.brown+colors.brown+colors.green+colors.red+colors.red+colors.black) ~= true) then
Though, it doesn't seems to want to work. So, I'm stuck at that. Any help would be appreciated
cant_delete_account #2
Posted 13 September 2012 - 12:31 AM
Please put those insanely long code snippets in spoilers.
GopherAtl #3
Posted 13 September 2012 - 12:53 AM
I've heard this a couple of times, and forgive me for hijacking your thread, but is there something I don't know about rednet? as I understand it, f you send to a known computer id, nobody else can listen in. They can't even send to it unless they know it's id, and even if they get that, it's easy to make it check who the sender was and ignore anything not on a recognized list. Only way they're getting around that is if they get to and hack one of the computers involved, and if they can do that, they can connect their own computer onto your bundled cable lines, too. I'm pretty new to computercraft, tho, so maybe there's some huge vulnerability in rednet wifi that I'm just not aware of, and if so, someone please tell me what it is?
Cranium #4
Posted 13 September 2012 - 01:04 AM
I've heard this a couple of times, and forgive me for hijacking your thread, but is there something I don't know about rednet? as I understand it, f you send to a known computer id, nobody else can listen in. They can't even send to it unless they know it's id, and even if they get that, it's easy to make it check who the sender was and ignore anything not on a recognized list. Only way they're getting around that is if they get to and hack one of the computers involved, and if they can do that, they can connect their own computer onto your bundled cable lines, too. I'm pretty new to computercraft, tho, so maybe there's some huge vulnerability in rednet wifi that I'm just not aware of, and if so, someone please tell me what it is?
Using rednet.send over wifi is definitely secure. That's hardcoded in. However, using rednet.send over bundled cable can be intercepted, since you are sending a series of redstone pulses, if I am not mistaken. If you are not concerned about security, bundled cables can be used in lieu of wireless modems.
Ivegon #5
Posted 13 September 2012 - 05:09 AM
But, without rednet. How could it be done? I understand the uses for rednet. Though, I'm in line to think of an alternative. And, that being, the bundled cables. Any suggestions?

Also, I'm doing this mainly to keep everything local. It's definitely secure where the bundled cables are. So, no risk of local hacking. Though, wireless hacking, even though it's hard, once you have the computer id and the right message to send, it can be done from afar. As for the bundles cables. One would have to always have access to the local channel. Anywho, thanks for replying!
Lyqyd #6
Posted 13 September 2012 - 06:09 PM
But, without rednet. How could it be done? I understand the uses for rednet. Though, I'm in line to think of an alternative. And, that being, the bundled cables. Any suggestions?

Also, I'm doing this mainly to keep everything local. It's definitely secure where the bundled cables are. So, no risk of local hacking. Though, wireless hacking, even though it's hard, once you have the computer id and the right message to send, it can be done from afar. As for the bundles cables. One would have to always have access to the local channel. Anywho, thanks for replying!

As long as each computer checks the sender to make sure that the messages are coming from a trusted computer, using the wireless rednet modems is significantly less likely to be compromised than any other method of communication between computers.
Ivegon #7
Posted 22 September 2012 - 12:43 AM
Small update: I`ve decided to use a hybrid redstone-rednet configuration. Essentially using the best of both options. So, I appreciate the help! And, by the way, it`s working marvellously at about 900 lines of code :3
GalactusX #8
Posted 22 September 2012 - 09:13 AM
one option would be to create a function in both the computer sending the signal as the recipient, to check if the signal received is correct or not, type "ping-pong", so would know the 2 computers or Furthermore, if the signal is authenticated, or otherwise is another sign "intruder" and therefore expendable.

I'm sorry if I'm wrong, only took one week programming in lua :P/>/>