PeerSim, if you don’t know it, is a famous P2P networks simulator, written in Java. You can find its home clicking this link.
Surely, when you are writing in Java, it’s convenient to use Eclipse. In this article I will talk about how to configure eclipse to work with PeerSim. I decide to write this article mainly because I’ve founded some articles that talk about this integration; but I disagree with their solutions.
# Download PeerSim
First of all, you need to download the PeerSim package from Sourceforge.Extract the package and then you will have a folder called
peersim-1.0.5, that contains all the PeerSim files. You can put this folder wherever you want, for example in your home directory.
# Project Configuration
Create a Java Project going to
File -> New -> Java Project.
Then, with the right button, click on the project name that you can find in the projects list (
Package Explorer). Hence, open the properties of the project, and go to the
Java Build Path form and open the
Libraries tab. In this way you can include the libraries of PeerSim.
To do that, click to
Add External JARs, and navigate until you reach the PeerSim folder that you extracted before. Select the following libraries:
Now, to import the documentation, expand the relative entry of the PeerSim library.
Double click on the documentation entry, and in the window that will appear, click to
Javadoc URL, and then to
Browse, navigate again until you reach the PeerSim folder, and select the “doc” folder that you will find inside.
# Configure for Run
To configure PeerSim, to run a simulation, open the run configuration window going to
Run -> Run Configurations. Now, with the right button, click the menu entry called “Java Application” and create a new configuration. Assign any name to it.
Then, in the “Main Class” section, click to
Search, and select the entry called “Simulator – peersim”. It is the main class of Peersim (it is in inside the PeerSim library).
To configure the arguments to start a simulation, in a way that you can specify the configuration file path, you can open the
Arguments tab, and changing the field called “Program Arguments”.
To do a fast test, you can create a folder inside your project folder, with the name “configs”. Then, you can copy in it the file “example/config-example1.txt”, that you can find in the PeerSim folder. Then, you can change the “Program Arguments” field, inserting the string “configs/config-example1.txt”.