天天看點

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,下載下傳不到。

繼續閱讀