From c48543c372f44816e7d688802a491be30534780c Mon Sep 17 00:00:00 2001 From: Willfrit Date: Wed, 17 Apr 2019 18:07:47 +0200 Subject: [PATCH] continue script app for testing! --- app_test/simple.lua | 5 +++-- app_test/simple_net.lua | 17 +++++++++-------- app_test/simple_topo.lua | 12 ++++++------ 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/app_test/simple.lua b/app_test/simple.lua index deef63d..2bb974c 100644 --- a/app_test/simple.lua +++ b/app_test/simple.lua @@ -1,15 +1,16 @@ --[[ -Small script to test splay, just log the different neighbours during 1 minutes +Small script to test splay, just log the different neighbours, exit directly after --]] require("splay.base") +print("SIMPLE.LUA START") print("I am the job "..job.position) neighbours = job.nodes print("I am link to :") for _, n in pairs(neighbours) do print(" - "..n.ip..":"..n.port) end -print("Exit Discovering Job") \ No newline at end of file +print("SIMPLE.LUA EXIT") \ No newline at end of file diff --git a/app_test/simple_net.lua b/app_test/simple_net.lua index 8a8d3bf..c5825dd 100644 --- a/app_test/simple_net.lua +++ b/app_test/simple_net.lua @@ -29,6 +29,7 @@ rs.init(settings) socket = rs.wrap(socket) package.loaded['socket.core'] = socket ]] +print("SIMPLE_NET.LUA START") print("Begin Simple network : I am "..job.me.ip..":"..job.me.port) require("splay.base") @@ -41,15 +42,15 @@ function receive(s) local ip, port = s:getpeername() while events.yield() do local data, err = s:receive("*l") - print("I received "..data.." from "..ip..":"..port) + print("I received : "..data) end end function send(s) print("Send Stand by") while events.yield() do - events.sleep(3) - s:send("Hello i am "..misc.dump(job.me).."\n") + events.sleep(1) + s:send("I AM "..job.position.."\n") end end @@ -60,16 +61,16 @@ end function final(s) local ip, port = s:getpeername() - print("Closing: "..ip..":"..port.." - index ") + print("Closing: "..ip..":"..port) end events.run(function() -- Accept connection from other nodes net.server(job.me.port, {initialize = init, send = send, receive = receive, finalize = final}) - -- Launch connection to each orther node (use the same function than server) (retry every 5 second) + -- Launch connection to each orther node events.thread(function () - events.sleep(5) + events.sleep(1) for i, n in pairs(job.nodes) do if n.port ~= job.me.port or n.ip ~= job.me.ip then print("Try to begin connection to "..n.ip..":"..n.port.." - index "..i) @@ -79,8 +80,8 @@ events.run(function() end) -- Stop after 20 seconds - events.sleep(20) - print("Simple Network exit") + events.sleep(4) + print("SIMPLE_NET.LUA EXIT") events.exit() end) diff --git a/app_test/simple_topo.lua b/app_test/simple_topo.lua index a641c73..0fb4805 100644 --- a/app_test/simple_topo.lua +++ b/app_test/simple_topo.lua @@ -16,8 +16,7 @@ WITH this topology and 2 slayds ]]-- -print("TOPO TEST") - +print("SIMPLE_TOPO.LUA START") require("splay.base") local events=require("splay.events") @@ -41,11 +40,10 @@ u = net.udp_helper(job.me.port, print_server) events.run(function() - print("Wait 5 seconds") - events.sleep(5) + print("Wait 2 seconds") + events.sleep(2) print("Start send hello") - local start = misc.time() for i, n in pairs(job.nodes) do if i ~= job.position then @@ -54,11 +52,13 @@ events.run(function() end end - events.sleep(5) + events.sleep(4) final_time = t_end - start print("Time to n1 -> hello -> n2 -> world -> n1 : "..final_time) + print("FINAL RTT : "..final_time.." sec") events.kill(u.server) end) +print("SIMPLE_TOPO.LUA EXIT")