From 01e9498dd9849ec8116b9b617ac6f9067b63dec5 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Wed, 25 Nov 2009 10:36:08 +0000 Subject: [PATCH] radio medium update: receiving nodes that become interfered still receive connection data, but may (should) choose to ignore or corrupt it. this solves a problem with half-filled FIFO buffers on CC2420 radio platforms + minor fixes: the received signal strength is the maximum of all active connection, and a transmitting radio may still be interfered --- .../java/se/sics/cooja/radiomediums/UDGM.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/radiomediums/UDGM.java b/tools/cooja/java/se/sics/cooja/radiomediums/UDGM.java index bfddd8290..b52c7e696 100644 --- a/tools/cooja/java/se/sics/cooja/radiomediums/UDGM.java +++ b/tools/cooja/java/se/sics/cooja/radiomediums/UDGM.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: UDGM.java,v 1.27 2009/10/27 10:36:01 fros4943 Exp $ + * $Id: UDGM.java,v 1.28 2009/11/25 10:36:08 fros4943 Exp $ */ package se.sics.cooja.radiomediums; @@ -215,7 +215,8 @@ public class UDGM extends AbstractRadioMedium { if (recv.isInterfered()) { /* Was interfered: keep interfering */ newConnection.addInterfered(recv); - + } else if (recv.isTransmitting()) { + newConnection.addInterfered(recv); } else if (recv.isReceiving() || (SUCCESS_RATIO_RX < 1.0 && random.nextDouble() > SUCCESS_RATIO_RX)) { /* Was receiving, or reception failed: start interfering */ @@ -226,7 +227,6 @@ public class UDGM extends AbstractRadioMedium { for (RadioConnection conn : getActiveConnections()) { for (Radio dstRadio : conn.getDestinations()) { if (dstRadio == recv) { - conn.removeDestination(recv); conn.addInterfered(recv); break; } @@ -249,7 +249,7 @@ public class UDGM extends AbstractRadioMedium { public void updateSignalStrengths() { /* Override: uses distance as signal strength factor */ - + /* Reset signal strengths */ for (Radio radio : getRegisteredRadios()) { radio.setCurrentSignalStrength(SS_NOTHING); @@ -258,7 +258,9 @@ public class UDGM extends AbstractRadioMedium { /* Set signal strength to below strong on destinations */ RadioConnection[] conns = getActiveConnections(); for (RadioConnection conn : conns) { - conn.getSource().setCurrentSignalStrength(SS_STRONG); + if (conn.getSource().getCurrentSignalStrength() < SS_STRONG) { + conn.getSource().setCurrentSignalStrength(SS_STRONG); + } for (Radio dstRadio : conn.getDestinations()) { double dist = conn.getSource().getPosition().getDistanceTo(dstRadio.getPosition()); @@ -267,7 +269,9 @@ public class UDGM extends AbstractRadioMedium { double distFactor = dist/maxTxDist; double signalStrength = SS_STRONG + distFactor*(SS_WEAK - SS_STRONG); - dstRadio.setCurrentSignalStrength(signalStrength); + if (dstRadio.getCurrentSignalStrength() < signalStrength) { + dstRadio.setCurrentSignalStrength(signalStrength); + } } } @@ -282,9 +286,14 @@ public class UDGM extends AbstractRadioMedium { if (distFactor < 1) { double signalStrength = SS_STRONG + distFactor*(SS_WEAK - SS_STRONG); - intfRadio.setCurrentSignalStrength(signalStrength); + if (intfRadio.getCurrentSignalStrength() < signalStrength) { + intfRadio.setCurrentSignalStrength(signalStrength); + } } else { intfRadio.setCurrentSignalStrength(SS_WEAK); + if (intfRadio.getCurrentSignalStrength() < SS_WEAK) { + intfRadio.setCurrentSignalStrength(SS_WEAK); + } } if (!intfRadio.isInterfered()) {