34
Project funded by the Future and Emerging Technologies arm of the IST Programme The BISON Project and the PeerSim P2P simulator Gian Paolo Jesi ([email protected]) Complex Adaptive Systems (CAS) Course Lecture

The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

Project funded by the Future and Emerging Technologies arm of the IST Programme

The BISON Project and the PeerSim P2P simulator

Gian Paolo Jesi ([email protected])

Complex Adaptive Systems (CAS) Course Lecture

Page 2: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 2

Summary:

BISON project introduction Acheived goals and results PeerSim simulator introduction PeerSim basic concepts PeerSim search framework tutorial Conclusions

Page 3: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 3

BISON Introduction(1/4)

BISON is a three-year Project (IST-2001-38923) funded by the Information Society Technologies Programme of the European Commission.

Since January 2003 (ends in December 2005) http://www.cs.unibo.it/bison Partners:

University of Bologna Telenor Communication AS Technical University of Dresden IDSIA SFI (out!)

Page 4: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 4

BISON Introduction(2/4)

BISON motivation: The modern Network Information Systems (NIS)

are too complex => traditional management techniques may fail due to: Huge system size (~millions users/devices); Complex interactions between components; Minor troubles somewhere may lead to

catastrophic, global failures;

Page 5: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 5

BISON Introduction(3/4)

What do we need?

A new paradigm to build self-organizing and self-repairing systems;

Biological inspiration (e.g.: from social insects, immune networks,...);

Promote the emergence of higher level properties (self-* properties) without explicit coding;

Page 6: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 6

BISON Introduction(4/4)

BISON goals:

Use of CAS techniques to build distributed systems;

Design solutions targeted to ad-hoc, P2P and grid networks;

Give guidelines to build CAS that perform the desired behaviour and properties;

Page 7: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 7

BISON Progress Areas

Topology management; T-Man, SuperPeer (2 flavours)

Aggregation; Gossip scheme

Load balancing (aggregation based); Ant, Chemotaxis, diffusion

Searching; Random walk, mutation based,...

Virtual path quality monitoring and management

Page 8: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 8

PeerSim Introduction (1/4)

PeerSim is an open source, Java based, P2P simulation framework aimed to develop and test any kind of P2P algorithm in a dynamic environment.

http://peersim.sf.netMain features: Scales up to 1 million peers; Highly configurable; Open architecture and component based;

Page 9: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 9

PeerSim Introduction (2/4)

Documentation: JavaDoc and tutorials available online.

Support: help web based mailing list available on sourceforge.

Peersim popularity is growing day by day: 59 downloads in December 2004.

All the algorithms developed in the Bison project have been developed and tested on Peersim.

Page 10: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 10

PeerSim Introduction (3/4)

Peersim supports 2 kind of simulation: Cycle based: the simulation runs in a sequential

order and in each cycle each protocol can run its behaviour.

Event based: support for concurrency; a set of events (messages) are scheduled and the node protocols are run accordingly to the message delivery.

Page 11: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 11

Peersim Introduction (4/4)

Peersim limits: Ignores the details of the transport

communication protocol stack Messages are not modeled by default (we

invoke object methods instead), but the developer is free to implement them.

Page 12: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 12

Components

Peersim is component based (nothing to deal with CORBA or .NET componet idea).

Components are “pluggable”.

Main Component types: Protocol Dynamics (and Initializers) Observer

Page 13: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 13

Protocol Component

It is the protocol behaviour core that the designer have to write.

Means implementing the peersim.cdsim.CDProtocol or peersim.edsim.EDProtocol interface (only 1 method).

Many protcols can run on every node. Each protocol has an identifier (ID), the same ID

at each node (NOTE: this may cause troubles to newbies).

Page 14: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 14

Dynamics Component

Used to add dynamism; they have global view of the system.

Means implementing the peersim.dynamics.Dynamics interface (only 1 method).

A Dynamics can be used as an Initializer (e.g.: to initialize peer views).

Examples: used to reset node status or to simulate random node crashes.

Page 15: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 15

Observer Components

Used to log important informations about the system; they have global view.

Means implementing the peersim.reports.Observer interface (only 1 method).

Each observer can use the peersim internal log facility to produce consistent data log during simulations.

Page 16: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 16

Basic Structures

Node: basic element of a network, is an interface defining basic operations on neighbor views. A basic node impl. is given.

Network: global array of Nodes, it represents the whole partecipants set.

Linkable: an interface to let public access to a protocol neighborhood.

Scheduler: objects that wrap any Protocol, Dynamics and Observer to supply scheduling facilities during the simulation (e.g.: Initializers are automagically scheduled at the beginning).

Page 17: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 17

Configuration

A configuration file is a standard ASCII text file. Example:# random.seed 1234567890 simulation.cycles 30 simulation.shuffle overlay.size 50000 overlay.maxsize 100000

protocol.0 peersim.core.IdleProtocol protocol.0.degree 20

protocol.1 example.aggregation.AverageFunction protocol.1.linkable 0

init.0 peersim.init.WireRegularRandom init.0.protocol 0 17 init.0.degree 20

init.1 example.loadbalance.LinearDistributionInitializer init.1.protocol 1 init.1.max 100 init.1.min 1

observer.0 example.aggregation.AverageObserver observer.0.protocol 1

Page 18: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 18

Configuration

Another example:simulation.cycles 30simulation.shuffleoverlay.size 50000overlay.maxsize 200000 protocol.0 example.newscast.SimpleNewscastprotocol.0.cache 20protocol.1 example.aggregation.AverageFunctionprotocol.1.linkable 0

init.0 peersim.dynamics.WireRegularRandominit.0.protocol 0init.0.degree 20init.1 example.loadbalance.LinearDistributionInitializerinit.1.protocol 1init.1.max 100init.1.min 1

observer.0 example.aggregation.AverageObserverobserver.0.protocol 1

dynamics.0 peersim.dynamics.GrowingNetworkdynamics.0.add -500dynamics.0.minsize 4000dynamics.0.from 5dynamics.0.until 10

Page 19: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 19

Peersim Search Framework Tutorial

Outline:

The idea

The components we are going to code

A simple random walk protocol

Page 20: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 20

The Search Framework Idea

Provide a set of general services for P2P search algorithm: Pick a neighbor, send/forward a query, common

init facilities, abstracting the query messages Each node has:

a repository (set) of documents (keys) a query distribution (may contains 1+ keys to

search for) At most 1 query can be started by any node at

every cycle.

Page 21: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 21

Components to code

SearchProtocol base class; every search protocol should inherit from this one.

Initializer: to bootstrap the data set (storage & query)

Observer: to collect data (e.g.: query hits, duplicate packets,...)

SMessage class: to abstract the query mesage; it contains the query and other message parameters (ttl, sender, ts, type,...)

Page 22: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 22

Data Structures Involved

MessageTable: hashtable tracking how many times a packet has been seen by the current node;

HitTable: stores the packets for which there is a hit;

IncomingQueue: inbound query messages; View: usual P2P neighborhood; KeyStorage: maps the frequency for each key; QueryDistro: holds the query to produce for

each cycle;

Page 23: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 23

SearchProtocol

Active Behaviour: Injects query

according to the distro Handled by the

NextCycle()

Passive Bahaviour: Reacts to the incoming

messages (collected in a queue)

Handled by NextCycle() and by the process() abstract method

Implements: peersim.cdsim.cdprotocol & peersim.core.Linkable;

Basic services: send(), forward(), matches(), getRNDNeighbor(), ...

Page 24: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 24

Search Protocol Code (1/3)

public void nextCycle(Node node, int protocolID) { int currentTime = CommonState.getCycle(); if (currentTime == 0) whoAmI = node;

Iterator iter = incomingQueue.iterator(); while (iter.hasNext()) { SMessage mes = (SMessage) iter.next(); if (mes.hops == (currentTime - mes.start + 1)) continue; Integer actual = (Integer) this.messageTable.get(mes); int index = (actual != null ? actual.intValue() + 1 : 1); this.messageTable.put(mes, new Integer(index)); this.process(mes); iter.remove(); } }

public abstract void process(SMessage mes);

Page 25: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 25

Search Protocol Code (2/3)

public void send(Node n, SMessage mes) { try { SMessage copy = (SMessage) mes.clone(); copy.hops++; this.messageTable.put(mes, new Integer(1)); SearchProtocol sp = (SearchProtocol) n.getProtocol(pid); sp.incomingQueue.add(copy); } catch (CloneNotSupportedException ex) ex.printStackTrace(); }

public void forward(Node n, SMessage mes) {

if (mes.hops < ttl) { try { //clone message and update TTL: SMessage copy = (SMessage) mes.clone(); copy.hops++; SearchProtocol sp = (SearchProtocol) n.getProtocol(pid); copy.type = SMessage.FWD; sp.incomingQueue.add(copy); } catch (CloneNotSupportedException cnse) System.out.println("Troubles with message cloning...!"); } }

Page 26: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 26

Search Protocol Code (3/3)

protected int[] matches(int[] keys) { int[] result = null; ArrayList temp = new ArrayList(); for (int i = 0; i < keys.length; i++) { if (this.keyStorage.containsKey(new Integer(keys[i]))) temp.add(new Integer(keys[i])); } if (temp.size() > 0) { result = new int[temp.size()]; for (int i = 0; i < temp.size(); i++) result[i] = ((Integer) temp.get(i)).intValue(); } return result; }

public void addQueryData(int cycle, int[] keys) { this.queryDistro.put(new Integer(cycle), (Object) keys); }

public void addKeyStorage(Map entry) { this.keyStorage.putAll(entry); }

Page 27: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 27

Linkable Interface Implementation

public boolean addNeighbor(peersim.core.Node neighbour) { view.add(neighbour); return true; }

public boolean contains(peersim.core.Node neighbor) { return this.view.contains(neighbor); }

public int degree() { if (pid == linkID) return this.view.size(); else { Linkable l = (Linkable) whoAmI.getProtocol(linkID); return l.degree(); } }

public peersim.core.Node getNeighbor(int i) { Node result = null; if (pid == linkID) { result = (Node) this.view.get(i); } else { // uses another Linkable Linkable l = (Linkable) whoAmI.getProtocol(linkID); result = l.getNeighbor(i); } return result; }

Page 28: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 28

SearchDataInitializer

Features handled by the initializer: keywords: the number of distinct keywords; query_nodes: how many nodes can emit

queries (default = network size); max_queries: the maximum number of queries

emitted by a single node (default = unlimited); query_interval: average time interval between

queries (default = 10); and_keys: if a match is in and or not;

Page 29: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 29

SMessage Code:

public class SMessage implements Cloneable { public static final int QRY = 0; public static final int FWD = 1; public

static final int HIT = 2; private static int seq_generator = 0; public int hops, type, seq, start; public Node originator; // the query producer public int[] payload; // an array of keys

public SMessage(Node originator, int type, int hops, int[] payload) { this.originator = originator; this.type = type; this.hops = hops; this.payload = payload; this.seq = ++seq_generator; this.start = CommonState.getCycle(); }

public Object clone() throws CloneNotSupportedException { SMessage m = (SMessage) super.clone(); return m; }

public int hashCode() { return seq; }

public boolean equals(Object obj) { return (obj instanceof SMessage) && (((SMessage) obj).seq == this.seq); }}

Page 30: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 30

The Observer

The Idea is that for each node the MessageTable is scanned and for each node seen, a special statistic object is created;

After the collectiong phase the following is printed for each query: Sequence number; Age of the query; Number of nodes having see the query; Number of hits; Number of messages sent on behalf of this

query;

Page 31: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 31

Random Walk Search Protocol

Implements a basic (stupid) random walk search;

Based on top of SearchProtocol;

What to do? Implement the process() abstract method to

handle any incoming query packet; Define your own active search strategy rewriting

NextCycle(), but call the superclass NextCycle() as a first step!

Page 32: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 32

RW Search Protocol Code

public class RWProtocol extends SearchProtocol { public static final String PAR_WALKERS = "walkers"; protected int walkers;

public RWProtocol(String prefix, Object obj) { super(prefix, obj); walkers = Configuration.getInt(prefix+"."+PAR_WALKERS, 1); } public void process(SMessage mes) { boolean match = this.match(mes.payload); if (match) this.notifyOriginator(mes); Node neighbor = this.getRNDNeighbor(); this.forward(neighbor, mes); } public void nextCycle(peersim.core.Node node, int protocolID) { super.nextCycle(node, protocolID); int[] data = this.pickQueryData(); // if we have to produce a query... if (data != null) { SMessage m = new SMessage(node, SMessage.QRY, 0, data); for (int i = 0; i < this.walkers && i < this.degree() ; i++) { this.send((Node) this.getNeighbor(i) , m); } } }

Page 33: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 33

Isearch Configuration

random.seed 1234567890simulation.cycles 300simulation.shuffle

overlay.size 100

protocol.search isearch.RWProtocolprotocol.search.ttl 100

init.0 peersim.dynamics.WireRegularRandominit.0.protocol searchinit.0.degree 10

init.1 isearch.SearchDataInitializerinit.1.protocol searchinit.1.keywords 10000init.1.query_nodes 100init.1.query_interval 1init.1.max_queries 1init.1.and_keys 0

observer.0 isearch.SearchObserverobserver.0.protocol searchobserver.0.verbosity 1observer.0.clean_cache

Page 34: The BISON Project and the PeerSim P2P simulatorbabaoglu/courses/cas04-05/slides/BISON-PeerSim.… · 06/04/05 13 Protocol Component It is the protocol behaviour core that the designer

06/04/05 34

Links:

Bison project publication list:http://www.cs.unibo.it/bison/pubs/list.shtml

iSearch cvs (pserver): [email protected]:/home/cvs/rep

Peersim site: http://peersim.sf.net Peersim tutorials:

http://peersim.sourceforge.net/#docs Delis project: http://delis.upb.de/