core
Class NetworkLayer

java.lang.Object
  extended by core.NetworkLayer
All Implemented Interfaces:
ModuleCommunicationListener

public class NetworkLayer
extends java.lang.Object
implements ModuleCommunicationListener

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


Field Summary
static java.lang.String RANGE_ID
          ModuleCommunicationBus identifier for the "radio range" variable.
static java.lang.String SCAN_INTERVAL_ID
          ModuleCommunicationBus identifier for the "scanning interval" variable.
static java.lang.String SPEED_ID
          ModuleCommunicationBus identifier for the "transmission speed" variable.
 
Constructor Summary
NetworkLayer(DTNHost host, java.util.List<ConnectionListener> cListeners, ModuleCommunicationBus comBus)
          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
 boolean isScanning()
           
 void moduleValueChanged(java.lang.String key, java.lang.Object newValue)
          This method is called by the ModuleCommunicationBus when/if someone changes the scanning interval, transmit speed, or range
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SCAN_INTERVAL_ID

public static final java.lang.String SCAN_INTERVAL_ID
ModuleCommunicationBus identifier for the "scanning interval" variable.

See Also:
Constant Field Values

RANGE_ID

public static final java.lang.String RANGE_ID
ModuleCommunicationBus identifier for the "radio range" variable. Value type: double

See Also:
Constant Field Values

SPEED_ID

public static final java.lang.String SPEED_ID
ModuleCommunicationBus identifier for the "transmission speed" variable. Value type: integer

See Also:
Constant Field Values
Constructor Detail

NetworkLayer

public NetworkLayer(DTNHost host,
                    java.util.List<ConnectionListener> cListeners,
                    ModuleCommunicationBus comBus)
Constructor.

Parameters:
host - The host where this network layer is
cListeners - ConnectionListeners
comBus - Communication bus
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

isScanning

public boolean isScanning()

connect

public void connect(DTNHost anotherHost)
Tries to connect this host to another host. This host must be currently in the "scanning" mode, 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).


moduleValueChanged

public void moduleValueChanged(java.lang.String key,
                               java.lang.Object newValue)
This method is called by the ModuleCommunicationBus when/if someone changes the scanning interval, transmit speed, or range

Specified by:
moduleValueChanged in interface ModuleCommunicationListener
Parameters:
key - Identifier of the changed value
newValue - New value for the variable

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