Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
050cc5e8
Commit
050cc5e8
authored
Jul 21, 2015
by
Björn Richerzhagen
Browse files
Merge remote-tracking branch 'origin/br/sis-development'
parents
04f1f32a
4d49e3e5
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/api/common/Position.java
View file @
050cc5e8
...
...
@@ -21,6 +21,7 @@
package
de.tud.kom.p2psim.api.common
;
import
de.tudarmstadt.maki.simonstrator.api.common.Transmitable
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
/**
* The common interface for positions within PeerfactSim, this hides the
...
...
@@ -30,9 +31,10 @@ import de.tudarmstadt.maki.simonstrator.api.common.Transmitable;
*
* @author Bjoern Richerzhagen
* @version 1.0, 05/26/2011
* @deprecated please consider using {@link Location} instead!
*/
public
interface
Position
extends
Transmitable
,
Cloneable
{
@Deprecated
public
interface
Position
extends
Transmitable
,
Cloneable
,
Location
{
/**
* Get the distance of this position compared to any other Position, if they
...
...
src/de/tud/kom/p2psim/api/linklayer/mac/MacLayer.java
View file @
050cc5e8
...
...
@@ -28,6 +28,7 @@ import de.tud.kom.p2psim.api.linklayer.LinkMessageListener;
import
de.tud.kom.p2psim.api.network.BandwidthImpl
;
import
de.tud.kom.p2psim.api.topology.views.TopologyView
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.component.network.NetID
;
/**
* The MAC (Medium Access Control) is a central part of the LinkLayer. In
...
...
@@ -45,6 +46,13 @@ public interface MacLayer extends SimHostComponent, EventHandler {
* @return
*/
public
MacAddress
getMacAddress
();
/**
* The NetID used via this mac (convenience method)
*
* @return
*/
public
NetID
getNetId
();
/**
* The {@link TopologyView} this MAC operates on
...
...
src/de/tud/kom/p2psim/api/topology/TopologyComponent.java
View file @
050cc5e8
...
...
@@ -47,6 +47,7 @@ public interface TopologyComponent extends SimHostComponent, MovementSupported,
* @author Bjoern Richerzhagen
* @version 1.0, 26.02.2012
*/
@Deprecated
public
static
enum
PositionAccuracy
{
HIGH
,
MEDIUM
,
LOW
}
...
...
@@ -61,6 +62,7 @@ public interface TopologyComponent extends SimHostComponent, MovementSupported,
* a QoS-Class for the accuracy
* @return An estimate of the current position
*/
@Deprecated
public
Position
getPosition
(
PositionAccuracy
accuracy
);
/**
...
...
src/de/tud/kom/p2psim/impl/linklayer/mac/AbstractMacLayer.java
View file @
050cc5e8
...
...
@@ -53,6 +53,7 @@ import de.tudarmstadt.maki.simonstrator.api.Monitor;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.core.MonitorComponent.AnalyzerNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.network.NetID
;
/**
* Basic implementation of a MacLayer running on a PHY-CommunicationComponent.
...
...
@@ -97,6 +98,11 @@ public abstract class AbstractMacLayer implements MacLayer {
* Our own MacAddress on this PHY
*/
private
MacAddress
macAddress
;
/**
* Our own IP used by the NetLayer on this PHY. Not available during initialization.
*/
private
NetID
netID
;
/**
* Each MAC has a Message queue for outgoing messages
...
...
@@ -889,6 +895,18 @@ public abstract class AbstractMacLayer implements MacLayer {
public
final
MacAddress
getMacAddress
()
{
return
macAddress
;
}
@Override
public
NetID
getNetId
()
{
if
(
netID
==
null
)
{
// Wow... :)
netID
=
host
.
getNetworkComponent
().
getByName
(
getPhyType
().
getNetInterfaceName
()).
getLocalInetAddress
();
if
(
netID
==
null
)
{
throw
new
AssertionError
();
}
}
return
netID
;
}
@Override
public
final
void
setMessageListener
(
LinkMessageListener
listener
)
{
...
...
src/de/tud/kom/p2psim/impl/network/gnp/topology/GnpPosition.java
View file @
050cc5e8
...
...
@@ -25,6 +25,7 @@ import java.util.ArrayList;
import
de.tud.kom.p2psim.api.common.Position
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
/**
* This class implements a NetPosition for a GNP-Based calculation of round trip
...
...
@@ -312,5 +313,36 @@ public class GnpPosition implements Position, Comparable<GnpPosition> {
public
GnpPosition
clone
()
{
return
new
GnpPosition
(
gnpCoordinates
);
}
@Override
public
float
bearingTo
(
Location
dest
)
{
throw
new
AssertionError
(
"bearingTo is not defined for this Position-Type"
);
}
@Override
public
double
distanceTo
(
Location
dest
)
{
return
getDistance
((
Position
)
dest
);
}
@Override
public
long
getAgeOfLocation
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
double
getLatitude
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
double
getLongitude
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
set
(
Location
l
)
{
throw
new
UnsupportedOperationException
();
}
}
src/de/tud/kom/p2psim/impl/topology/DefaultTopologyComponent.java
View file @
050cc5e8
...
...
@@ -45,15 +45,18 @@ import de.tud.kom.p2psim.impl.topology.movement.modular.attraction.AttractionPoi
import
de.tudarmstadt.maki.simonstrator.api.Graphs
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.DirectedEdge
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.Graph
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.Node
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.IEdge
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.INode
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID
;
import
de.tudarmstadt.maki.simonstrator.api.component.network.NetInterface
;
import
de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.NetInterfaceName
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.LocationListener
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.LocationRequest
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.LocationSensor
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSType
;
import
de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSTypes
;
import
de.tudarmstadt.maki.simonstrator.api.component.topology.TopologyID
;
import
de.tudarmstadt.maki.simonstrator.api.component.transport.ConnectivityListener
;
import
de.tudarmstadt.maki.simonstrator.api.operation.Operations
;
...
...
@@ -339,13 +342,13 @@ public class DefaultTopologyComponent implements TopologyComponent {
}
@Override
public
Node
getNode
(
TopologyID
identifier
)
{
public
I
Node
getNode
(
TopologyID
identifier
)
{
assert
graphViews
.
containsKey
(
identifier
);
return
graphViews
.
get
(
identifier
).
getOwnNode
(
host
);
}
@Override
public
Set
<
Directed
Edge
>
getNeighbors
(
TopologyID
topologyIdentifier
)
{
public
Set
<
I
Edge
>
getNeighbors
(
TopologyID
topologyIdentifier
)
{
assert
graphViews
.
containsKey
(
topologyIdentifier
);
return
graphViews
.
get
(
topologyIdentifier
).
getNeighbors
(
host
);
}
...
...
@@ -401,7 +404,8 @@ public class DefaultTopologyComponent implements TopologyComponent {
this
.
medium
=
medium
;
PhyType
localPhy
=
null
;
for
(
PhyType
currPhy
:
PhyType
.
values
())
{
if
(
currPhy
.
getNetInterfaceName
()
==
medium
)
{
if
(
currPhy
.
getNetInterfaceName
()
==
medium
&&
getTopology
().
getTopologyView
(
currPhy
)
!=
null
)
{
localPhy
=
currPhy
;
break
;
}
...
...
@@ -443,28 +447,32 @@ public class DefaultTopologyComponent implements TopologyComponent {
// Add all (online?) nodes
for
(
MacLayer
mac
:
topoView
.
getAllMacs
())
{
if
(!
onlyOnline
||
mac
.
isOnline
())
{
currentView
.
createAndAddNode
(
mac
.
getHost
().
getHostId
());
INode
node
=
currentView
.
createNode
(
INodeID
.
get
(
mac
.
getNetId
()));
node
.
setProperty
(
SiSTypes
.
PHY_LOCATION
,
topoView
.
getPosition
(
mac
.
getMacAddress
()));
currentView
.
addElement
(
node
);
}
}
if
(
isDistanceBased
)
{
// Build neighbors solely based on an assumed range
for
(
MacLayer
mac
:
topoView
.
getAllMacs
())
{
// Add neighbors
Node
currentNode
=
currentView
.
createNode
(
mac
.
getMacAddress
());
// Consider all nodes as potential neighbors
for
(
MacLayer
neighborMac
:
topoView
.
getAllMacs
())
{
// create, but do NOT add the node object
Node
neighbor
=
currentView
.
createNode
(
neighborMac
.
get
MacAddress
(
));
I
Node
neighbor
=
currentView
.
createNode
(
INodeID
.
get
(
neighborMac
.
getNetId
()
));
// only online nodes (already in graph)
if
(!
onlyOnline
||
currentView
.
contains
(
neighbor
))
{
if
(!
onlyOnline
||
currentView
.
containsNode
(
neighbor
.
getId
()))
{
// Distance?
if
(
topoView
.
getDistance
(
mac
.
getMacAddress
(),
neighborMac
.
getMacAddress
())
<=
distance
)
{
currentView
.
createAndAddEdge
(
currentNode
,
neighbor
);
IEdge
edge
=
currentView
.
createEdge
(
INodeID
.
get
(
mac
.
getNetId
()),
INodeID
.
get
(
neighborMac
.
getNetId
()));
currentView
.
addElement
(
edge
);
}
}
}
...
...
@@ -472,18 +480,23 @@ public class DefaultTopologyComponent implements TopologyComponent {
}
else
{
// Build neighborhoods based on underlay neighbors (1-hop)
for
(
MacLayer
mac
:
topoView
.
getAllMacs
())
{
// Add neighbors
Node
currentNode
=
currentView
.
createNode
(
mac
.
getMacAddress
());
// Rely on underlay for neighbors
List
<
MacAddress
>
neighbors
=
topoView
.
getNeighbors
(
mac
.
getMacAddress
());
for
(
MacAddress
neighborMac
:
neighbors
)
{
// create, but do NOT add the node object
Node
neighbor
=
currentView
.
createNode
(
neighborMac
);
INode
neighbor
=
currentView
.
createNode
(
INodeID
.
get
(
topoView
.
getMac
(
neighborMac
).
getNetId
()));
// only online nodes (already in graph)
if
(!
onlyOnline
||
currentView
.
contains
(
neighbor
))
{
currentView
.
createAndAddEdge
(
currentNode
,
neighbor
);
if
(!
onlyOnline
||
currentView
.
containsNode
(
neighbor
.
getId
()))
{
IEdge
edge
=
currentView
.
createEdge
(
INodeID
.
get
(
mac
.
getNetId
()),
INodeID
.
get
(
topoView
.
getMac
(
neighborMac
).
getNetId
()));
currentView
.
addElement
(
edge
);
edge
.
setProperty
(
SiSTypes
.
PHY_DISTANCE
,
topoView
.
getDistance
(
mac
.
getMacAddress
(),
neighborMac
));
}
}
}
...
...
@@ -492,19 +505,19 @@ public class DefaultTopologyComponent implements TopologyComponent {
isInvalid
=
false
;
}
public
Node
getOwnNode
(
SimHost
ownHost
)
{
public
I
Node
getOwnNode
(
SimHost
ownHost
)
{
MacLayer
mac
=
ownHost
.
getLinkLayer
().
getMac
(
phy
);
if
(!
onlyOnline
||
mac
.
isOnline
())
{
return
currentView
.
createNode
(
ownHost
.
getLinkLayer
()
.
getMac
(
phy
).
get
MacAddress
(
));
return
currentView
.
createNode
(
INodeID
.
get
(
ownHost
.
getLinkLayer
()
.
getMac
(
phy
).
get
NetId
()
));
}
return
null
;
}
public
Set
<
Directed
Edge
>
getNeighbors
(
SimHost
ownHost
)
{
public
Set
<
I
Edge
>
getNeighbors
(
SimHost
ownHost
)
{
recalculateLocalView
();
Node
ownNode
=
getOwnNode
(
ownHost
);
return
currentView
.
getOutgoingEdges
(
ownNode
);
I
Node
ownNode
=
getOwnNode
(
ownHost
);
return
currentView
.
getOutgoingEdges
(
ownNode
.
getId
()
);
}
/**
...
...
src/de/tud/kom/p2psim/impl/util/oracle/GlobalOracle.java
View file @
050cc5e8
...
...
@@ -35,6 +35,8 @@ import de.tudarmstadt.maki.simonstrator.api.Host;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.DirectedEdge
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.Graph
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.IEdge
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.INode
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.Node
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.core.OracleComponent
;
...
...
@@ -196,8 +198,8 @@ public class GlobalOracle implements OracleComponent {
public
static
<
T
extends
TopologyProvider
>
Graph
getTopology
(
Class
<
T
>
component
,
TopologyID
identifier
)
{
HashSet
<
Directed
Edge
>
edges
=
new
LinkedHashSet
<>();
HashSet
<
Node
>
nodes
=
new
LinkedHashSet
<
Node
>();
HashSet
<
I
Edge
>
edges
=
new
LinkedHashSet
<>();
HashSet
<
I
Node
>
nodes
=
new
LinkedHashSet
<>();
LinkedList
<
TopologyProvider
>
allProviders
=
new
LinkedList
<>();
...
...
@@ -206,7 +208,7 @@ public class GlobalOracle implements OracleComponent {
TopologyProvider
topologyProvider
=
host
.
getComponent
(
component
);
Node
providerNode
=
topologyProvider
.
getNode
(
identifier
);
I
Node
providerNode
=
topologyProvider
.
getNode
(
identifier
);
nodes
.
add
(
providerNode
);
...
...
@@ -221,17 +223,21 @@ public class GlobalOracle implements OracleComponent {
}
for
(
TopologyProvider
topologyProvider
:
allProviders
)
{
Set
<
de
.
tudarmstadt
.
maki
.
simonstrator
.
api
.
common
.
graph
.
DirectedEdge
>
neighbors
=
topologyProvider
.
getNeighbors
(
identifier
);
Set
<
IEdge
>
neighbors
=
topologyProvider
.
getNeighbors
(
identifier
);
edges
.
addAll
(
neighbors
);
}
/*
* Copy elements and (!) attached properties
*/
Graph
graph
=
Graphs
.
createGraph
();
for
(
Node
node
:
nodes
){
graph
.
add
(
node
);
for
(
INode
node
:
nodes
){
INode
copy
=
graph
.
createNode
(
node
.
getId
());
copy
.
addPropertiesFrom
(
node
);
}
for
(
DirectedEdge
edge
:
edges
)
{
graph
.
add
(
edge
);
for
(
IEdge
edge
:
edges
)
{
IEdge
copy
=
graph
.
createEdge
(
edge
.
fromId
(),
edge
.
toId
());
copy
.
addPropertiesFrom
(
edge
);
}
return
graph
;
...
...
src/de/tud/kom/p2psim/impl/util/positioning/GeoSpherePosition.java
View file @
050cc5e8
...
...
@@ -8,6 +8,7 @@ import de.tud.kom.p2psim.api.common.Position;
import
de.tud.kom.p2psim.impl.network.modular.common.GeoToolkit
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
import
de.tudarmstadt.maki.simonstrator.api.common.Transmitable
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
/** Immutable geographical position implementation based on a spherical Earth model.
*
...
...
@@ -89,11 +90,13 @@ public class GeoSpherePosition implements Transmitable, Position {
}
/** Get the latitude in degrees */
@Override
public
double
getLatitude
()
{
return
Math
.
toDegrees
(
latitude
);
}
/** Get the longitude in degrees */
@Override
public
double
getLongitude
()
{
return
Math
.
toDegrees
(
longitude
);
}
...
...
@@ -435,4 +438,24 @@ public class GeoSpherePosition implements Transmitable, Position {
public
static
boolean
isBearingCacheEnabled
()
{
return
enableBearingCache
;
}
@Override
public
void
set
(
Location
l
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
long
getAgeOfLocation
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
double
distanceTo
(
Location
dest
)
{
return
getDistance
((
Position
)
dest
);
}
@Override
public
float
bearingTo
(
Location
dest
)
{
return
(
float
)
getBearing
((
Position
)
dest
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment