Commit fa7e07fc authored by Marc Schiller's avatar Marc Schiller
Browse files

Merge branch 'master' into nr/monitoring-model

parents cbfe8761 21216cd4
...@@ -207,6 +207,10 @@ public class ModularMovementModel implements MovementModel, EventHandler { ...@@ -207,6 +207,10 @@ public class ModularMovementModel implements MovementModel, EventHandler {
moveableHosts.add(comp); moveableHosts.add(comp);
offsetPosition.put(comp, randomOffsetVector()); offsetPosition.put(comp, randomOffsetVector());
} }
public Set<SimLocationActuator> getAllLocationActuators() {
return moveableHosts;
}
@Override @Override
public void setTimeBetweenMoveOperations(long time) { public void setTimeBetweenMoveOperations(long time) {
......
...@@ -20,15 +20,21 @@ ...@@ -20,15 +20,21 @@
package de.tud.kom.p2psim.impl.topology.movement.modularosm; package de.tud.kom.p2psim.impl.topology.movement.modularosm;
import java.awt.AlphaComposite;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.geom.Point2D;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JMenu; import javax.swing.JMenu;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import de.tud.kom.p2psim.api.topology.movement.SimLocationActuator;
import de.tud.kom.p2psim.impl.topology.PositionVector; import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView; import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView;
import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.VisualizationInjector; import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.VisualizationInjector;
...@@ -36,17 +42,29 @@ import de.tud.kom.p2psim.impl.topology.views.visualization.ui.VisualizationCompo ...@@ -36,17 +42,29 @@ import de.tud.kom.p2psim.impl.topology.views.visualization.ui.VisualizationCompo
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
/** /**
* Visualization Component of the Attraction Points in the Modular Movement Model. * Visualization Component of the Attraction Points in the Modular Movement
* Model.
* *
* *
* @author Martin Hellwig * @author Martin Hellwig, Bjoern Richerzhagen
* @version 1.0, 02.07.2015 * @version 1.0, 02.07.2015
*/ */
public class ModularMovementModelViz extends JComponent implements VisualizationComponent { public class ModularMovementModelViz extends JComponent
implements VisualizationComponent {
private ModularMovementModel movementModel; private ModularMovementModel movementModel;
private static Color COLOR_ATTR_POINT = new Color(0.2f, 0.2f, 0.2f, 0.4f); protected boolean showAttractionPoints = true;
protected boolean showNodePositions = true;
private JMenu menu;
private final static int NODE_PAD = 2;
private final static int ATTR_PAD = 10;
private static Color COLOR_ATTR_POINT = Color.decode("#4A7B9D");
public ModularMovementModelViz(ModularMovementModel model) { public ModularMovementModelViz(ModularMovementModel model) {
setBounds(0, 0, VisualizationInjector.getWorldX(), setBounds(0, 0, VisualizationInjector.getWorldX(),
...@@ -54,6 +72,36 @@ public class ModularMovementModelViz extends JComponent implements Visualization ...@@ -54,6 +72,36 @@ public class ModularMovementModelViz extends JComponent implements Visualization
setOpaque(true); setOpaque(true);
setVisible(true); setVisible(true);
this.movementModel = model; this.movementModel = model;
menu = new JMenu("Mobility Model");
menu.add(createCheckboxAp());
menu.add(createCheckboxNodePositions());
}
private JCheckBoxMenuItem createCheckboxAp() {
final JCheckBoxMenuItem checkBox = new JCheckBoxMenuItem(
"show attraction points", showAttractionPoints);
checkBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
showAttractionPoints = checkBox.isSelected();
VisualizationInjector.invalidate();
}
});
return checkBox;
}
private JCheckBoxMenuItem createCheckboxNodePositions() {
final JCheckBoxMenuItem checkBox = new JCheckBoxMenuItem(
"show node positions", showNodePositions);
checkBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
showNodePositions = checkBox.isSelected();
VisualizationInjector.invalidate();
}
});
return checkBox;
} }
@Override @Override
...@@ -63,18 +111,34 @@ public class ModularMovementModelViz extends JComponent implements Visualization ...@@ -63,18 +111,34 @@ public class ModularMovementModelViz extends JComponent implements Visualization
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON); RenderingHints.VALUE_ANTIALIAS_ON);
for (AttractionPoint aPoint : movementModel.getAttractionPoints()) { if (showAttractionPoints) {
Point point = ((PositionVector) aPoint).asPoint(); for (AttractionPoint aPoint : movementModel.getAttractionPoints()) {
// draw border Point point = ((PositionVector) aPoint).asPoint();
g2.setColor(Color.BLACK); // draw border
g2.setFont(VisualizationTopologyView.FONT_MEDIUM); g2.setColor(Color.BLACK);
g2.drawString(aPoint.getName(), g2.setFont(VisualizationTopologyView.FONT_MEDIUM);
VisualizationInjector.scaleValue(point.x) - 15, g2.drawString(aPoint.getName(),
VisualizationInjector.scaleValue(point.y) - 15); VisualizationInjector.scaleValue(point.x) - ATTR_PAD,
g2.setColor(COLOR_ATTR_POINT); VisualizationInjector.scaleValue(point.y) - ATTR_PAD);
g2.fillOval(VisualizationInjector.scaleValue(point.x) - 15, g2.setColor(COLOR_ATTR_POINT);
VisualizationInjector.scaleValue(point.y) - 15, 20, 20); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
g2.fillOval(
VisualizationInjector.scaleValue(point.x) - ATTR_PAD,
VisualizationInjector.scaleValue(point.y) - ATTR_PAD,
ATTR_PAD * 2 + 1, ATTR_PAD * 2 + 1);
}
}
if (showNodePositions) {
for (SimLocationActuator comp : movementModel
.getAllLocationActuators()) {
Point2D pt = comp.getRealPosition().asPoint();
g2.setColor(Color.GRAY);
g2.fillOval((int) pt.getX() - NODE_PAD,
(int) pt.getY() - NODE_PAD, NODE_PAD * 2 + 1,
NODE_PAD * 2 + 1);
}
} }
} }
...@@ -90,7 +154,7 @@ public class ModularMovementModelViz extends JComponent implements Visualization ...@@ -90,7 +154,7 @@ public class ModularMovementModelViz extends JComponent implements Visualization
@Override @Override
public JMenu getCustomMenu() { public JMenu getCustomMenu() {
return null; return menu;
} }
@Override @Override
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
package de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction; package de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Random; import java.util.Random;
import de.tud.kom.p2psim.impl.topology.PositionVector; import de.tud.kom.p2psim.impl.topology.PositionVector;
...@@ -28,31 +30,68 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction ...@@ -28,31 +30,68 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
/** /**
* In the current implementation, {@link AttractionPoint}s cannot move anymore. * In the current implementation, {@link AttractionPoint}s cannot move anymore.
* * We hold a static list of attraction points to ensure that there exists only
* one instance of each name at a time.
* *
* @author Christoph Muenker, Bjoern Richerzhagen * @author Christoph Muenker, Bjoern Richerzhagen
* @version 1.0, 02.07.2013 * @version 1.0, 02.07.2013
*/ */
public class AttractionPointImpl extends PositionVector implements AttractionPoint { public class AttractionPointImpl extends PositionVector
implements AttractionPoint {
protected static Random rnd = Randoms.getRandom(AttractionPoint.class); protected static Random rnd = Randoms.getRandom(AttractionPoint.class);
private static Map<String, AttractionPointImpl> instances = new LinkedHashMap<>();
private String name; private String name;
private double weight = 0;
private double radius = 0;
public AttractionPointImpl(String name, PositionVector posVec) { public AttractionPointImpl(String name, PositionVector posVec) {
super(posVec); super(posVec);
this.name = name; this.name = name;
if (instances.containsKey(name)) {
throw new AssertionError("Name "+name+" already in use for an attraction point.");
}
instances.put(name, this);
} }
@Override @Override
public String getName() { public String getName() {
return name; return name;
} }
@Override
public double getWeight() {
return weight;
}
@Override
public double getRadius() {
return radius;
}
@Override
public void setWeight(double weight) {
this.weight = weight;
}
@Override
public void setRadius(double radius) {
this.radius = radius;
}
@Override @Override
public AttractionPoint clone(String newName) { public AttractionPoint clone(String newName) {
return new AttractionPointImpl(name, this); return new AttractionPointImpl(name, this);
} }
@Override
public int getTransmissionSize() {
return super.getTransmissionSize() + name.length() + Double.BYTES * 2;
}
@Override @Override
public int hashCode() { public int hashCode() {
...@@ -75,5 +114,5 @@ public class AttractionPointImpl extends PositionVector implements AttractionPoi ...@@ -75,5 +114,5 @@ public class AttractionPointImpl extends PositionVector implements AttractionPoi
return false; return false;
return true; return true;
} }
} }
...@@ -40,6 +40,7 @@ import de.tud.kom.p2psim.api.topology.views.DropProbabilityDeterminator; ...@@ -40,6 +40,7 @@ import de.tud.kom.p2psim.api.topology.views.DropProbabilityDeterminator;
import de.tud.kom.p2psim.api.topology.views.LatencyDeterminator; import de.tud.kom.p2psim.api.topology.views.LatencyDeterminator;
import de.tud.kom.p2psim.api.topology.views.TopologyView; import de.tud.kom.p2psim.api.topology.views.TopologyView;
import de.tud.kom.p2psim.impl.topology.PositionVector; import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.Binder;
import de.tudarmstadt.maki.simonstrator.api.Host; import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.Monitor; import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Monitor.Level; import de.tudarmstadt.maki.simonstrator.api.Monitor.Level;
...@@ -130,6 +131,7 @@ public abstract class AbstractTopologyView<L extends DefaultLink> implements ...@@ -130,6 +131,7 @@ public abstract class AbstractTopologyView<L extends DefaultLink> implements
* @param obstaclesSupported * @param obstaclesSupported
*/ */
public AbstractTopologyView(PhyType phy, boolean movementSupported) { public AbstractTopologyView(PhyType phy, boolean movementSupported) {
Binder.registerComponent(this);
this.phy = phy; this.phy = phy;
this.movementSupported = movementSupported; this.movementSupported = movementSupported;
if (movementSupported) { if (movementSupported) {
......
...@@ -314,6 +314,26 @@ public class FiveGTopologyView extends AbstractTopologyView<CellLink> { ...@@ -314,6 +314,26 @@ public class FiveGTopologyView extends AbstractTopologyView<CellLink> {
} }
} }
/**
* Access to the {@link FiveGTopologyDatabase} that takes care of the
* UMTS-links in the 5G-TopoView.
*
* @return
*/
public FiveGTopologyDatabase getUMTSTopologyDatabase() {
return database;
}
/**
* Access to the {@link FiveGTopologyDatabase} used to determine Wi-Fi AP
* connectivity in the 5G TopoView.
*
* @return
*/
public FiveGTopologyDatabase getAccessPointTopologyDatabase() {
return databaseAccessPoints;
}
/* /*
* Configuration options * Configuration options
*/ */
...@@ -453,6 +473,44 @@ public class FiveGTopologyView extends AbstractTopologyView<CellLink> { ...@@ -453,6 +473,44 @@ public class FiveGTopologyView extends AbstractTopologyView<CellLink> {
public void setLinkData(FiveGTopologyDatabase.Entry linkData, public void setLinkData(FiveGTopologyDatabase.Entry linkData,
FiveGTopologyDatabase.Entry apLinkData) { FiveGTopologyDatabase.Entry apLinkData) {
// Initialization
if (this.linkData == null && this.apLinkData == null) {
this.linkData = linkData;
this.apLinkData = apLinkData;
if (apLinkData != null) {
apLinkData.onHostEntersSegment(mobileClient);
} else {
linkData.onHostEntersSegment(mobileClient);
}
// For the first update on link creation.
return;
}
// Update
if (apLinkData != null) {
assert supportsAccessPoints;
if (this.apLinkData != null) {
// was in AP, moves into AP
this.apLinkData.onHostLeavesSegment(mobileClient);
apLinkData.onHostEntersSegment(mobileClient);
} else {
// was NOT in AP, moves into AP
this.linkData.onHostLeavesSegment(mobileClient);
apLinkData.onHostEntersSegment(mobileClient);
}
} else {
if (this.apLinkData != null) {
// was in AP, moves OUT OF AP
this.apLinkData.onHostLeavesSegment(mobileClient);
linkData.onHostEntersSegment(mobileClient);
} else {
// was NOT in AP, moves into NON-AP segment
this.linkData.onHostLeavesSegment(mobileClient);
linkData.onHostEntersSegment(mobileClient);
}
}
this.linkData = linkData; this.linkData = linkData;
assert (apLinkData != null && supportsAccessPoints) assert (apLinkData != null && supportsAccessPoints)
|| apLinkData == null; || apLinkData == null;
...@@ -497,10 +555,12 @@ public class FiveGTopologyView extends AbstractTopologyView<CellLink> { ...@@ -497,10 +555,12 @@ public class FiveGTopologyView extends AbstractTopologyView<CellLink> {
@Override @Override
public boolean isConnected() { public boolean isConnected() {
if (apLinkData != null) if (apLinkData != null) {
return apLinkData.getConnectivity(); return apLinkData.isAvailable();
if (linkData != null) }
return linkData.getConnectivity(); if (linkData != null) {
return linkData.isAvailable();
}
return false; return false;
} }
......
...@@ -112,6 +112,8 @@ public class VisualizationTopologyView extends JFrame ...@@ -112,6 +112,8 @@ public class VisualizationTopologyView extends JFrame
protected SimControlPanel simControls; protected SimControlPanel simControls;
protected JSplitPane splitPane; protected JSplitPane splitPane;
protected boolean showNodes = true;
public static final Stroke STROKE_BASIC = new BasicStroke(0.8f); public static final Stroke STROKE_BASIC = new BasicStroke(0.8f);
...@@ -135,6 +137,7 @@ public class VisualizationTopologyView extends JFrame ...@@ -135,6 +137,7 @@ public class VisualizationTopologyView extends JFrame
* *
*/ */
public VisualizationTopologyView() { public VisualizationTopologyView() {
Binder.registerComponent(this);
WORLD_X = (int) Binder.getComponentOrNull(Topology.class) WORLD_X = (int) Binder.getComponentOrNull(Topology.class)
.getWorldDimensions().getX(); .getWorldDimensions().getX();
WORLD_Y = (int) Binder.getComponentOrNull(Topology.class) WORLD_Y = (int) Binder.getComponentOrNull(Topology.class)
...@@ -334,6 +337,15 @@ public class VisualizationTopologyView extends JFrame ...@@ -334,6 +337,15 @@ public class VisualizationTopologyView extends JFrame
return null; return null;
} }
/**
* Set to false to disable default drawing of nodes.
*
* @param showNodes
*/
public void setShowNodes(boolean showNodes) {
this.showNodes = showNodes;
}
/** /**
* Mini-Container for per-node information * Mini-Container for per-node information
* *
...@@ -378,6 +390,8 @@ public class VisualizationTopologyView extends JFrame ...@@ -378,6 +390,8 @@ public class VisualizationTopologyView extends JFrame
protected HashMap<INodeID, VisNodeInformation> nodeInformation = new HashMap<INodeID, VisNodeInformation>(); protected HashMap<INodeID, VisNodeInformation> nodeInformation = new HashMap<INodeID, VisNodeInformation>();
protected final static int PADDING = 16; protected final static int PADDING = 16;
protected final static int NODE_PAD = 2;
private static final long serialVersionUID = -3023020559483652110L; private static final long serialVersionUID = -3023020559483652110L;
...@@ -443,7 +457,6 @@ public class VisualizationTopologyView extends JFrame ...@@ -443,7 +457,6 @@ public class VisualizationTopologyView extends JFrame
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON); RenderingHints.VALUE_ANTIALIAS_ON);
//paintPlayingFieldBorder(g2);
paintNodes(g2); paintNodes(g2);
super.paintComponent(g); super.paintComponent(g);
} }
...@@ -455,21 +468,18 @@ public class VisualizationTopologyView extends JFrame ...@@ -455,21 +468,18 @@ public class VisualizationTopologyView extends JFrame
g2.fillOval((int) node.position.getX() - PADDING, g2.fillOval((int) node.position.getX() - PADDING,
(int) node.position.getY() - PADDING, (int) node.position.getY() - PADDING,
PADDING * 2 + 1, PADDING * 2 + 1); PADDING * 2 + 1, PADDING * 2 + 1);
} else {
if (showNodes) {
// Draw nodes
g2.setColor(Color.DARK_GRAY);
g2.fillOval((int) node.position.getX() - NODE_PAD,
(int) node.position.getY() - NODE_PAD,
NODE_PAD * 2 + 1, NODE_PAD * 2 + 1);
}
} }
} }
} }
private void paintPlayingFieldBorder(Graphics2D g2) {
g2.setColor(Color.DARK_GRAY);
g2.fillRect(0, 0, getWidth(), getHeight());
g2.setColor(Color.WHITE);
g2.fillRect(0, 0, VisualizationInjector.getWorldX(),
VisualizationInjector.getWorldY());
g2.setPaint(Color.MAGENTA);
g2.setStroke(new BasicStroke(2));
g2.drawLine(0, 0, VisualizationInjector.scaleValue(100), 0);
}
} }
public void notifyInteractionListenersOnClick(long hostid, public void notifyInteractionListenersOnClick(long hostid,
......
...@@ -25,6 +25,7 @@ import java.util.Map; ...@@ -25,6 +25,7 @@ import java.util.Map;
import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.VisualizationInjector; import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.VisualizationInjector;
import de.tud.kom.p2psim.impl.topology.views.visualization.world.FiveGVisualization; import de.tud.kom.p2psim.impl.topology.views.visualization.world.FiveGVisualization;
import de.tudarmstadt.maki.simonstrator.api.Binder;
import de.tudarmstadt.maki.simonstrator.api.Event; import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler; import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.Time; import de.tudarmstadt.maki.simonstrator.api.Time;
...@@ -58,6 +59,7 @@ public abstract class AbstractGridBasedTopologyDatabase ...@@ -58,6 +59,7 @@ public abstract class AbstractGridBasedTopologyDatabase
*/ */
public AbstractGridBasedTopologyDatabase(int gridSize, public AbstractGridBasedTopologyDatabase(int gridSize,
boolean supportCloudlets) { boolean supportCloudlets) {
Binder.registerComponent(this);
this.gridSize = gridSize; this.gridSize = gridSize;
this.cloudEntries = new LinkedHashMap<>(); this.cloudEntries = new LinkedHashMap<>();
this.cloudletEntries = new LinkedHashMap<>(); this.cloudletEntries = new LinkedHashMap<>();
...@@ -149,7 +151,7 @@ public abstract class AbstractGridBasedTopologyDatabase ...@@ -149,7 +151,7 @@ public abstract class AbstractGridBasedTopologyDatabase
private final long latencyUp, latencyDown, bandwidthUp, bandwidthDown; private final long latencyUp, latencyDown, bandwidthUp, bandwidthDown;
private boolean connectivity = true; private boolean isAvailable = true;
/** /**
...@@ -183,7 +185,8 @@ public abstract class AbstractGridBasedTopologyDatabase ...@@ -183,7 +185,8 @@ public abstract class AbstractGridBasedTopologyDatabase
@Override @Override
public double getDropProbability(boolean isUpload) { public double getDropProbability(boolean isUpload) {
if(!getConnectivity()){ if(!isAvailable){
// Link is broken.
return 1; return 1;
} }
return isUpload ? dropUp : dropDown; return isUpload ? dropUp : dropDown;
...@@ -191,30 +194,26 @@ public abstract class AbstractGridBasedTopologyDatabase ...@@ -191,30 +194,26 @@ public abstract class AbstractGridBasedTopologyDatabase
@Override @Override
public long getLatency(boolean isUpload) { public long getLatency(boolean isUpload) {
if(!getConnectivity()){
return 9999 * Time.MILLISECOND;
}
return isUpload ? latencyUp : latencyDown; return isUpload ? latencyUp : latencyDown;
} }
@Override @Override
public long getBandwidth(boolean isUpload) { public long getBandwidth(boolean isUpload) {
if(!getConnectivity()){ if(!isAvailable){
// Link is broken.
return 0; return 0;
} }
return isUpload ? bandwidthUp : bandwidthDown; return isUpload ? bandwidthUp : bandwidthDown;
} }
@Override @Override
public boolean getConnectivity() public boolean isAvailable() {
{ return isAvailable;
return connectivity;
} }
@Override @Override
public void setConnectivity(boolean connectivity) public void setAvailability(boolean isAvailable) {
{ this.isAvailable = isAvailable;
this.connectivity = connectivity;
} }
} }
......
...@@ -20,8 +20,10 @@ ...@@ -20,8 +20,10 @@
package de.tud.kom.p2psim.impl.topology.views.fiveg; package de.tud.kom.p2psim.impl.topology.views.fiveg;
import de.tud.kom.p2psim.api.linklayer.mac.MacAddress;
import de.tud.kom.p2psim.impl.topology.views.FiveGTopologyView; import de.tud.kom.p2psim.impl.topology.views.FiveGTopologyView;
import de.tud.kom.p2psim.impl.topology.views.FiveGTopologyView.CellLink; import de.tud.kom.p2psim.impl.topology.views.FiveGTopologyView.CellLink;
import de.tudarmstadt.maki.simonstrator.api.component.GlobalComponent;
/** /**
* Database for the {@link FiveGTopologyView} - containing a mapping of position * Database for the {@link FiveGTopologyView} - containing a mapping of position
...@@ -34,7 +36,7 @@ import de.tud.kom.p2psim.impl.topology.views.FiveGTopologyView.CellLink; ...@@ -34,7 +36,7 @@ import de.tud.kom.p2psim.impl.topology.views.FiveGTopologyView.CellLink;
* @author Bjoern Richerzhagen * @author Bjoern Richerzhagen
* @version 1.0, Nov 5, 2015 * @version 1.0, Nov 5, 2015
*/ */
public interface FiveGTopologyDatabase { public interface FiveGTopologyDatabase extends GlobalComponent {
/** /**
* Calculation of a segment ID based on a position (usually given in * Calculation of a segment ID based on a position (usually given in
...@@ -94,6 +96,14 @@ public interface FiveGTopologyDatabase { ...@@ -94,6 +96,14 @@ public interface FiveGTopologyDatabase {
*/ */
public int getSegmentID(); public int getSegmentID();
default public void onHostLeavesSegment(MacAddress hostAddr) {
// ignore
}
default public void onHostEntersSegment(MacAddress hostAddr) {
// ignore
}
/** /**
* Probability of a packet drop on the link - can even be 1, so that the * Probability of a packet drop on the link - can even be 1, so that the
* link is virtually disconnected. * link is virtually disconnected.
...@@ -117,22 +127,19 @@ public interface FiveGTopologyDatabase { ...@@ -117,22 +127,19 @@ public interface FiveGTopologyDatabase {
public long getBandwidth(boolean isUpload); public long getBandwidth(boolean isUpload);
/** /**
* Connectivity of the cell. * Availability of the cell (false, if the current cell is "broken")
* *
* @return <code>false</code> if the cell is broken down/damaged and * @return
* upload/download isn't possible. <code>true</code> otherwise.
*/ */
boolean getConnectivity(); boolean isAvailable();
/** /**
* Set the connectivity of the cell. When set to <code>false</code>, it * Set the connectivity of the cell. When set to false, the cell is no
* should be impossible to upload or download data via this cell. * longer accepting connections and existing connections fail.
* {@link CellLink} refers to this attribute when returning e.g. BW or
* drop rate.
* *
* @param connectivity * @param isAvailable
*/ */
void setConnectivity(boolean connectivity); void setAvailability(boolean isAvailable);
} }
} }
...@@ -117,12 +117,6 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec ...@@ -117,12 +117,6 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec
if (entry == null) { if (entry == null) {
continue; continue;
} }
if (entry.getConnectivity() && entry.getLatency(isUpload) > maxLatency) {
maxLatency = entry.getLatency(isUpload);
}
if (entry.getConnectivity() && entry.getLatency(isUpload) < minLatency) {
minLatency = entry.getLatency(isUpload);
}
} }
} }
...@@ -140,8 +134,8 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec ...@@ -140,8 +134,8 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec
// TODO add checkbox for upload/download toggle? // TODO add checkbox for upload/download toggle?
// Latency // Latency
double latencyFactor = entry.getConnectivity() ? (entry.getLatency(isUpload) - minLatency) double latencyFactor = (entry.getLatency(isUpload) - minLatency)
/ (maxLatency - minLatency) : 4; / (maxLatency - minLatency);
g2.setColor( g2.setColor(
new Color(255, 0, 0, 10 + (int) (40 * latencyFactor))); new Color(255, 0, 0, 10 + (int) (40 * latencyFactor)));
g2.fillRect(x, y, stepSize, stepSize); g2.fillRect(x, y, stepSize, stepSize);
...@@ -149,7 +143,7 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec ...@@ -149,7 +143,7 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec
// Drop-Prob // Drop-Prob
g2.setColor(new Color(255, 0, 0, g2.setColor(new Color(255, 0, 0,
10 + (int) (100 * entry.getDropProbability(isUpload)))); 10 + (int) (100 * entry.getDropProbability(isUpload))));
float strokeWidth = entry.getConnectivity() ? (float) entry.getDropProbability(isUpload) : 0.2f; float strokeWidth = (float) entry.getDropProbability(isUpload);
g2.setStroke(new BasicStroke((10 * strokeWidth))); g2.setStroke(new BasicStroke((10 * strokeWidth)));
g2.drawRect(x, y, stepSize, stepSize); g2.drawRect(x, y, stepSize, stepSize);
g2.setColor(new Color(255, 255, 255, 255)); g2.setColor(new Color(255, 255, 255, 255));
...@@ -163,8 +157,7 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec ...@@ -163,8 +157,7 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec
g2.drawString("BW: " g2.drawString("BW: "
+ (int) (entry.getBandwidth(isUpload) / Rate.kbit_s) + (int) (entry.getBandwidth(isUpload) / Rate.kbit_s)
+ " kBit/s", x + 10, y + 35); + " kBit/s", x + 10, y + 35);
if(!entry.getConnectivity()) if(!entry.isAvailable()) {
{
g2.drawString("!DEAD!", x + 30, y + 70); g2.drawString("!DEAD!", x + 30, y + 70);
} }
} }
...@@ -180,7 +173,7 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec ...@@ -180,7 +173,7 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec
{ {
int segID = database.getSegmentID(x, y); int segID = database.getSegmentID(x, y);
Entry entry = database.getEntryFor(segID, false); Entry entry = database.getEntryFor(segID, false);
entry.setConnectivity(!entry.getConnectivity()); entry.setAvailability(!entry.isAvailable());
needsRedraw = true; needsRedraw = true;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment