Query Cycle Simulator HEADER

qcsim.peer.impl
Class PeerBehaviorImpl

java.lang.Object
  |
  +--qcsim.peer.impl.PeerBehaviorImpl
All Implemented Interfaces:
PeerBehavior

public class PeerBehaviorImpl
extends java.lang.Object
implements PeerBehavior

Represents a peer's behavior during a simulation. The peer will use an object of this type to make decisions regarding its behavior.

Version:
1.0
Author:
unascribed

Field Summary
(package private) static int ACTIVE
           
(package private) static int ACTIVITY_ALWAYSUP
           
(package private) static int ACTIVITY_ALWAYSUPNOQUERIES
           
(package private) static int ACTIVITY_RANDOM
           
(package private) static int BOTTOM_CATEGORY
           
(package private) static int GOOD_PEER
           
(package private) static int HIGHLY_TRUSTED_PEER
           
(package private) static int INACTIVE
           
(package private) static int MALICIOUS_CAMOUFLAGED
           
(package private) static int MALICIOUS_COLLECTIVE
           
(package private) static int MALICIOUS_PEER
           
(package private) static int MALICIOUS_SPY
           
(package private) static int MAX_TTL
           
(package private) static int MED_TTL
           
(package private) static int MIN_TTL
           
(package private) static int RANDOM_CATEGORY
           
(package private) static int RPB_RANDOM
           
(package private) static int RPB_SIMPLEPROBABILISTIC
           
(package private) static int RPB_TRUSTDETERMINISTIC
           
(package private) static int RPB_TRUSTPROBABILISTIC
           
(package private) static int TOP_CATEGORY
           
 
Constructor Summary
PeerBehaviorImpl(Peer peer, int type)
          Constructor
 
Method Summary
 void activity(int activity)
          Initializes uptime ratio and query activity ratio for all specified peers.
 int categoryPreference()
          Get the peers category preference.
 void categoryPreference(int preference)
          Indicates which category of files a peer is likely to respond to.
 void errorFraction(double errorFraction)
          The fraction of uploads that will contain errors.
 double opinion(Peer peer, boolean authenticFile)
          Will determine the value a peer should use to update it's local trust
 double queryActivity()
          The fraction of cycles this peer will participate by sending to queries.
 boolean respond(PeerMsgQuery msg)
          Will determine if peer should respond to a query
 int responseSelector()
          This determines how a peer will choose a site to download from.
 void responseSelector(int selector)
          Set the selector for how a peer will choose a download site.
 int type()
          The type of peer.
 void type(int type)
          Set the type of peer.
 double uploadStatus(Peer dest)
          Will determine the file upload status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GOOD_PEER

static final int GOOD_PEER
See Also:
Constant Field Values

HIGHLY_TRUSTED_PEER

static final int HIGHLY_TRUSTED_PEER
See Also:
Constant Field Values

MALICIOUS_PEER

static final int MALICIOUS_PEER
See Also:
Constant Field Values

MALICIOUS_COLLECTIVE

static final int MALICIOUS_COLLECTIVE
See Also:
Constant Field Values

MALICIOUS_CAMOUFLAGED

static final int MALICIOUS_CAMOUFLAGED
See Also:
Constant Field Values

MALICIOUS_SPY

static final int MALICIOUS_SPY
See Also:
Constant Field Values

INACTIVE

static final int INACTIVE
See Also:
Constant Field Values

ACTIVE

static final int ACTIVE
See Also:
Constant Field Values

ACTIVITY_ALWAYSUP

static final int ACTIVITY_ALWAYSUP
See Also:
Constant Field Values

ACTIVITY_RANDOM

static final int ACTIVITY_RANDOM
See Also:
Constant Field Values

ACTIVITY_ALWAYSUPNOQUERIES

static final int ACTIVITY_ALWAYSUPNOQUERIES
See Also:
Constant Field Values

MIN_TTL

static final int MIN_TTL
See Also:
Constant Field Values

MED_TTL

static final int MED_TTL
See Also:
Constant Field Values

MAX_TTL

static final int MAX_TTL
See Also:
Constant Field Values

TOP_CATEGORY

static final int TOP_CATEGORY
See Also:
Constant Field Values

BOTTOM_CATEGORY

static final int BOTTOM_CATEGORY
See Also:
Constant Field Values

RANDOM_CATEGORY

static final int RANDOM_CATEGORY
See Also:
Constant Field Values

RPB_RANDOM

static final int RPB_RANDOM
See Also:
Constant Field Values

RPB_TRUSTDETERMINISTIC

static final int RPB_TRUSTDETERMINISTIC
See Also:
Constant Field Values

RPB_TRUSTPROBABILISTIC

static final int RPB_TRUSTPROBABILISTIC
See Also:
Constant Field Values

RPB_SIMPLEPROBABILISTIC

static final int RPB_SIMPLEPROBABILISTIC
See Also:
Constant Field Values
Constructor Detail

PeerBehaviorImpl

public PeerBehaviorImpl(Peer peer,
                        int type)
Constructor

Method Detail

queryActivity

public double queryActivity()
Description copied from interface: PeerBehavior
The fraction of cycles this peer will participate by sending to queries.

Specified by:
queryActivity in interface PeerBehavior
Returns:
the query activity.

type

public int type()
Description copied from interface: PeerBehavior
The type of peer.

Specified by:
type in interface PeerBehavior
Returns:
the peer type.

type

public void type(int type)
Description copied from interface: PeerBehavior
Set the type of peer.

Specified by:
type in interface PeerBehavior
Returns:
the peer type.

errorFraction

public void errorFraction(double errorFraction)
Description copied from interface: PeerBehavior
The fraction of uploads that will contain errors.

Specified by:
errorFraction in interface PeerBehavior
Parameters:
errorFraction - fraction of file upload errors.

categoryPreference

public int categoryPreference()
Description copied from interface: PeerBehavior
Get the peers category preference.

Specified by:
categoryPreference in interface PeerBehavior
Returns:
TOP_CATEGORY, BOTTOM_CATEGORY, or RANDOM_CATEGORY

categoryPreference

public void categoryPreference(int preference)
Description copied from interface: PeerBehavior
Indicates which category of files a peer is likely to respond to. For instance setting the value to RB_TOP will focus the peer's interest to top level categories of files.

Specified by:
categoryPreference in interface PeerBehavior

responseSelector

public int responseSelector()
Description copied from interface: PeerBehavior
This determines how a peer will choose a site to download from.

Specified by:
responseSelector in interface PeerBehavior
Returns:
selector type

responseSelector

public void responseSelector(int selector)
Description copied from interface: PeerBehavior
Set the selector for how a peer will choose a download site.

Specified by:
responseSelector in interface PeerBehavior
Parameters:
selector - type

respond

public boolean respond(PeerMsgQuery msg)
Will determine if peer should respond to a query

Specified by:
respond in interface PeerBehavior
Parameters:
msg - The query message

uploadStatus

public double uploadStatus(Peer dest)
Will determine the file upload status.

Specified by:
uploadStatus in interface PeerBehavior
Parameters:
dest - The destination peer.
Returns:
The files status: GOOD_FILE or BAD_FILE.

opinion

public double opinion(Peer peer,
                      boolean authenticFile)
Will determine the value a peer should use to update it's local trust

Specified by:
opinion in interface PeerBehavior
Parameters:
peer - the peer that was downloaded from.
authenticFile - true if the file download successful.

activity

public void activity(int activity)
Initializes uptime ratio and query activity ratio for all specified peers.

Specified by:
activity in interface PeerBehavior

Query Cycle Simulator HEADER