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:
parent
5ed294f001
commit
01e9498dd9
|
@ -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.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;
|
package se.sics.cooja.radiomediums;
|
||||||
|
@ -215,7 +215,8 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
if (recv.isInterfered()) {
|
if (recv.isInterfered()) {
|
||||||
/* Was interfered: keep interfering */
|
/* Was interfered: keep interfering */
|
||||||
newConnection.addInterfered(recv);
|
newConnection.addInterfered(recv);
|
||||||
|
} else if (recv.isTransmitting()) {
|
||||||
|
newConnection.addInterfered(recv);
|
||||||
} else if (recv.isReceiving() ||
|
} else if (recv.isReceiving() ||
|
||||||
(SUCCESS_RATIO_RX < 1.0 && random.nextDouble() > SUCCESS_RATIO_RX)) {
|
(SUCCESS_RATIO_RX < 1.0 && random.nextDouble() > SUCCESS_RATIO_RX)) {
|
||||||
/* Was receiving, or reception failed: start interfering */
|
/* Was receiving, or reception failed: start interfering */
|
||||||
|
@ -226,7 +227,6 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
for (RadioConnection conn : getActiveConnections()) {
|
for (RadioConnection conn : getActiveConnections()) {
|
||||||
for (Radio dstRadio : conn.getDestinations()) {
|
for (Radio dstRadio : conn.getDestinations()) {
|
||||||
if (dstRadio == recv) {
|
if (dstRadio == recv) {
|
||||||
conn.removeDestination(recv);
|
|
||||||
conn.addInterfered(recv);
|
conn.addInterfered(recv);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
|
|
||||||
public void updateSignalStrengths() {
|
public void updateSignalStrengths() {
|
||||||
/* Override: uses distance as signal strength factor */
|
/* Override: uses distance as signal strength factor */
|
||||||
|
|
||||||
/* Reset signal strengths */
|
/* Reset signal strengths */
|
||||||
for (Radio radio : getRegisteredRadios()) {
|
for (Radio radio : getRegisteredRadios()) {
|
||||||
radio.setCurrentSignalStrength(SS_NOTHING);
|
radio.setCurrentSignalStrength(SS_NOTHING);
|
||||||
|
@ -258,7 +258,9 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
/* Set signal strength to below strong on destinations */
|
/* Set signal strength to below strong on destinations */
|
||||||
RadioConnection[] conns = getActiveConnections();
|
RadioConnection[] conns = getActiveConnections();
|
||||||
for (RadioConnection conn : conns) {
|
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()) {
|
for (Radio dstRadio : conn.getDestinations()) {
|
||||||
double dist = conn.getSource().getPosition().getDistanceTo(dstRadio.getPosition());
|
double dist = conn.getSource().getPosition().getDistanceTo(dstRadio.getPosition());
|
||||||
|
|
||||||
|
@ -267,7 +269,9 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
double distFactor = dist/maxTxDist;
|
double distFactor = dist/maxTxDist;
|
||||||
|
|
||||||
double signalStrength = SS_STRONG + distFactor*(SS_WEAK - SS_STRONG);
|
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) {
|
if (distFactor < 1) {
|
||||||
double signalStrength = SS_STRONG + distFactor*(SS_WEAK - SS_STRONG);
|
double signalStrength = SS_STRONG + distFactor*(SS_WEAK - SS_STRONG);
|
||||||
intfRadio.setCurrentSignalStrength(signalStrength);
|
if (intfRadio.getCurrentSignalStrength() < signalStrength) {
|
||||||
|
intfRadio.setCurrentSignalStrength(signalStrength);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
intfRadio.setCurrentSignalStrength(SS_WEAK);
|
intfRadio.setCurrentSignalStrength(SS_WEAK);
|
||||||
|
if (intfRadio.getCurrentSignalStrength() < SS_WEAK) {
|
||||||
|
intfRadio.setCurrentSignalStrength(SS_WEAK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!intfRadio.isInterfered()) {
|
if (!intfRadio.isInterfered()) {
|
||||||
|
|
Loading…
Reference in a new issue