A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add VM energy extensions - Adrien
[simgrid.git]
/
examples
/
lua
/
bittorrent
/
tracker.lua
diff --git
a/examples/lua/bittorrent/tracker.lua
b/examples/lua/bittorrent/tracker.lua
index e66299017829a34d806984f4908436fc3814e2a0..fee6c3adae37cb030c0daa1006050462a5292a5c 100644
(file)
--- a/
examples/lua/bittorrent/tracker.lua
+++ b/
examples/lua/bittorrent/tracker.lua
@@
-1,3
+1,9
@@
+-- Copyright (c) 2012, 2014. The SimGrid Team.
+-- All rights reserved.
+
+-- This program is free software; you can redistribute it and/or modify it
+-- under the terms of the license (GNU LGPL) which comes with this package.
+
-- A SimGrid Lua implementation of the Bittorrent protocol.
require("simgrid")
-- A SimGrid Lua implementation of the Bittorrent protocol.
require("simgrid")
@@
-19,8
+25,6
@@
function tracker(...)
if #args ~= 1 then
simgrid.info("Wrong number of arguments for the tracker")
end
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])
-- Retrieve the end time
tracker_data.deadline = tonumber(args[1])
@@
-41,8
+45,8
@@
function tracker(...)
i = math.random(1,#tracker_data.peers_list)
end
while #peers < #tracker_data.peers_list and #peers < common_tracker.MAXIMUM_PEERS do
i = math.random(1,#tracker_data.peers_list)
end
while #peers < #tracker_data.peers_list and #peers < common_tracker.MAXIMUM_PEERS do
- table.insert(peers,tracker_data.peers_list[i])
- i = (i
+ 1) % #tracker_data.peers_list
+ table.insert(peers,tracker_data.peers_list[i])
+ i = (i
% #tracker_data.peers_list) +1
end
task.type = "ANSWER"
task.peers = peers
end
task.type = "ANSWER"
task.peers = peers