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 @@
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* 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
/**
* Default implementation of a {@link TopologyComponent}.
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 29.02.2012
*/
...
...
@@ -95,7 +95,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
/**
* Create a TopologyComponent for the current host.
*
*
* @param host
* @param topology
* @param movementModel
...
...
@@ -134,48 +134,74 @@ public class DefaultTopologyComponent implements TopologyComponent {
position
.
set
(
placementModel
.
place
(
this
));
}
if
(
registerAsInformationProviderInSiS
)
{
try
{
final
SiSComponent
sis
=
host
.
getComponent
(
SiSComponent
.
class
);
sis
.
provide
().
nodeState
(
SiSTypes
.
PHY_LOCATION
,
new
SiSDataCallback
<
Location
>()
{
Set
<
INodeID
>
localID
=
INodeID
.
getSingleIDSet
(
getHost
().
getId
());
@Override
public
Location
getValue
(
INodeID
nodeID
,
SiSProviderHandle
providerHandle
)
throws
InformationNotAvailableException
{
if
(
nodeID
.
equals
(
getHost
().
getId
()))
{
return
getLastLocation
();
}
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
);
}
try
{
final
SiSComponent
sis
=
host
.
getComponent
(
SiSComponent
.
class
);
sis
.
provide
().
nodeState
(
SiSTypes
.
PHY_LOCATION
,
new
SiSDataCallback
<
Location
>()
{
Set
<
INodeID
>
localID
=
INodeID
.
getSingleIDSet
(
getHost
().
getId
());
@Override
public
Location
getValue
(
INodeID
nodeID
,
SiSProviderHandle
providerHandle
)
throws
InformationNotAvailableException
{
if
(
nodeID
.
equals
(
getHost
().
getId
()))
{
return
getLastLocation
();
}
else
{
throw
new
InformationNotAvailableException
();
}
}
@Override
public
Set
<
INodeID
>
getObservedNodes
()
{
return
localID
;
}
@Override
public
SiSInfoProperties
getInfoProperties
()
{
return
new
SiSInfoProperties
();
}
});
sis
.
provide
().
nodeState
(
SiSTypes
.
SPEED
,
new
SiSDataCallback
<
Double
>()
{
Set
<
INodeID
>
localID
=
INodeID
.
getSingleIDSet
(
getHost
().
getId
());
@Override
public
Double
getValue
(
INodeID
nodeID
,
SiSProviderHandle
providerHandle
)
throws
InformationNotAvailableException
{
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
);
...
...
@@ -206,7 +232,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
public
Topology
getTopology
()
{
return
topology
;
}
/**
* Access to the movement model
* @return
...
...
@@ -279,19 +305,19 @@ public class DefaultTopologyComponent implements TopologyComponent {
locationListener
.
onLocationChanged
(
getHost
(),
getLastLocation
());
}
}
@Override
public
void
setTargetAttractionPoint
(
AttractionPoint
targetAttractionPoint
)
throws
UnsupportedOperationException
{
movementModel
.
changeTargetLocation
(
this
,
targetAttractionPoint
);
// NodeDebugMonitor.update(this.getClass(), getHost().getId(), "Target Location", targetAttractionPoint);
}
@Override
public
AttractionPoint
getCurrentTargetAttractionPoint
()
{
return
movementModel
.
getTargetLocation
(
this
);
}
@Override
public
Set
<
AttractionPoint
>
getAllAttractionPoints
()
{
return
movementModel
.
getAllAttractionPoints
();
...
...
@@ -339,7 +365,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
/**
* Update 15.03.16 added support for multiple listeners (however, frequency
* etc. is immune after the first request is registered.)
*
*
* @author Bjoern Richerzhagen
* @version 1.0, Mar 15, 2016
*/
...
...
@@ -354,7 +380,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
private
Location
lastLocation
=
null
;
private
List
<
LocationListener
>
listeners
=
new
LinkedList
<
LocationListener
>();
private
int
eventTypeSeq
=
0
;
public
LocationRequestImpl
()
{
...
...
@@ -402,9 +428,9 @@ public class DefaultTopologyComponent implements TopologyComponent {
public
void
eventOccurred
(
Object
content
,
int
type
)
{
if
(
eventTypeSeq
!=
type
)
{
/*
* Discard invalid events caused when a client cancels updates
* but reactivates the request within the update frequency
* interval. In this case, the old events continue rescheduling
* Discard invalid events caused when a client cancels updates
* but reactivates the request within the update frequency
* interval. In this case, the old events continue rescheduling
* themselves.
*/
return
;
...
...
@@ -413,7 +439,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
// Only reschedule, if at least one listener is ... listening
Location
newLoc
=
getLastLocation
();
listeners
.
forEach
((
LocationListener
listener
)
->
listener
.
onLocationChanged
(
getHost
(),
newLoc
));
.
onLocationChanged
(
getHost
(),
newLoc
));
lastLocation
=
newLoc
;
Event
.
scheduleWithDelay
(
interval
,
this
,
null
,
eventTypeSeq
);
}
...
...
@@ -448,7 +474,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
boolean
onlyOnline
,
double
range
)
{
TopologyID
id
=
TopologyID
.
getIdentifier
(
netName
.
toString
()
+
(
onlyOnline
?
"-online"
:
"-all"
)
+
String
.
valueOf
(
range
),
+
String
.
valueOf
(
range
),
DefaultTopologyComponent
.
class
);
if
(!
this
.
graphViews
.
containsKey
(
id
))
{
this
.
graphViews
.
put
(
id
,
...
...
@@ -483,12 +509,12 @@ public class DefaultTopologyComponent implements TopologyComponent {
/**
* This is calculated based on global knowledge. It only registers as
* {@link LocationListener}, if a range is specified by the Provider.
*
*
* @author Bjoern Richerzhagen
* @version 1.0, May 13, 2015
*/
private
class
LocalGraphView
implements
LocationListener
,
ConnectivityListener
{
implements
LocationListener
,
ConnectivityListener
{
/**
* Marker: has there been any movement since the graph view was last
...
...
@@ -550,8 +576,8 @@ public class DefaultTopologyComponent implements TopologyComponent {
if
(
host
.
getNetworkComponent
()
.
getByName
(
medium
)
!=
null
)
{
host
.
getNetworkComponent
().
getByName
(
medium
)
.
addConnectivityListener
(
LocalGraphView
.
this
);
.
addConnectivityListener
(
LocalGraphView
.
this
);
}
}
}
...
...
@@ -636,7 +662,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
IEdge
edge
=
currentView
.
createEdge
(
mac
.
getHost
().
getId
(),
topoView
.
getMac
(
neighborMac
).
getHost
()
.
getId
());
.
getId
());
currentView
.
addElement
(
edge
);
edge
.
setProperty
(
SiSTypes
.
PHY_DISTANCE
,
topoView
.
getDistance
(
mac
.
getMacAddress
(),
...
...
@@ -666,7 +692,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
/**
* This is the global view, therefore we do not distinguish between
* hosts.
*
*
* @return
*/
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