


######### This experiment was run with the aim of proving the "Modelling and Analysing Routing Protocols Diagrammatically with Bigraphs" paper claims. ###############

######### It is to compare the RPL Bigraphs model with RPL_Lite in Cooja simulation. ##################



           ##########################################################################################################


# The folder contents:

  1. First Python script (Part#1_Generate _csc_and_big_Files.py) that does:
     a. Generate a random topology
     b. Generate the Bigraphs model ".big file".
     c. Generate RPL_Lite Cooja code ".csc file".


  2. Second Python script (Part#2_Extract_DAGs_and_Check_the_Model.py) that does:
     a. Extract DAGs built by BigraphER and Cooja.
     b. Generate properties (related to the topology).
     c. Run PRISM to check the Bigraphs model against the properties.

  3. The_Experiment_Templates folder (to be used in running the experiment) that contains:
     a. RPL Bigraphs model template (RPL_Bigrapher_Template.big).
     b. RPL_Lite Cooja code template (RPL_Cooja_Template.csc).

  4. The_Experiment_Data folder ( that was used when we run the experiment) contains: 
     a. RPL Bigraphs models (100 .big files) generated by the script (1.b).
     b. RPL_Lite Cooja codes (100 .csc files) generated by the script (1.c).
  5. The_Experiment_Results folder that contains our experiments results from the files in The_Experiment_Data folder.

  6. ScriptRunner.java file that has an extra piece of code allowing you to write to unique testlog files each time you run Cooja.



# To run the experiment:

 # pre-requests:

  1. Setup BigraphER and Cooja on your machine.

  2. Create a new folder inside your rpl-udp folder and name it "S_1" (if you prefer another name please change this in the scripts as in steps 3 and 4 below to what you name but please keep _1 to save each experiment testlog files separately when you run more .csc files), so all testlogs are stored in this folder separately from any existing testlogs so the Python scripts only work on a specific experiment testlogs file. Important step: please replace "ScriptRunner.java" file you find in your Contiki-NG folder at a path like: "./tools/cooja/java/org/contikios/cooja/plugins" with one provided in this folder as in step 6 in "The folder contents" section above.

  2. There are two variables in the first script: outPathCooja and outPathBigraph, edit them as required to the absolute path to your rpl-udp folder and bigraphER respectively. 

  3. There are four variables in the second script: outPathBigraph, outPathCooja, outPathPRISM, and outpathExperiment edit them as required to the absolute paths of where each one is, outpathExperiment is where you download the zip.



 # Do the following for each experiment (if you are doing it for more than one network topology):

  1. Run the First Python script (Part#1_Generate _csc_and_big_Files.py). It is recommended that Keep the template files (.csc and .big) in their own folder where the script is, otherwise, please edit as required to their absolute paths in the script as you where save them. 

     Note: the output files are: .csc, and .big files. The Topology Document text file contains the randomly generated topology data

  2. With your own shell run the Cooja (repeatedly for 500 times as the experiment does) and BigraphER (for one time) on the .csc and .big files generated from the previous step (first Python script). 
        
     The suggested commands are:
         1. For Cooja from inside rpl-udp/S_1 folder: "for counter in {1..500}; do java -mx2048m -jar ../../../tools/cooja/dist/cooja.jar -nogui=AutoCooja_1.csc -contiki=../../..;  done "
         2. For BigraphER: "./bigrapher.exe full -f dot -s. -t AutoBigraphER_1.dot AutoBigraphER_1.big -p AutoBigraphER_1.tra -l AutoBigraphER_1.lab -M50000 "

     Note: BigraphER produces 3 files: (.dot, .tra, and .lab in the same folder of BigraphER ) and Cooja produces 500 testlog files ( or as you set it)

  3. Use the output files from the previous step to run the second Python script.

     Note: the output files from this step will be:
      a. the extracted DAGs that were constructed by both bigraphER and Cooja ( in two separate files: DAGsFromRepeatedRunCooja and DAGFromBigraphER text files, there should be 500 DAGs in the Cooja file)
      b. DAGFromCoojaAndBigraphER text file contains Cooja DAGs with repeated time for each of them and Bigraph DAGs
      c. PRISM model checking output in a text file

Recommendation: 
     In case you run the experiment more than one time, you may wish to rename all input\output files by changing the files number in the scripts( they currently are _1 in the scripts so change them to _2 and so on) 
      

