From: Christian Heinrich Date: Thu, 23 Jul 2015 16:27:46 +0000 (+0200) Subject: [Lua] Updated the bittorent.lua test X-Git-Tag: v3_13~1644^2~21 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/370ad894d47debda32fbbdfa0130893b857e63a6?ds=sidebyside [Lua] Updated the bittorent.lua test - Changed several simgrid.info to simgrid.debug calls - Removed junk code; this is not needed any more - Updated the test results; these changed because we fixed a bug with random numbers (the seed was only initialized for the tracker, not for peers). --- diff --git a/examples/lua/bittorrent/bittorrent.lua b/examples/lua/bittorrent/bittorrent.lua index 0570ef0a47..b1999b6682 100644 --- a/examples/lua/bittorrent/bittorrent.lua +++ b/examples/lua/bittorrent/bittorrent.lua @@ -14,6 +14,6 @@ require("tracker") -- Initialization of the random generator table.sort(math) math.randomseed(42) -simgrid.platform("../../platforms/platform.xml") -simgrid.application("bittorrent.xml") +simgrid.platform(arg[1] or "../../platforms/platform.xml") +simgrid.application(arg[2] or "bittorrent.xml") simgrid.run() diff --git a/examples/lua/bittorrent/bittorrent.tesh b/examples/lua/bittorrent/bittorrent.tesh index 3dc1dddd40..1ce407186c 100644 --- a/examples/lua/bittorrent/bittorrent.tesh +++ b/examples/lua/bittorrent/bittorrent.tesh @@ -23,13 +23,12 @@ $ lua bittorrent.lua > [iRMX:peer:(7) 15.043659] [lua/INFO] Received an answer from the tracker with 5 peers inside > [iRMX:peer:(7) 15.043659] [lua/INFO] Start downloading. > [McGee:peer:(8) 16.609414] [lua/INFO] Starting main leech loop -> [iRMX:peer:(7) 24.873510] [lua/INFO] Starting main leech loop +> [iRMX:peer:(7) 17.228855] [lua/INFO] Starting main leech loop > [Jacquelin:tracker:(1) 3000.000000] [lua/INFO] Tracker is leaving > [Geoff:peer:(5) 5000.005341] [lua/INFO] My status is now 1111111111 > [Boivin:peer:(2) 5000.048882] [lua/INFO] My status is now 1111111111 +> [iRMX:peer:(7) 5000.228855] [lua/INFO] My status is now 1111111111 > [McGee:peer:(8) 5000.609414] [lua/INFO] My status is now 1111111111 > [TeX:peer:(4) 5000.619837] [lua/INFO] My status is now 1111111111 > [Disney:peer:(6) 5000.644339] [lua/INFO] My status is now 1111111111 -> [iRMX:peer:(7) 5000.873506] [lua/INFO] My status is now 1111111111 > [Jean_Yves:peer:(3) 5000.925088] [lua/INFO] My status is now 1111111111 - diff --git a/examples/lua/bittorrent/peer.lua b/examples/lua/bittorrent/peer.lua index 7166c004eb..f9a0d8b410 100644 --- a/examples/lua/bittorrent/peer.lua +++ b/examples/lua/bittorrent/peer.lua @@ -183,26 +183,16 @@ function get_peers_data() if v ~= data.id then --Add the peer to our list and build its data local peer_data = {} - peer_data.id = math.tointeger(v); + peer_data.id = v; peer_data.bitfield = nil - peer_data.mailbox = math.tointeger(v); + peer_data.mailbox = tostring(v); peer_data.am_interested = false peer_data.interested = false peer_data.choked_upload = true peer_data.choked_download = true - data.peers[v] = peer_data - simgrid.info("Added " .. v) + data.peers[v] = peer_data end end - mt = {} - mt.__len = function(obj) - local len = 0; - for j,k in pairs(obj) do - len = len+1 - end - return len - end - setmetatable(data.peers, mt) else success = false end @@ -286,7 +276,6 @@ function handle_message(task) end end elseif task.type == "PIECE" then - task.piece = math.tointeger(task.piece) if task.stalled == true then simgrid.debug("The received piece is stalled") else @@ -427,7 +416,7 @@ function send_interested(mailbox) end -- Send a "not interested" message to a peer. function send_not_interested(mailbox) - simgrid.info("Sending a send_not_interested") + simgrid.debug("Sending a send_not_interested") local task = new_task("NOTINTERESTED") task:dsend(mailbox) end @@ -511,4 +500,4 @@ function get_status() end end return s -end \ No newline at end of file +end diff --git a/examples/lua/bittorrent/tracker.lua b/examples/lua/bittorrent/tracker.lua index cdf3e3b642..fee6c3adae 100644 --- a/examples/lua/bittorrent/tracker.lua +++ b/examples/lua/bittorrent/tracker.lua @@ -25,8 +25,6 @@ function tracker(...) if #args ~= 1 then simgrid.info("Wrong number of arguments for the tracker") end - -- Initialization of the random generator - math.randomseed(42) -- Retrieve the end time tracker_data.deadline = tonumber(args[1])