Commit fd2994f1 authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

Minor refactoring for DRAS interaction with 5GCells

parent 62b25401
......@@ -306,6 +306,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
*/
......@@ -442,7 +462,7 @@ public class FiveGTopologyView extends AbstractTopologyView<CellLink> {
public void setLinkData(FiveGTopologyDatabase.Entry linkData,
FiveGTopologyDatabase.Entry apLinkData) {
// Initialization
if (this.linkData == null && this.apLinkData == null) {
this.linkData = linkData;
......@@ -455,7 +475,7 @@ public class FiveGTopologyView extends AbstractTopologyView<CellLink> {
// For the first update on link creation.
return;
}
// Update
if (apLinkData != null) {
assert supportsAccessPoints;
......@@ -479,7 +499,7 @@ public class FiveGTopologyView extends AbstractTopologyView<CellLink> {
linkData.onHostEntersSegment(mobileClient);
}
}
this.linkData = linkData;
assert (apLinkData != null && supportsAccessPoints)
|| apLinkData == null;
......@@ -524,10 +544,12 @@ public class FiveGTopologyView extends AbstractTopologyView<CellLink> {
@Override
public boolean isConnected() {
if (apLinkData != null)
return apLinkData.getConnectivity();
if (linkData != null)
return linkData.getConnectivity();
if (apLinkData != null) {
return apLinkData.isAvailable();
}
if (linkData != null) {
return linkData.isAvailable();
}
return false;
}
......
......@@ -151,7 +151,7 @@ public abstract class AbstractGridBasedTopologyDatabase
private final long latencyUp, latencyDown, bandwidthUp, bandwidthDown;
private boolean connectivity = true;
private boolean isAvailable = true;
/**
......@@ -185,7 +185,8 @@ public abstract class AbstractGridBasedTopologyDatabase
@Override
public double getDropProbability(boolean isUpload) {
if(!getConnectivity()){
if(!isAvailable){
// Link is broken.
return 1;
}
return isUpload ? dropUp : dropDown;
......@@ -193,30 +194,26 @@ public abstract class AbstractGridBasedTopologyDatabase
@Override
public long getLatency(boolean isUpload) {
if(!getConnectivity()){
return 9999 * Time.MILLISECOND;
}
return isUpload ? latencyUp : latencyDown;
}
@Override
public long getBandwidth(boolean isUpload) {
if(!getConnectivity()){
if(!isAvailable){
// Link is broken.
return 0;
}
return isUpload ? bandwidthUp : bandwidthDown;
}
@Override
public boolean getConnectivity()
{
return connectivity;
public boolean isAvailable() {
return isAvailable;
}
@Override
public void setConnectivity(boolean connectivity)
{
this.connectivity = connectivity;
public void setAvailability(boolean isAvailable) {
this.isAvailable = isAvailable;
}
}
......
......@@ -95,11 +95,11 @@ public interface FiveGTopologyDatabase extends GlobalComponent {
* @return
*/
public int getSegmentID();
default public void onHostLeavesSegment(MacAddress hostAddr) {
// ignore
}
default public void onHostEntersSegment(MacAddress hostAddr) {
// ignore
}
......@@ -127,22 +127,19 @@ public interface FiveGTopologyDatabase extends GlobalComponent {
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
* upload/download isn't possible. <code>true</code> otherwise.
* @return
*/
boolean getConnectivity();
boolean isAvailable();
/**
* Set the connectivity of the cell. When set to <code>false</code>, it
* should be impossible to upload or download data via this cell.
* {@link CellLink} refers to this attribute when returning e.g. BW or
* drop rate.
* Set the connectivity of the cell. When set to false, the cell is no
* longer accepting connections and existing connections fail.
*
* @param connectivity
* @param isAvailable
*/
void setConnectivity(boolean connectivity);
void setAvailability(boolean isAvailable);
}
}
......@@ -117,12 +117,6 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec
if (entry == null) {
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
// TODO add checkbox for upload/download toggle?
// Latency
double latencyFactor = entry.getConnectivity() ? (entry.getLatency(isUpload) - minLatency)
/ (maxLatency - minLatency) : 4;
double latencyFactor = (entry.getLatency(isUpload) - minLatency)
/ (maxLatency - minLatency);
g2.setColor(
new Color(255, 0, 0, 10 + (int) (40 * latencyFactor)));
g2.fillRect(x, y, stepSize, stepSize);
......@@ -149,7 +143,7 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec
// Drop-Prob
g2.setColor(new Color(255, 0, 0,
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.drawRect(x, y, stepSize, stepSize);
g2.setColor(new Color(255, 255, 255, 255));
......@@ -163,8 +157,7 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec
g2.drawString("BW: "
+ (int) (entry.getBandwidth(isUpload) / Rate.kbit_s)
+ " kBit/s", x + 10, y + 35);
if(!entry.getConnectivity())
{
if(!entry.isAvailable()) {
g2.drawString("!DEAD!", x + 30, y + 70);
}
}
......@@ -180,7 +173,7 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec
{
int segID = database.getSegmentID(x, y);
Entry entry = database.getEntryFor(segID, false);
entry.setConnectivity(!entry.getConnectivity());
entry.setAvailability(!entry.isAvailable());
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