core
Class NetworkLayer

java.lang.Object
  extended by core.NetworkLayer

public class NetworkLayer
extends java.lang.Object

Network layer of a DTNHost. Takes care of connectivity among hosts.


Constructor Summary
NetworkLayer(DTNHost host, java.util.List<ConnectionListener> cListeners, double transmitRange, int transmitSpeed)
          Constructor.
 
Method Summary
 void connect(DTNHost anotherHost)
          Tries to connect this host to another host.
 void createConnection(DTNHost anotherHost)
          Creates a connection to another host.
 void destroyConnection(DTNHost anotherHost)
          Disconnect a connection between this and another host.
 int getAddress()
          Returns the network layer address.
 java.util.List<Connection> getConnections()
          Returns a list of currently connected connections
 double getTransmitRange()
          Returns the transmit range of this network layer
 int getTransmitSpeed()
          Returns the transmit speed of this network layer
static void reset()
          Resets the static fields of the class
 java.lang.String toString()
          Returns a string representation of the object.
 void update()
          Updates the state of current connections (i.e. tears down connections that are out of range).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NetworkLayer

public NetworkLayer(DTNHost host,
                    java.util.List<ConnectionListener> cListeners,
                    double transmitRange,
                    int transmitSpeed)
Constructor.

Parameters:
host - The host where this network layer is
cListeners - ConnectionListeners
transmitRange - Transmit range of the radio
transmitSpeed - Transmit speed of the radio
Method Detail

getAddress

public int getAddress()
Returns the network layer address.

Returns:
The address (integer)

getTransmitRange

public double getTransmitRange()
Returns the transmit range of this network layer

Returns:
the transmit range

getTransmitSpeed

public int getTransmitSpeed()
Returns the transmit speed of this network layer

Returns:
the transmit speed

getConnections

public java.util.List<Connection> getConnections()
Returns a list of currently connected connections

Returns:
a list of currently connected connections

connect

public void connect(DTNHost anotherHost)
Tries to connect this host to another host. The other host must be active and within range of this host for the connection to succeed.

Parameters:
anotherHost - The host to try to connect to

createConnection

public void createConnection(DTNHost anotherHost)
Creates a connection to another host. This method does not do any checks on whether the other node is in range or active (cf. connect(DTNHost)).

Parameters:
anotherHost - The host to create the connection to

destroyConnection

public void destroyConnection(DTNHost anotherHost)
Disconnect a connection between this and another host.

Parameters:
anotherHost - The host to disconnect from this host

update

public void update()
Updates the state of current connections (i.e. tears down connections that are out of range).


toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.

reset

public static void reset()
Resets the static fields of the class