Example #1
0
  // Do a O(n) pass through the motes updating the given moteSender's
  // connectivity to and from each other mote
  public void updateLossRates(MoteSimObject moteSender) {
    Iterator it = state.getMoteSimObjects().iterator();
    while (it.hasNext()) {
      MoteSimObject moteReceiver = (MoteSimObject) it.next();
      if (moteReceiver.getID() == moteSender.getID()) continue;

      updateLossRate(moteSender, moteReceiver);
      updateLossRate(moteReceiver, moteSender);
    }
  }
Example #2
0
  // Send the loss rate for the pair of motes to the simulator
  public void publishLossRate(MoteSimObject moteSender, MoteSimObject moteReceiver, double prob) {
    try {
      int senderID = moteSender.getID();
      int receiverID = moteReceiver.getID();

      debug.err.println(
          "RADIOMODEL: publishing rate [" + senderID + "->" + receiverID + "]: " + prob);

      long scaledBitLossRate = (long) (curModel.getBitLossRate(prob) * 10000);
      SetLinkProbCommand cmd =
          new SetLinkProbCommand((short) senderID, 0L, (short) receiverID, scaledBitLossRate);
      simComm.sendCommand(cmd);
    } catch (java.io.IOException ioe) {
      System.err.println("RADIOMODEL: Cannot send command: " + ioe);
    }
  }
Example #3
0
  // Send the loss rate for all pairs of motes to the simulator
  public void publishModel() {
    debug.err.println("RADIOMODEL: Publishing model, current is " + curModel);
    Iterator it1 = state.getMoteSimObjects().iterator();
    while (it1.hasNext()) {
      MoteSimObject moteSender = (MoteSimObject) it1.next();
      MoteCoordinateAttribute moteSenderCoord = moteSender.getCoordinate();
      Iterator it2 = state.getMoteSimObjects().iterator();
      while (it2.hasNext()) {
        MoteSimObject moteReceiver = (MoteSimObject) it2.next();
        if (moteReceiver.getID() == moteSender.getID()) continue;

        String key = graphKey(moteSender, moteReceiver);
        double prob = ((Double) connectivityGraph.get(key)).doubleValue();
        publishLossRate(moteSender, moteReceiver, prob);
      }
    }
  }
Example #4
0
  // Recalculate the loss rate for the pair of motes based on their
  // distance and the current model
  public void updateLossRate(MoteSimObject moteSender, MoteSimObject moteReceiver) {
    double distance = moteSender.getDistance(moteReceiver);
    double prob = curModel.getPacketLossRate(distance, this.scalingFactor);

    debug.out.println(
        "RADIOMODEL: "
            + moteSender
            + "->"
            + moteReceiver
            + " dist "
            + distance
            + " scale "
            + scalingFactor
            + " prob "
            + prob);

    long scaledBitLossRate = (long) (curModel.getBitLossRate(prob) * 10000);

    debug.out.println(
        "RADIOMODEL: sampleLossRate "
            + "[moteSender "
            + moteSender
            + "] 1"
            + "[moteReceiver "
            + moteReceiver
            + "] "
            + "[packetLossRate "
            + prob
            + "] "
            + "[scaledBitLossRate "
            + scaledBitLossRate
            + "]");

    connectivityGraph.put(graphKey(moteSender, moteReceiver), new Double(prob));

    if (autoPublish) {
      publishLossRate(moteSender, moteReceiver, prob);
    }
  }
Example #5
0
 public double getLossRate(MoteSimObject sender, MoteSimObject receiver) {
   return getLossRate(sender.getID(), receiver.getID());
 }
Example #6
0
 private String graphKey(MoteSimObject sender, MoteSimObject receiver) {
   return graphKey(sender.getID(), receiver.getID());
 }