コード例 #1
0
  /** {@inheritDoc} */
  @Override
  public void transmit(Radio tx, byte[] data, double txPower, Band band) {

    Vector3f diff = new Vector3f();

    // determine the received signal strength at each radio
    for (Map.Entry<Integer, Radio> entry : radios.entrySet()) {

      Radio rx = entry.getValue();

      // do not overhear your own transmission
      if (rx.equals(tx)) {
        continue;
      }

      // check if it is within the operating band of the receiver
      if (!rx.getOperatingBand().isInBand(band.getCenterFrequency())) {
        continue;
      }

      diff.sub(rx.getPosition(), tx.getPosition());

      double dist = diff.length();

      // a course filtering of recipients based on range
      if (dist > rangeThresh) {
        continue;
      }

      double rxPower = calculatePathLoss(tx, rx, txPower, band, dist);

      // todo: random degradation of signal?

      // todo: offset reception time?

      // todo: copy the data?

      getSimEngine()
          .scheduleEvent(
              entry.getKey(),
              clockControl.getCurrentTime(),
              new ReceptionEvent(data, rxPower, band));
    }
  }