Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- write("Enter the side your wireless modem is on: ")
- rednet.open(read())
- write("Enter the ID of the server computer: ")
- id = read()
- results = {}
- for i=1, 5 do
- event = "temp"
- temp = 0
- rednet.send(tonumber(id), "pingTestStart")
- while event ~= "rednet_message" and param2 ~= "pingTestEnd" and temp <= 30 do
- os.startTimer(0.1)
- event, param1, param2 = os.pullEvent()
- if event == "timer" then
- temp = temp+1
- end
- if temp%10 == 0 then
- write(".")
- end
- end
- results[i] = temp
- if event == "timer" then
- results[i] = "fail"
- end
- print()
- end
- fails = 0
- temp = 0
- for i=1, 5 do
- if results[i] == "fail" then
- fails = fails+1
- else
- temp = temp+results[i]
- end
- end
- if fails < 5 then
- result = temp/(5-fails)
- print("Ping is "..result*100 .." ms, "..fails.." packets lost.")
- else
- print("An error occurred, all packets lost.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement