-- 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()
> [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
-
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
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
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
end
end
return s
-end
\ No newline at end of file
+end