ants.p2p
Class Ant

java.lang.Object
  extended by java.lang.Thread
      extended by ants.p2p.Ant
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
WarriorAnt

public class Ant
extends java.lang.Thread


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  boolean acceptTCPDirectConnections
           
static int beingRoutedMessages
           
static java.lang.String ConnectionType
           
 java.util.List failedMessages
           
 java.util.List inTransitMessages
           
static int inTransitMessageSizeMax
           
 java.lang.String localNattedInetAddress
           
 int localNattedPort
           
static int maxFailedMessageToTrace
           
static int maxMessagesToRouteToghether
           
static int maxNeighbours
           
static int maxRetransmissions
           
static int maxRetransmissionsForceDirection
           
static long messageTimeout
           
 java.util.List myMessages
           
static int myMessageSizeMax
           
static int netModificationsTimeout
           
static int probeCheckInterval
           
 java.beans.PropertyChangeSupport propertyChangeSupport
           
static boolean proxied
           
static long routeInactiveTimeout
           
 java.util.Hashtable routingTable
           
protected  SecureServer ss
           
static double underRateConnections
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Ant(java.lang.String id, int maxNeighbours, int serverPort, boolean acceptDC, java.lang.String localInetAddress, boolean UPnP)
           
 
Method Summary
 boolean acceptTCPDirectConnections()
           
 Router activateNewRouterProcess(Message m, java.lang.String requirer)
           
 void addNeighbour(NeighbourAnt n)
           
 void addP2PNeighbour(java.lang.String remoteAddress, int port, boolean isRequirer, java.net.InetAddress localhost)
           
 Neighbour checkForRoute(Message m, java.lang.String requirer, java.util.List notToBeConsidered, boolean alreadySeen)
           
 Neighbour checkForRoute(MessageWrapper wm, java.util.List notToBeConsidered)
           
static void decBeingRoutedMessages()
           
 void disconnect()
           
 boolean equals(java.lang.Object o)
           
 boolean existRouteTo(java.lang.String dest)
           
 void generateNetModificationAlert(java.util.ArrayList unreachableNeighbours, java.lang.String requirer)
           
 void generateNetModificationAlert(Message m, java.lang.String neighbourId)
           
 void generateNetModificationAlert(NeighbourAnt disconnectedNeighbour)
           
static java.lang.String getApplicationName()
           
 java.util.List getFailedMessages()
           
 java.lang.String getIdent()
           
 java.lang.String getLanAddress()
           
 java.lang.String getLocalInetAddress()
           
 int getMaxNeighbours()
           
 MessageWrapper getMessage(java.lang.String id)
           
 NeighbourAnt getNeighbour(java.lang.String id)
           
 java.util.List getNeighbours()
           
 int getNeighboursNumber()
           
static java.lang.String getNetName()
           
 java.beans.PropertyChangeSupport getPropertyChangeSupport()
           
static java.lang.String getProtocolVersion()
           
static int getRateThresold()
           
 int getServerPort()
           
 java.lang.String getShortId()
           
 int getUnderRatedNeighbours()
           
static java.lang.String getVersion()
           
 boolean isDisconnected()
           
static boolean isInternetPublicAddress(java.net.InetAddress address)
           
protected  void processMessage(Message m, Router r)
           
protected  void processNetModificationAlert(NetModificationAlert alert, Neighbour source)
           
 void removeNeighbour(NeighbourAnt n)
           
 SenderThread[] route(MessageWrapper wm, Message m, java.lang.String requirer, Router r, boolean external, boolean retransmission)
           
 void run()
           
 MessageWrapper sendBroadcastMessage(Message message)
           
 MessageWrapper sendMessage(Message message, java.lang.String dest, boolean disableAutoRetransmit, boolean maskSource)
           
static void setDirectConnection()
           
 void setLocalInetAddress(java.lang.String localInetAddress)
           
 void setMaxNeighbours(int mn)
           
static void setProxied(java.net.InetAddress proxyAddress, int proxyPort)
           
 void traceDeliveredMessage(MessageWrapper wm)
           
 void traceHints(Message m, java.lang.String requirer)
           
 void traceMessage(Message m, java.lang.String requirer, java.lang.String routedTo)
           
 void traceMyMessage(MessageWrapper wm, java.lang.String routedTo)
           
 void uPnPMapping()
           
static boolean verifyAndIncBeingRoutedMessages()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ConnectionType

public static java.lang.String ConnectionType

myMessageSizeMax

public static int myMessageSizeMax

inTransitMessageSizeMax

public static int inTransitMessageSizeMax

routeInactiveTimeout

public static long routeInactiveTimeout

maxNeighbours

public static int maxNeighbours

myMessages

public java.util.List myMessages

failedMessages

public java.util.List failedMessages

routingTable

public java.util.Hashtable routingTable

inTransitMessages

public java.util.List inTransitMessages

ss

protected SecureServer ss

messageTimeout

public static long messageTimeout

maxRetransmissions

public static int maxRetransmissions

maxRetransmissionsForceDirection

public static int maxRetransmissionsForceDirection

maxFailedMessageToTrace

public static int maxFailedMessageToTrace

beingRoutedMessages

public static int beingRoutedMessages

maxMessagesToRouteToghether

public static int maxMessagesToRouteToghether

netModificationsTimeout

public static int netModificationsTimeout

probeCheckInterval

public static int probeCheckInterval

underRateConnections

public static double underRateConnections

acceptTCPDirectConnections

protected boolean acceptTCPDirectConnections

propertyChangeSupport

public java.beans.PropertyChangeSupport propertyChangeSupport

localNattedPort

public int localNattedPort

localNattedInetAddress

public java.lang.String localNattedInetAddress

proxied

public static boolean proxied
Constructor Detail

Ant

public Ant(java.lang.String id,
           int maxNeighbours,
           int serverPort,
           boolean acceptDC,
           java.lang.String localInetAddress,
           boolean UPnP)
Method Detail

setProxied

public static void setProxied(java.net.InetAddress proxyAddress,
                              int proxyPort)

setDirectConnection

public static void setDirectConnection()

acceptTCPDirectConnections

public boolean acceptTCPDirectConnections()

getLocalInetAddress

public java.lang.String getLocalInetAddress()

setLocalInetAddress

public void setLocalInetAddress(java.lang.String localInetAddress)

getLanAddress

public java.lang.String getLanAddress()

isInternetPublicAddress

public static boolean isInternetPublicAddress(java.net.InetAddress address)

getVersion

public static java.lang.String getVersion()

getProtocolVersion

public static java.lang.String getProtocolVersion()

getApplicationName

public static java.lang.String getApplicationName()

getNetName

public static java.lang.String getNetName()

getIdent

public java.lang.String getIdent()

getShortId

public java.lang.String getShortId()

getServerPort

public int getServerPort()

getFailedMessages

public java.util.List getFailedMessages()

setMaxNeighbours

public void setMaxNeighbours(int mn)

getMaxNeighbours

public int getMaxNeighbours()

removeNeighbour

public void removeNeighbour(NeighbourAnt n)

generateNetModificationAlert

public void generateNetModificationAlert(NeighbourAnt disconnectedNeighbour)

generateNetModificationAlert

public void generateNetModificationAlert(Message m,
                                         java.lang.String neighbourId)

generateNetModificationAlert

public void generateNetModificationAlert(java.util.ArrayList unreachableNeighbours,
                                         java.lang.String requirer)

processNetModificationAlert

protected void processNetModificationAlert(NetModificationAlert alert,
                                           Neighbour source)

getNeighbour

public NeighbourAnt getNeighbour(java.lang.String id)

getRateThresold

public static int getRateThresold()

getUnderRatedNeighbours

public int getUnderRatedNeighbours()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getNeighboursNumber

public int getNeighboursNumber()

addNeighbour

public void addNeighbour(NeighbourAnt n)
                  throws java.lang.Exception
Throws:
java.lang.Exception

addP2PNeighbour

public void addP2PNeighbour(java.lang.String remoteAddress,
                            int port,
                            boolean isRequirer,
                            java.net.InetAddress localhost)
                     throws java.lang.Exception
Throws:
java.lang.Exception

getNeighbours

public java.util.List getNeighbours()

getMessage

public MessageWrapper getMessage(java.lang.String id)

traceHints

public void traceHints(Message m,
                       java.lang.String requirer)

traceDeliveredMessage

public void traceDeliveredMessage(MessageWrapper wm)

traceMessage

public void traceMessage(Message m,
                         java.lang.String requirer,
                         java.lang.String routedTo)

traceMyMessage

public void traceMyMessage(MessageWrapper wm,
                           java.lang.String routedTo)

decBeingRoutedMessages

public static void decBeingRoutedMessages()

verifyAndIncBeingRoutedMessages

public static boolean verifyAndIncBeingRoutedMessages()

activateNewRouterProcess

public Router activateNewRouterProcess(Message m,
                                       java.lang.String requirer)
                                throws java.lang.Exception
Throws:
java.lang.Exception

route

public SenderThread[] route(MessageWrapper wm,
                            Message m,
                            java.lang.String requirer,
                            Router r,
                            boolean external,
                            boolean retransmission)
                     throws java.lang.Exception
Throws:
java.lang.Exception

sendMessage

public MessageWrapper sendMessage(Message message,
                                  java.lang.String dest,
                                  boolean disableAutoRetransmit,
                                  boolean maskSource)
                           throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

sendBroadcastMessage

public MessageWrapper sendBroadcastMessage(Message message)

checkForRoute

public Neighbour checkForRoute(MessageWrapper wm,
                               java.util.List notToBeConsidered)
                        throws java.lang.Exception
Throws:
java.lang.Exception

existRouteTo

public boolean existRouteTo(java.lang.String dest)

checkForRoute

public Neighbour checkForRoute(Message m,
                               java.lang.String requirer,
                               java.util.List notToBeConsidered,
                               boolean alreadySeen)
                        throws java.lang.Exception
Throws:
java.lang.Exception

uPnPMapping

public void uPnPMapping()

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

processMessage

protected void processMessage(Message m,
                              Router r)
                       throws java.lang.Exception
Throws:
java.lang.Exception

getPropertyChangeSupport

public java.beans.PropertyChangeSupport getPropertyChangeSupport()

disconnect

public void disconnect()

isDisconnected

public boolean isDisconnected()