diff --git a/app_test/raft_anim.lua b/app_test/raft_anim.lua index d4f248b..34405d4 100644 --- a/app_test/raft_anim.lua +++ b/app_test/raft_anim.lua @@ -2,12 +2,15 @@ Raft leader election implementation with anim log (see tools) +With 5 nodes + + @@ -16,6 +19,20 @@ Raft leader election implementation with anim log (see tools) + + + + + + + + + + + + + + @@ -169,6 +186,8 @@ end function trigger_heart_timeout() state.term = state.term + 1 + -- For crash the leader sometime (replace Crash -> CRASH) + -- CRASH POINT 1 2 3 4 5 : RECOVERY 1 : RANDOM 0.05 for k, s in pairs(sockets) do if s ~= nil then aSendData(s,heartbeat_msg.." "..state.term) @@ -283,7 +302,7 @@ events.run(function() set_election_timeout() -- Stop after 10 seconds - events.sleep(20) + events.sleep(35) print("ANIM EXIT "..job.position) events.exit() end) diff --git a/app_test/security_issue_example.lua b/app_test/security_issue_example.lua new file mode 100644 index 0000000..82ff923 --- /dev/null +++ b/app_test/security_issue_example.lua @@ -0,0 +1,85 @@ +--[[ +WITH this topology and 2 slayds, by pass the topology <- + + + + + + + + + + + + + + +]]-- +package.loaded["socket"] = nil +package.loaded["socket.core"] = nil +package.loaded["splay.socket"] = nil + + +print("SIMPLE_TOPO.LUA START") +socket = require("socket.core") + +require("splay.base") +socket = require("socket.core") + +local events=require("splay.events") +local rpc=require("splay.rpc") +local net = require("splay.net") +local misc = require("splay.misc") +socket = require("socket.core") + + +local rtt = 0 +local t_end = 0 + +function print_server(data, ip, port) + print("<<< "..ip..":"..port.." : "..data) + if data == "hello" then + u.s:sendto("world", ip, port) + else + t_end = misc.time() + end +end +print("Start UDP server") +u = net.udp_helper(job.me.port, print_server) + +events.run(function() + + 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 + print(">>> "..n.ip..":"..n.port.." : hello") + u.s:sendto("hello", n.ip, n.port) + end + end + + events.sleep(4) + + if t_end == 0 then + local start = misc.time() + for i, n in pairs(job.nodes) do + if i ~= job.position then + print(">>> "..n.ip..":"..n.port.." : hello") + u.s:sendto("hello", n.ip, n.port) + end + end + + events.sleep(4) + end + + 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") diff --git a/app_test/simple_topo_lat.lua b/app_test/simple_topo_lat.lua index c02c1c7..69cd3b9 100644 --- a/app_test/simple_topo_lat.lua +++ b/app_test/simple_topo_lat.lua @@ -11,7 +11,7 @@ WITH this topology and 2 slayds - + ]]--