3 # Copyright (c) 2012-2018. 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.
9 # This script generates a specific deployment file for the Bittorrent example.
10 # It assumes that the platform will be a cluster.
11 # Usage: python generate.py nb_nodes nb_bits end_date percentage
12 # Example: python generate.py 10000 5000
17 if len(sys.argv) != 4:
19 "Usage: python generate.py nb_nodes end_date seed_percentage > deployment_file.xml")
22 nb_nodes = int(sys.argv[1])
23 end_date = int(sys.argv[2])
24 seed_percentage = int(sys.argv[3])
27 max_id = 2 ** nb_bits - 1
30 sys.stdout.write("<?xml version='1.0'?>\n"
31 "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n"
32 "<platform version=\"4\">\n"
33 " <process host=\"node-0.acme.org\" function=\"tracker\">\n"
34 " <argument value=\"%d\"/>\n </process>\n" % end_date)
36 for i in range(1, nb_nodes):
40 my_id = random.randint(0, max_id)
41 ok = not my_id in all_ids
43 line = " <process host=\"node-%d.acme.org\" function=\"peer\">\n" % i
44 line += " <argument value=\"%d\"/>\n <argument value=\"%d\"/>\n" % (
46 if random.randint(0, 100) < seed_percentage:
47 line += " <argument value=\"1\"/>\n"
48 line += " </process>\n"
49 sys.stdout.write(line)
51 sys.stdout.write("</platform>")