Outline Simulating overlay networks with PeerSim Introduction to Peersim

Outline
Simulating overlay networks with
PeerSim
! Introduction
to Peersim
– What is Peersim
– Peersim components
! Aggregation
– What is aggregation
– Average in Peersim
Andrea Marcozzi
06/03/2008
Dipartimento di Scienze
dell’Informazione, Università di
Bologna
! SLAC
– Tags
– What is SLAC
– SLAC in Peersim
0
1
What is PeerSim?
Introduction: P2P Systems
!
! Peer-to-Peer
systems are potentially
huge (composed of millions of nodes);
! Nodes join and leave the network
continuously;
! Evaluating a new protocol in a real
environment is not an easy task
!
!
!
!
!
!
2
PeerSim is an open source P2P systems
simulator developed at the Department of
Computer Science, University of Bologna
It has been developed with Java
Available on Source Forge (peersim.sf.net)
Its aim is to cope with P2P systems
properties
High Scalability (up to 1 million nodes)
Highly configurable
Architecture based on pluggable components
3
Network Representation (I)
The Peersim Simulation Engine
! Peersim
Node 1
has two simulation modes:
– Event-driven: a set of events (messages) are
scheduled at different simulation time and
the node protocols are run accordingly to
messages’ delivery times
– Cycle-driven: sequential simulation, in each
cycle each protocol’s actions are executed
by every node (we will focus on this)
2
3
! Network:
global array which contains all
the network nodes
! Node: each node’s state and actions are
described through a stack of protocols.
Protocols are accessed through a Pid
! Linkable: interface used to access and
manage node’s view
n-2
n-1
n
Network
Node
Protocol 1 (Application)
!
Protocol 0 (Linkable)
!
4
Network Representation (II)
………
A node is a stack of
protocols
node.getProtocol(pid)
5
Network Representation (III)
! CDProtocol:
interface used to describe
node’s actions at each cycle. A generic
node can both perform local actions
(CDProtocol) and manage the local
view (Linkable)
! Control: performs the global initialization
and performances analysis
6
7
Main Interfaces: Protocol
! The
CDProtocol interface is used to
define cycle-driven protocols, that is the
actions performed by each node at
each simulation cycle
! Each node can run more than one
protocol
! Protocols are executed sequentially
Main Interfaces: Linkable
! Linkable
is used to manage node’s
view. Typical actions are:
– Add neighbor
– Get neighbor
– Node’s degree
– Remove neighbor
8
9
Peersim tree
Main Interfaces: Control
! SRC
! Control
is used to define operations that
require global network knowledge as:
– Initialization of the network and protocols
– Network dynamism
– Statistical analysis (observer)
10
contains the source
code of Peersim and of
some example protocols
(aggregation, newscast)
! The parameters for the
simulation are specified
by a Configuration File
11
Example: AverageFunction
1. AverageFunction
0. Newscast
Aggregation
By Aggregation we mean calculating a
certain function (eg. average) over a
number of values distributed over a
network
12
Example: AverageFunction (II)
! Each
node has a numeric value
! The aggregate value has to be known
by each node
! Local value of node i contains current
estimate of the average
! Node i select random peer j:
– i and j exchange estimates
– i and j update local estimate with the
average
14
13
Configuration File
01 #random.seed 1150540268549
02 simulation.cycles 300
03 control.shf Shuffle
04 network.size 50000
05
06 protocol.0 example.newscast.SimpleNewscast
07 protocol.0.cache 20
08 protocol.1 example.aggregation.AverageFunction
09 protocol.1.linkable 0
10 order.protocol 0 1
11
12 init.0 peersim.dynamics.WireKOut
13 init.0.protocol 0
14 init.0.k 20
15
16 init.1 example.aggregation.PeakDistributionInitializer
17 init.1.protocol 1
18 init.1.value 10000
19
20 control.ob0 aggregation.AverageObserver
21 control.ob0.protocol 1
General settings
Protocols settings
Control settings
15
Config File: Protocol Settings
Config File: General Settings
06 protocol.0 example.newscast.SimpleNewscast
07 protocol.0.cache 20
08 protocol.1 example.aggregation.AverageFunction
09 protocol.1.linkable 0
10 order.protocol 0 1
01 #random.seed 1150540268549
02 simulation.cycles 300
03 control.shf Shuffle
04 network.size 50000
!
!
!
!
Line 01: define the seed to be used. If not
defined uses a random seed;
Line 02: defines the number of cycles
Line 03: if defined, shuffles the Network array at
the beginning of each cycle
Line 04: defines the Network size
!
!
!
!
!
Line 06: define protocol 0 as Newscast
Line 07: define protocol 0’s variable cache (it is the
view size)
Line 08: define protocol 1 as the application
calculating average aggregation
Line 09: indicates that the linkable is Newscast (0)
Line 10: indicated the order for protocols execution
16
Config File: Control Settings
17
Aggregation: execution
12 init.0 peersim.dynamics.WireKOut
13 init.0.protocol 0
14 init.0.k 20
15
16 init.1 example.aggregation.PeakDistributionInitializer
17 init.1.protocol 1
18 init.1.value 10000
19
20 control.ob0 aggregation.AverageObserver
21 control.ob0.protocol 1
!
!
!
Lines 12 - 14: protocol 0 initialization
Lines 16 - 18: protocol 1 initialization
Lines 20 - 21: protocol 1 observer
18
On the ReadMe file in the Peersim home directory there are the
instructions for running the example
19
Peersim Scheduler
! Hence
a Peersim simulation is
scheduled in this way:
Initializers execution
while (time < cycles)
for each node in the Network
CDProtocol actions are executed
end foreach
Control actions are executed
end while
20
Implementing AverageFunction
01. public void nextCycle(Node node, int protocolID) {
02. int linkableID = FastConfig.getLinkable(protocolID);
03. Linkable linkable = (Linkable) node.getProtocol(linkableID);
04.
if (linkable.degree() > 0) {
05.
Node peer = linkable.getNeighbor(CommonState.r
.nextInt(linkable.degree()));
06.
07.
// Failure handling
08.
if (!peer.isUp()) return;
09.
10.
AverageFunction neighbor =
(AverageFunction)peer.getProtocol(protocolID);
11.
double mean = (this.value + neighbor.value) / 2;
12.
this.value = mean;
13.
neighbor.value = mean;
}
}
21
SLAC: Introduction
! SLAC
is an evolutionary algorithm whose
aim is to promote Cooperation in P2P
systems
! Inspired by Computational Sociology
(Tag systems)
! Tested with the “Prisoner’s Dilemma”
SLAC
(Selfish Link and behavioural
Adaptation to produce Cooperation)
– Simple 2 player game
– Represents contradiction between
selfishness of the players and global benefit
22
23
What are Tags?
The Prisoner’s Dilemma (PD)
Player 1
1.9
1
0.1
0
Strategy
DC
CC
DD
CD
! Studied
by computational sociology
(Holland 1992)
! Tags are observable markings (hair
style, clothes…)
! Tags evolve just like any other artificial
trait
! Limiting interactions between agents
with similar tags leads to cooperative
altruistic behaviour
Player 2
0
1
0.1
1.9
!D
= Defect; C = Cooperate
! PD Constraints:
– DC > CC > DD > CD
– 2CC > DC+CD
24
25
Tag Systems’ agents
!
!
!
Each agent in a Tag system is identified by a “Tag” (it
may be a set of bits)
Each agent has a “behaviour” (it may simply be to
cooperate or defect)
Each agent has an “utility”
Mutation
! Mutation
of the tag:
– Changing some traits (i.e. some bits)
! Mutation
of the strategy:
– Flipping the strategy bit (from cooperation
to defection or vice-versa)
- Selfish optimization: agents copy tags and behaviour of
those performing better (with higher utility)
- Periodically tags and strategies are mutated with a
certain probability
26
27
Tag systems’ evolutionary
algorithm
From Tags to Networks (P2P)
! Agents
are nodes
! Tags are represented by the node’s view
(we consider this as a kind of tag)
LOOP some number of generations
LOOP for each agent (a) in the population
Select a game partner agent (b)
Agent (a) and (b) invoke their strategies
receiving the appropriate payoff
END LOOP
Reproduce agents in proportion to their
average payoff
Apply mutation to tag and strategy of each
reproduced agent with low probability
END LOOP
Interaction phase
-
Evolution phase
– Interaction is between neighbors
! Behaviour
– File sharing (share files or free riding)
– Prisoner’s Dilemma (cooperate or defect)
! Utility
!
!
28
SLAC is an attempt to move tags in P2P
networks
Nodes performs some application task (file
sharing, PD) and get some utility
The nodes move to find better neighbors
29
SLAC Pseudocode
Each node i periodically with a certain probability:
j := selectRandomPeer();
if U j >U i
drops all its current links
links to node j and copy j’s strategy and links
mutate (with low probability) links and strategy
end if
– The links and the strategy of the nodes with better
performances (higher utility) are copied
– The topology of the network evolves
!
evaluated at application level
– File sharing: number of files downloaded
– PD: outcome given by the payoffs matrix
SLAC
!
defined by the application
Groop-like selection between clusters of nodes
– Groups of good guys spread
– Selfish nodes become isolated
30
!
Mutation: i drops all its links and connects to a
random node
Random Peer given by Newscast
31
Copy and Rewire - Mutation
SLAC simulations
! SLAC
has been implemented in
Peersim on top of Newscast (random
sampling for utility comparison)
! The abstract application used for testing
SLAC is the PD
– Each node has a strategy (C / D)
– At each Peersim cycle nodes play a single
round with a random neighbor
! At
the end of each cycle, SLAC is
invoked
32
33
SLACER (I)
SLACER (II)
! SLACER
is a variant of SLAC
! In SLAC when a node moves, it first
drops all its link
! In SLACER when a node moves, it drops
its links with a certain probability W
! If W = 1, then SLACER == SLAC
34
! Drop
probability value leads to different
kind of topology:
– W = 1, highly partitioned network
(disconnected);
– W = 0.9, SmallWorld-like network
– Low W, random network (more robust, less
cooperation)
35
SLAC(ER) architecture
#random.seed 1150540268549
simulation.cycles 300
control.shf Shuffle
network.size 4000
Three protocol: Newscast,
SLACER, PDapp
2. PDapp
(Application)
Cooperative
neighbor
Random node
(movement)
Configuration File (I)
utility
protocol.0 example.newscast.SimpleNewscast
protocol.0.cache 20
protocol.1 slacer.Slacer
protocol.1.degree 20
protocol.1.linkable 0
protocol.1.application 2
protocol.1.reprprob 0.20
protocol.1.mutation 0.001
protocol.1.tagmutation 0.01
1. SLACER
0. Newscast
(Peer Sampling Service)
General settings
Protocols settings
protocol.2 slacer.PdApp.PdProtocol
protocol.2.linkable 1
36
37
Configuration File (II)
SLAC experiments (I)
init.0 peersim.dynamics.WireKOut
init.0.protocol 0
init.0.k 20
init.1 slacer.SlacerInitializer
init.1.protocol 1
init.1.isolateprob 1
init.1.copyprob 1
init.2 slacer.PdApp.PdStrategyInitializer
init.2.protocol 2
init.2.quantity 0
Control settings
init.3 peersim.dynamics.WireKOut
init.3.protocol 1
init.3.k 20
control.ob0 slacer.BooleanStrategyObserver
control.ob0.protocol 2
control.ob1 slacer.PdApp.PdObserver
control.ob1.protocol 2
38
Cycles=4000; ReprRate=0.20; Single run
39
SLAC experiments (II)
Internet resources
! Peersim
resources page:
http://peersim.sf.net
! These slides on:
http://www.cs.unibo.it/~marcozzi
! Other similar slides:
http://www.cs.unibo.it/~arteconi
! For any questions:
[email protected]
Cycles for high cooperation (93%)
40
References
Hales, D. and Arteconi, S. (2006) Slacer: A self-organizing
protocol for coordination in p2p networks. IEEE Intelligent
Systems
! Jelasity, M., Montresor, A. and Babaoglu, O. (2005)
Gossip-based aggregation in large dynamic networks. In
ACM Transaction on Computer Systems (TOCS). Volume
23, Issue 3
! Marcozzi, A.; Hales, D.; Jesi, G.; Arteconi, S.; Babaoglu,
O. (2005) Tag-Based Cooperation in Peer-to-Peer
Networks with Newscast. In Self- Organization and
Autonomic Informatics (I), Volume 135 Frontiers in
Artificial Intelligence and Applications, Edited by: H. Czap,
R. Unland, C. Branki and H. Tianfield, IOS Press,
Netherlands
!
- Some of them available as UBLCS technical report at:
www.cs.unibo.it/research/reports/42
41