资源简介

本资源包含一次项目研究的全部资料。详细分析了PeerSim的用法,并对当前P2P仿真状况进行了研究,最后,作为示例,作者设计了一个简单的P2P信任协议并移植到了PeerSim中,以使人们更加了解PeerSim的运行流程。资源中包含的代码都有详细的注释。本资源稍加修改就可作为一次本科毕业设计直接上交

资源截图

代码片段和文件信息

/*
 * Copyright (c) 2003-2005 The BISON Project
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not write to the Free Software
 * Foundation Inc. 675 Mass Ave Cambridge MA 02139 USA.
 *
 */

package example.aggregation;

import peersim.core.*;
import peersim.config.FastConfig;
import peersim.vector.SingleValueHolder;
import peersim.cdsim.CDProtocol;

/**
 * This class provides an implementation for the averaging function in the
 * aggregation framework. When a pair of nodes interact their values are
 * averaged. The class subclasses {@link SingleValueHolder} in
 * order to provide a consistent access to the averaging variable value.
 *
 * Note that this class does not override the clone method because it does
 * not have any state other than what is inheritred from
 * {@link SingleValueHolder}.
 * 
 * @author Alberto Montresor
 * @version $Revision: 1.10 $
 */
public class AverageFunction extends SingleValueHolder implements CDProtocol {
    /**
     * Creates a new {@link example.aggregation.AverageFunction} protocol
     * instance.
     * 
     * @param prefix
     *            the component prefix declared in the configuration file.
     */
    public AverageFunction(String prefix) {
        super(prefix);
    }

    /**
     * Using an underlying {@link linkable} protocol choses a neighbor and
     * performs a variance reduction step.
     * 
     * @param node
     *            the node on which this component is run.
     * @param protocolID
     *            the id of this protocol in the protocol array.
     */
    public void nextCycle(Node node int protocolID) {
        int linkableID = FastConfig.getlinkable(protocolID);
        linkable linkable = (linkable) node.getProtocol(linkableID);
        if (linkable.degree() > 0) {
            Node peer = linkable.getNeighbor(CommonState.r.nextInt(linkable
                    .degree()));

            // Failure handling
            if (!peer.isUp())
                return;

            AverageFunction neighbor = (AverageFunction) peer
                    .getProtocol(protocolID);
            double mean = (this.value + neighbor.value) / 2;
            this.value = mean;
            neighbor.value = mean;
        }
    }

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件   10387008  2010-08-19 22:15  P2P仿真\P2P仿真.chm

     文件     547840  2010-09-10 10:26  P2P仿真\P2P仿真实习报告 .doc

     文件     741376  2010-08-20 11:02  P2P仿真\P2P仿真实习报告.ppt

    ..A.SH.      5120  2010-08-06 11:31  P2P仿真\P2P仿真调研报告\Thumbs.db

    ..A..H.       162  2010-08-16 09:59  P2P仿真\P2P仿真调研报告\~$-P2P仿真调研报告.doc

     文件     581632  2010-09-10 10:29  P2P仿真\P2P仿真调研报告\P2P仿真调研报告.doc

     文件     968192  2010-09-10 10:31  P2P仿真\P2P仿真调研报告\P2P仿真调研报告.ppt

     文件        389  2010-08-05 17:18  P2P仿真\代码\TrustModelSimulation\.classpath

     文件        396  2008-03-13 21:52  P2P仿真\代码\TrustModelSimulation\.project

     文件     136404  2007-12-24 06:47  P2P仿真\代码\TrustModelSimulation\djep-1.0.0.jar

     文件      75818  2007-12-24 06:47  P2P仿真\代码\TrustModelSimulation\jep-2.3.0.jar

     文件      17483  2005-09-01 20:58  P2P仿真\代码\TrustModelSimulation\slacer.jar

     文件      41811  2010-08-19 20:01  P2P仿真\代码\TrustModelSimulation\data\TrustMonitor.dat

     文件         13  2010-08-19 20:01  P2P仿真\代码\TrustModelSimulation\data\BadPeerNumCount.dat

     文件      43690  2010-08-19 20:01  P2P仿真\代码\TrustModelSimulation\data\MaliceAttackCount.dat

     文件       4790  2010-08-19 20:01  P2P仿真\代码\TrustModelSimulation\data\BadPeerTrustValue.dat

     文件      37021  2010-08-19 20:01  P2P仿真\代码\TrustModelSimulation\data\GoodPeerTrustValue.dat

     文件        685  2010-08-19 20:01  P2P仿真\代码\TrustModelSimulation\data\AverageTrustValuePerCycle.dat

     文件        685  2010-08-19 20:01  P2P仿真\代码\TrustModelSimulation\data\GoodPeerAverageTrustValuePerCycle.dat

     文件        658  2010-08-19 20:01  P2P仿真\代码\TrustModelSimulation\data\BadPeerAverageTrustValuePerCycle.dat

     文件      80218  2010-08-19 20:01  P2P仿真\代码\TrustModelSimulation\data\PeerSuccessfulDownloadPercentage.dat

     文件        432  2010-08-19 19:52  P2P仿真\代码\TrustModelSimulation\config\slacer-conf1.cfg

     文件       2743  2008-03-13 21:52  P2P仿真\代码\TrustModelSimulation\example\aggregation\AverageFunction.java

     文件       3851  2008-03-13 21:52  P2P仿真\代码\TrustModelSimulation\example\aggregation\AverageObserver.java

     文件       3155  2008-03-13 21:52  P2P仿真\代码\TrustModelSimulation\example\aggregation\PeakDistributionInitializer.java

     文件       1512  2010-08-19 19:29  P2P仿真\代码\TrustModelSimulation\example\aggregation\PeakDistributionInitializer.class

     文件       1998  2010-08-19 19:29  P2P仿真\代码\TrustModelSimulation\example\aggregation\AverageObserver.class

     文件       1324  2010-08-19 19:29  P2P仿真\代码\TrustModelSimulation\example\aggregation\AverageFunction.class

     文件       3309  2008-03-13 21:52  P2P仿真\代码\TrustModelSimulation\example\edaggregation\AverageED.java

     文件        453  2010-08-19 19:29  P2P仿真\代码\TrustModelSimulation\example\edaggregation\AverageMessage.class

............此处省略304个文件信息

评论

共有 条评论