routing代码分析1--ProphetRouter

来源:互联网 发布:运营数据分析专员 编辑:程序博客网 时间:2024/05/24 05:49
Implementation of PRoPHET router as described in 
 * <I>Probabilistic routing in intermittently connected networks</I> by
 * Anders Lindgren et al

原理

outline

public class ProphetRouter extends ActiveRouter
重要属性:
P_INIT = 0.75  //delivery predictability initialization constant交付预测初始常量
DEFAULT_BETA = 0.25 //delivery predictability transitivity scaling constant default value 交付预测传输缩放默认值
GAMMA = 0.98 //delivery predictability aging constant交付预测衰减常量

SECONDS_IN_UNIT_S ="secondsInTimeUnit" //Number of seconds in time unit在一个时间单位中有多少秒(当计算交付预测时)
BETA_S = "beta" //Transitivity scaling constant传输缩放常量 (默认值为0.25)

变量
secondsInTimeUnit  //the value of nrof seconds in time unit在一个时间单位内秒数的值
beta  //value of beta setting(beta设置的值)

private Map<DTNHost, Double> preds  //交付预测
lastAgeUpdate  //last delivery predictability update (sim)time(上一次交付预测的仿真更新时间)

方法
构造方法
public ProphetRouter(Settings s){}  //根据setting文件建立新的信息路由
    super(s);  //建立新的信息路由,读取设置中的缓存大小,TTL,主机上的application
    //设置此路由的名称
   获得可配置参数SECONDS_IN_UNIT_S,beta
    initPreds(); // 初始化预测哈希表
 
protected ProphetRouter(ProphetRouter r){}  //构造方法的重载

initPreds() {}//初始化预测哈希表

changedConnection(Connection con){} // 覆写,当连接状态变化时被调用
        updateDeliveryPredFor(otherHost);
        updateTransitivePreds(otherHost); //当与其他主机连接时,更新

updateDeliveryPredFor(DTNHost host){} //为主机更新交付预测
        oldValue = getPredFor(host); //返回当前交付预测p的值
        newValue = oldValue + (1 - oldValue) * P_INIT

getPredFor(DTNHost host){} //返回当前交付预测p的值,若没有,返回0
        ageDeliveryPreds();  //Ages all entries in the delivery predictions

updateTransitivePreds(DTNHost host){} //更新传递交付预测(A->B->C)
        //注:PRoPHET only works with other routers of same type
     pForHost = getPredFor(host); // P(a,b)
     pOld = getPredFor(e.getKey()); // P(a,c)_old
     pNew = pOld + ( 1 - pOld) * pForHost * e.getValue() * beta;

ageDeliveryPreds(){} //衰减交付预测中的记录
     timeDiff = (SimClock.getTime() - this.lastAgeUpdate) / secondsInTimeUnit;
     mult = Math.pow(GAMMA, timeDiff) ;
     e.setValue(e.getValue()*mult)

getDeliveryPreds(){} //返回路由的交付预测

update(){} //Checks out all sending connections to finalize the ready ones and abort those whose connection went down. Also drops messages whose TTL <= 0 (checking every one simulated minute).

tryOtherMessages(){} // Tries to send all other messages to all connected hosts ordered by their delivery probability  返回tryMessagesForConnected(List)

    //for all connected hosts collect all messages that have a higher probability of delivery by the other host
if (othRouter.getPredFor(m.getTo()) > getPredFor(m.getTo())) {// the other node has higher probability of delivery
messages.add(new Tuple<Message, Connection>(m,con));}

private class TupleComparator implements Comparator <Tuple<Message, Connection>>{} //Comparator for Message-Connection-Tuples that orders the tuples by their delivery probability by the host on the other side of the  connection (GRTRMax)

public RoutingInfo getRoutingInfo(){} //Returns routing information about this router

public MessageRouter replicate(){} //Creates a replicate of this router. The replicate has the same settings as this router but empty buffers and routing tables.

0 0
原创粉丝点击