simulator_lib
Class SimulatorSource

java.lang.Object
  extended by simulator_lib.SimulatorSource

public class SimulatorSource
extends java.lang.Object

The SimulatorSource class assists the TraceSimulator driver program in dynamic source selection based on user/file availability and trust values.


Nested Class Summary
static class SimulatorSource.Strategy
          The Strategy enumeration lists the source selection strategies.
 
Constructor Summary
SimulatorSource()
           
 
Method Summary
static int pickSource(Network nw, int cycle, int recv, int file, SimulatorSource.Strategy strategy)
          Decide the source for a transaction, given current Network status.
static SimulatorSource.Strategy pickStrategy(User.Behavior model)
          Given a user Behavior, return the source Strategy they should follow.
private static int sourceBest(Network nw, int cycle, int recv, int file)
          Choose the best (most trusted) available source for a transaction.
private static int sourceRandom(Network nw, int cycle, int recv, int file)
          Choose a random available source for a transaction.
private static int sourceWorst(Network nw, int cycle, int recv, int file)
          Choose the worse (least trusted) available source for a transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimulatorSource

public SimulatorSource()
Method Detail

pickStrategy

public static SimulatorSource.Strategy pickStrategy(User.Behavior model)
Given a user Behavior, return the source Strategy they should follow.

Parameters:
model - The behavior model of some User
Returns:
The source Strategy that user should apply

pickSource

public static int pickSource(Network nw,
                             int cycle,
                             int recv,
                             int file,
                             SimulatorSource.Strategy strategy)
Decide the source for a transaction, given current Network status.

Parameters:
nw - Network in which the transaction will take place
cycle - The current cycle
recv - Identifier of the user requesting the file
file - Identifier of the file being requested
strategy - Source selection Strategy being employed
Returns:
Identifier of source user, or -1 if no source exists

sourceBest

private static int sourceBest(Network nw,
                              int cycle,
                              int recv,
                              int file)
Choose the best (most trusted) available source for a transaction.

Parameters:
nw - Network in which transaction will take place
cycle - The current cycle
recv - Identifier of the user requesting the file
file - Identifier of the file being requested
Returns:
Identifier of source user, or -1 if no source exists

sourceWorst

private static int sourceWorst(Network nw,
                               int cycle,
                               int recv,
                               int file)
Choose the worse (least trusted) available source for a transaction.

Parameters:
nw - Network in which transaction will take place
cycle - The current cycle
recv - Identifier of the user requesting the file
file - Identifier of the file being requested
Returns:
Identifier of source user, or -1 if no source exists

sourceRandom

private static int sourceRandom(Network nw,
                                int cycle,
                                int recv,
                                int file)
Choose a random available source for a transaction.

Parameters:
nw - Network in which transaction will take place
cycle - The current cycle
recv - Identifier of the user requesting the file
file - Identifier of the file being requested
Returns:
Identifier of source user, or -1 if no source exists