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

Ping

Started by jaffacakesareamazing, 10 November 2014 - 06:18 PM
jaffacakesareamazing #1
Posted 10 November 2014 - 07:18 PM
Ping


Just a quick little program that I made that allows you (the client) to ping a server! This program is useful if:
1. You have a large rednet network and you want to see if the signal will go down the networking cable
2. You want to see if you are in wireless range of a transmitter
3. To test the raw speed of your network - ComputerCraft uses ping instead of upload and download time, the lower the ping time, the quicker it takes to send rednet messages between computers and to post and receive messages using the 'chat' program etc

Ping requires one server computer that is to be placed and connected to the area where you are either hosting other server related programs or at the main part of your ComputerCraft network. The other computers are just clients, which you can have as many of as you like! Just download the client file on every (pocket/turtle)computer that you want to test the connection of. Make sure to enter the ID number in the client to the ID of your Ping server or your clients will not be able to find the server. Ping also has a lookup time (the time it takes before it displays the message saying that the server is not found) of 5 seconds. 5 seconds will be plenty for most networks - unless you are some crazy person with thousands of computers and repeaters running.

Screenshots:

Ping server running:


Ping client running:




Downloads and setup!
Server: pastebin get R15hq8zd startup
Client: pastebin get mmPh9fkH ping

Server: Please run the server on its own computer that is new! Just download the file and reboot the computer to start the server!
Client: Download the file and edit the top line of the code to the ID of your server (this is displayed on the servers screen once it is started) and save it. Type 'ping' and you should receive a response!

I hope this proves useful to some people and I will keep maintaining it to fix bugs and add features in the future! If you find any bugs or have any questions, please message me! :)/>/>
Edited on 14 November 2014 - 06:27 PM
DannySMc #2
Posted 12 November 2014 - 12:01 PM
Nice idea!! I like the speed feature!

More Features (Just other things I think would be good, and I would personally use on my server if these were added):
+ Returns a distance from server to client
+ Returns list of computers / peripherals around or connected to it!
+ Maybe even some stats (up-time, ping count, etc)

Other than that quite cool,

One thing I would say is add a nice interface so it looks pretty and maybe even make it touch screen, and give an API to ping and get all these features so it can be used in other programs other than just the client one? :D/>
jaffacakesareamazing #3
Posted 13 November 2014 - 10:09 PM
Nice idea!! I like the speed feature!

More Features (Just other things I think would be good, and I would personally use on my server if these were added):
+ Returns a distance from server to client
+ Returns list of computers / peripherals around or connected to it!
+ Maybe even some stats (up-time, ping count, etc)

Other than that quite cool,

One thing I would say is add a nice interface so it looks pretty and maybe even make it touch screen, and give an API to ping and get all these features so it can be used in other programs other than just the client one? :D/>

Thanks for the suggestions. I am working on Ping 2.0 now! It should be released soon! Ping 2.0 adds a touchscreen GUI instead of a console based system and also multi-server support! For example you could have one server placed one side of your world and another one the other side and you can ping and see what the latency is on the closest 3 servers to you but I might change it up to 5. It will also show you the side that the modem is connected on and the side that Ping is going to use to test against (if you have multiple modems connected).

The distance from server to client would be a nice idea that I would like to add however it wouldn't work for wireless modems as that support was taken out in CC 1.6 and would mean the setup of a GPS system and create vectors to tell the distance apart. I might be able to do it using the modem API however but this would only work through wired modems (I might add support for this if I can - I am still working on the development of it). There aren't many stats to view as the ping time from the computers in CC won't change for example if you do it 1 time or 1000 times. So for the minute there are is only the ping time that is displayed unless I can think of any more features to add to it.

I also might work on an API for Ping at some point and include it in a new thread that I will start for Ping 2.0!

Thanks for the suggestions again!
MKlegoman357 #4
Posted 14 November 2014 - 02:13 PM
Actually, getting the distance through wired modems is not possible, but getting the distance through wireless modems is. You have to use the modem directly if you want to get the distance.
jaffacakesareamazing #5
Posted 14 November 2014 - 04:33 PM
Actually, getting the distance through wired modems is not possible, but getting the distance through wireless modems is. You have to use the modem directly if you want to get the distance.

Unfortunately it was removed in CC 1.6. It used to return like this: senderID, message, distance = rednet.receive([timeout]) however it now returns like this: senderID, message, protocol = rednet.receive([protocol filter, timeout]). This information has been got off the CC wiki page:

Rednet API: http://computercraft.info/wiki/Rednet_(API)
Modem API: http://computercraft.info/wiki/Modem_(API)

If you read through the page it will tell you more about what you can do and I have found the information correct in testing. If you can find another way around it, please tell me :)/>
KingofGamesYami #6
Posted 14 November 2014 - 04:40 PM
Proof modem api works (not rednet, modem)

Edit: The colors are funky because of this.
Edited on 14 November 2014 - 03:44 PM
jaffacakesareamazing #7
Posted 14 November 2014 - 05:56 PM
Proof modem api works (not rednet, modem)

Edit: The colors are funky because of this.
Actually, getting the distance through wired modems is not possible, but getting the distance through wireless modems is. You have to use the modem directly if you want to get the distance.

Yep thats what I was getting the info from, thanks KingofGamesYami :)/>
MKlegoman357 #8
Posted 14 November 2014 - 09:15 PM
Actually, getting the distance through wired modems is not possible, but getting the distance through wireless modems is. You have to use the modem directly if you want to get the distance.

Unfortunately it was removed in CC 1.6. It used to return like this: senderID, message, distance = rednet.receive([timeout]) however it now returns like this: senderID, message, protocol = rednet.receive([protocol filter, timeout]). This information has been got off the CC wiki page:

Rednet API: http://computercraft.info/wiki/Rednet_(API)
Modem API: http://computercraft.info/wiki/Modem_(API)

If you read through the page it will tell you more about what you can do and I have found the information correct in testing. If you can find another way around it, please tell me :)/>/>

Huh, sorry about that. I somehow mistaken what rednet.receive returned.