3 # Copyright (c) 2012-2023. The SimGrid Team.
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the license (GNU LGPL) which comes with this package.
10 This script generates a specific deployment file for the Bittorrent example.
11 It assumes that the platform will be a cluster.
12 Usage: python generate.py nb_nodes nb_bits end_date percentage
13 Example: python generate.py 10000 5000
19 if len(sys.argv) != 4:
21 "Usage: python generate.py nb_nodes end_date seed_percentage > deployment_file.xml")
24 nb_nodes = int(sys.argv[1])
25 end_date = int(sys.argv[2])
26 seed_percentage = int(sys.argv[3])
29 max_id = 2 ** nb_bits - 1
32 sys.stdout.write("<?xml version='1.0'?>\n"
33 "<!DOCTYPE platform SYSTEM \"https://simgrid.org/simgrid.dtd\">\n"
34 "<platform version=\"4\">\n"
35 " <actor host=\"node-0.simgrid.org\" function=\"tracker\">\n"
36 " <argument value=\"%d\"/>\n </actor>\n" % end_date)
38 for i in range(1, nb_nodes):
42 my_id = random.randint(0, max_id)
43 ok = my_id not in all_ids
45 line = " <actor host=\"node-%d.simgrid.org\" function=\"peer\">\n" % i
46 line += " <argument value=\"%d\"/>\n <argument value=\"%d\"/>\n" % (
48 if random.randint(0, 100) < seed_percentage:
49 line += " <argument value=\"1\"/>\n"
51 sys.stdout.write(line)
53 sys.stdout.write("</platform>")