コード例 #1
0
ファイル: FadToSink.java プロジェクト: KhMassri/ONENC
  private void timeOutUpdate() {

    if (SimClock.getTime() - this.lastUpdate < secondsForTimeOut) return;

    for (Connection con : this.getConnections())
      if (con.getOtherNode(getHost()).isSink()) {
        delProb = (1 - alpha) * delProb + alpha;
        this.lastUpdate = SimClock.getTime();
        return;
      }

    delProb = (1 - alpha) * delProb;
    this.lastUpdate = SimClock.getTime();
  }
コード例 #2
0
ファイル: FadToSink.java プロジェクト: KhMassri/ONENC
 /**
  * Copy constructor. Creates a new router based on the given prototype.
  *
  * @param r The router prototype where setting values are copied from
  */
 protected FadToSink(FadToSink r) {
   super(r);
   this.alpha = r.alpha;
   this.gamma = r.gamma;
   threshold = (2 - 2 * alpha) / (2 - alpha);
   this.secondsForTimeOut = r.secondsForTimeOut;
   neighb = new ArrayList<DTNHost>();
   this.lastUpdate = SimClock.getTime();
   neighbComparator = new NeihbComparator();
   msgComparator = new MessageComparator();
 }
コード例 #3
0
ファイル: FadToSink.java プロジェクト: KhMassri/ONENC
  public void changedConnection(Connection con) {
    DTNHost other = con.getOtherNode(getHost());
    if (con.isUp()) {
      if (other.getRouter().hello().equals("DTNRouter")) neighb.add(other);
      else if (other.isSink()) {
        delProb = (1 - alpha) * delProb + alpha;
        this.lastUpdate = SimClock.getTime();
      }

    } else if (other.getRouter().hello().equals("DTNRouter")) neighb.remove(other);

    Collections.sort(neighb, neighbComparator);
  }
コード例 #4
0
  private void updateTree() {
    JTree tree;
    super.setTitle("Routing Info of " + host + " at " + SimClock.getTime());
    RoutingInfo ri = host.getRoutingInfo();
    DefaultMutableTreeNode top = new DefaultMutableTreeNode(ri);
    addChildren(top, ri);

    tree = new JTree(top);
    for (int i = 0; i < tree.getRowCount(); i++) {
      tree.expandRow(i); // expand all rows
    }

    this.treePane.setViewportView(tree);
    this.treePane.revalidate();
  }
コード例 #5
0
ファイル: FadToSink.java プロジェクト: KhMassri/ONENC
  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;
  }