天天看点

p2psim学习笔记(一) 編译运行

p2psim学习笔记(一)

    暑假我们就要在实验室好好学习P2P啦,首先的就是学好p2psim这个仿真开源程序,因为它还自带实现了Chord, Tapestry等模型,可以在对模型学习后进一步理解其实现机制,当然最重要的就是在理解了p2psim的原理后,要在上面实现我们自己的协议仿真。由于网上资料比较乱,而且官网也没有详细教程,所以我就想在学习过程中记录一下,方便大家学习,部分资料由网上所得。

  1. 下载编译

    $ wget http://pdos.lcs.mit.edu/p2psim/p2psim-0.3.tar.gz

    $ tar xvfz p2psim-0.3.tar.gz

    $ cd p2psim-0.3

    $ ./configure

    $ make

  2. 因为p2psim的开发在05年就停止了,gcc版本要求2.95.3,不过没关系,用现在版本也可以编译通过,要作出如下改动(注意编译错误提示的位置)

    (1)把misc/vivalditest.h 第68行注释掉再编译!--不知道用处,但对运行无影响

    (2)注意有些地方要去掉XXX::,因为新版本已支持

    (3) 如果出现在const static XX = XX无法初始化的话,那就将这个初始化放到构造函数即可

  1. 編译完成后会以p2psim目标下生成一个p2psim的可执行文件,可先用例子试试

    (1)p2psim/p2psim example/protocol.txt example/topology.txt example/events.txt

(注意运行的目录,会输出一大堆)

p2psim运行要解析三个配置文件

example/topology.txt: 拓扑配置

example/protocol.txt: 协议配置

example/events.txt :事件配置

(2)还有一种方式,利用提供的perl脚本进行大批量的测试,并能够对运行结果分析,最后生成自己想要的图形数据(我们的终极目标)

scripts/run-simulations.pl --protocol Chord --topology example/topology.txt --logdir . --args example/chord_args //调用脚本运行p2psim

scripts/merge-stats.pl --args example/chord_args *.log > chord_out //将运行数据进行分析,规范格式

scripts/make-graph.pl --dat chord_out --x BW_TOTALS:live_bw --y CORRECT_LOOKUPS:lookup_mean --convex both //调用gnuplot生成图形数据(要先装gnuplot哦)

注:要先装好gnuplot和gv,这是脚本要用到的工具,如果是在ubuntu下比较方便 ,可立得里就可以下载到, fedora应该有自带

  1. 源代码的目录介绍:

    observers: 观察者类,执行日志记录

    eventgenerators:事件发送器的一些工厂模式

    events:定义事件,主要包括netevent(网络事件), p2pevent(应用事件), simevent(模拟事件)

    failuremodels:事件处理失败的工厂模式

    libtask:和操作系统相关的线程调度,任务调度,可以不用过多关注

    p2psim: 主目录,是p2p实现的一些基类的定义,如event, eventgenerator, eventqueue, network, node, observed, p2protocol, p2psim,packet, parse, rpchanndle(在p2p的的事件服务采用rpc调用方式?),thread, threadmanager, topology.这些都是为实现其它具体p2p协议做的准备

    protocols:具体p2p实现协议,如chord, chordfinger, koorde, kademlia等,是研究协议实现和进行协议修改的地方

    topologies:我们在设定模拟环境是采用何种网络top,和我们的topology.txt配置文件相关,如果我们设定了Euclidean模式,那么程序在解析结点的时候,就按照Euclidean模式读取结点信息

  2. 最后贴一下P2P仿真方面的一些软件

http://www.idsia.ch/~andrea/simtools.html 列举了大量的模拟器

P2P方面的模拟器包括:

1. P2Psim: http://www.pdos.lcs.mit.edu/p2psim/

可以模拟chord, koorde, Tapestry等协议,你可以直接拿来用。

2.PLP2P(Packet-level Peer-to-Peer Simulation Framework and

Gnutellasim)

http://www.cc.gatech.edu/computing/compass/gnutella/

是基于Ns-2.27和pdns开发的模拟Gnutella系统的模拟器。

实现了Gnutella 0.4 和 0.6版的协议.

PDNS是NS的分布式版本。 如果要模拟的节点数目很多,在单机上模拟速度慢时,可以使

用PDNS把模拟分布到多个节点上并行分布的模拟。

3.Peersim Peer-to-Peer Simulator

http://peersim.sourceforge.net/

Peer-to-peer systems can reach huge dimensions such as millions of nodes,

which typically join and leave continously. These properties are very

challenging to deal with. Evaluating a new protocol in a real environment,

especially in its early stages of development, is not feasible. There are

distributed planetary-scale open platforms (e.g., PlanetLab) to develop and

deploy network services, but these solutions don't include more than about

440 nodes. Thus, for large-scale systems, a scalable simulation testbed is

mandatory.

Peersim has been developed with extreme scalability and support for

dynamicity in mind. It is composed of many simple extendable and pluggable

components, with a flexible configuration mechanism. To allow for

scalability and focus on self-organization properties of large scale

systems, some simplifying assumpions have been made, such as ignoring the

details of the transport communication protocol stack. Peersim is devolped

within the BISON project and it is distributed under an open source

license. Peersim is written in the Java language.

4.The P2P File-sharing simulator

http://www.cs.uiowa.edu/~rbriggs/gt/

The P2P File-sharing simulator was designed as an implementation of the

incentive based scheme, based on the contribution of a peer to the entire

system. This scheme is detailed in the paper “Incentive Resource

Distribution in P2P Networks”by Ma, Lee, Lui, and Yau. The simulator

makes use of randomness in order to create events such as new peers

joining the system, a peer leaving the system, the start of downloads, and

the completion of current downloads. The paper details the Progressive

Filling (PF) algorithm, the Contribution Dependent Progressive Filling

(CDPF)algorithm and the Contribution Update algorithm, which are used to

determine a peer’s contribution to the system in order to allocate

bandwidths based on those contributions. Using this incentive based

scheme, the simulator shows how the scheme encourages peers to share

information and resources.

5.其他的如SimP^2 Simulator, 3LS,下载不到。

继续阅读