58
PeerfactSim.KOM – Community Edition A Peer-to-Peer System Simulator http://www.peerfact.org Getting Started Document PG DynaSearch Andreas Cord-Landwehr Markus Benter Max Drees Peter Kling Friedhelm Meyer auf der Heide Slides Jun.-Prof. Dr.-Ing. Kalman Graffi Heinrich Heine Universität Düsseldorf

PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

PeerfactSim.KOM – Community EditionA Peer-to-Peer System Simulator

http://www.peerfact.orgGetting Started Document

PG DynaSearchAndreas Cord-LandwehrMarkus BenterMax DreesPeter KlingFriedhelm Meyer auf der Heide

SlidesJun.-Prof. Dr.-Ing. Kalman GraffiHeinrich Heine Universität Düsseldorf

Page 2: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 2

Overview

1 Why Simulations?2 Overview on PeerfactSim.KOM

– 2.1 Layers in PeerfactSim.KOM– 2.2 Observing what is happening Analyzers

3 PeerfactSim.KOM – A Step by Step Guide– 3.1 Downloading and Installation– 3.2 Running a Simulation

• GUI Runner• SimulationRunner• BatchRunner

– 3.3 Setting up a first Simulation - the Config - File

4 Modifying the Protocols– 4.1 How to send messages– 4.2 How to receive and process messages

Page 3: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 3

Overview

1 Why Simulations?2 Overview on PeerfactSim.KOM

– 2.1 Layers in PeerfactSim.KOM– 2.2 Observing what is happening Analyzers

3 PeerfactSim.KOM – A Step by Step Guide– 3.1 Downloading and Installation– 3.2 Running a Simulation

• GUI Runner• SimulationRunner• BatchRunner

– 3.3 Setting up a first Simulation - the Config - File

4 Modifying the Protocols– 4.1 How to send messages– 4.2 How to receive and process messages

Page 4: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 4

General Evaluation Methods

Analysis– Often simplified model

• Homogeneous nodes, probabilistic actions– Leads to proofs (under specific conditions)

Example– Given: Weighted DAG– Results:

• Proofs• Complexities - O (log N)

Good: General resultsWeakness:

– Details lost in abstraction– Sometimes the constants are important

Page 5: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 5

General Evaluation Methods

Prototype – in testbed / in real world– Deployment of code in real testbed (e.g. PlanetLab)– Most adequate models, unpredictable user behaviour– Challenging to coordinate the tests, gather results– Logging and coordination might disturb the results

Example– Given:

• 733 PlanetLab nodes• Full protocol stack: IP, TCP/UDP, middleware, application, virtual

users• Deployment in global PlanetLab

– Results:• Behavior realistic network conditions

– Delays, jitter, node load …

Page 6: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 6

General Evaluation Methods

Simulation– Advanced and heterogeneous model

• Specific node characteristics, capacities, behavior– Investigates emerging behavior– Often focus on quality of service

• Response times, induced traffic, specific node load• A response time of 1s to 5s matters!

Example– Given:

• 10.000 nodes, capacity distribution X• 70% altruistic nodes, 20% selfish nodes, 10% malicious nodes• Protocol XY, workload Z

– Results:• Statistics on quality of service over time

Page 7: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 7

Simplified Overview on SimulationsSimulated hosts

– Every node has own state• Current load, capacities, strategies …

– Set of possible actions• Triggered by workload / autonomously

– Defined reactions on incoming messages

Round-based simulations– All actions in one round in parallel – Round i only affects round i+1– Unrealistic behavior– Easier to implement

Event-based simulations– Every event is scheduled for a time point– Only passed to receiver when time is due– Events may initiate new events– Strict order of events, more realistic

Timeline of events

Node A:my state

Node B:my state

Node F:my state

Node C:my state

Node D:my state Node E:

my state

Page 8: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 8

Overview

1 Why Simulations?2 Overview on PeerfactSim.KOM

– 2.1 Layers in PeerfactSim.KOM– 2.2 Observing what is happening Analyzers

3 PeerfactSim.KOM – A Step by Step Guide– 3.1 Downloading and Installation– 3.2 Running a Simulation

• GUI Runner• SimulationRunner• BatchRunner

– 3.3 Setting up a first Simulation - the Config - File

4 Modifying the Protocols– 4.1 How to send messages– 4.2 How to receive and process messages

Page 9: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 9

Overview on PeerfactSim.KOM

Website: http://www.peerfact.org

History– Started in 2005 as evaluation tool– Used and heavily extended in the p2p project

• DFG – Forschergruppe 733 – QuaP2P• Improvement of the Quality of Peer-to-Peer Systems by

Systematically Researching Quality Features and Their Interdependencies

Type– Event-based simulator– Written in Java– Simulations up to 100K peers possible– Focus on simulation of p2p systems on various layers

• Remember 7+ researchers looking at interdependencies

Page 10: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 10

Layered View

Layered architecture– Easy exchange of

components– Testing of new applications– Testing of new mechanisms

Main idea– Every layer has a simple

implementation– Enables testing of individual

layer mechanisms• on its own• in combination with other

layers

Page 11: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 11

Application Layer

General Concept– Manage the application logic

• E.g. only search for previously published files

– Implement various user behaviors

Current applications– File sharing

• Manage a set of files with givenpopularity distribution

• Publish, lookup and download files– Keyword-based Search

• Index and search files in a DHT based on keywords– Lookup Generators

• For distributed hash tables to generate load

Application Layer

Transport Layer

Overlay Layer

User Layer

UDP TCP

Online-timeModel Behavior

Jitter

Unstructured Structured

Network LayerRTT

Service Layer

Monitoring Replication

PackageLoss

File Sharing Tag-based Search

Page 12: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 12

Service Layer

General concept– Functionality on top of the p2p overlay– Offering services, not an application

Replication – PAST: store data on neighboring nodes

Monitoring– Gathers information on the network– Tree-based approaches: SkyEye

• Gathers statistics• Supports capacity-based peer-search

– Gossip-based approaches: PushSumManagement

– SkyNet.KOM: Adapting the parameters of the system to meet the preset goals

Application Layer

Transport Layer

Overlay Layer

User Layer

UDP TCP

Online-timeModel Behavior

Jitter PackageLoss

Unstruct. Structured

Network LayerRTT

Service Layer

Monitoring Replication

File Sharing Tag-based Search

P2P Overlay

Monitoring

Analysis andPlanning

Execute

Preset QualityGoals

SystemDynamics

Page 13: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 13

Overlay Layer

General concept– Implements unstructured and

structured p2p overlay

Unstructured overlays– Gnutella 0.4– Hierarchical overlays

• Gnutella 0.6, Gia

Distributed Hash Tables– Chord and variants

• EpiChord, Re-Chord, CaRe-Chord– CAN, Pastry, Kademlia– Centralized Hash Table

Information Dissemination Overlays– VON, pSense, Mercury

Application Layer

Transport Layer

Overlay Layer

User Layer

UDP TCP

Online-timeModel Behavior

Jitter PackageLoss

Unstruct. Structured

Network LayerRTT

Service Layer

Monitoring Replication

File Sharing Tag-based Search

Page 14: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 14

Underlay: Network and Transport Layer

General Concept– Hide topology of the Internet– Consider only End-to-End connections– Dedicated component for the logic

Simple Network Layer– Simple latency models

• Static latency• Distance-based latency

– No packet loss– Omission of packet size and bandwidth– Supporting simplified UDP

Application Layer

Transport Layer

Overlay Layer

User Layer

UDP TCP

Online-timeModel Behavior

Jitter PackageLoss

Unstruct. Structured

Network LayerRTT

Service Layer

Monitoring Replication

File Sharing Tag-based Search

Page 15: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 15

Underlay: Network and Transport Layer

More advanced network layer: Global Network Positioning– Based on different Internet measurement projects– Packet loss depending on the geographical positions– Supporting UDP and simplified TCP

Model the Internet as an d-dimensional geometric space – Characterize the position of any end host with coordinates– Latency prediction: based on distance in geometric space

• And a bit of variance based on PingER data set

y(x2,y2,z2)

x

z

(x1,y1,z1)

(x3,y3,z3) (x4,y4,z4)

Page 16: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 16

The Influence of the Geographical Position

IEPM PingEr Project– ∼ 40 monitor hosts and 670 destination hosts – ∼ 960 RTTs per link per day– RTT variation for inter and intra country and region links

Region-to-region average round-trip time in ms (November 2007)

Page 17: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 17

Underlay: Network and Transport Layer

Modular Network Layer: Configurable– Allows to have realistic network, but slow– Or fast network simulation, but less realistic

Page 18: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 18

Additional Components: Visualization

Visualization– Graphical representation of running simulations– Visualization of recorded simulations– Nice to see, but not well suited for evaluation purposes

Page 19: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 19

Additional Components: Analyzer

Analyzers are used for logs– Each layer informs corresponding analyzers about current actions– Analyzers keep track of statistics– Write periodically these statistics

to the disk (csv-files)

After the simulation– Corresponding gnuplot-scripts

are written to the disc as well– With gnuplot and the csv-files

plots can be rendered easily

Page 20: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 20

Overview

1 Why Simulations?2 Overview on PeerfactSim.KOM

– 2.1 Layers in PeerfactSim.KOM– 2.2 Observing what is happening Analyzers

3 PeerfactSim.KOM – A Step by Step Guide– 3.1 Downloading and Installation– 3.2 Running a Simulation

• GUI Runner• SimulationRunner• BatchRunner

– 3.3 Setting up a first Simulation - the Config - File

4 Modifying the Protocols– 4.1 How to send messages– 4.2 How to receive and process messages

Page 21: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 21

PeerfactSim.KOM – A Step by Step Guide

Up-to-date guide at http://www.peerfact.org

Page 22: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 22

Downloading and Installation

Download Eclipse– http://eclipse.org/

Download gnuplot– http://www.gnuplot.info/

Download PeerfactSim.KOM – http://www.peerfact.org

– https://peerfactsimkom-community/googlecode.com/archive/master.zip

With Eclipse– Copy master.zip’s content in a folder in the Eclipse Workspace– Create a new Java project in Eclipse with the same name– Compile the code

Also good: read the documentation or watch the tutorials

Page 23: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 23

Three ways to start the Simulator

Graphical visualization (For beginners)– Allows to chose a configuration file from a dialog– Visualizes the network– runGUI.bat and runGUI.sh

Headless simulation (Standard)– For quick and common simulations from the console– run.bat and run.sh

Batch runner (advanced, for papers)– For comparison of various setups with a number of random seeds– runBatch.bat and runBatch.sh– Creates evaluation results for

• Each simulation run: each setup and each random seed• Each setup: aggregates the results of the simulation runs with various

seeds• Comparative results: Aggregates the results for all seeds and each setup,

and compares the results of each setup

Page 24: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 24

Running a Simulation with VisualizationIn Eclipse:

– Run as Application: org.peerfact.GUIRunner

– Or: Start runGui.bat/.sh– No program arguments needed here– VM arguments (example)

• -Xms200m -Xmx600mSelect and run

– Select config/visualization/chord.xml– Start the simulation– Once the simulation finished, press play

Page 25: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 25

Simulation Visualization (Replay)

Page 26: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 26

Inspecting the Results - .dat Files

Where and what– In the outputs folder a new folder was created

• Name contains: date – time – config file name – Seed• The seed is used for initialization of the pseudo random function

– Output folder contains .dat and .plt files• .dat – files contain the results of the simulation

– csv: comma separated values– Each column represents a metric– Metric names are given in the begin of the file– To each file, also a file with „...Peers.dat“ and „...PeersSort.dat“ is created

» No suffix: x-axis is time, Peers: x-axis are peers, PeersSort: sorted

Example (Net.dat)#Time [minutes]Online Hosts Messages out Messages in Bytes Sent Bytes Received Bandwidth out Bandwidth in0 0 0.0 0.0 0.0 0.0 0.0 0.01 1 0.0 0.0 0.0 0.0 0.0 0.02 9 270.0 260.0 126078.0 121200.0 16810.4 16160.03 15 547.0 528.0 254337.0 245100.0 33911.6 32680.04 20 597.0 579.0 275239.0 266559.0 36698.53333333333 35541.25 28 846.0 825.0 391160.0 381367.0 52154.666666666664 50848.933333333334

Page 27: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 27

Inspecting the Results - .plt Files

How to create graphs– .plt files are gnuplot scripts, they are used to render graphs– Scripts have knowledge about each column in corresponding .dat file– Labels of figures, graphs and axis are set

Run: gnuplot <scriptname>.plt

Example of a gnuplot-script (from Net.plt)– Generates a .png and a .pdf file using column 1 as x, and column 2 as y axis

#------------------------------------------------------------# Plot Online Hosts#------------------------------------------------------------set term png giant size 800,600 font 'Helvetica,20'set output 'Net-Online_Hosts.png'set key top leftset xlabel 'Time [minutes]'set ylabel 'Online Hosts [number]'plot 'Net.dat' using 1:2 title 'Sum of Online Hosts' with lines axis x1y1 smooth unique

set terminal pdf monochrome font 'Helvetica,10'set output 'Net-Online_Hosts.pdf'replot

Page 28: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 28

Inspecting the Results – Example Graphs

Net-Online-HostsDHTOverlay-Additional-Finished-Lookups

DHTOverlayPeersSort-Additional-Finished-Lookups

Operation-Duration-Average

Page 29: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 29

Inspecting the Results – Example Graphs

Net-Bandwidth-In

Net-Bandwidth-In NetPeersSort-Bytes-Received

OperationPeersSort-Initiated_Operations

Actions: #Scenario IdealGlasgowCity 1s JoinLeaveOverlayNode:join callbackLatinAmerica 1m-8m JoinLeaveOverlayNode:join callbackGermany 1m-8m JoinLeaveOverlayNode:join callback

Page 30: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 30

More revealing example: config/FileSharing.xmlCall: run.sh config/FileSharing.xml

1000 nodes, 300 minutesActions:all 1s-120m FileSharingApplication:joinall 120m-180m FileSharingApplication:publishResourcesFromSet files 100all 180m FileSharingApplication:lookupResourceFromSetPeriodically files 10m

Page 31: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 31

More revealing example: config/FileSharing.xml

Page 32: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 32

FileSharing Results sorted according to Peers

Page 33: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 33

Even more interesting setup

Call: runBatch.sh 2 5 config/FileSharing.xml Overlay=Chord,Pastry

– 2 simulations at once– 5 seeds per setup– Config file: FileSharing– Overlays: Chord AND Pastry

Setup: 1000 nodes, 300 minutesActions:all 1s-120m FileSharingApplication:joinall 120m-180m FileSharingApplication:publishResourcesFromSet files 100all 180m FileSharingApplication:lookupResourceFromSetPeriodically files 10m

Page 34: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 34

Overview

1 Why Simulations?2 Overview on PeerfactSim.KOM

– 2.1 Layers in PeerfactSim.KOM– 2.2 Observing what is happening Analyzers

3 How to Use PeerfactSim.KOM – A Step by Step Guide– 3.1 Downloading and Installation– 3.2 Running a Simulation

• GUI Runner• SimulationRunner• BatchRunner

– 3.3 Setting up a first Simulation - the Config - File

4 Modifying the Protocols– 4.1 How to send messages– 4.2 How to receive and process messages

Page 35: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 35

Setting up a first Simulation - the Config - File

In the folder: /config

Defines– the components to be

simulated– the action file to use

Example: config/FileSharing.xml

The first part of the file contains all selections

Here, all relevant parts are to be chosen

Begin – Selection based on switches<?xml version='1.0' encoding='utf-8'?><Configuration xmlns:xi="http://www.w3.org/2001/XInclude">

<!-- Variables --><Default>

<Variable name="seed" value="0" /><Variable name="size" value="1000" /><Variable name="startTime" value="0m" /><Variable name="finishTime" value="300m" /><Variable name="ChurnModel" value="" /><Variable name="NetLayer" value="SIMPLE" /><Variable name="Overlay" value="Chord" /><Variable name="server" value="false" /><Variable name="Service" value="" /><Variable name="GUI" value="false" />

</Default>

Page 36: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 36

Setting up a first Simulation - the Config - FileThe possible selection is given in the next part of the file:

<!-- Description --><Description> Generic configuration for FileSharing with all possible DHT overlays with the following possible configurations:ChurnModel: Exponential, Kad, Herrera, StaticNetLayer: MOD, MOD-NoPacketLoss, GNP, SIMPLE, MOBILEOverlay: Can, CentralizedIndex, CentralizedStorage, AdaptiveChord, CaReChord, Chord, EpiChord, MaliciousChord, ReChord, HKademlia, Kademlia, Kandy, Pastry, [server= true (for CentralizedStorage and CentralizedIndex)]

Gia, Gnutella06</Description>

Switch resolving:<!-- NetLayer --><IfEqualStr arg0="$NetLayer" arg1="MOD"><xi:include href="includes/network/ModularNetLayer.xml" /></IfEqualStr>

<IfEqualStr arg0="$NetLayer" arg1="MOD-NoPacketLoss"><xi:include href="includes/network/ModularNetLayer-NoPacketLoss.xml" /></IfEqualStr>

<IfEqualStr arg0="$NetLayer" arg1="GNP“><xi:include href="includes/network/GnpNetLayer.xml" /></IfEqualStr>

<IfEqualStr arg0="$NetLayer" arg1="SIMPLE"><xi:include href="includes/network/SimpleNetLayer.xml" /></IfEqualStr>

<IfEqualStr arg0="$NetLayer" arg1="MOBILE"><xi:include href="includes/network/MobileNetLayer.xml" /></IfEqualStr>

Page 37: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 37

Actions File

Describes what happens– Joins: who, when

• Single peer• Group of peers

– Specific actions to be done by peers

• Call operations• At specific time

Example Part in config/FileSharing.xml

<!-- Scenario --><IfEqualStr arg0="$server" arg1="false">

<xi:include href="includes/scenario/FileSharing.xml" /></IfEqualStr>…</IfEqualStr>

In: includes/scenario/FileSharing.xml

<?xml version='1.0' encoding='utf-8'?><Scenario class="org.peerfact.impl.scenario.CSVScenarioFactory"

actionsFile="config/includes/actions/FileSharing.dat"

componentClass="org.peerfact.impl.application.filesharing.FileSharingApplication"

additionalClasses="org.peerfact.api.overlay.JoinLeaveOverlayNode"></Scenario>

In: config/includes/actions/FileSharing.dat

# action file for FileSharing

all 1s-120m FileSharingApplication:joinall 120m-180m FileSharingApplication:publishResourcesFromSet files 100all 180m FileSharingApplication:lookupResourceFromSetPeriodically files 10m

Page 38: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 38

Overview

1 Why Simulations?2 Overview on PeerfactSim.KOM

– 2.1 Layers in PeerfactSim.KOM– 2.2 Observing what is happening Analyzers

3 PeerfactSim.KOM – A Step by Step Guide– 3.1 Downloading and Installation– 3.2 Running a Simulation

• GUI Runner• SimulationRunner• BatchRunner

– 3.3 Setting up a first Simulation - the Config - File

4 Modifying the Protocols– 4.1 How to send messages– 4.2 How to receive and process messages

Page 39: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 39

Basics for creating your own Protocol

Sending and receiving messages– At the example of Chord

Agenda for the following slides

– Small introduction to Chord– The concept of Operations in the simulator– How to send messages in the simulator– How to receive messages in the simulator– How the analyzers create statistics on the simulations

Page 40: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 40

Chord: An Efficient Lookup Network

Chord uses SHA-1 hash function– Results in a 160-bit object/node identifier– Same hash function for objects and nodes

Node ID hashed from e.g., IP addressObject ID hashed from object name

– Object names assumed to be known

Chord is organized in a ring which wraps around– Nodes keep track of predecessor and successor

• System invariant for valid network operation– Node responsible for

• objects between its predecessor and itself– Fingers used to enable efficient content addressing

• O(log(N)) fingers lead to lookup operation of O(log(N)) length

Page 41: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 41

Chord: Network Topology

Basic ring topology – Successor/

Predecessor

Uses SHA-1to map – IP address/object name

onto – 160 Bit ID

Circular Key Space

Link to ring successor

22072012-2207

29062683-29063485

2907-3485

20111623-2011

16221009-16221008

710-1008709660-709

659612-659

26822208-2682

6113486-40470-611 Peers are responsible

for own ID and IDs back to predecessor

Page 42: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 42

Chord: Network Topology

Enhanced topology– kth finger of Peer n is shortcut pointing

to peers being responsible for Object ID (n + 2^k)– k ranges from 0 to log(N)– O(log(N)) fingers lead to lookup operation of O(log(N))

Fingers points to peers with ObjectIDs increasing exponentially. Here: 709 + 2k

= …, 965, 1221, 1733, 2757

22072012-2207

29062683-29063485

2907-3485

20111623-2011

16221009-16221008

710-1008709660-709

659612-659

26822208-2682

6113486-40470-611

Page 43: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 43

Chord: Addressing Content

Query– Contains the hash value of the queried content– On each step the distance from the destination is halved

(remember fingers)Node 1008 queries item 3000

Use Fingers to locate the destination fasterWithout fingers: no shortcuts, walk the circle

Responsible peer found

22072012-2207

29062683-29063485

2907-3485

20111623-2011

16221009-16221008

710-1008709660-709

659612-659

26822208-2682

6113486-…0-611

2

Responsible for 1008 + 1024

31

Responsible for 2207 + 512

Responsible for 3000

Page 44: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 44

Chord in the Simulator

All „actions“ in the simulator are eventsEvents are called operations in overlays

– Required: simulation time, Event Handler, Event Type

Can be initiated by– Action file (as seen before) scheduled at corresponding time– By generators (e.g. DHTLookupGenerator)

Page 45: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 45

What happens inside: Executing an Event

Insides– Operations are schedulable events, e.g. LookupOperation– Events are scheduled for a specific time– .execute() is called at that time

Page 46: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 46

How messages are sentLet us inspect the LookupOperation

@Overridepublic void execute() {

if (...) {...

} else {lookupMsg = new LookupMsg(

master.getLocalOverlayContact().getOverlayID(), master.routingNext(target).getOverlayID(), master.getLocalOverlayContact().clone(), target, this.getOperationID());

master.getTransLayer().send(lookupMsg, master.routingNext(target).getTransInfo(),master.getPort(), TransProtocol.UDP);

master.registerLookupStore(getOperationID(), this);

// Schedule a timeout to redo the lookup after some timescheduleOperationTimeout(CanConfig.waitTimeToStore);}

}

Create Message

Send Message usingthe TransLayer

Pick as next hopfrom routing table

Save OperationID

for laterreference

Page 47: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 47

How messages are Received

All messages are received by the TransLayerEvery protocol can register a MessageHandler as Listener to the TransLayer

– Registered MessageHandler receive a copy of received messages– MessageHandler checks their responsibility for the message by “instance of”– The message type determines the message handler

Message

SimpleNetMessage

(Abstract)NetMessage

AbstractOverlayMessage

SimpleNetMessageSimpleNet

Message

KBR ForwardMsg

ChordMsg CanMsg

...

...

...

Page 48: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 48

How messages are receivedAll messages arrive at the TransLayer:

private void receive(AbstractTransMessage transMsg, NetID sender) {// Inform about transport layer message receiveSimulator.getMonitor().transMsgReceived(transMsg);

TransInfo senderInfo = getAddress(sender, transMsg.getSenderPort());Message payload = transMsg.getPayload();

if (transMsg.isReply()) {TransMessageCallback responseCallback = replyCallbacks.remove(transMsg.getCommId());if (responseCallback != null) {

responseCallback.receive(payload, senderInfo, transMsg.getCommId());}

} else {List<TransMessageListener> messageReceiver = this.transMessageListeners.get(transMsg.getReceiverPort());

if (messageReceiver == null || messageReceiver.size() == 0) {log.debug("Message " + transMsg + " cannot be dispatched as no receiver is registered");

} else {for (TransMessageListener listener : messageReceiver) {

listener.messageArrived(new TransMsgEvent(transMsg, senderInfo, this));}

}}

}

Inform Analyzers aboutreceived message

Get payload and senderinformation

If it is a reply: find corresponding operation

for processing

If it is NOT a reply: Get list of possiblemessage handlers

Send message to ALL registered message

handlers

Page 49: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 49

The ChordMessageHandler: Processing of Messages

When a ChordNode is created:

– It creates also a ChordMessageHandler

– The ChordMessage-Handler is registered at theTransLayer

public ChordNode(TransLayer transLayer, short port,

ChordBootstrapManager bootstrap) {

super(transLayer, port, bootstrap);operationListener = new

ChordOperationListener(this);

// create message handlermessageHandler = new

ChordMessageHandler(this);

// add message handler to the listeners listthis.getTransLayer().addTransMsgListener(this.messageHandler, this.getPort());

}

In the ChordMessageHandler

– Check if received message type is know,

– React accordingly

Page 50: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 50

The ChordMessageHandler: Processing of MessagesIn the ChordMessageHandler

– Check if received message type is know,

– React accordingly

Here the example of the processing of a LookupMessage is shown

public void messageArrived(TransMsgEvent receivingEvent) {

if (msg instanceof AbstractRequestMessage) {...}

// request messagesif (msg instanceof LookupMessage) {

LookupMessage lookupMsg = (LookupMessage) msg;

handleLookupMsg(lookupMsg);sendAck(msg, receivingEvent, true);

}

else if (msg instanceof JoinMessage) {...}else if (msg instanceof HandshakeMsg) {...}else if (msg instanceof RetrievePredecessorMsg) {...}else if (msg instanceof RetrieveSuccessorMsg) {...}else if (msg instanceof NotifyPredecessorMsg) {...}else if (msg instanceof NotifySuccessorMsg) {...}else if (msg instanceof NotifyOfflineMsg) {...}else if (msg instanceof LeaveMessage) {...}// reply messageselse if (msg instanceof LookupReply) {...}// messages used to confirm to the DHTNode interfaceelse if (msg instanceof StoreMessage) {...} else if (msg instanceof ValueLookupMessage){...} // download messages:if (msg instanceof InitializeDownloadMessage) {...} }

Page 51: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 51

Example for the Lookup Operation

Page 52: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 52

Example for the Join Operation

Page 53: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 53

Observing what is happening Analyzers

Analyzers are informed everytime something relevant happens

Their task:– Create statistics

• Received messages• In / out bandwidth• Hop count in lookups ...

– Write periodically statistics to file

Page 54: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 54

Example for Analyzers

Page 55: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 55

Example of a successfull Lookup

When initiating, forwarding and finishing a lookup

– Analyzers is called– Analyzers create statistics

Initiating a lookup: Finishing a lookup:

In org.peerfact.impl.overlay.dht.chord.base.components.AbstractChordNode

public int nodeLookup(ChordKey key, OperationCallback<List<AbstractChordContact>> callback,

boolean returnSingleNode) {

if (!(key != null)) { return -1; }

// Inform the monitors about an initiated querySimulator.getMonitor().dhtLookupInitiated(

getLocalOverlayContact(), key);

return overlayNodeLookup(key.getCorrespondingID(),callback);}

In org.peerfact.impl.overlay.dht.chord.base.operations.LookupOperation

public void deliverResult(AbstractChordContact responsibleContact1,ChordID targetKey, int lookupOperationID, int hopCount) {

lookupHopCount = hopCount;this.responsibleContact = responsibleContact1;responsible.add(0, responsibleContact1);

Simulator.getMonitor().dhtLookupFinished(

this.getComponent().getLocalOverlayContact(),targetKey.getCorrespondingKey(),responsible, hopCount);

if (!isFinished()) {

masterNode.removeLookupOperation(getLookupId());operationFinished(true);

}}

Page 56: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 56

Summary

PeerfactSim.KOM– Event-based P2P system simulator, written in Java– Focus on layered p2p systems

Getting started– http://www.peerfact.org– Getting Started Document

• https://peerfactsimkom-community.googlecode.com/git-history/documentation/PeerfactSim.KOM__Getting-Started/PeerfactSim.KOM__Getting-Started.pdf

– Three ways of starting the simulator

Modifying / extending the code– https://code.google.com/p/peerfactsimkom-community/– For questions: the forum– https://groups.google.com/forum/?fromgroups#!forum/peerfactsim-kom

Page 57: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 57

YouTube Channel of Kalman Graffi

http://www.youtube.com/user/KGraffi

Page 58: PG DynaSearch · • Improvement of the Quality of Peer-to-Peer Systems by Systematically Researching Quality Features and Their Interdependencies Type – Event-based simulator –

Graffi ▪ Benter Heinrich Heine Universität Düsseldorf ▪ Universität Paderborn 12/11/13 58

Thanks for Your Attention

More information at http://www.peerfact.org