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

Netsharp - Keeping Computers Connected

Started by Antelux, 16 February 2018 - 11:39 PM
Antelux #1
Posted 17 February 2018 - 12:39 AM
pastebin get wxiWB8rw netsharp

Hi guys! It's been a while since I've posted something on the forums but I've had some recent interest in the mod again.

Anyway, Netsharp is a program I've been working on for the past two days or so. I decided to create it since I need the functionality and didn't know of any other program that does this (though I'd feel a little embarrassed if there actually was one that was decently executed :unsure:/>). A description of it is as follows:

This program connects multiple computers over a given network to allow accessing their file systems by providing them as separate folders within a folder named "network" that's found on the root level. Thus, this allows for an easy and transparent way for people to access the data on other computers and modify it accordingly. This program also strives to maintain comparability so other programs that rely on the computer's file system don't need to use special APIs or take precautions while Netsharp is operating to maintain ease of operability.

Why is this useful?
Well, you no longer have to move files around by floppy disks. In the example of having multiple computers acting as servers, they can simply be connected by modems to access each others' files.

The setup:
Simply connecting multiple computers together with modems and networking cable will suffice for the hardware part of it. Here's a simple example:


The Setup (Software):
After downloading the program, all you need to do to get up and running is netsharp connect <channel> where channel is a number between 0 and 65530.
Then you can simply access all computers on the network as if they were a folder on the computer itself. Another example:

If you'd like to have this run upon startup on the computer, simply stick shell.run("netsharp connect <channel>") at the top of the computer's startup file.

FAQs
Can I use wireless modems instead of wired ones?
While I have yet to try it (as it isn't the current goal of this program), it should in theory work with wireless modems just as well. However, I heavily advise against it if you plan to use it on a public server for the reasoning given in the next question:

How secure is it?
Somewhat secure. There are options that allow making a computer hidden from the network folder as well as making a computer read only to all other computers. However, I still recommend as of now that this program stick to private wired networks only.

What's the performance of it?
With the exception of listing all computers in the "network" folder (which waits the full length of the default timeout, 0.15s, to get replies), it feels around 70-80% as fast as the default shell when accessing other computers. If this is too big a penalty, auto complete can be shut off (settings.set("shell.autocomplete", false)) to make it feel like there is practically no overhead at all.

How scalable is it?
While I haven't tried using it with more than four computers, it should be able to support much, much more. Things only become problematic if the channel it's using starts to get heavy traffic from computers using it for other purposes.

Are there any "gotchas" I should worry about?
Running the program without any arguments will give a list of commands that are usable with it. Those that begin with an asterisk (*) aren't implemented.
Some of the commands change settings for the network. These, along with setting the computer's label, don't take effect until netsharp refresh is ran.

Current Bugs:
  • Editing a file from another computer with the program 'edit' only gives the first few lines or so of it.
  • Probably a few more from very case-specific stuff I have yet to uncover.
Anyway, hope you guys will find this program useful. Let me know of any other comments or concerns there might be.
Edited on 16 February 2018 - 11:47 PM
Bomb Bloke #2
Posted 17 February 2018 - 04:02 AM
If this is too big a penalty, auto complete can be shut off (settings.set("shell.autocomplete", false)) to make it feel like there is practically no overhead at all.

The trick might be to cache network directory listings in a table somewhere so that you don't need to rely on rednet for every keypress. Setting a timer for, say, 10s and deleting the local listing when it expires would help keep things current.
Antelux #3
Posted 17 February 2018 - 06:28 AM
The trick might be to cache network directory listings in a table somewhere so that you don't need to rely on rednet for every keypress. Setting a timer for, say, 10s and deleting the local listing when it expires would help keep things current.

Yeah, I was thinking of something along those lines. I'll implement speed-increasing things like that once any other bugs are taken out.
Oh, and it doesn't use the rednet API. It uses the actual modem API itself to remove overhead.
Edited on 17 February 2018 - 05:29 AM
Bomb Bloke #4
Posted 18 February 2018 - 12:28 AM
Come to think of it, it might be better to just inspect the system clock directly, rather than relying on timers. No need to rely on events that way.