예제 #1
0
  protected int checkReceiving(Message m) {
    if (m.getProperty(ftStr) == null) return super.checkReceiving(m);

    Message old = this.getOldestMessage(true);
    if (old == null) return super.checkReceiving(m);
    if ((Double) old.getProperty(ftStr) < (Double) m.getProperty(ftStr))
      return MessageRouter.DENIED_NO_SPACE;

    return super.checkReceiving(m);
  }
예제 #2
0
    public int compare(Message m1, Message m2) {
      // delivery probability of tuple1's message with tuple1's connection
      double p1 = (Double) m1.getProperty(ftStr);
      double p2 = (Double) m2.getProperty(ftStr);

      if (p1 > p2) {
        return 1;
      } else if (p1 < p2) {
        return -1;
      } else return 0;
    }
예제 #3
0
  @Override
  public RoutingInfo getRoutingInfo() {

    RoutingInfo top = super.getRoutingInfo();
    RoutingInfo ri1 = new RoutingInfo("DelProb =--> " + delProb);

    RoutingInfo ri = new RoutingInfo("Messages FT-->");

    for (Message m : this.getMessageCollection()) {
      ri.addMoreInfo(new RoutingInfo(String.format("%s : %.6f", m.getId(), m.getProperty(ftStr))));
    }

    top.addMoreInfo(ri1);
    top.addMoreInfo(ri);
    return top;
  }
예제 #4
0
  private Connection tryOtherMessages() {

    Collection<Message> msgCollection = getMessageCollection();
    if (msgCollection.size() == 0) return null;

    if (neighb.size() == 0) return null;

    List<Message> messages = new ArrayList<Message>();
    messages.addAll(msgCollection);
    Collections.sort(messages, msgComparator);

    double curFt;
    double newFt;
    Connection con = null;

    for (Message m : messages) {

      for (DTNHost h : neighb) {
        if ((this.getDelProb() >= threshold * (((FadToSink) h.getRouter()).getDelProb()))) continue;

        con = getConOf(h);
        if (con == null || h.getRouter().hasMessage(m.getId())) continue;

        curFt = (Double) m.getProperty(ftStr);
        newFt = 1 - (1 - curFt) * (1 - delProb);
        Message msg = m.replicate();
        msg.updateProperty(ftStr, newFt);

        if (startTransfer(msg, con) != RCV_OK) continue;

        m.updateProperty(ftStr, 1 - (1 - curFt) * (1 - ((FadToSink) h.getRouter()).getDelProb()));
        delProb = (1 - alpha) * delProb + alpha * ((FadToSink) h.getRouter()).getDelProb();
        this.lastUpdate = SimClock.getTime();
        return con;
      }
    }
    return con;
  }
예제 #5
0
 public Message messageTransferred(String id, DTNHost from) {
   Message m = super.messageTransferred(id, from);
   if (m.getProperty(ftStr) == null) m.addProperty(ftStr, new Double(0));
   return m;
 }