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
a8488c41
Commit
a8488c41
authored
Jun 21, 2017
by
Tobias Meuser
Committed by
Jose Ignacio Monreal Bailey
Aug 20, 2019
Browse files
Added speed to SiSTypes, provided by DefaultTopologyComponent
parent
02e300e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/DefaultTopologyComponent.java
View file @
a8488c41
...
@@ -2,17 +2,17 @@
...
@@ -2,17 +2,17 @@
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
*
* This file is part of PeerfactSim.KOM.
* This file is part of PeerfactSim.KOM.
*
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* any later version.
*
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*
...
@@ -67,7 +67,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.transport.ConnectivityList
...
@@ -67,7 +67,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.transport.ConnectivityList
/**
/**
* Default implementation of a {@link TopologyComponent}.
* Default implementation of a {@link TopologyComponent}.
*
*
* @author Bjoern Richerzhagen
* @author Bjoern Richerzhagen
* @version 1.0, 29.02.2012
* @version 1.0, 29.02.2012
*/
*/
...
@@ -95,7 +95,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
...
@@ -95,7 +95,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
/**
/**
* Create a TopologyComponent for the current host.
* Create a TopologyComponent for the current host.
*
*
* @param host
* @param host
* @param topology
* @param topology
* @param movementModel
* @param movementModel
...
@@ -134,48 +134,74 @@ public class DefaultTopologyComponent implements TopologyComponent {
...
@@ -134,48 +134,74 @@ public class DefaultTopologyComponent implements TopologyComponent {
position
.
set
(
placementModel
.
place
(
this
));
position
.
set
(
placementModel
.
place
(
this
));
}
}
if
(
registerAsInformationProviderInSiS
)
{
try
{
try
{
final
SiSComponent
sis
=
host
.
getComponent
(
SiSComponent
.
class
);
final
SiSComponent
sis
=
host
.
getComponent
(
SiSComponent
.
class
);
sis
.
provide
().
nodeState
(
SiSTypes
.
PHY_LOCATION
,
sis
.
provide
().
nodeState
(
SiSTypes
.
PHY_LOCATION
,
new
SiSDataCallback
<
Location
>()
{
new
SiSDataCallback
<
Location
>()
{
Set
<
INodeID
>
localID
=
INodeID
Set
<
INodeID
>
localID
=
INodeID
.
getSingleIDSet
(
getHost
().
getId
());
.
getSingleIDSet
(
getHost
().
getId
());
@Override
@Override
public
Location
getValue
(
INodeID
nodeID
,
public
Location
getValue
(
INodeID
nodeID
,
SiSProviderHandle
providerHandle
)
SiSProviderHandle
providerHandle
)
throws
InformationNotAvailableException
{
throws
InformationNotAvailableException
{
if
(
nodeID
.
equals
(
getHost
().
getId
()))
{
if
(
nodeID
.
equals
(
getHost
().
getId
()))
{
return
getLastLocation
();
return
getLastLocation
();
}
else
{
}
else
{
throw
new
InformationNotAvailableException
();
throw
new
InformationNotAvailableException
();
}
}
}
}
@Override
@Override
public
Set
<
INodeID
>
getObservedNodes
()
{
public
Set
<
INodeID
>
getObservedNodes
()
{
return
localID
;
return
localID
;
}
}
@Override
@Override
public
SiSInfoProperties
getInfoProperties
()
{
public
SiSInfoProperties
getInfoProperties
()
{
return
new
SiSInfoProperties
();
return
new
SiSInfoProperties
();
}
}
});
});
sis
.
provide
().
nodeState
(
SiSTypes
.
SPEED
,
// Provide Underlay topology
new
SiSDataCallback
<
Double
>()
{
Event
.
scheduleImmediately
(
new
EventHandler
()
{
Set
<
INodeID
>
localID
=
INodeID
@Override
.
getSingleIDSet
(
getHost
().
getId
());
public
void
eventOccurred
(
Object
content
,
int
type
)
{
if
(
getHost
().
getLinkLayer
().
hasPhy
(
PhyType
.
WIFI
))
{
@Override
new
SiSTopologyProvider
(
sis
,
SiSTypes
.
NEIGHBORS_WIFI
,
public
Double
getValue
(
INodeID
nodeID
,
DefaultTopologyComponent
.
this
,
SiSProviderHandle
providerHandle
)
getTopologyID
(
NetInterfaceName
.
WIFI
,
true
),
throws
InformationNotAvailableException
{
DefaultTopologyComponent
.
class
);
if
(
nodeID
.
equals
(
getHost
().
getId
()))
{
}
return
getMovementSpeed
();
}
else
{
throw
new
InformationNotAvailableException
();
}
}
@Override
public
Set
<
INodeID
>
getObservedNodes
()
{
return
localID
;
}
@Override
public
SiSInfoProperties
getInfoProperties
()
{
return
new
SiSInfoProperties
();
}
});
// Provide Underlay topology
Event
.
scheduleImmediately
(
new
EventHandler
()
{
@Override
public
void
eventOccurred
(
Object
content
,
int
type
)
{
if
(
getHost
().
getLinkLayer
().
hasPhy
(
PhyType
.
WIFI
))
{
new
SiSTopologyProvider
(
sis
,
SiSTypes
.
NEIGHBORS_WIFI
,
DefaultTopologyComponent
.
this
,
getTopologyID
(
NetInterfaceName
.
WIFI
,
true
),
DefaultTopologyComponent
.
class
);
}
}
},
null
,
0
);
},
null
,
0
);
...
@@ -206,7 +232,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
...
@@ -206,7 +232,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
public
Topology
getTopology
()
{
public
Topology
getTopology
()
{
return
topology
;
return
topology
;
}
}
/**
/**
* Access to the movement model
* Access to the movement model
* @return
* @return
...
@@ -279,19 +305,19 @@ public class DefaultTopologyComponent implements TopologyComponent {
...
@@ -279,19 +305,19 @@ public class DefaultTopologyComponent implements TopologyComponent {
locationListener
.
onLocationChanged
(
getHost
(),
getLastLocation
());
locationListener
.
onLocationChanged
(
getHost
(),
getLastLocation
());
}
}
}
}
@Override
@Override
public
void
setTargetAttractionPoint
(
AttractionPoint
targetAttractionPoint
)
public
void
setTargetAttractionPoint
(
AttractionPoint
targetAttractionPoint
)
throws
UnsupportedOperationException
{
throws
UnsupportedOperationException
{
movementModel
.
changeTargetLocation
(
this
,
targetAttractionPoint
);
movementModel
.
changeTargetLocation
(
this
,
targetAttractionPoint
);
// NodeDebugMonitor.update(this.getClass(), getHost().getId(), "Target Location", targetAttractionPoint);
// NodeDebugMonitor.update(this.getClass(), getHost().getId(), "Target Location", targetAttractionPoint);
}
}
@Override
@Override
public
AttractionPoint
getCurrentTargetAttractionPoint
()
{
public
AttractionPoint
getCurrentTargetAttractionPoint
()
{
return
movementModel
.
getTargetLocation
(
this
);
return
movementModel
.
getTargetLocation
(
this
);
}
}
@Override
@Override
public
Set
<
AttractionPoint
>
getAllAttractionPoints
()
{
public
Set
<
AttractionPoint
>
getAllAttractionPoints
()
{
return
movementModel
.
getAllAttractionPoints
();
return
movementModel
.
getAllAttractionPoints
();
...
@@ -339,7 +365,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
...
@@ -339,7 +365,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
/**
/**
* Update 15.03.16 added support for multiple listeners (however, frequency
* Update 15.03.16 added support for multiple listeners (however, frequency
* etc. is immune after the first request is registered.)
* etc. is immune after the first request is registered.)
*
*
* @author Bjoern Richerzhagen
* @author Bjoern Richerzhagen
* @version 1.0, Mar 15, 2016
* @version 1.0, Mar 15, 2016
*/
*/
...
@@ -354,7 +380,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
...
@@ -354,7 +380,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
private
Location
lastLocation
=
null
;
private
Location
lastLocation
=
null
;
private
List
<
LocationListener
>
listeners
=
new
LinkedList
<
LocationListener
>();
private
List
<
LocationListener
>
listeners
=
new
LinkedList
<
LocationListener
>();
private
int
eventTypeSeq
=
0
;
private
int
eventTypeSeq
=
0
;
public
LocationRequestImpl
()
{
public
LocationRequestImpl
()
{
...
@@ -402,9 +428,9 @@ public class DefaultTopologyComponent implements TopologyComponent {
...
@@ -402,9 +428,9 @@ public class DefaultTopologyComponent implements TopologyComponent {
public
void
eventOccurred
(
Object
content
,
int
type
)
{
public
void
eventOccurred
(
Object
content
,
int
type
)
{
if
(
eventTypeSeq
!=
type
)
{
if
(
eventTypeSeq
!=
type
)
{
/*
/*
* Discard invalid events caused when a client cancels updates
* Discard invalid events caused when a client cancels updates
* but reactivates the request within the update frequency
* but reactivates the request within the update frequency
* interval. In this case, the old events continue rescheduling
* interval. In this case, the old events continue rescheduling
* themselves.
* themselves.
*/
*/
return
;
return
;
...
@@ -413,7 +439,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
...
@@ -413,7 +439,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
// Only reschedule, if at least one listener is ... listening
// Only reschedule, if at least one listener is ... listening
Location
newLoc
=
getLastLocation
();
Location
newLoc
=
getLastLocation
();
listeners
.
forEach
((
LocationListener
listener
)
->
listener
listeners
.
forEach
((
LocationListener
listener
)
->
listener
.
onLocationChanged
(
getHost
(),
newLoc
));
.
onLocationChanged
(
getHost
(),
newLoc
));
lastLocation
=
newLoc
;
lastLocation
=
newLoc
;
Event
.
scheduleWithDelay
(
interval
,
this
,
null
,
eventTypeSeq
);
Event
.
scheduleWithDelay
(
interval
,
this
,
null
,
eventTypeSeq
);
}
}
...
@@ -448,7 +474,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
...
@@ -448,7 +474,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
boolean
onlyOnline
,
double
range
)
{
boolean
onlyOnline
,
double
range
)
{
TopologyID
id
=
TopologyID
.
getIdentifier
(
TopologyID
id
=
TopologyID
.
getIdentifier
(
netName
.
toString
()
+
(
onlyOnline
?
"-online"
:
"-all"
)
netName
.
toString
()
+
(
onlyOnline
?
"-online"
:
"-all"
)
+
String
.
valueOf
(
range
),
+
String
.
valueOf
(
range
),
DefaultTopologyComponent
.
class
);
DefaultTopologyComponent
.
class
);
if
(!
this
.
graphViews
.
containsKey
(
id
))
{
if
(!
this
.
graphViews
.
containsKey
(
id
))
{
this
.
graphViews
.
put
(
id
,
this
.
graphViews
.
put
(
id
,
...
@@ -483,12 +509,12 @@ public class DefaultTopologyComponent implements TopologyComponent {
...
@@ -483,12 +509,12 @@ public class DefaultTopologyComponent implements TopologyComponent {
/**
/**
* This is calculated based on global knowledge. It only registers as
* This is calculated based on global knowledge. It only registers as
* {@link LocationListener}, if a range is specified by the Provider.
* {@link LocationListener}, if a range is specified by the Provider.
*
*
* @author Bjoern Richerzhagen
* @author Bjoern Richerzhagen
* @version 1.0, May 13, 2015
* @version 1.0, May 13, 2015
*/
*/
private
class
LocalGraphView
private
class
LocalGraphView
implements
LocationListener
,
ConnectivityListener
{
implements
LocationListener
,
ConnectivityListener
{
/**
/**
* Marker: has there been any movement since the graph view was last
* Marker: has there been any movement since the graph view was last
...
@@ -550,8 +576,8 @@ public class DefaultTopologyComponent implements TopologyComponent {
...
@@ -550,8 +576,8 @@ public class DefaultTopologyComponent implements TopologyComponent {
if
(
host
.
getNetworkComponent
()
if
(
host
.
getNetworkComponent
()
.
getByName
(
medium
)
!=
null
)
{
.
getByName
(
medium
)
!=
null
)
{
host
.
getNetworkComponent
().
getByName
(
medium
)
host
.
getNetworkComponent
().
getByName
(
medium
)
.
addConnectivityListener
(
.
addConnectivityListener
(
LocalGraphView
.
this
);
LocalGraphView
.
this
);
}
}
}
}
}
}
...
@@ -636,7 +662,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
...
@@ -636,7 +662,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
IEdge
edge
=
currentView
.
createEdge
(
IEdge
edge
=
currentView
.
createEdge
(
mac
.
getHost
().
getId
(),
mac
.
getHost
().
getId
(),
topoView
.
getMac
(
neighborMac
).
getHost
()
topoView
.
getMac
(
neighborMac
).
getHost
()
.
getId
());
.
getId
());
currentView
.
addElement
(
edge
);
currentView
.
addElement
(
edge
);
edge
.
setProperty
(
SiSTypes
.
PHY_DISTANCE
,
edge
.
setProperty
(
SiSTypes
.
PHY_DISTANCE
,
topoView
.
getDistance
(
mac
.
getMacAddress
(),
topoView
.
getDistance
(
mac
.
getMacAddress
(),
...
@@ -666,7 +692,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
...
@@ -666,7 +692,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
/**
/**
* This is the global view, therefore we do not distinguish between
* This is the global view, therefore we do not distinguish between
* hosts.
* hosts.
*
*
* @return
* @return
*/
*/
public
Graph
getLocalView
()
{
public
Graph
getLocalView
()
{
...
...
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