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
This commit is contained in:
fros4943 2009-11-25 10:36:08 +00:00
parent 5ed294f001
commit 01e9498dd9

View file

@ -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;
}
@ -258,7 +258,9 @@ public class UDGM extends AbstractRadioMedium {
/* Set signal strength to below strong on destinations */
RadioConnection[] conns = getActiveConnections();
for (RadioConnection conn : conns) {
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,9 +269,11 @@ public class UDGM extends AbstractRadioMedium {
double distFactor = dist/maxTxDist;
double signalStrength = SS_STRONG + distFactor*(SS_WEAK - SS_STRONG);
if (dstRadio.getCurrentSignalStrength() < signalStrength) {
dstRadio.setCurrentSignalStrength(signalStrength);
}
}
}
/* Set signal strength to below weak on interfered */
for (RadioConnection conn : conns) {
@ -282,9 +286,14 @@ public class UDGM extends AbstractRadioMedium {
if (distFactor < 1) {
double signalStrength = SS_STRONG + distFactor*(SS_WEAK - SS_STRONG);
if (intfRadio.getCurrentSignalStrength() < signalStrength) {
intfRadio.setCurrentSignalStrength(signalStrength);
}
} else {
intfRadio.setCurrentSignalStrength(SS_WEAK);
if (intfRadio.getCurrentSignalStrength() < SS_WEAK) {
intfRadio.setCurrentSignalStrength(SS_WEAK);
}
}
if (!intfRadio.isInterfered()) {