changed default udgm to calculate success probabilities by distance. the previous behavior of udgm was renamed to "UDGM: Constant Loss"
This commit is contained in:
parent
a36ea1f506
commit
1b87be975a
5 changed files with 116 additions and 9 deletions
|
@ -2,4 +2,4 @@ se.sics.cooja.GUI.MOTETYPES = se.sics.cooja.motes.DisturberMoteType se.sics.cooj
|
||||||
se.sics.cooja.GUI.PLUGINS = se.sics.cooja.plugins.Visualizer se.sics.cooja.plugins.LogListener se.sics.cooja.plugins.MoteInformation se.sics.cooja.plugins.MoteInterfaceViewer se.sics.cooja.plugins.VariableWatcher se.sics.cooja.plugins.EventListener se.sics.cooja.plugins.RadioLogger se.sics.cooja.mspmote.plugins.MspCodeWatcher se.sics.cooja.mspmote.plugins.MspStackWatcher se.sics.cooja.mspmote.plugins.MspCycleWatcher
|
se.sics.cooja.GUI.PLUGINS = se.sics.cooja.plugins.Visualizer se.sics.cooja.plugins.LogListener se.sics.cooja.plugins.MoteInformation se.sics.cooja.plugins.MoteInterfaceViewer se.sics.cooja.plugins.VariableWatcher se.sics.cooja.plugins.EventListener se.sics.cooja.plugins.RadioLogger se.sics.cooja.mspmote.plugins.MspCodeWatcher se.sics.cooja.mspmote.plugins.MspStackWatcher se.sics.cooja.mspmote.plugins.MspCycleWatcher
|
||||||
se.sics.cooja.GUI.IP_DISTRIBUTORS = se.sics.cooja.ipdistributors.RandomIPDistributor se.sics.cooja.ipdistributors.SpatialIPDistributor se.sics.cooja.ipdistributors.IdIPDistributor
|
se.sics.cooja.GUI.IP_DISTRIBUTORS = se.sics.cooja.ipdistributors.RandomIPDistributor se.sics.cooja.ipdistributors.SpatialIPDistributor se.sics.cooja.ipdistributors.IdIPDistributor
|
||||||
se.sics.cooja.GUI.POSITIONERS = se.sics.cooja.positioners.RandomPositioner se.sics.cooja.positioners.LinearPositioner se.sics.cooja.positioners.EllipsePositioner se.sics.cooja.positioners.ManualPositioner
|
se.sics.cooja.GUI.POSITIONERS = se.sics.cooja.positioners.RandomPositioner se.sics.cooja.positioners.LinearPositioner se.sics.cooja.positioners.EllipsePositioner se.sics.cooja.positioners.ManualPositioner
|
||||||
se.sics.cooja.GUI.RADIOMEDIUMS = se.sics.cooja.radiomediums.UDGM se.sics.cooja.radiomediums.DirectedGraphMedium se.sics.mrm.MRM se.sics.cooja.radiomediums.SilentRadioMedium
|
se.sics.cooja.GUI.RADIOMEDIUMS = se.sics.cooja.radiomediums.UDGM se.sics.cooja.radiomediums.UDGMConstantLoss se.sics.cooja.radiomediums.DirectedGraphMedium se.sics.mrm.MRM se.sics.cooja.radiomediums.SilentRadioMedium
|
||||||
|
|
|
@ -6,4 +6,4 @@ se.sics.cooja.GUI.MOTETYPES = se.sics.cooja.motes.ImportAppMoteType se.sics.cooj
|
||||||
se.sics.cooja.GUI.PLUGINS = se.sics.cooja.plugins.Visualizer se.sics.cooja.plugins.LogListener se.sics.cooja.plugins.TimeLine se.sics.cooja.plugins.MoteInformation se.sics.cooja.plugins.MoteInterfaceViewer se.sics.cooja.plugins.VariableWatcher se.sics.cooja.plugins.EventListener se.sics.cooja.plugins.RadioLogger se.sics.cooja.plugins.ScriptRunner se.sics.cooja.plugins.Notes
|
se.sics.cooja.GUI.PLUGINS = se.sics.cooja.plugins.Visualizer se.sics.cooja.plugins.LogListener se.sics.cooja.plugins.TimeLine se.sics.cooja.plugins.MoteInformation se.sics.cooja.plugins.MoteInterfaceViewer se.sics.cooja.plugins.VariableWatcher se.sics.cooja.plugins.EventListener se.sics.cooja.plugins.RadioLogger se.sics.cooja.plugins.ScriptRunner se.sics.cooja.plugins.Notes
|
||||||
se.sics.cooja.GUI.IP_DISTRIBUTORS = se.sics.cooja.ipdistributors.RandomIPDistributor se.sics.cooja.ipdistributors.SpatialIPDistributor se.sics.cooja.ipdistributors.IdIPDistributor
|
se.sics.cooja.GUI.IP_DISTRIBUTORS = se.sics.cooja.ipdistributors.RandomIPDistributor se.sics.cooja.ipdistributors.SpatialIPDistributor se.sics.cooja.ipdistributors.IdIPDistributor
|
||||||
se.sics.cooja.GUI.POSITIONERS = se.sics.cooja.positioners.RandomPositioner se.sics.cooja.positioners.LinearPositioner se.sics.cooja.positioners.EllipsePositioner se.sics.cooja.positioners.ManualPositioner
|
se.sics.cooja.GUI.POSITIONERS = se.sics.cooja.positioners.RandomPositioner se.sics.cooja.positioners.LinearPositioner se.sics.cooja.positioners.EllipsePositioner se.sics.cooja.positioners.ManualPositioner
|
||||||
se.sics.cooja.GUI.RADIOMEDIUMS = se.sics.cooja.radiomediums.UDGM se.sics.cooja.radiomediums.DirectedGraphMedium se.sics.cooja.radiomediums.SilentRadioMedium
|
se.sics.cooja.GUI.RADIOMEDIUMS = se.sics.cooja.radiomediums.UDGM se.sics.cooja.radiomediums.UDGMConstantLoss se.sics.cooja.radiomediums.DirectedGraphMedium se.sics.cooja.radiomediums.SilentRadioMedium
|
||||||
|
|
|
@ -26,12 +26,13 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: UDGMVisualizerSkin.java,v 1.10 2010/02/03 15:49:25 fros4943 Exp $
|
* $Id: UDGMVisualizerSkin.java,v 1.11 2010/09/06 12:00:46 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.plugins.skins;
|
package se.sics.cooja.plugins.skins;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
|
@ -336,6 +337,28 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
|
||||||
y - translatedTransmissionMax.y,
|
y - translatedTransmissionMax.y,
|
||||||
2 * translatedTransmissionMax.x,
|
2 * translatedTransmissionMax.x,
|
||||||
2 * translatedTransmissionMax.y);
|
2 * translatedTransmissionMax.y);
|
||||||
|
|
||||||
|
|
||||||
|
FontMetrics fm = g.getFontMetrics();
|
||||||
|
g.setColor(Color.BLACK);
|
||||||
|
|
||||||
|
/* Print transmission success probabilities */
|
||||||
|
for (Mote m: simulation.getMotes()) {
|
||||||
|
if (m == selectedMote) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
double prob =
|
||||||
|
((UDGM) simulation.getRadioMedium()).getSuccessProbability(selectedRadio, m.getInterfaces().getRadio());
|
||||||
|
if (prob == 0.0d) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String msg = (double)(((int)(1000*prob))/10.0) + "%";
|
||||||
|
Position pos = m.getInterfaces().getPosition();
|
||||||
|
Point pixel = visualizer.transformPositionToPixel(pos);
|
||||||
|
int msgWidth = fm.stringWidth(msg);
|
||||||
|
g.drawString(msg, pixel.x - msgWidth/2, pixel.y + 2*Visualizer.MOTE_RADIUS + 3);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paintAfterMotes(Graphics g) {
|
public void paintAfterMotes(Graphics g) {
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: UDGM.java,v 1.30 2010/02/03 15:49:25 fros4943 Exp $
|
* $Id: UDGM.java,v 1.31 2010/09/06 12:00:46 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.radiomediums;
|
package se.sics.cooja.radiomediums;
|
||||||
|
@ -80,7 +80,7 @@ import se.sics.cooja.radiomediums.DirectedGraphMedium.DestinationRadio;
|
||||||
* @see UDGMVisualizerSkin
|
* @see UDGMVisualizerSkin
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
@ClassDescription("Unit Disk Graph Medium (UDGM)")
|
@ClassDescription("Unit Disk Graph Medium (UDGM): Distance Loss")
|
||||||
public class UDGM extends AbstractRadioMedium {
|
public class UDGM extends AbstractRadioMedium {
|
||||||
private static Logger logger = Logger.getLogger(UDGM.class);
|
private static Logger logger = Logger.getLogger(UDGM.class);
|
||||||
|
|
||||||
|
@ -89,14 +89,12 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
public double TRANSMITTING_RANGE = 50; /* Transmission range. */
|
public double TRANSMITTING_RANGE = 50; /* Transmission range. */
|
||||||
public double INTERFERENCE_RANGE = 100; /* Interference range. Ignored if below transmission range. */
|
public double INTERFERENCE_RANGE = 100; /* Interference range. Ignored if below transmission range. */
|
||||||
|
|
||||||
private Simulation simulation;
|
|
||||||
private DirectedGraphMedium dgrm; /* Used only for efficient destination lookup */
|
private DirectedGraphMedium dgrm; /* Used only for efficient destination lookup */
|
||||||
|
|
||||||
private Random random = null;
|
private Random random = null;
|
||||||
|
|
||||||
public UDGM(Simulation simulation) {
|
public UDGM(Simulation simulation) {
|
||||||
super(simulation);
|
super(simulation);
|
||||||
this.simulation = simulation;
|
|
||||||
random = simulation.getRandomGenerator();
|
random = simulation.getRandomGenerator();
|
||||||
dgrm = new DirectedGraphMedium() {
|
dgrm = new DirectedGraphMedium() {
|
||||||
protected void analyzeEdges() {
|
protected void analyzeEdges() {
|
||||||
|
@ -166,7 +164,7 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
RadioConnection newConnection = new RadioConnection(sender);
|
RadioConnection newConnection = new RadioConnection(sender);
|
||||||
|
|
||||||
/* Fail radio transmission randomly - no radios will hear this transmission */
|
/* Fail radio transmission randomly - no radios will hear this transmission */
|
||||||
if (SUCCESS_RATIO_TX < 1.0 && random.nextDouble() > SUCCESS_RATIO_TX) {
|
if (getTxSuccessProbability(sender) < 1.0 && random.nextDouble() > getTxSuccessProbability(sender)) {
|
||||||
return newConnection;
|
return newConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +220,7 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
} else if (recv.isTransmitting()) {
|
} else if (recv.isTransmitting()) {
|
||||||
newConnection.addInterfered(recv);
|
newConnection.addInterfered(recv);
|
||||||
} else if (recv.isReceiving() ||
|
} else if (recv.isReceiving() ||
|
||||||
(SUCCESS_RATIO_RX < 1.0 && random.nextDouble() > SUCCESS_RATIO_RX)) {
|
(random.nextDouble() > getRxSuccessProbability(sender, recv))) {
|
||||||
/* Was receiving, or reception failed: start interfering */
|
/* Was receiving, or reception failed: start interfering */
|
||||||
newConnection.addInterfered(recv);
|
newConnection.addInterfered(recv);
|
||||||
recv.interfereAnyReception();
|
recv.interfereAnyReception();
|
||||||
|
@ -248,6 +246,28 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
return newConnection;
|
return newConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getSuccessProbability(Radio source, Radio dest) {
|
||||||
|
return getTxSuccessProbability(source) * getRxSuccessProbability(source, dest);
|
||||||
|
}
|
||||||
|
public double getTxSuccessProbability(Radio source) {
|
||||||
|
return SUCCESS_RATIO_TX;
|
||||||
|
}
|
||||||
|
public double getRxSuccessProbability(Radio source, Radio dest) {
|
||||||
|
double distance = source.getPosition().getDistanceTo(dest.getPosition());
|
||||||
|
double distanceSquared = Math.pow(distance,2.0);
|
||||||
|
double distanceMax = TRANSMITTING_RANGE *
|
||||||
|
((double) source.getCurrentOutputPowerIndicator() / (double) source.getOutputPowerIndicatorMax());
|
||||||
|
if (distanceMax == 0.0) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
double distanceMaxSquared = Math.pow(distanceMax,2.0);
|
||||||
|
double ratio = distanceSquared / distanceMaxSquared;
|
||||||
|
if (ratio > 1.0) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
return 1.0 - ratio*(1.0-SUCCESS_RATIO_RX);
|
||||||
|
}
|
||||||
|
|
||||||
public void updateSignalStrengths() {
|
public void updateSignalStrengths() {
|
||||||
/* Override: uses distance as signal strength factor */
|
/* Override: uses distance as signal strength factor */
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* $Id: UDGMConstantLoss.java,v 1.1 2010/09/06 12:00:46 fros4943 Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
package se.sics.cooja.radiomediums;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import se.sics.cooja.ClassDescription;
|
||||||
|
import se.sics.cooja.Simulation;
|
||||||
|
import se.sics.cooja.interfaces.Radio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UDGM with constant loss probablity.
|
||||||
|
*
|
||||||
|
* @see UDGM
|
||||||
|
* @author Fredrik Osterlind
|
||||||
|
*/
|
||||||
|
@ClassDescription("UDGM: Constant Loss")
|
||||||
|
public class UDGMConstantLoss extends UDGM {
|
||||||
|
private static Logger logger = Logger.getLogger(UDGMConstantLoss.class);
|
||||||
|
|
||||||
|
public UDGMConstantLoss(Simulation simulation) {
|
||||||
|
super(simulation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getRxSuccessProbability(Radio source, Radio dest) {
|
||||||
|
double distance = source.getPosition().getDistanceTo(dest.getPosition());
|
||||||
|
double moteTransmissionRange = TRANSMITTING_RANGE
|
||||||
|
* ((double) source.getCurrentOutputPowerIndicator() / (double) source.getOutputPowerIndicatorMax());
|
||||||
|
if (distance > moteTransmissionRange) {
|
||||||
|
return 0.0d;
|
||||||
|
}
|
||||||
|
return SUCCESS_RATIO_RX;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue