亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? mspastryprotocol.java

?? pastry 協(xié)議在peersim下的仿真環(huán)境。測試無誤。在eclipse下打開源文件夾為工程即可使用和做仿真實驗。
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
package peersim.pastry;

/**
 *
 *
 * <p>Title: MSPASTRY</p>
 *
 * <p>Description: MsPastry implementation for PeerSim</p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: The Pastry Group</p>
 *
 * @author Elisa Bisoffi, Manuel Cortella
 * @version 1.0
 */

import java.math.*;

import peersim.config.*;
import peersim.core.*;
import peersim.edsim.*;
import peersim.transport.*;
import java.util.Comparator;

//__________________________________________________________________________________________________
public class MSPastryProtocol implements Cloneable, EDProtocol {
    //______________________________________________________________________________________________
    /**
     * Event Handler container for managing the receiving of a message
     *
     * <p>Title: MSPASTRY</p>
     *
     * <p>Description: MsPastry implementation for PeerSim</p>
     *
     * <p>Copyright: Copyright (c) 2007</p>
     *
     * <p>Company: The Pastry Group</p>
     *
     * @author Elisa Bisoffi, Manuel Cortella
     * @version 1.0
     */
    public static interface Listener {
        /**
         * This method is called every time a message is received
         * @param m Message
         */
        public void receive(Message m);
    }

    /**
     * Listener assingned to the receiving of a message. If null it is not called
     */
    private Listener listener;

    //______________________________________________________________________________________________
    /**
     * allows to change/clear the listener
     * @param l Listener
     */
    public void setListener(Listener l) {
    	listener = l;
    }

    //______________________________________________________________________________________________
    private static final String PAR_TRANSPORT = "transport";
    private static String prefix = null;
    private UnreliableTransport transport;
    private int tid;
    private int mspastryid;
    private boolean cleaningScheduled = false;

    /**
     * allow to call the cleaning service initializer only once
     */
    private static boolean _ALREADY_INSTALLED = false;

    //______________________________________________________________________________________________
    /**
     * nodeId of this pastry node
     */
    public BigInteger nodeId;

    /**
     * routing table of this pastry node
     */
    public RoutingTable routingTable;

    /**
     * leaf set of this pastry node
     */
    public LeafSet leafSet;


    //______________________________________________________________________________________________
    /**
     * Replicate this object by returning an identical copy.
     * it put the eye on the fact that only the peersim initializer call this
     * method and we expects to replicate every time a non-initialized table.
     * Thus the method clone() do not fill any particular field;
     * @return Object
     */
    public Object clone() {

        MSPastryProtocol dolly = new MSPastryProtocol(MSPastryProtocol.prefix);
        dolly.routingTable = (RoutingTable)this.routingTable.clone();
        dolly.leafSet = (LeafSet)this.leafSet.clone();
        //dolly.nodeId is not copied, because ID is unique!
        return dolly;
    }


    //______________________________________________________________________________________________
    /**
     * Used only by the initializer when creating the prototype Every other instance call CLONE to
     * create the new object. clone could not use this constructor, preferring a more quick
     * constructor
     *
     * @param prefix String
     */
    public MSPastryProtocol(String prefix) {
        this.nodeId = null;              // empty nodeId
        MSPastryProtocol.prefix = prefix;

        _init();

        routingTable = new RoutingTable(MSPastryCommonConfig.BITS / MSPastryCommonConfig.B, Util.pow2(MSPastryCommonConfig.B));
        leafSet = new LeafSet(BigInteger.ZERO, MSPastryCommonConfig.L);

        tid = Configuration.getPid(prefix + "." + PAR_TRANSPORT);

    }

    //______________________________________________________________________________________________
    /**
     * This subrouting is called only once and allow to inizialize the internal state of the
     * MSPastreyProtocol. Every node shares the same configuration, so it is sufficient caling
     * ont this this sub in order to set up the configuration
     */
    private void _init() {
        if (_ALREADY_INSTALLED) return;

        int b=0, l=0, base=0;
        final String PAR_B = "B";
        final String PAR_L = "L";


        b = Configuration.getInt(prefix + "." + PAR_B, 4);
        l = Configuration.getInt(prefix + "." + PAR_L, MSPastryCommonConfig.BITS / b);
        base = Util.pow2(b);

        MSPastryCommonConfig.B = b;
        MSPastryCommonConfig.L = l;
        MSPastryCommonConfig.BASE = base;

        e(MSPastryCommonConfig.info()+"\n");

        _ALREADY_INSTALLED = true;
    }

    //______________________________________________________________________________________________
    /**
     * called when a Lookup message is ready to be passed through the upper/application level, by
     * calling the "message received" event handler (listener). It also provide some statistical
     * update
     * @param m Message
     */
    private void deliver(Message m) {
        //statistiche utili all'observer
        MSPastryObserver.hopStore.add(m.nrHops-1);
        long timeInterval = (CommonState.getTime())-(m.timestamp);
        MSPastryObserver.timeStore.add(timeInterval);

        if (listener != null) {
            listener.receive(m);
        }

    }

    //______________________________________________________________________________________________
    /**
     * given one nodeId, it search through the network its node reference, by performing binary serach
     * (we concern about the ordering of the network).
     * @param searchNodeId BigInteger
     * @return Node
     */
    private Node nodeIdtoNode(BigInteger searchNodeId) {
        if (searchNodeId==null) return null;

        int inf = 0;
        int sup = Network.size() - 1;
        int m;

        while (inf <= sup) {
            m = (inf + sup) / 2;

            BigInteger mId = ((MSPastryProtocol) Network.get(m).getProtocol(mspastryid)).nodeId;

            if (mId.equals(searchNodeId))
                return Network.get(m);

            if (mId.compareTo(searchNodeId) < 0)
                inf = m + 1;
            else
                sup = m - 1;
        }

        /**
         * La ricerca binaria ? veloce ed efficiente, ma qualche volta pu? capitare che l'array dei
         * nodi di Network non sia ordinato, quindi si applica ora la ricerca sequenziale.
         * Se nemmeno la ricerca sequenziale trova il nodo cercato, viene ritornato null
         */
        BigInteger mId;
        for (int i= Network.size()-1; i >= 0 ; i--) {
              mId = ((MSPastryProtocol) Network.get(i).getProtocol(mspastryid)).nodeId;
             if  (mId.equals(searchNodeId))
                    return Network.get(i);
        }

        return null;
    }

    //______________________________________________________________________________________________
    /**
     * see MSPastry protocol "ReceiveRoute" primitive
     * @param m Message
     */
    public void receiveRoute(Message m) {
        switch (m.messageType) {
        case Message.MSG_LOOKUP:
            deliver(m);
            o(" [rr] Delivered message [m.id="+m.id+"] [src=dest=" + RoutingTable.truncateNodeId(nodeId) + "[in "+ ((CommonState.getTime())-(m.timestamp))+" msecs] ["+m.nrHops+" hops]");
            break;
        case Message.MSG_JOINREQUEST:

            m.messageType = Message.MSG_JOINREPLY;
            // ((Message.BodyJoinRequestReply)m.body).joiner = null; //not necessary anymore
            ((Message.BodyJoinRequestReply)m.body).ls = this.leafSet;
            //  ((Message.BodyJoinRequestReply)m.body).rt = ...LEAVE AS IS...

            transport = (UnreliableTransport) (Network.prototype).getProtocol(tid);
            transport.send(nodeIdtoNode(this.nodeId), nodeIdtoNode(m.dest), m, mspastryid);
            break;

        }
    }

    //______________________________________________________________________________________________
    /**
     * see MSPastry protocol "Route" primitive
     * @param m Message
     * @param srcNode Node
     */
    private void route(Message m, Node srcNode) {

        // u("["+RoutingTable.truncateNodeId(nodeId)+"] received msg:[" + m.id + "] to route, with track: <");        o(m.traceToString(false) + ">");

        BigInteger nexthop = null;

        //leave a track of the transit of the message over this node
        m.nrHops++;
        if(m.trackSize<m.tracks.length)
            m.trackSize++;
        m.tracks[m.trackSize-1]= this.nodeId;

        BigInteger curdist;
        BigInteger[] allNodes;
        BigInteger mindist;



        if (leafSet.encompass(m.dest)) {
            // il nodeID j in Li t.c. |k-j| ? minimo
            int near = 0;
            allNodes = leafSet.listAllNodes();

            if (allNodes.length != 0)  {

                mindist = m.dest.subtract(allNodes[near]).abs();
                for (int i = 1; i < allNodes.length; i++) {
                    curdist = m.dest.subtract(allNodes[i]).abs();
                    if (mindist.compareTo(curdist) > 0) {
                        mindist = curdist;
                        near = i;
                    }
                }
                nexthop = allNodes[near];
            } else  nexthop = this.nodeId;

        }
        else {
            int r = Util.prefixLen(m.dest, this.nodeId);
            if (r == MSPastryCommonConfig.DIGITS) {
                deliver(m);
                o("  [route]   Delivered message src=dest=" + RoutingTable.truncateNodeId(nodeId));
                return;
            }

            nexthop = this.routingTable.get(r, Util.charToIndex(Util.put0(m.dest).charAt(r))  );

            if (nexthop == null) {
                //il nodeID j in (Li U Ri) t.c. |k-j| < |k-i| && prefixLen(k,j)>=r

                BigInteger[] l = this.leafSet.listAllNodes();


                for (int jrow = 0; jrow < routingTable.rows; jrow++) {
                    for (int jcol = 0; jcol < routingTable.cols; jcol++) {
                        BigInteger nodejj = routingTable.get(jrow, jcol);
                        if (nodejj!=null)
                         if (cond1(m.dest, this.nodeId,nodejj) &&
                             cond2(m.dest, nodejj, r)) {
                            nexthop = nodejj;
                            break;
                        }
                    }
                }

                if (nexthop == null)
                for (int j = 0; j < l.length; j++) {
                    if (cond1(m.dest, this.nodeId, l[j]) &&
                        cond2(m.dest, l[j], r)) {
                        nexthop = l[j];
                        break;
                    }
                }


            } // end if (nexthop==null)
        }


        o(String.format("[%s].route([type=%s][src:%s][dest:%s][m.id=%d]): [nexthop:%s]",
            RoutingTable.truncateNodeId(nodeId),
            m.messageTypetoString(),
            "", // RoutingTable.truncateNodeId(src.nodeId),
            RoutingTable.truncateNodeId(m.dest),
            m.id,
            RoutingTable.truncateNodeId(nexthop)
                ));

        if ( m.body instanceof Message.BodyJoinRequestReply && false)
         o("m.RT "+((Message.BodyJoinRequestReply)(m.body)).rt);




        /** !!!
         *  (this.nodeId.equals(m.dest)) ? troppo limitativo, noi vogliamo vedere se "io" sono
         * quello pi? (numericammente) vicino possibile.
         * Poich? supponiamo di avvicinarci progressivamente, questo si traduce nel controllare
         * se sono pi? vicino dell'ultimo nodo attraversato (m.traks[last])
         *
         * l'hop lo facciamo solo se facendolo... ridurremo la distanza,
         * la distanza tra destinatario e me
         *   rispetto alla distanza fra destinatario e precedente
         */
        if ((m.trackSize > 0) && (nexthop != null)) {
            BigInteger src = m.tracks[m.trackSize-1]; if (!Util.nearer(m.dest,nexthop,src))
            //if (!Util.nearer(m.dest,nexthop,src.nodeId))
             nexthop = this.nodeId;
        }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一级高清毛片| av成人免费在线观看| 欧美日韩一区二区三区免费看| 欧美日韩中文字幕精品| 一区二区三区四区中文字幕| 91免费视频网址| 国产蜜臀97一区二区三区 | 久久精品在这里| 久久av老司机精品网站导航| 日韩欧美一级二级三级| 亚洲精品一线二线三线| 国产一区在线视频| 国产三级一区二区| 国产黄色精品视频| 中文字幕欧美国产| 国产传媒欧美日韩成人| 欧美国产精品中文字幕| 成人免费毛片aaaaa**| 国产精品麻豆欧美日韩ww| zzijzzij亚洲日本少妇熟睡| 亚洲丝袜精品丝袜在线| 日本电影亚洲天堂一区| 亚洲午夜久久久久久久久电影网| 欧美亚洲国产一区在线观看网站| 一区二区三区在线看| 色又黄又爽网站www久久| 日韩avvvv在线播放| 日韩一级高清毛片| 国产乱码精品一区二区三区忘忧草| 国产人伦精品一区二区| 91丝袜国产在线播放| 亚洲国产日韩综合久久精品| 欧美日韩免费不卡视频一区二区三区| 香蕉成人啪国产精品视频综合网| 欧美一区二区播放| 国产精品综合视频| 亚洲人成7777| 欧美一区二区三区在线看| 精品亚洲国内自在自线福利| 精品国产精品一区二区夜夜嗨| 成人久久久精品乱码一区二区三区| 一区二区三区欧美亚洲| 91精品国产综合久久久久| 国产一区二区三区四区在线观看| 国产精品国产自产拍高清av| 欧美一级黄色大片| 在线日韩av片| 成人激情动漫在线观看| 久久99精品国产| 午夜精品一区二区三区三上悠亚| 中文字幕一区二区三| 精品国产免费久久| 欧美日韩国产在线播放网站| 99久久综合精品| 国产九色sp调教91| 久久99国产精品久久99| 婷婷成人综合网| 亚洲一线二线三线视频| 亚洲视频一区在线观看| 中文字幕av免费专区久久| 26uuu久久天堂性欧美| 制服丝袜激情欧洲亚洲| 欧美日韩免费在线视频| av不卡一区二区三区| 麻豆91精品91久久久的内涵| 午夜电影一区二区三区| 亚洲午夜成aⅴ人片| 亚洲免费观看视频| 亚洲欧洲综合另类在线| ...中文天堂在线一区| 国产欧美日韩三级| 国产日韩av一区| 国产欧美综合在线| 欧美国产精品久久| 欧美韩日一区二区三区四区| 国产日产欧美一区二区视频| 国产日韩欧美一区二区三区乱码| 久久婷婷成人综合色| 2024国产精品视频| 久久久久亚洲综合| 国产日韩精品一区二区三区在线| 国产午夜精品久久| 中文字幕av在线一区二区三区| 日本一区二区三区四区在线视频| 国产午夜精品理论片a级大结局| 久久精品亚洲精品国产欧美| 国产色91在线| 最近中文字幕一区二区三区| 亚洲精品高清在线| 午夜一区二区三区视频| 日一区二区三区| 精品午夜久久福利影院 | 欧美三级韩国三级日本三斤| 欧美日韩一区二区三区不卡| 欧美老肥妇做.爰bbww| 欧美岛国在线观看| 久久久久久亚洲综合| 国产精品美女www爽爽爽| 日韩美女久久久| 无码av中文一区二区三区桃花岛| 奇米精品一区二区三区在线观看| 久草热8精品视频在线观看| 国产成人精品免费| 在线观看一区不卡| 日韩一区二区三区免费观看| 国产欧美一区二区精品久导航| 一区二区三区四区在线播放| 午夜不卡av在线| 国产乱理伦片在线观看夜一区| 粉嫩一区二区三区在线看| 色婷婷精品大在线视频| 欧美一级欧美三级| 国产欧美日韩综合精品一区二区| 一区二区三区在线观看网站| 麻豆91在线看| av亚洲精华国产精华| 91精品久久久久久久久99蜜臂| 久久精品夜色噜噜亚洲aⅴ| 亚洲猫色日本管| 久久爱www久久做| 91网址在线看| www成人在线观看| 亚洲高清免费观看 | 丁香婷婷综合网| 欧美日韩免费一区二区三区视频| 久久久久久久综合日本| 亚洲福利视频一区| 国产成a人无v码亚洲福利| 欧美人牲a欧美精品| 国产精品区一区二区三区| 日韩高清国产一区在线| 91麻豆产精品久久久久久 | 久久精品视频在线看| 性感美女极品91精品| 成人福利视频在线看| 日韩精品自拍偷拍| 一区二区三区在线观看视频| 国产激情精品久久久第一区二区| 欧美视频三区在线播放| 亚洲国产精品99久久久久久久久 | 国产精品麻豆视频| 精品在线免费视频| 欧美久久久久久久久| 亚洲另类中文字| 成人动漫av在线| 久久久久国产成人精品亚洲午夜| 日韩中文字幕不卡| 欧美色偷偷大香| 亚洲男同性视频| 成人免费毛片片v| 久久久久高清精品| 久久99精品国产麻豆婷婷洗澡| 欧美高清精品3d| 亚洲线精品一区二区三区| 一本一本大道香蕉久在线精品| 国产精品私人影院| 成人一级视频在线观看| 欧美v国产在线一区二区三区| 日本亚洲一区二区| 7777精品伊人久久久大香线蕉的| 一区二区三区美女| 91久久精品国产91性色tv| 最新日韩在线视频| 99在线精品免费| 亚洲欧洲日韩综合一区二区| 成人理论电影网| 日韩美女精品在线| 97久久久精品综合88久久| 中文字幕一区二区三区色视频 | 日韩高清不卡一区二区三区| 欧美日韩在线综合| 丝袜a∨在线一区二区三区不卡| 欧美日韩在线播放三区| 亚洲国产成人porn| 欧美日韩中文精品| 免费看黄色91| 久久嫩草精品久久久久| 国产成人啪免费观看软件| 国产欧美一区二区三区在线老狼| 高清成人在线观看| 亚洲乱码国产乱码精品精小说| 欧美一级二级三级蜜桃| 秋霞av亚洲一区二区三| 精品国产一区二区亚洲人成毛片| 激情综合色播激情啊| 国产偷国产偷精品高清尤物| 粉嫩aⅴ一区二区三区四区| 日韩伦理电影网| 欧美三级在线播放| 麻豆视频观看网址久久| 久久影院视频免费| 99视频在线观看一区三区| 亚洲精品高清在线| 欧美久久久一区| 黄一区二区三区| 亚洲欧美另类小说视频| 7777精品伊人久久久大香线蕉 | 欧美体内she精高潮| 麻豆成人91精品二区三区| 国产精品视频在线看|