only using distance when calculating received signal strength for nodes closer than transmitting range

This commit is contained in:
fros4943 2008-03-17 10:10:17 +00:00
parent 3a7feb7df7
commit b96b3ae8c6

View file

@ -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.15 2008/03/17 09:49:44 fros4943 Exp $ * $Id: UDGM.java,v 1.16 2008/03/17 10:10:17 fros4943 Exp $
*/ */
package se.sics.cooja.radiomediums; package se.sics.cooja.radiomediums;
@ -536,8 +536,12 @@ public class UDGM extends AbstractRadioMedium {
for (Radio intfRadio : conn.getInterfered()) { for (Radio intfRadio : conn.getInterfered()) {
double dist = conn.getSource().getPosition().getDistanceTo(intfRadio.getPosition()); double dist = conn.getSource().getPosition().getDistanceTo(intfRadio.getPosition());
double distFactor = dist/TRANSMITTING_RANGE; double distFactor = dist/TRANSMITTING_RANGE;
double signalStrength = SS_STRONG + distFactor*(SS_WEAK - SS_STRONG); if (distFactor < 1) {
intfRadio.setCurrentSignalStrength(signalStrength); double signalStrength = SS_STRONG + distFactor*(SS_WEAK - SS_STRONG);
intfRadio.setCurrentSignalStrength(signalStrength);
} else {
intfRadio.setCurrentSignalStrength(SS_WEAK);
}
if (!intfRadio.isInterfered()) { if (!intfRadio.isInterfered()) {
// Set to interfered again // Set to interfered again