Commit 02dda393 authored by Nils Richerzhagen's avatar Nils Richerzhagen
Browse files

Merge branch 'master' into 'nr/master-debug'

Merge Master into nr/master-debug



See merge request !21
parents c9a213fb b1ae37ae
# PeerfactSim.KOM, Simonstrator-Version
# PeerfactSim.KOM, Simonstrator-Version, Open-Street-Map Integration
This is PeerfactSim.KOM in the Simonstrator-enabled version. It contains models for common network and physical layer types as well as movement and placement models. Combined with the analyzing and evaluation toolchain, it supports rapid prototyping and performance evaluations of new services, protocols, and overlays.
This branch of the PeerfactSim-project implements the functionality to load real world maps data out of several resources. All relevant modifications are in the `de.tud.kom.p2psim.impl.topology.movement.modularosm`-package. The `ModularMovementModel`-class is the main-class for this approach. This class loads all other classes as defined in the XML-configurable file in the simRunner-project.
## Installation
For the possible implementations of the AttractionGenerator (generates POIs), the map visualization and the transition strategy we have defined interfaces and implemented at least two implementations for each interface.
One configurable interface we copied from the `de.tud.kom.p2psim.impl.topology.movement.modular`-package. In the `de.tud.kom.p2psim.impl.topology.movement.local`-package are some classes, which calculate the routes of the moving nodes. Here you can use some simple algorithmic approaches or use one out of two possible implementations, which use real world street data to navigate the nodes through the sreets to their destination.
Just clone this repository, it already includes an Eclipse project. The project is built using Maven, so you need to install the M2E-extension in Eclipse when working with PeerfactSim.KOM. Furthermore, the project depends on the Simonstrator-API. Which version of the API to use is defined within the VERSION file contained in the root folder of this project.
## Usage
Usually, you do not need to touch a single line of code within this project. It is provided mostly for debugging purposes. In order to configure and run your simulations, please refer to the simonstrator-simRunner project and its documentation.
## Extending PeerfactSim.KOM
In some cases you might want to implement new movement models, network layer routing protocols, or any other kind of "below transport-layer"-functionality. In oder to do so, please create a new feature branch (name convention: [yourname]/[featurename]) and implement you feature there. Once you are finished, please create a merge request and assign it to one of the project maintainers (usually @br ) to get it approved. A description of the feature in the merge request is required, as well as corresponding simRunner configurations for sample simulation runs.
\ No newline at end of file
The code itself is (hopefully) self-explaining. All possible configurations can be made via the XML-config in the simRunner-project.
\ No newline at end of file
......@@ -400,6 +400,26 @@
<version>2.0.1</version>
</dependency> -->
<!-- OSM-Data for movement models -->
<dependency>
<groupId>com.graphhopper</groupId>
<artifactId>graphhopper</artifactId>
<version>0.5.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Json (used for OSM-Movement-Model) -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<!-- Simonstrator-Platform -->
<dependency>
......
......@@ -21,7 +21,6 @@
package de.tud.kom.p2psim.api.linklayer.mac;
import de.tud.kom.p2psim.api.linklayer.LinkLayer;
import de.tud.kom.p2psim.impl.linklayer.DefaultLinkLayerMessage;
import de.tud.kom.p2psim.impl.simengine.Simulator;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.NetInterfaceName;
......@@ -42,25 +41,8 @@ public enum PhyType {
/**
* Direct wireless connections between adjacent hosts or AP-based (decided
* by the MAC/TopologyView used)
*
* The provided values are based on the paper
* by the MAC/TopologyView used). Based on
* "WiFi in Ad Hoc Mode: A Meaurement Study" by Anastasi et al. (2004),
* which describes the behavior of a 802.11B WiFi interface. The following
* setup contains the values for the usage of this model with a Bitrate of
* 1Mbit/s:<br>
* <li>TODO For the drop-rate, the authors must be addressed to provide the
* underlying values <li>netto BW of 758000Bit/s (Based on mathematical
* calculations) <li>500us latency <li>2346 Byte (minus 2x6 Bytes for the
* sender and receiver address, which are automatically added by the
* {@link DefaultLinkLayerMessage}. <li>Broadcast
*/
WIFI80211B(NetInterfaceName.WIFI, -1, 758000 / 8,
500 * Time.MICROSECOND, 2334, true),
/**
* Direct wireless connections between adjacent hosts or AP-based (decided
* by the MAC/TopologyView used)
*
* Assuming the following defaults: 1% drop-rate of LinkLayer-Packets
* (LinkLayer might add retransmission behavior as in 802.11), 5MBit/s netto
......@@ -77,14 +59,15 @@ public enum PhyType {
ETHERNET(NetInterfaceName.ETHERNET, 0.001, 100000000 / 8,
1 * Time.MILLISECOND, 1500, false),
// /**
// * A centrally scheduled wireless connection connecting a host to at most
// * one base-station. No direct communication between hosts.
// *
// * Assuming the following defaults: zero link-layer packet loss due to
// * scheduling, 384kBit/s, 500us latency, 1,4 kByte MTU
// */
// UMTS(0, 384000 / 8, 500 * Simulator.MICROSECOND_UNIT, 1472, false),
/**
* A centrally scheduled wireless connection connecting a host to at most
* one base-station. No direct communication between hosts.
*
* Assuming the following defaults: zero link-layer packet loss due to
* scheduling, 384kBit/s, 500us latency, 1,4 kByte MTU
*/
UMTS(NetInterfaceName.MOBILE, 0, 384000 / 8,
500 * Simulator.MICROSECOND_UNIT, 1472, false),
/**
*
......
......@@ -22,13 +22,13 @@
package de.tud.kom.p2psim.api.network;
import de.tud.kom.p2psim.api.common.Position;
import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.api.network.routing.RoutingAlgorithm;
import de.tudarmstadt.maki.simonstrator.api.Message;
import de.tudarmstadt.maki.simonstrator.api.component.network.Bandwidth;
import de.tudarmstadt.maki.simonstrator.api.component.network.NetID;
import de.tudarmstadt.maki.simonstrator.api.component.network.NetInterface;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
/**
* The NetLayer provides a general interface to encapsulate various networking
......@@ -123,7 +123,7 @@ public interface NetLayer extends NetInterface {
*
* @return Position the appropriate position
*/
public Position getNetPosition();
public Location getNetPosition();
/**
* Returns the maximum physical bandwidth that is available at the given
......
......@@ -65,15 +65,4 @@ public interface HostBuilder extends Builder, GlobalComponent {
* de.tud.kom.p2psim.api.scenario.Configurator)
*/
public void parse(Element elem, Configurator config);
/**
* Return the group of hosts with the given ID. This must be the same id as
* specified in the configuration file. Single hosts with an own id will be
* returned by this method too (as a list with only one entry).
*
* @param groupId
* same group or host id as in the configuration file
* @return list of hosts (or single host packed in a list).
*/
public List<SimHost> getHosts(String groupId);
}
......@@ -26,6 +26,7 @@ import de.tud.kom.p2psim.api.topology.social.SocialView;
import de.tud.kom.p2psim.api.topology.views.TopologyView;
import de.tud.kom.p2psim.api.topology.waypoints.WaypointModel;
import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.component.GlobalComponent;
/**
* We provide a global Topology-Object (ie. this object is only created once in
......@@ -36,7 +37,7 @@ import de.tud.kom.p2psim.impl.topology.PositionVector;
* @author Bjoern Richerzhagen
* @version 1.0, 21.02.2012
*/
public interface Topology {
public interface Topology extends GlobalComponent {
/**
* This Position Vector contains the upper bounds for each dimension used in
......
......@@ -20,9 +20,7 @@
package de.tud.kom.p2psim.api.topology;
import de.tud.kom.p2psim.api.common.Position;
import de.tud.kom.p2psim.api.common.SimHostComponent;
import de.tud.kom.p2psim.api.energy.EnergyComponent;
import de.tud.kom.p2psim.api.topology.movement.MovementListener;
import de.tud.kom.p2psim.api.topology.movement.MovementSupported;
import de.tud.kom.p2psim.api.topology.views.TopologyView;
......@@ -40,33 +38,10 @@ import de.tudarmstadt.maki.simonstrator.api.component.topology.UnderlayTopologyP
public interface TopologyComponent extends SimHostComponent, MovementSupported,
MovementListener, UnderlayTopologyProvider, LocationSensor {
/**
* Abstract QoS-Classes for the Accuracy of the position. Implementation
* depends on the {@link EnergyComponent}
*
* @author Bjoern Richerzhagen
* @version 1.0, 26.02.2012
*/
@Deprecated
public static enum PositionAccuracy {
HIGH, MEDIUM, LOW
}
/**
* This uses an {@link EnergyComponent} for position retrieving (ie a GPS).
* A call might trigger energy consumption and the result will in most cases
* not be 100% accurate. Use this in your application if you want to add
* another layer of realism.
*
* @param accuracy
* a QoS-Class for the accuracy
* @return An estimate of the current position
*/
@Deprecated
public Position getPosition(PositionAccuracy accuracy);
/**
* Returns the Topology-Object that provides access to {@link TopologyView}s
* Note: the {@link Topology} is also available as a GlobalComponent via the
* Binder-class.
*
* @return
*/
......
......@@ -109,10 +109,18 @@ public interface MovementSupported {
public double getMaxMovementSpeed();
/**
* Gets a movement speed between min and max movement speed. This will be
* randomly calculated!
* Gets the currently set movement speed for that node. Initialized with a
* random value between min and max. Use setMovementSpeed() to lateron
* change the value.
*
* @return A random movement speed between min and max movement speed.
* @return
*/
public double getMovementSpeed();
/**
* Allows to set the movement speed in meter per second. Should be between
* min and max speed, but this is not enforced.
*/
public void setMovementSpeed(double speed);
}
......@@ -24,7 +24,6 @@ import java.util.List;
import com.vividsolutions.jts.geom.Geometry;
import de.tud.kom.p2psim.api.common.Position;
import de.tud.kom.p2psim.api.topology.views.TopologyView;
import de.tud.kom.p2psim.impl.topology.PositionVector;
......
......@@ -20,15 +20,17 @@
package de.tud.kom.p2psim.api.topology.views;
import de.tud.kom.p2psim.api.linklayer.mac.Link;
import de.tud.kom.p2psim.api.linklayer.mac.MacAddress;
import de.tud.kom.p2psim.api.linklayer.mac.MacLayer;
/**
* Determines the probability of a packet drop on a link.
*
* @author Bjoern Richerzhagen
* @version 1.0, 24.07.2012
*/
public interface DropRateDeterminator {
public interface DropProbabilityDeterminator {
/**
* Called for each host that is added to the TopologyView
......@@ -38,7 +40,7 @@ public interface DropRateDeterminator {
public void onMacAdded(MacLayer mac, TopologyView viewParent);
/**
* Return the drop-rate between 0.0 and 1.0
* Return the drop-probability between 0.0 and 1.0
*
* @param view
* This object can be used to access advanced information such as
......@@ -46,9 +48,12 @@ public interface DropRateDeterminator {
* implementing a cache to speed up the calculations.
* @param source
* @param destination
* @param link
* in case a link object already exists (and should be updated),
* it is passed. Otherwise: null.
* @return
*/
public double getDropRate(TopologyView view, MacAddress source,
MacAddress destination);
public double getDropProbability(TopologyView view, MacAddress source,
MacAddress destination, Link link);
}
......@@ -20,6 +20,7 @@
package de.tud.kom.p2psim.api.topology.views;
import de.tud.kom.p2psim.api.linklayer.mac.Link;
import de.tud.kom.p2psim.api.linklayer.mac.MacAddress;
import de.tud.kom.p2psim.api.linklayer.mac.MacLayer;
......@@ -51,9 +52,12 @@ public interface LatencyDeterminator {
* implementing a cache to speed up the calculations.
* @param source
* @param destination
* @param link
* in case a link object already exists (and should be updated),
* it is passed. Otherwise: null.
* @return
*/
public long getLatency(TopologyView view, MacAddress source,
MacAddress destination);
MacAddress destination, Link link);
}
......@@ -23,13 +23,14 @@ package de.tud.kom.p2psim.api.topology.views;
import java.util.Collection;
import java.util.List;
import de.tud.kom.p2psim.api.common.Position;
import de.tud.kom.p2psim.api.linklayer.mac.Link;
import de.tud.kom.p2psim.api.linklayer.mac.MacAddress;
import de.tud.kom.p2psim.api.linklayer.mac.MacLayer;
import de.tud.kom.p2psim.api.linklayer.mac.PhyType;
import de.tud.kom.p2psim.api.topology.TopologyListener;
import de.tud.kom.p2psim.api.topology.movement.MovementListener;
import de.tudarmstadt.maki.simonstrator.api.component.GlobalComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
/**
* Each MAC has a view on the global topology of hosts (ie. the
......@@ -42,7 +43,8 @@ import de.tud.kom.p2psim.api.topology.movement.MovementListener;
* @author Bjoern Richerzhagen
* @version 1.0, 21.02.2012
*/
public interface TopologyView extends TopologyListener, MovementListener {
public interface TopologyView
extends TopologyListener, MovementListener, GlobalComponent {
/**
* The {@link PhyType} this View represents
......@@ -119,7 +121,7 @@ public interface TopologyView extends TopologyListener, MovementListener {
* The {@link MacAddress} of the host
* @return The real Position of the Host.
*/
public Position getPosition(MacAddress address);
public Location getPosition(MacAddress address);
/**
* Gets the real distance between the two hosts.
......
......@@ -20,7 +20,7 @@
package de.tud.kom.p2psim.api.topology.views.wifi.phy;
import de.tud.kom.p2psim.api.common.Position;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
/**
* This interface is for the calculation of the propagation loss of an
......@@ -52,8 +52,8 @@ public abstract class PropagationLossModel {
* The second position
* @return The RX power in dBm
*/
public abstract double getRxPowerDbm(double txPowerDbm, Position a,
Position b);
public abstract double getRxPowerDbm(double txPowerDbm, Location a,
Location b);
/**
* Gets the RX Power in dBm for the distance.
......
......@@ -28,13 +28,13 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import de.tud.kom.p2psim.api.common.Position;
import de.tud.kom.p2psim.api.linklayer.mac.MacAddress;
import de.tud.kom.p2psim.api.linklayer.mac.MacLayer;
import de.tud.kom.p2psim.api.topology.views.wifi.phy.PropagationLossModel;
import de.tud.kom.p2psim.api.topology.views.wifi.phy.WifiMode;
import de.tud.kom.p2psim.api.topology.views.wifi.phy.WifiPhy.Standard_802_11;
import de.tud.kom.p2psim.impl.topology.views.wifi.phy.InterferenceHelper;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
/**
* This class is an interface for other implementation of Rate Managers. The
......@@ -598,8 +598,8 @@ public abstract class AbstractRateManager {
* antenna. <br>
* This is only a helper to calculate the SNR in the AdHocMac.
*/
public double calculateActuallySNR(Position startPosition,
Position targetPosition, WifiMode mode, double txPowerDbm) {
public double calculateActuallySNR(Location startPosition,
Location targetPosition, WifiMode mode, double txPowerDbm) {
InterferenceHelper helper = mac.getWifiTopologyView()
.getInterferenceHelper();
double noiseInterferenceW = helper
......
......@@ -28,7 +28,6 @@ import java.util.Random;
import de.tud.kom.p2psim.api.analyzer.LinklayerAnalyzer;
import de.tud.kom.p2psim.api.analyzer.MessageAnalyzer.Reason;
import de.tud.kom.p2psim.api.common.Position;
import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.api.linklayer.LinkLayerMessage;
import de.tud.kom.p2psim.api.linklayer.mac.Link;
......@@ -47,6 +46,7 @@ import de.tud.kom.p2psim.impl.linklayer.DefaultLinkMessageEvent;
import de.tud.kom.p2psim.impl.linklayer.mac.AbstractMacLayer;
import de.tud.kom.p2psim.impl.linklayer.mac.wifi.AbstractRateManager.RateManagerTypes;
import de.tud.kom.p2psim.impl.linklayer.mac.wifi.DcfManager.WifiState;
import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tud.kom.p2psim.impl.topology.views.wifi.WifiTopologyView;
import de.tud.kom.p2psim.impl.util.LiveMonitoring;
import de.tud.kom.p2psim.impl.util.LiveMonitoring.ProgressValue;
......@@ -56,6 +56,7 @@ import de.tudarmstadt.maki.simonstrator.api.Monitor.Level;
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.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.operation.AbstractOperation;
/**
......@@ -671,14 +672,12 @@ public class Ieee80211AdHocMac extends AbstractMacLayer {
/**
* Gets a copy of the real position of this host.
*
* Clone <strong>ONLY</strong> here.
*
* @return The position of this host.
*/
private Position getPosition() {
/*
* FIXME this leads to serious performance degradations. Do we REALLY
* need a copy?
*/
return this.getHost().getTopologyComponent().getRealPosition(); // .clone();
private PositionVector getPosition() {
return this.getHost().getTopologyComponent().getRealPosition().clone();
}
/**
......@@ -919,9 +918,9 @@ public class Ieee80211AdHocMac extends AbstractMacLayer {
WifiMacEventInformation eInfo = (WifiMacEventInformation) eventInfo;
// startPosition is from receiver (because ack come from this!)
Position startPosition = ((Ieee80211AdHocMac) topoView
Location startPosition = ((Ieee80211AdHocMac) topoView
.getMac(eventInfo.getReceiver())).getPosition();
Position targetPosition = this.getPosition();
Location targetPosition = this.getPosition();
double ackSnr = rateManager.calculateActuallySNR(startPosition,
targetPosition, eInfo.getAckMode(), txPowerDbm);
rateManager.reportDataOk(eventInfo.getReceiver(), ackSnr,
......
......@@ -26,7 +26,6 @@ import java.util.List;
import de.tud.kom.p2psim.api.analyzer.ConnectivityAnalyzer;
import de.tud.kom.p2psim.api.analyzer.MessageAnalyzer.Reason;
import de.tud.kom.p2psim.api.analyzer.NetlayerAnalyzer;
import de.tud.kom.p2psim.api.common.Position;
import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.api.linklayer.mac.PhyType;
import de.tud.kom.p2psim.api.network.NetMessage;
......@@ -42,6 +41,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.core.MonitorComponent.Anal
import de.tudarmstadt.maki.simonstrator.api.component.network.Bandwidth;
import de.tudarmstadt.maki.simonstrator.api.component.network.NetID;
import de.tudarmstadt.maki.simonstrator.api.component.network.NetInterface;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import de.tudarmstadt.maki.simonstrator.api.component.transport.ConnectivityListener;
/**
......@@ -70,7 +70,7 @@ public abstract class AbstractNetLayer implements SimNetworkComponent,
private boolean online;
private Position position;
private Location position;
Bandwidth currentBandwidth;
......@@ -93,7 +93,7 @@ public abstract class AbstractNetLayer implements SimNetworkComponent,
* the NetPosition of the network layer
*/
public AbstractNetLayer(SimHost host, NetID netId, Bandwidth maxBandwidth,
Position position, NetMeasurementDB.Host hostMeta) {
Location position, NetMeasurementDB.Host hostMeta) {
this.myID = netId;
this.msgListeners = new LinkedList<NetMessageListener>();
this.connListeners = new LinkedList<ConnectivityListener>();
......@@ -378,7 +378,7 @@ public abstract class AbstractNetLayer implements SimNetworkComponent,
* @see de.tud.kom.p2psim.api.api.network.NetLayer#getNetPosition()
*/
@Override
public Position getNetPosition() {
public Location getNetPosition() {
return this.position;
}
......
......@@ -7,7 +7,6 @@ import java.util.List;
import java.util.Map;
import de.tud.kom.p2psim.api.analyzer.MessageAnalyzer.Reason;
import de.tud.kom.p2psim.api.common.Position;
import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.api.network.BandwidthImpl;
import de.tud.kom.p2psim.api.network.FlowBasedNetlayer;
......@@ -22,6 +21,7 @@ import de.tudarmstadt.maki.simonstrator.api.Message;
import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Monitor.Level;
import de.tudarmstadt.maki.simonstrator.api.component.network.NetID;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
/**
* The Class Node.
......@@ -48,7 +48,7 @@ public class FairshareNode extends AbstractNetLayer implements
* @param geoLoc
*/
public FairshareNode(SimHost host, FairshareSubnet subnet, NetID netID,
BandwidthImpl maxBandwidth, Position position,
BandwidthImpl maxBandwidth, Location position,
NetMeasurementDB.Host hostMeta) {
super(host, netID, maxBandwidth, position, hostMeta);
this.subnet = subnet;
......
......@@ -23,8 +23,6 @@ package de.tud.kom.p2psim.impl.network.gnp;
import java.util.Random;
import umontreal.iro.lecuyer.probdist.LognormalDist;
import de.tud.kom.p2psim.api.common.Position;
import de.tud.kom.p2psim.api.linklayer.mac.PhyType;
import de.tud.kom.p2psim.api.network.NetLatencyModel;
import de.tud.kom.p2psim.api.network.NetLayer;
......@@ -35,6 +33,8 @@ import de.tud.kom.p2psim.impl.network.gnp.topology.CountryLookup;
import de.tud.kom.p2psim.impl.network.gnp.topology.PingErLookup;
import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import umontreal.iro.lecuyer.probdist.LognormalDist;
public class GnpLatencyModel implements NetLatencyModel {
......@@ -71,9 +71,9 @@ public class GnpLatencyModel implements NetLatencyModel {
double distance = GeoLocationOracle.getGeographicalDistance(sender.getNetID(), receiver.getNetID());
minRtt = 62 + (0.02 * distance);
} else {
Position senderPos = sender.getNetPosition();
Position receiverPos = receiver.getNetPosition();
minRtt = senderPos.getDistance(receiverPos);
Location senderPos = sender.getNetPosition();
Location receiverPos = receiver.getNetPosition();
minRtt = senderPos.distanceTo(receiverPos);
}
return minRtt;
}
......
......@@ -23,8 +23,8 @@ package de.tud.kom.p2psim.impl.network.gnp.topology;
import de.tud.kom.p2psim.api.common.Position;
import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
/**
* Implementation of NetPosition for Position and distance measurnment on the
......@@ -55,7 +55,7 @@ public class GeographicPosition extends PositionVector {
/**
* @return geographical distance in km
*/
public double getDistance(Position point) {
public double distanceTo(Location point) {
double pi = 3.14159265;
double radConverter = pi / 180;
double lat1 = latitude * radConverter;
......@@ -68,12 +68,6 @@ public class GeographicPosition extends PositionVector {
return 2 * 6378.2 * Math.atan2(Math.sqrt(temp), Math.sqrt(1 - temp));
}
@Override
public double getAngle(Position target) {
throw new AssertionError(
"getAngle is not defined for this Position-Type");
}
@Override
public int getTransmissionSize() {
return 16; // 2 * double
......
......@@ -23,7 +23,6 @@ package de.tud.kom.p2psim.impl.network.gnp.topology;
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;
......@@ -37,7 +36,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
*
*/
public class GnpPosition implements Position, Comparable<GnpPosition> {
public class GnpPosition implements Location, Comparable<GnpPosition> {
private static final long serialVersionUID = -1103996725403557900L;
......@@ -165,7 +164,7 @@ public class GnpPosition implements Position, Comparable<GnpPosition> {
* @return error
*/
public double getDownhillSimplexError(GnpPosition monitor) {
double calculatedDistance = this.getDistance(monitor);
double calculatedDistance = this.distanceTo(monitor);
double measuredDistance = this.getMeasuredRtt(monitor);
if (Double.compare(measuredDistance, Double.NaN) == 0)
return 0.0;
......@@ -182,7 +181,7 @@ public class GnpPosition implements Position, Comparable<GnpPosition> {
* @return error value
*/
public double getDirectionalRelativError(GnpPosition monitor) {
double calculatedDistance = this.getDistance(monitor);
double calculatedDistance = this.distanceTo(monitor);
double measuredDistance = this.getMeasuredRtt(monitor);
if (Double.compare(measuredDistance, Double.NaN) == 0)
return Double.NaN;
......@@ -236,7 +235,7 @@ public class GnpPosition implements Position, Comparable<GnpPosition> {
/**
* @return euclidean distance
*/
public double getDistance(Position point) {
public double getDistance(Location point) {
GnpPosition coord = (GnpPosition) point;
double distance = 0.0;
for (int c = 0; c < gnpCoordinates.length; c++)
......@@ -245,18 +244,6 @@ public class GnpPosition implements Position, Comparable<GnpPosition> {
return Math.sqrt(distance);
}
@Override
public double getAngle(Position target) {
throw new AssertionError(
"getAngle is not defined for this Position-Type");
}
@Override
public Position getTarget(double distance, double angle) {
throw new AssertionError(
"getTarget is not defined for this Position-Type");
}
@Override
public int getTransmissionSize() {
return 16; // 2 * double
......@@ -323,7 +310,7 @@ public class GnpPosition implements Position, Comparable<GnpPosition> {
@Override
public double distanceTo(Location dest) {
return getDistance((Position) dest);
return getDistance(dest);
}
@Override
......
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