pongsim_ri_app
index
u:\f\project - pongsim\pongsim850\pongsim_ri_app.py

PONGsim (Python Overlay Network Graphical Simulator)
Module simulating the Routed Index approach
 
Version: 1.60
 
Nicklas Beijar, nbeijar@netlab.tkk.fi
Networking Laboratory, Helsinki University of Technology
 
######################################################################
 
Simulator for distribution algorithms for fully distributed user groups
 
Copyright (c) 2005-2007 Nicklas Beijar
 
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
 
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
 
######################################################################
 
To do:
- Everything

 
Modules
       
bisect
pongsim
pongsim_bloom
pongsim_resources
pongsim_sil
random

 
Classes
       
pongsim_resources.Resources
RIApplication(pongsim_sil.SILApplication, pongsim_resources.Resources)
OverlayTopology
pongsim_sil.SILApplication(pongsim.Application)
RIApplication(pongsim_sil.SILApplication, pongsim_resources.Resources)

 
class OverlayTopology
    A class for storing one node's view of the group's topology.
 
Stores the link table of the group, which is used to calculate a routing table.
 
  Methods defined here:
__init__(self, node)
Initialize the topology rooted in the given node.
__str__(self)
Return a multi-line string representation of the routing table.
calculate(self)
Calculate a new routing table using Dijkstra's algorithm.
distance(self, node)
Return the distance to the given node.
isreachable(self, node)
Return True if the given node is reachable, otherwise False.
update(self, node, neighbors)
Update the link table with the given node's given neighbors.

 
class RIApplication(pongsim_sil.SILApplication, pongsim_resources.Resources)
    
Method resolution order:
RIApplication
pongsim_sil.SILApplication
pongsim.Application
pongsim_resources.Resources

Methods defined here:
forceupdate(self)
Force an update to all known peers as a result of index change.
 
No need to schedule updates to peers that anyway will receive an update soon.
generate_update(self, node)
Generate and send an update message to the given node.
getdetailedinfo(self)
Return the the node's description that is written in a separate window when the node is examined.
getdisplayinfo(self)
Return the text written beside the node.
init(self)
Initialize the application.
on_added_resource(self, resource)
Handle an added resource.
 
Called by the Resources class when a resource has been added. 
The RI application forces an update to all known peers.
on_receive_ack(self, msg)
Handle a received ack message.
on_receive_query(self, msg)
Handle received search requests.
on_receive_response(self, msg)
Handle a received search reply. 
 
Count the answers.
on_receive_update(self, msg)
Handle a received update message.
on_removed_resource(self, resource)
Handle an removed resource.
 
Called by the Resources class when a resource has been removed. 
The RI application forces an update to all known peers.
on_search_request(self, resource, searchid)
Handles a search request generated by the node. 
 
Called by the Resources class when a resource request is generated.
outofbanddata(self, key, value)
Set the data that is agreed without any protocol (operator agreements) or manually configured.
 
Corresponds to the user/administrator configuring the application.
receivegeneral(self, ttl, type, id, msg)
Handle reception of a general message and call the corresponding handler. 
 
Called by the SIL framework.

Data and other attributes defined here:
UPDATE_REQUEST = 1
UPDATE_RESPONSE = 2

Methods inherited from pongsim_sil.SILApplication:
addindexlink(self, dest, ttl=255)
Add a index link from this node to the destination node.
addlink(self, dest, index, search, indexttl=255, searchttl=255)
Add a search or index link (or both) from this node to the destination node.  
 
For an index link: index = True, indexttl defined (default 255)
For a search link: search = True, searchttl defined (default 255)
If there already exists a link to the given node, that is updated.
addsearchlink(self, dest, ttl=255)
Add a search link from this node to the destination node.
draw(self, canvas, x, y)
Draw the application-specific details - here the search and index links.
floodindex(self, msg, ttl=None, id=None)
Send a index update message using flooding. 
 
If no ttl is specified, the link-specific one is used. If no id is specified, a random one is generated. 
NOT to be subclassed.
floodsearch(self, msg, ttl=None, id=None)
Send a search message using flooding. 
 
If no ttl is specified, the link-specific one is used. If no id is specified, a random one is generated. 
NOT to be subclassed.
forwardindex(self, msg, destinations, ttl=None, id=None)
Forward a previously received index update message using flooding.
 
If no ttl is specified, the link-specific one is used. NOT to be subclassed.
forwardsearch(self, msg, destinations, ttl=None, id=None)
Forward a previously received search message using flooding.
 
If no ttl is specified, the link-specific one is used. NOT to be subclassed.
getindexneighbors(self, exclude=None)
Return the neighbors to which this node has an index link, excluding an optional node.
getsearchneighbors(self, exclude=None)
Return the neighbors to which this node has a search link, excluding an optional node.
isnew(self, id)
Returns True if the message with the given id has been forwarded earlier by this node.
 
Remembers the current id. NOT recommended to be subclassed, but CAN be subclassed to skip checking.
receive(self, packedmsg)
Handle received message.
 
This function is called by the Node when a message is received. The SIL framework handles
index, search and generic messages separately. NOT to be subclassed.
receiveindex(self, ttl, msg, destinations, firsthop, previoushop)
Handle received index requests.
 
Determines the nodes to which the message is forwarded from the candidate destinations based on 
the index strategy. Returns a list of (msg, destination) tuples, where msg is the (possibly modified) 
message to be forwarded to the nodes in the destination list. To be subclassed.
receivesearch(self, ttl, msg, destinations, firsthop, previoushop)
Handle received search requests.
 
Determines the nodes to which the message is forwarded from the candidate destinations based on 
the search strategy. Returns a list of (msg, destination) tuples, where msg is the (possibly modified) 
message to be forwarded to the nodes in the destination list. To be subclassed.
remove(self)
Remove node.
removealllinks(self)
removeindexlink(self, dest)
Remove a index link from this node to the destination node.
removelinks(self, dest)
Remove a search link from this node to the destination node.
removesearchlink(self, dest)
Remove a search link from this node to the destination node.
sendgeneral(self, msg, dest, type=0, ttl=None, id=None)
Send a message of other type to a specified node.
 
Messages are sent directly to the destination - there is no need for a search/index link path to the destination. 
TTL and ID defaults to None, since these messages are not affected by flooding. They can be used for 
an application-specific purpose. Type can be any integer, except for the reserved values (1 and 2), defaulting to 0. 
NOT recommended to be subclassed.

Methods inherited from pongsim.Application:
__init__(self, node)
Initiate the application.
 
The original function MUST be called from an overriding function. A better approach
is to override the init() function.
send(self, message, destination=None)
Send the given message to the given destination.

Methods inherited from pongsim_resources.Resources:
addresource(self, dummy=None)
Add a resource to the node. 
 
Adds a random resource, id defined by the scenario-parameters dynamicresourcefrom and dynamicresourceto.
If dynamicresourceto is undefined, nrofresources is used as upper limit. 
Schedules itself again after interval defined in the scenario-parameter indexaddinterval.
Schedules removal of the added resource after interval defined in the scenario-parameter indexremoveinterval
(or in indexaddinterval if indexremoveinterval is undefined).
generate_search(self, dummy=None)
Generate a search request, which is flooded on the search links. 
 
Scheduled calling, with rescheduling.
generateresources(self, count=None)
initialresources(self, resources)
Add the given resources as the initial resources.
removeresource(self, resource)
Remove a resource from the node.
reportfound(self, searchid, where)
Reports a found resource and collect statistics.
timeoutsearch(self, searchid)
Examine the search results collected during the search, and collect statistics about the search.
 
Called when a given time has expired since the search was initiated. A search request timed out with either results or without results.

Data and other attributes inherited from pongsim_resources.Resources:
nextsearchid = 1

 
Data
        MSG_ACK = 11
MSG_SEARCH_QUERY = 12
MSG_SEARCH_RESPONSE = 13
MSG_UPDATE = 10