public abstract class NetworkInterface extends java.lang.Object implements ModuleCommunicationListener
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ACT_JITTER_S
Activeness offset jitter -setting id ("activenessOffsetJitter")
The maximum amount of random offset for the offset
|
protected java.util.List<Connection> |
connections |
protected DTNHost |
host |
protected java.lang.String |
interfacetype |
static java.lang.String |
NET_SUB_NS
Sub-namespace for the network related settings in the Group namespace
("net")
|
protected double |
oldTransmitRange |
protected ConnectivityOptimizer |
optimizer |
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 |
SCAN_INTERVAL_S
scanning interval -setting id ("scanInterval")
|
static java.lang.String |
SPEED_ID
ModuleCommunicationBus identifier for the "transmission speed"
variable. |
static java.lang.String |
TRANSMIT_RANGE_S
transmit range -setting id ("transmitRange")
|
static java.lang.String |
TRANSMIT_SPEED_S
transmit speed -setting id ("transmitSpeed")
|
protected double |
transmitRange |
protected int |
transmitSpeed |
| Constructor and Description |
|---|
NetworkInterface()
For creating an empty class of a specific type
|
NetworkInterface(NetworkInterface ni)
copy constructor
|
NetworkInterface(Settings s)
For creating an empty class of a specific type
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
connect(Connection con,
NetworkInterface anotherInterface)
Connects this host to another host.
|
abstract void |
connect(NetworkInterface anotherInterface)
Connects the interface to another interface.
|
abstract void |
createConnection(NetworkInterface anotherInterface)
Creates a connection to another host.
|
void |
destroyConnection(NetworkInterface anotherInterface)
Disconnect a connection between this and another host.
|
protected void |
disconnect(Connection con,
NetworkInterface anotherInterface)
Disconnects this host from another host.
|
protected void |
ensurePositiveValue(double value,
java.lang.String settingName)
Makes sure that a value is positive
|
java.util.List<Connection> |
getConnections()
Returns a list of currently connected connections
|
DTNHost |
getHost()
Returns the DTNHost of this interface
|
java.lang.String |
getInterfaceType()
For checking what interface type this interface is
|
Coord |
getLocation()
Returns the current location of the host of this interface.
|
double |
getTransmitRange()
Returns the transmit range of this network layer
|
int |
getTransmitSpeed()
Returns the transmit speed of this network layer
|
boolean |
isActive()
Returns true if the interface is on at the moment (false if not)
|
protected boolean |
isConnected(NetworkInterface netinterface)
Returns true if the given NetworkInterface is connected to this host.
|
boolean |
isScanning()
Checks if this interface is currently in the scanning mode
|
boolean |
isTransferring()
Returns true if one of the connections of this interface is transferring
data
|
protected boolean |
isWithinRange(NetworkInterface anotherInterface)
Returns true if another interface is within radio range of this interface
and this interface is also within radio range of the another interface.
|
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 |
abstract NetworkInterface |
replicate()
Replication function
|
static void |
reset()
Resets the static fields of the class
|
void |
setClisteners(java.util.List<ConnectionListener> cListeners)
For setting the connectionListeners
|
void |
setGroupSettings(Settings s)
Sets group-based settings for the network interface
|
void |
setHost(DTNHost host)
For setting the host - needed when a prototype is copied for several
hosts
|
java.lang.String |
toString()
Returns a string representation of the object.
|
abstract void |
update()
Updates the state of current connections (ie tears down connections
that are out of range, recalculates transmission speeds etc.).
|
public static final java.lang.String TRANSMIT_RANGE_S
public static final java.lang.String TRANSMIT_SPEED_S
public static final java.lang.String SCAN_INTERVAL_S
public static final java.lang.String NET_SUB_NS
public static final java.lang.String ACT_JITTER_S
public static final java.lang.String SCAN_INTERVAL_ID
ModuleCommunicationBus identifier for the "scanning interval"
variable.public static final java.lang.String RANGE_ID
ModuleCommunicationBus identifier for the "radio range"
variable. Value type: doublepublic static final java.lang.String SPEED_ID
ModuleCommunicationBus identifier for the "transmission speed"
variable. Value type: integerprotected DTNHost host
protected java.lang.String interfacetype
protected java.util.List<Connection> connections
protected double transmitRange
protected double oldTransmitRange
protected int transmitSpeed
protected ConnectivityOptimizer optimizer
public NetworkInterface(Settings s)
public NetworkInterface()
public NetworkInterface(NetworkInterface ni)
public static void reset()
public abstract NetworkInterface replicate()
public void setHost(DTNHost host)
host - The host where the network interface ispublic void setGroupSettings(Settings s)
s - The settings object using the right group namespacepublic java.lang.String getInterfaceType()
public void setClisteners(java.util.List<ConnectionListener> cListeners)
cListeners - List of connection listenerspublic double getTransmitRange()
public int getTransmitSpeed()
public java.util.List<Connection> getConnections()
public boolean isActive()
public boolean isScanning()
public boolean isTransferring()
public abstract void connect(NetworkInterface anotherInterface)
anotherInterface - The interface to connect toprotected void connect(Connection con, NetworkInterface anotherInterface)
con - The new connection objectanotherInterface - The interface to connect toprotected void disconnect(Connection con, NetworkInterface anotherInterface)
con - The connection to tear downprotected boolean isWithinRange(NetworkInterface anotherInterface)
anotherInterface - The another interfaceprotected boolean isConnected(NetworkInterface netinterface)
netinterface - The other NetworkInterface to checkprotected void ensurePositiveValue(double value,
java.lang.String settingName)
value - Value to checksettingName - Name of the setting (for error's message)SettingsError - if the value was not positivepublic abstract void update()
public void moduleValueChanged(java.lang.String key,
java.lang.Object newValue)
ModuleCommunicationBus when/if
someone changes the scanning interval, transmit speed, or rangemoduleValueChanged in interface ModuleCommunicationListenerkey - Identifier of the changed valuenewValue - New value for the variablepublic abstract void createConnection(NetworkInterface anotherInterface)
connect(NetworkInterface)).anotherInterface - The interface to create the connection topublic void destroyConnection(NetworkInterface anotherInterface)
anotherInterface - The other host's network interface to disconnect
from this hostpublic DTNHost getHost()
public Coord getLocation()
public java.lang.String toString()
toString in class java.lang.Object