Thursday, January 5, 2012

Integrating PeerSim ( P2P Simulator) with Eclipse

In this article I will explain how to integrate PeerSim with Eclipse IDE .
I am using peersim version 1.0.5 and Eclipse Helios IDE

Step 1: Download peersim-1.0.5 and extract it in a folder you like . Say the downloaded zip file was saved in C:\My Documents\Downloads. Extract it here and you will find a folder named peersim-1.0.5 .


Step 2: At first create a JAVA project . ( Go File -> Project -> JAVA Project )
Step 3: In window that popped up , unmark the option Use default location. A text box will be alive and show there the directory where peersim-1.0.5 was extracted . According to Step 1 that should be C:\My Documents\Downloads\peersim-1.0.5


Step 3: Press next to see everything is included correctly .


Step 4: Right Click on project name in the project explorer. Select Build Path -> Configure Build Path . In the window that popped up ,select the Libraries tab . Remove the jars named peersim-1.0.5.jar and peersim-doclet.jar.

Step 5: Right Click on project name in the project explorer. Select Run as -> Run Configuration. In the explorer at the left double click on JAVA Application.You will see a new run configuration window is on the right. Give any name you like at the Name field. Hit  Search to find the main class.
The class name is Simulator under peersim package.

Step 6: Go to the Arguments tab. In the program arguments field input "example/config-example1.txt". The press Run. That will simulate a protocol configured in the example/config-example1.txt file.

There are also some other configuration files in the "example/" directory . Change in the "Argument" tab to check the others.    

26 comments:

  1. can u please tell me how can we add peersim and chord in the jcreator or NetBeans and how can we run the configuration file?

    ReplyDelete
    Replies
    1. You can get an example of chord implementation from the PeerSim home page. The name of the file is chord.tar.gz. Say you have configured PeerSim for Netbeans. Create a package peersim.chord under the "Source Package". Put all the files from src/peersim/chord folder of the downloaded chord file to that package just created.
      Put the example.cfg file into any folder in the project directory.That is the config file for chord protocol.

      I do not know about JCreator , But to configure in Netbeans is almost similar to doing it in eclipse. Create a Java project by using "java Project form existing sources" and show the directory of PeerSim folder. Add the two jars mentioned above to "Libraries" folder of the project.Go to project properties.Select Run from the left panel.and you will find the Main class and Argument fields. Do similar what i did in my original post.

      Delete
    2. thanks.i have done all but it shows...
      run:
      Simulator: loading configuration
      ConfigProperties: Property 'config-example3' set.
      Simulator: unable to determine simulation engine type

      there is also some errors...
      import org.lsmp.djep.groupJep.*;
      have u any idea...please let me know...

      Delete
    3. For the first error i would suggest you to check the file-name is correct or not . As i can see from the output there is no extension in the file name.Check the file-name and directory.

      For the second error ,see you have correctly included the
      jep-2.3.0.jar
      djep-1.0.0.jar
      files in the Libraries folder. Versions are not important.You will find these files in Peersim folder.

      Hope it Helps :-)

      Delete
    4. I mean to say the file-name of the config file.

      Delete
    5. Hi sayeed i have done the following steps but shows run:
      Simulator: loading configuration
      ConfigProperties: Property 'config-example3' set.
      Simulator: unable to determine simulation engine type

      What code do i need to put in the Arguements tab

      Delete
    6. hi after a long time...
      in peersim it basicaly runs one overlay network..if i want to run two overlay network..then what thing i have to do or is it possible?

      Delete
  2. Man, thank you very much to post this step by step. You just saved a lot trouble saving me time which I already don't have.

    Cheers!

    ReplyDelete
  3. how to execute chord in peersim eclipse

    ReplyDelete
    Replies
    1. See the 1st half of reply of The first comment on this post.

      Delete
  4. i tried whether the output of chord is that example.cfg file or some other one i want the output of chord

    ReplyDelete
    Replies
    1. example.cfg is the configuration file.Here is the output of chord using the config file here. Hope it helps.

      Delete
    2. thank u very much it helped me a lot.......do u have executable gnutella peersim source code i searched and got this http://code.google.com/p/gnutella-peersim/downloads/detail?name=P2PGnutella.tgz but it is fully java not peersim package can i integrate this code with peersim if so pls say me how

      Delete
  5. Bonjour,

    comment je peux exécuter chord et gnutella sur peersim sous eclipse car je veux faire une comparaison entre les deux. je suis debutante. est ce que vous pouvez me donner une reponse rapide ce urgent. merci

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. dear i am running peersim on eclipse in ubuntu environment which is the main exe file so i should complie.
    and i compile some file which gives this type of error
    "Simulator: loading configuration
    Simulator: unable to determine simulation engine type
    "

    ReplyDelete
    Replies
    1. I think you forgot to set the configuration file-name as program argument. Please follow the Step 6 of the post. Thanks

      Delete
  8. I am trying to integrate bittorrent on eclipse. i downloaded bittorrent.tar.gz from peersim homepage.
    Made a java project
    Imported libraries (djep-1.0.0.jar, jep-2.3.0.jar, peersim-1.0.3.jar)
    to project's src folder i copied all the files from bitpeer/src/peersim folder of the extracted bittorrent.tar.gz
    I also copied config-BitTorrent.txt configuration file
    then I added the javadoc location path by right clicking on peersim-1.0.3.jar under Referenced Libraries section of project.
    Then i moved to run->run as configuration..
    There i added new java application and to Project i added bitTorrent
    and to main class i added peersim.Simulator
    To arguments i added the configuration file

    but after running i'm getting the error :
    peersim.config.IllegalParameterException: Parameter "protocol.bittorrent": Class peersim.bittorrent.BitTorrent not found
    At peersim.config.ConfigContainer.getClazz:606

    Can you please tell me what's wrong here?

    ReplyDelete
  9. Please use source code file instead of peersim-1.0.3.jar. Add peersim sources to "src" folder and copy the bittorrent related codes in package "peersim.bittorent"

    ReplyDelete
    Replies
    1. i didn't get one thing that what exactly you mean by source code file? i didn't get location of it
      can u please give me a screenshot of the location of source code.
      Thanks alot for your help!

      Delete
  10. Thanks for simple and clear explanation.
    I am trying to run a project for SuperPeer which is available in Peersim website titled by SG-1 in the following link:
    http://peersim.sourceforge.net/code/Superpeer.zip
    I was trying to implement the same steps mentioned in this page but it does not work. I would appreciate your help.

    ReplyDelete
  11. Please brother, describe example1 output parameters in briefly.

    ReplyDelete
  12. good evening , i am beginner in peersim , and i am obliged to implement Gnutella System using this simulator, if you have some suggestions, or you have already this project, please help , it is urgent ... Thanks

    ReplyDelete
  13. your blog is a big help to set-up chord in peersim .I am a beginner I want to set every node with a success rate and some task and want to print that .How do i do that . where to look.Thanks

    ReplyDelete
  14. how to intergrate peersim in netbeans?

    ReplyDelete