# The FreePastry Tutorial.

This tutorial is designed to get you cooking quickly with the FreePastry API and software toolkit.

#### Version @tutorial_version@; @tutorial_date@. For FreePastry version @freepastry_version@. Maintained by @maintainer@.

# Simulator Tutorial 2

## FreePastry's Direct Simulator (Using Latency Matrix)

### Download the tutorial files: DirectTutorial.java MyApp.java, MyMsg.java into a directory called rice/tutorial/gtitm/.

Before completing this Tutorial, we recommend completing Simulator Tutorial of the FreePastry tutorial.

FreePastry's Simulator is a Discreet Event Simulator. The puropse of this tutorial is to show you how to use the GenericNetwork to use a latency matrix to more accurately simulate your application with FreePastry's Discreet Event Simulator. Changes: There is only 1 change to the code... the Netowork Topology, and a command line argument to specify the file name:

      new GenericNetwork(env, new File(fileName))

The format of this file is a matrix of floats representing the table of latency values. It should be N lines with N floats on each line representing N latencies.

You should also specify the parameter: `pastry_direct_gtitm_max_overlay_size` if you want to provide an input file over 2000 nodes. Note that FreePastry will automatically accpet a smaller file, but to save memory, it will not read more than `pastry_direct_gtitm_max_overlay_size` lines in an input file.

If anyone has an example of how to use the GT-ITM Topology Generator to generate a latency matrix, please let me know so I can integrate it into this tutorial.

One other note. To create larger networks, it may be necessary to accelerate the simulator as you construct more nodes. This tutorial employs a simple trick to accomplish this:

          // accelerate the simulation as we give it more work
          simulator.setMaxSpeed(curNode+1);

Complie and execute this code as before, but this time provide a Matrix file. The tutorial directory includes this file which must be copied to the working directory to execute this tutorial.

    java -cp .:FreePastry-@freepastry_version@.jar rice.tutorial.gtitm.DistTutorial 10 GNPINPUT
    Size of Generic Network matrix= 1000
    :rice.pastry.direct.DirectPastryNodeFactory:0:No bootstrap node provided, starting a new ring...
    Finished creating new node Pastry node <0x7B5ABF..>
    Finished creating new node Pastry node <0xFFA2A6..>
    Finished creating new node Pastry node <0x74A71D..>
    Finished creating new node Pastry node <0x7B2F8A..>
    Finished creating new node Pastry node <0x18215A..>
    Finished creating new node Pastry node <0x8B5561..>
    Finished creating new node Pastry node <0xF5D135..>
    Finished creating new node Pastry node <0xB40815..>
    Finished creating new node Pastry node <0x0235C0..>
    Finished creating new node Pastry node <0x337A07..>
    MyApp <0x7B5ABF..> sending to <0x3535C9..>
    MyApp <0xFFA2A6..> sending to <0x203CDD..>
    MyApp <0x74A71D..> sending to <0xD78164..>
    MyApp <0x337A07..> received MyMsg from <0x7B5ABF..> to <0x3535C9..>
    MyApp <0x7B2F8A..> sending to <0x0F584A..>
    MyApp <0x18215A..> sending to <0x9D9264..>
    MyApp <0xF5D135..> received MyMsg from <0x74A71D..> to <0xD78164..>
    MyApp <0x18215A..> received MyMsg from <0xFFA2A6..> to <0x203CDD..>
    MyApp <0x8B5561..> sending to <0xD931FB..>
    MyApp <0xF5D135..> sending to <0xDFE72D..>
    MyApp <0x18215A..> received MyMsg from <0x7B2F8A..> to <0x0F584A..>
    MyApp <0xF5D135..> received MyMsg from <0xF5D135..> to <0xDFE72D..>
    MyApp <0xB40815..> sending to <0xC5E0B6..>
    MyApp <0xB40815..> received MyMsg from <0xB40815..> to <0xC5E0B6..>
    MyApp <0x0235C0..> sending to <0x2FF4DF..>
    MyApp <0x8B5561..> received MyMsg from <0x18215A..> to <0x9D9264..>
    MyApp <0x337A07..> sending to <0x3E6C26..>
    MyApp <0x337A07..> received MyMsg from <0x337A07..> to <0x3E6C26..>
    MyApp <0xF5D135..> received MyMsg from <0x8B5561..> to <0xD931FB..>

    ...

### Congratulations! You have just simulated a handful of nodes in FreePastry's Discreet Event Simulator. This should make it much easier to test your application.