Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[Lua] Updated the bittorent.lua test
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Thu, 23 Jul 2015 16:27:46 +0000 (18:27 +0200)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Thu, 15 Oct 2015 17:17:18 +0000 (19:17 +0200)
- 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).

examples/lua/bittorrent/bittorrent.lua
examples/lua/bittorrent/bittorrent.tesh
examples/lua/bittorrent/peer.lua
examples/lua/bittorrent/tracker.lua

index 0570ef0..b1999b6 100644 (file)
@@ -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()
index 3dc1ddd..1ce4071 100644 (file)
@@ -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
-
index 7166c00..f9a0d8b 100644 (file)
@@ -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
index cdf3e3b..fee6c3a 100644 (file)
@@ -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])