Jump to content




Dynamic Rednet Connectivity


  • You cannot reply to this topic
3 replies to this topic

#1 Cozzimoto

  • Members
  • 221 posts
  • LocationDallas, Tx

Posted 28 July 2013 - 11:04 AM

first before i get into the problem at hand, im not too familiar with timers and modem_messages with the os.pullevent(). im not entirely sure if a modem_message will still trigger if the computer is going through a current process.

problem trying to solve:
i am trying to create dynamic rednet sucurity with the modem api, i know a computer can only have 128 maximum channels (or ports i call them) open at the same time, so i figure that a server can listen on a certain channel as a public channel for clients to connect to. channels 1 - 128 would be public and channels 129 - 65535 would be private channels for interacting with servers.

problem i ran into:
i think i am getting the timing wrong but my test client is pinging on the test server, but the client isnt showing the response the server should have sent. im not sure how long i should wait between the transmit and reply and a little longer of a wait for a timer so if nothing happens the timer will fire and the client will continue on to other public ports.

i have both programs here and a screenshot of 1 run on the client program to the server.

tell me what yall think and test it out

P.S. im not giving out my encoding and decoding port functions due for the security purpose of this build.

Posted Image

test server code
Spoiler

test client code
Spoiler


#2 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 28 July 2013 - 09:10 PM

You might want to print out the messages that are sent and received, for easier debugging.

#3 Cozzimoto

  • Members
  • 221 posts
  • LocationDallas, Tx

Posted 29 July 2013 - 07:38 AM

the reason i put a status variable there for each computer id is i am making several steps to connect to the server, the client doesnt know what channel the server is listening on, so what the client does is i want it to scan each channel (most all the public channels [1-128]) and try and find the server its looking for. and the server keeps track of credentials that every connection needs, with is a table of the computerID computerName (if available), the status of the connection process and the port number assigned to that computer.

im not sure if i need to keep track of status of the connection, i mainly put it in there to make it hack proof and have a computer follow a specific format to connecting to the server without skipping a step.


this is the thought process i have drawn out of how i want the dynamic connection to work
  • so the client sends out pings for a server reply, if no rely go on to next channel and ping again.
  • once there is a pong, the client then asks "whoareyou?" so the server can reply with a unique id of what purpose that server does.
  • if the unique id isnt what the client wants then it will continue on the next channel.
  • if it is the right server then the client asks permission to connect
  • the server then encodes a port over rednet and sends it back to the client opening that private port
  • the client then decodes the port received by the server and closes all ports and opens the private port
  • last the client then sends a "connectionVerify" to see if it decoded the correct port from the server, and if so the server replies with "connectionEstablished"


and all the important information i am printing to the screen, im just not seeing the pong return from the server on the client that sent the ping. for testing i reduced the scan down to 15 channels and i should see a pong on the client on channel 10 but i dont, so thats why i am coming to the forums to see if i had a timing issue, or if i need to run the parallel api to try and solve this issue. i mainly think its a timing issue but im gunna keep tinkering with it and illl still listen on your guys' input like always

#4 Cozzimoto

  • Members
  • 221 posts
  • LocationDallas, Tx

Posted 29 July 2013 - 01:16 PM

ok so after tinkering around alot, i have a proof of concept dynamically creating private ports on certain computer ids. expanding on the idea of hashing everything broadcasted on the public channels yes, but i did have timing issues, i learned today that i can sleep(0) to yield just long enough that a modem_message isnt triggered when i was sending a reply. code is very rough but im gunns work on it and place the beta builds in my pastebin. again i took out the RNG and encode and decode functions due to security. but here is a few screen shots and some data of the two programs i made, now i need to implement this on my banking system im creating.

Client Side
Posted Image
Spoiler


Server-Side
Posted Image
Spoiler

and a picture of a monitor listening to all the events happening
Posted Image





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users