Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
nightsta69

not understanding the network loot disk

Question

ok so i've been playing with the network loot disk for the past few days, and i don't seem to understand what i'm doing wrong here, so i'll show you what i'm doing, and trying to do, and the results of said actions.

 

i have 3 computers that i'm trying to connect together thru the udp protocol from the network loot disk.

 

Server A: 192.168.1.1 -- serves as a "database" server to hold variables sent to it and relay them to other servers that request said variables.

 

server B: 192.168.1.10 -- server that collects information about my reactor and components attached and then pushes it to Server A

 

Server C: 192.168.1.11 -- client program that requests information from server A and displays it.

 

server A

local component = require("component")
local event = require("event")
local s = require("serialization")
local network = require("network")
network.ip.bind("192.168.1.1")
network.udp.open(1024)
network.udp.open(1025)
reactorinfo = {}


function incoming(origin, port, data)
        print("we have something!")
        if port == 1024 then
            reactorinfo = s.unserialize(data)
        elseif port == 1025 and data == "request" then
            print("sending reactorinfo")
            network.udp.send(origin, port, s.serialize(reactorinfo))
        end 
end
event.listen("datagram", incoming)
while true do
event.pull()
os.sleep(0)
end

Server B

local component = require("component")
local event = require("event")
local s = require("serialization")
local term = require("term")
local network = require("network")
local br = component.proxy(component.list("br_reactor")())
local pm = component.proxy(component.list("power_monitor")())
local reactorinfo = {}
local isactive = 0
local percentpowerlow = 0
local percentpowerhigh = 0
local charging = false
local running = true
term.clear()
network.ip.bind("192.168.1.10")
network.udp.open(1024)
print("reactor control relay initiating...")
print("gathering information about the connected reactor.")
print("ready to transmit data.")
while running do
        reactorinfo = {["name"] = "reactorinfo", ["maxcapacity"] = pm.getMaxPowerInCapBanks(), ["curcap"] = pm.getPowerInCapBanks(), ["avgreceived"]= pm.getAverageEnergyReceived(), ["avgsent"] = pm.getAverageEnergySent(), ["ppt"] = pm.getPowerPerTick(), ["isactive"] = br.getActive(), ["casetemp"] = br.getCasingTemperature(), ["energytick"] = br.getEnergyProducedLastTick(), ["fuelamt"] = br.getFuelAmount(), ["fuelmax"] = br.getFuelAmountMax(), ["fuelconsumed"] = br.getFuelConsumedLastTick()}
        print("sending")
        network.udp.send("192.168.1.1", 1024, s.serialize(reactorinfo))
        print("sent")
charging = reactorinfo.isactive
percentpowerlow = math.floor(.1*reactorinfo.maxcapacity)
percentpowerhigh = math.floor(.99*reactorinfo.maxcapacity)
 
     if reactorinfo.curcap < percentpowerlow and charging == false then
        if br.getActive() == false then
            br.setActive(true)
            charging = true
        end
     elseif reactorinfo.curcap > percentpowerhigh and charging == true then
            if br.getActive() == true then
                br.setActive(false)
                charging = false
            end
     end  
 
end

server C

local component = require("component")
local event = require("event")
local keyboard = require("keyboard")
local s = require("serialization")
local term = require("term")
local tun = component.proxy(component.list("tunnel")())
local running = true
local gpu = component.gpu
local network = require("network")
local reactorinfo = {}
gpu.setResolution(45, 16)
term.clear()
network.ip.bind("192.168.1.11")
network.udp.open(1025)
network.udp.send("192.168.1.1",1025, "request")
local _, origin, port, data = event.pull("datagram")
    reactorinfo = s.unserialize(data)
charging = reactorinfo.isactive
 
local function printXY(row, col, ...)
  term.setCursor(col, row)
  term.clearLine()
  print(...)
end
function round(num, idp)
  local mult = 10^(idp or 0)
  return math.floor(num * mult + 0.5) / mult
end
 
term.clear()
while running do
printXY(1, 1, "Reactor Information")
printXY(2, 1, "=========================")
 
     if reactorinfo.isactive == true then
        printXY(3, 1,"Reactor: Online")
     else
        printXY(3, 1,"Reactor: Offline")
     end
printXY(4, 1, "Case Temperature: "..round(reactorinfo.casetemp, 2).." degrees C")
printXY(5, 1, "Current Fuel: " ..reactorinfo.fuelamt.." / "..reactorinfo.fuelmax)
printXY(6, 1, "Fuel Consumed: " ..round(reactorinfo.fuelconsumed, 3).." mb/Tick")
printXY(7, 1, "RF/T Produced: " ..round(reactorinfo.energytick, 2))
printXY(8, 1, "")
printXY(9, 1, "")
printXY(10, 1, "Capacitor Information")
printXY(11, 1, "=========================")
    if reactorinfo.isactive == true then
        printXY(12, 1, "Charge State: Charging")
    else
        printXY(12, 1, "Charge State: Discharging")
    end
printXY(13, 1, "Current Capacitor: " ..reactorinfo.curcap.." / "..reactorinfo.maxcapacity)
printXY(14, 1, "Average Input: "..round(reactorinfo.avgreceived, 2).." RF/Tick")
printXY(15, 1, "Average Output: "..round(reactorinfo.avgsent, 2).." RF/Tick")
 
network.tcp.send(1, "request")
network.udp.send("192.168.1.1",1025, "request")
local _, origin, port, data = event.pull("datagram")
        reactorinfo = s.unserialize(data)
end
term.clear()

now i start everything up, and Server B says that its sending the information through my debug prints, but Server A NEVER receives anything. no events fire or anything.

now i do the below code in the lua interpreter on Server A 

network.ip.bind("192.168.1.1")
network.tcp.listen(1024)

while true do local _, origin, port, data = event.pull("datagram") print(origin, port, data) network.udp.send(origin, port, "got it") end


and this on Server B

network.ip.bind("192.168.1.10")
network.tcp.listen(1024)
network.udp.send("192.168.1.1", 1024, "test") local _, origin, port, data = event.pull("datagram") print(origin, port, data)

and i get a response. both of these servers are in the same rack, with both servers having network cards, and routing is set to internal.

 

now i do on server C 

network.ip.bind("192.168.1.11")
network.tcp.listen(1024)
network.udp.send("192.168.1.1", 1024, "test") local _, origin, port, data = event.pull("datagram") print(origin, port, data)

and i get a response. Server C is completely seperate from the network except for a linked card on Server A.

 

I can also do the same thing and request to talk to server B THROUGH server A's linked card from Server C and it works just fine, but only through the interpreter.

 

so the only thing left that i don't understand, is why Server A isn't getting information from Server B, OR getting a request from Server C for the variable reactorinfo to be sent.

 

i've been beating my head against the wall for the past couple days trying to figure it out, so any help would be greatly appreciated. thanks!

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

so is my implementation of the networking protocol right? does the networking protocol still work? i've kinda been waiting for some sort of response on this for the past few days now. if it doesn't work anymore, i'll figure out something else, i just thought it would be neat to use it, since it was provided by the mod itself.

Link to post
Share on other sites
  • 0

Hello, sorry for reponsing that late, but I'm not really into the forums, I'm reachable via IRC more.

 

anyways, looking at code of server A I see the

function incoming(origin, port, data)

it should be

function incoming(_, origin, port, data)

This seems to be 99% of the problem

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.