peer sim (p2p network)
TRANSCRIPT
What is PeerSim?
● Peer Simulator (PeerSim) is a simulation engine ○ Used to write network protocols for P2P (Peer-to-Peer) networks○ Scalable (up to 1 million nodes), portable and highly configurable ○ Open source Peer-to-Peer (P2P) system developed using Java ○ Developed at the department of Computer Science in University of Bologna
What is a simulation engine?
● An application on top of which we can write simulations, collect results and analyze them.
● The engine takes care of the temporal structure of the experiment● The programmer takes care of the logic of the interactions among the
elements of the scenario.● There are two modes of simulation engines: ● More on next slide!!
PeerSim Simulation Engines
● PeerSim 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 be focusing on this)
Aim
● To create new protocol○ protocols to find Min & Max in the network
● To explore PeerSim package
Objectives
● To create new protocols to generate networks with the maximum and minimum value.
○ create package for new codes○ create two classes for Min and Max protocols○ create observer classes○ create Max and Min configuration files ○ visualise the topology of the network
Key themes/Ideas
● Key theme and idea was to calculate Max and Min values that exists within the network
● Source of idea - Average function ??● More on next slides!!!
Average Function
● Calculates average between two interacting nodes, and assign that value to them.
● Perform that computation at every node in each cycle.● After certain amount of time, all the average values in the network converge.
Min/Max Function
● Finds min/max value between two interacting nodes, and assign that value to them.
● Perform that computation at every node in each cycle.● After certain amount of time, all the values in the network become (the same)
min/max.
MaxFunction and MinFunction
● Took AverageFunction class as example to create MaxFunction and MinFunction
Observer classes
● Based on AverageObserver, we created two different observer classesa. node values in the network (NodeValuesObserver)b. similar to average observer (MaxMinObserver)
NodeValuesObserver
● observes the values at each node in all the cycles. ○ to see how the values of the nodes change over time
NodeValuesObserver● same as AverageObserver,
except execute() method,● use MedianStats Object
○ to print out all the values in node
○ more about MedianStats in next slide
● line 111○ protocol name○ cycle
● line 112 - 114: print node values
● line 115: number of nodes
MedianStats and IncrementalStats
● included in peersim.util package● IncrementalStats - keep track of statistics about the network
○ average, min, max, etc.
● MedianStats - extends IncrementalStats○ can retrieve median element○ STORE all the elements (ArrayList)○ we added a getter method to retrieve all the elements
MaxMinObserver
● Observe the statistics about the nodes at each cycle● Same as AverageObserver, except changes to what we want to see in output
MaxMinObserver● same as AverageObserver, except execute() method● MedianStats is used● line 112 - prints out only Minimum and Maximum values of the network and no. of nodes
Configuration File
● We wrote several configuration files with different components to learn more about PeerSim.
● Different components we tried will be preseneted in coming slides.
Configuration File
● Created configuration files based on Average configuration file for Max and Min
● simulation.cycles value are the number of cycles in the network
● network.size is the size of the network
Configuration File: Protocols
● Created new protocols to run Max and Min functions
● IdleProtocol is the topology of the network which determines the nodes and degree of network
● aMaxMin.MaxFuntion reads in the Max function and uses it to find the maximum value in the network
● IdleProtocol serve as a source of neighbourhood information for other protocols
● It stores links: useful to model a static link-structure
Configuration: Linking Nodes
● link nodes to form network● takes “linkable” protocol, add edges to define topology● WireKOut: adds random connection
○ Parameter: k - number of edges coming out of each node
Configuration: Assigning Values to Nodes
● assign values to the node during initilisation● ways to distribute values
○ provided in peersim.vector package○ PeakDistribution
■ parameter: peak - peak value■ assign peak nodes the peak value, the rest 0
○ LinearDistribution■ parameter: min and max■ assign values in the range (min & max) in linearly increasing manner from min to max
○ UniformDistribution■ parameter: min and max■ assign values in random from the range (min & max)
Configuration File: Visualisation
● used built-in GraphPrinter control○ provided in peersim.report package○ print the whole graph in given format
● two parameters○ outf - prefix of filename
■ extension - .graph■ prefix0000001.graph
○ format - format of output graph■ neighborlist: neighborlist■ edgelist: one node pair at each line for each edge■ gml: generic format for many graph tools
● We used Gephi to visualise the graph ○ change file name from .graph extension to .gml
Configuration File: Visualisation Example
Example .gml file
Graph visualised in GephiNodes = 1000, k = 10Edges = 10000
Configuration File: Statistics
● Used built-in DegreeStats control○ provided in peersim.report package○ statistics about the node degree in graph
● four parameters○ n: numbers of nodes for sampling degree○ method: method to print results
■ stats: statistics about degrees of graph (min degree, max degree, average degree, etc.)■ freq: frequency of degrees of graph■ list: lists degree of sampled nodes
○ linktype: type of links to print information about (live (default), dead, all)○ trace: trace the given number of nodes
Configuration File: Statistics ExampleExample print out to console using stats
Example print out to console using lists & n = 10
Example: freq & n = 25
Configuration File: Dynamic Network
● dynamically change the size of network○ add or remove nodes from the network
● line 31: adds DynamicNetwork control to configuration file.○ provided in peersim.dynamics package
● line 32: take out 500 nodes from network● line 33 & 34: when to add/remove nodes from network
Results - I
Network size: 10,000
Protocol: MaxFunction
Connection: WireKOut (k=30)
Observer: MaxMinObserver
Dynamic Network: remove 500 from cycle 1 till 5
Results - II
Network size: 10,000
Protocol: MinFunction
Connection: WireKOut (k=30)
Observer: MaxMinObserver
Dynamic Network: remove 500 from cycle 1 till 5
What have been achieved?
● Created Max/Min functions● Created two observer classes● Multiple configurations with different components● Visualised the graph
Observations
● the more the edges, the faster it reaches min/max/average of the network○ using the same configurations except k;
■ k=10, 20 cycles for all nodes to become minimum value■ k = 20, 14 cycles for all nodes to become minimum value■ k = 30, 12 cycles for all nodes to become minimum value
Benefits of PeerSim (P2P Network)
● Portability○ Possible to reuse simulation code with minor modification ○ Allows user defined entities to replace almost all predefined entities ○ highly configurable○ Architecture based on extendable and pluggable component features
● Scalability ○ Provides high scalability ○ Can simulate millions of network nodes ○ Can hold up a network up to 106 nodes in the cycle-based model ○ Able to solve problems related to scalability○ One of the major parameters on which a simulator can be analysed
Limitations of PeerSim
● Lacks support for simulating unstructured or semi-structured P2P routing protocols
● Ability to scale will be reduced if resources are not used efficiently ● Limited support for extending the simulator for protocols other than Bit
○ Difficult to implement other protocols as the simulator is tightly coupled to the Bittorrent protocol
● No support for distributed simulation ● Simulator makes use of main memory to store visualisation events
○ Limits the system performance in terms of nodes