P2P simulator for testing Clarinet based on PeerSim. Includes some updates to make building and running a bit more self-contained.
You will need Make installed. If you do not have it, you can find information on it here.
You will also need a somewhat newer version of Java. I've verified Java 17 (LTS) works. This is the most recent LTS version that will work, but if you wish to use a non-LTS version, you can likely run as old as Java 14.
Additionally, all support scripts are written in bash since this should be accessible in some form on basically any operating system. The scripts should use relatively platform-agnostic features, so hopefully everything works, but I can't make any promises.
Any custom classes should be placed in the src/clarinetsim
package. So long as you add things here, they'll be
accessible without further configuration.
To build the application run make release
from the project root.
Config values include the following:
TODO -- rewrite this
To run a simulation run make run {path to your cfg file}
. For example make run ./myconfig.txt
.
TODO -- rewrite this
If you would like to run a series of simulations, you can use simulations/run-sims.sh
. The script has several sets of
values toward the top. Values here are demonstrative and not necessarily what is currently in the script.
NODE_CNTS=(100 500 1000 5000) # number of nodes in the simulation
CYCLE_CNTS=(10 100 1000 10000) # number of cycles in the simulation
COEFF_VALS=(1 10 100 1000) # see line 6 of simulations/template.txt
MAL_PCTS=(0 10 25 50 75 90) # percentage of malicious nodes
These are used to determine the runs, and are the best place to customize runs.
The script generates configurations for each run and stores them in the simulations/configs
directory. This gets
cleaned at the start of every run, so don't add files manually. Files are named
config-{node_cnt}-{cycle_cnt}-{coeff_val}-{mal_pct}.txt
.
Results of the runs are stored in the simulations/output
directory. Similarly, these get cleaned at the start of every
run, so copy any you would like to keep to a different directory. Files are named
results-{node_cnt}-{cycle_cnt}-{coeff_val}-{mal_pct}.txt
.
Additionally, this means the more simulations you run, the more files will be generated, so again, be careful about combinatorial explosion.
Note: The PeerSim random seed is commented out. If you would like to enable it, uncomment line 16 of
simulations/template.txt
.
- The values used by
run-sims.sh
are permuted on, so that means that the total number of runs, and subsequently config and results files will belen(NODE_CNTS) * len(CYCLE_CNTS) * len(COEFF_VALS) * len(MAL_PCTS)
. - Larger simulations can take quite some time. This seems to be mostly dependent on the
NODE_CNTS
andCYCLE_CNTS
values.COEFF_VALS
andMAL_PCTS
don't seem to have any noticeable effect. I don't recommend going pastNODE_CNT=1000
andCYCLE_CNT=10000
unless you have some separate machine to run on with quite a bit of ram. For reference, 1000 x 10000 took about 10-15 minutes on my laptop while 5000 x 10000 took about 4 hours on a 128GB VM with 64GB max memory given to the Java process.
- Since there can be a potentially large number of simulations, and they can take a while, the
simulations/watch.sh
script will print out the last file in theresults
directory in a continuous loop. This is an infinite loop, so it is up to you to manually stop the process. You can provide an optional integer parameter to tell the script how long to wait between checks in seconds, for example./watch.sh 2
to check every 2 seconds. - The results files are essentially the STDOUT of the run, which results in some noise. The
simulations/cleanup-output.sh
will remove all this noise. To run it pass the directory with the results files you want to clean as the first arg and where to output the cleaned files as the second argument. For example, with input directoryoutput/
and cleaned directorycleaned/
, run./cleanup-output.sh output/ cleaned/
. Note this doesn't do any sort of validation on input format, so running it on files with different contents is undefined behavior.
TODO
Everything that shouldn't be committed should be included in the .gitignore
file, but to be safe, run make clean
prior to staging and committing.