icarus.execution package

Submodules

icarus.execution.collectors module

Performance metrics loggers

This module contains all data collectors that record events while simulations are being executed and compute performance metrics.

Currently implemented data collectors allow users to measure cache hit ratio, latency, path stretch and link load.

To create a new data collector, it is sufficient to create a new class inheriting from the DataCollector class and override all required methods.

class DataCollector(view, **params)[source]

Bases: object

Object collecting notifications about simulation events and measuring relevant metrics.

Methods

cache_hit(node) Reports that the requested content has been served by the cache at node node.
cache_miss(node) Reports that the cache at node node has been looked up for requested content but there was a cache miss.
content_hop(u, v[, main_path]) Reports that a content has traversed the link (u, v)
end_session([success]) Reports that the session is closed, i.e.
request_hop(u, v[, main_path]) Reports that a request has traversed the link (u, v)
results() Returns the aggregated results measured by the collector.
server_hit(node) Reports that the requested content has been served by the server at node node.
start_session(timestamp, receiver, content) Notifies the collector that a new network session started.
cache_hit(node)[source]

Reports that the requested content has been served by the cache at node node.

Parameters:

node : any hashable type

The node whose cache served the content

cache_miss(node)[source]

Reports that the cache at node node has been looked up for requested content but there was a cache miss.

Parameters:

node : any hashable type

The node whose cache served the content

content_hop(u, v, main_path=True)[source]

Reports that a content has traversed the link (u, v)

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that this link is being traversed by content that will be delivered to the receiver. This is needed to calculate latency correctly in multicast cases. Default value is True

end_session(success=True)[source]

Reports that the session is closed, i.e. the content has been successfully delivered to the receiver or a failure blocked the execution of the request

Parameters:

success : bool, optional

True if the session was completed successfully, False otherwise

request_hop(u, v, main_path=True)[source]

Reports that a request has traversed the link (u, v)

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that link link is on the main path that will lead to hit a content. It is normally used to calculate latency correctly in multicast cases. Default value is True

results()[source]

Returns the aggregated results measured by the collector.

Returns:

results : dict

Dictionary mapping metric with results.

server_hit(node)[source]

Reports that the requested content has been served by the server at node node.

Parameters:

node : any hashable type

The server node which served the content

start_session(timestamp, receiver, content)[source]

Notifies the collector that a new network session started.

A session refers to the retrieval of a content from a receiver, from the issuing of a content request to the delivery of the content.

Parameters:

timestamp : int

The timestamp of the event

receiver : any hashable type

The receiver node requesting a content

content : any hashable type

The content identifier requested by the receiver

class CollectorProxy(view, collectors)[source]

Bases: icarus.execution.collectors.DataCollector

This class acts as a proxy for all concrete collectors towards the network controller.

An instance of this class registers itself with the network controller and it receives notifications for all events. This class is responsible for dispatching events of interests to concrete collectors.

Methods

cache_hit(node) Reports that the requested content has been served by the cache at node node.
cache_miss(node) Reports that the cache at node node has been looked up for requested content but there was a cache miss.
content_hop(u, v[, main_path]) Reports that a content has traversed the link (u, v)
end_session([success]) Reports that the session is closed, i.e.
request_hop(u, v[, main_path]) Reports that a request has traversed the link (u, v)
results() Returns the aggregated results measured by the collector.
server_hit(node) Reports that the requested content has been served by the server at node node.
start_session(timestamp, receiver, content) Notifies the collector that a new network session started.
EVENTS = ('start_session', 'end_session', 'cache_hit', 'cache_miss', 'server_hit', 'request_hop', 'content_hop', 'results')
cache_hit(node)[source]

Reports that the requested content has been served by the cache at node node.

Parameters:

node : any hashable type

The node whose cache served the content

cache_miss(node)[source]

Reports that the cache at node node has been looked up for requested content but there was a cache miss.

Parameters:

node : any hashable type

The node whose cache served the content

content_hop(u, v, main_path=True)[source]

Reports that a content has traversed the link (u, v)

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that this link is being traversed by content that will be delivered to the receiver. This is needed to calculate latency correctly in multicast cases. Default value is True

end_session(success=True)[source]

Reports that the session is closed, i.e. the content has been successfully delivered to the receiver or a failure blocked the execution of the request

Parameters:

success : bool, optional

True if the session was completed successfully, False otherwise

request_hop(u, v, main_path=True)[source]

Reports that a request has traversed the link (u, v)

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that link link is on the main path that will lead to hit a content. It is normally used to calculate latency correctly in multicast cases. Default value is True

results()[source]

Returns the aggregated results measured by the collector.

Returns:

results : dict

Dictionary mapping metric with results.

server_hit(node)[source]

Reports that the requested content has been served by the server at node node.

Parameters:

node : any hashable type

The server node which served the content

start_session(timestamp, receiver, content)[source]

Notifies the collector that a new network session started.

A session refers to the retrieval of a content from a receiver, from the issuing of a content request to the delivery of the content.

Parameters:

timestamp : int

The timestamp of the event

receiver : any hashable type

The receiver node requesting a content

content : any hashable type

The content identifier requested by the receiver

class CacheHitRatioCollector(view, off_path_hits=False, per_node=True, content_hits=False)[source]

Bases: icarus.execution.collectors.DataCollector

Collector measuring the cache hit ratio, i.e. the portion of content requests served by a cache.

Methods

cache_hit(node) Reports that the requested content has been served by the cache at node node.
cache_miss(node) Reports that the cache at node node has been looked up for requested content but there was a cache miss.
content_hop(u, v[, main_path]) Reports that a content has traversed the link (u, v)
end_session([success]) Reports that the session is closed, i.e.
request_hop(u, v[, main_path]) Reports that a request has traversed the link (u, v)
results() Returns the aggregated results measured by the collector.
server_hit(node) Reports that the requested content has been served by the server at node node.
start_session(timestamp, receiver, content) Notifies the collector that a new network session started.
cache_hit(node)[source]

Reports that the requested content has been served by the cache at node node.

Parameters:

node : any hashable type

The node whose cache served the content

name = 'CACHE_HIT_RATIO'
results()[source]

Returns the aggregated results measured by the collector.

Returns:

results : dict

Dictionary mapping metric with results.

server_hit(node)[source]

Reports that the requested content has been served by the server at node node.

Parameters:

node : any hashable type

The server node which served the content

start_session(timestamp, receiver, content)[source]

Notifies the collector that a new network session started.

A session refers to the retrieval of a content from a receiver, from the issuing of a content request to the delivery of the content.

Parameters:

timestamp : int

The timestamp of the event

receiver : any hashable type

The receiver node requesting a content

content : any hashable type

The content identifier requested by the receiver

class LinkLoadCollector(view, req_size=150, content_size=1500)[source]

Bases: icarus.execution.collectors.DataCollector

Data collector measuring the link load

Methods

cache_hit(node) Reports that the requested content has been served by the cache at node node.
cache_miss(node) Reports that the cache at node node has been looked up for requested content but there was a cache miss.
content_hop(u, v[, main_path]) Reports that a content has traversed the link (u, v)
end_session([success]) Reports that the session is closed, i.e.
request_hop(u, v[, main_path]) Reports that a request has traversed the link (u, v)
results() Returns the aggregated results measured by the collector.
server_hit(node) Reports that the requested content has been served by the server at node node.
start_session(timestamp, receiver, content) Notifies the collector that a new network session started.
content_hop(u, v, main_path=True)[source]

Reports that a content has traversed the link (u, v)

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that this link is being traversed by content that will be delivered to the receiver. This is needed to calculate latency correctly in multicast cases. Default value is True

name = 'LINK_LOAD'
request_hop(u, v, main_path=True)[source]

Reports that a request has traversed the link (u, v)

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that link link is on the main path that will lead to hit a content. It is normally used to calculate latency correctly in multicast cases. Default value is True

results()[source]

Returns the aggregated results measured by the collector.

Returns:

results : dict

Dictionary mapping metric with results.

start_session(timestamp, receiver, content)[source]

Notifies the collector that a new network session started.

A session refers to the retrieval of a content from a receiver, from the issuing of a content request to the delivery of the content.

Parameters:

timestamp : int

The timestamp of the event

receiver : any hashable type

The receiver node requesting a content

content : any hashable type

The content identifier requested by the receiver

class LatencyCollector(view, cdf=False)[source]

Bases: icarus.execution.collectors.DataCollector

Data collector measuring latency, i.e. the delay taken to delivery a content.

Methods

cache_hit(node) Reports that the requested content has been served by the cache at node node.
cache_miss(node) Reports that the cache at node node has been looked up for requested content but there was a cache miss.
content_hop(u, v[, main_path]) Reports that a content has traversed the link (u, v)
end_session([success]) Reports that the session is closed, i.e.
request_hop(u, v[, main_path]) Reports that a request has traversed the link (u, v)
results() Returns the aggregated results measured by the collector.
server_hit(node) Reports that the requested content has been served by the server at node node.
start_session(timestamp, receiver, content) Notifies the collector that a new network session started.
content_hop(u, v, main_path=True)[source]

Reports that a content has traversed the link (u, v)

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that this link is being traversed by content that will be delivered to the receiver. This is needed to calculate latency correctly in multicast cases. Default value is True

end_session(success=True)[source]

Reports that the session is closed, i.e. the content has been successfully delivered to the receiver or a failure blocked the execution of the request

Parameters:

success : bool, optional

True if the session was completed successfully, False otherwise

name = 'LATENCY'
request_hop(u, v, main_path=True)[source]

Reports that a request has traversed the link (u, v)

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that link link is on the main path that will lead to hit a content. It is normally used to calculate latency correctly in multicast cases. Default value is True

results()[source]

Returns the aggregated results measured by the collector.

Returns:

results : dict

Dictionary mapping metric with results.

start_session(timestamp, receiver, content)[source]

Notifies the collector that a new network session started.

A session refers to the retrieval of a content from a receiver, from the issuing of a content request to the delivery of the content.

Parameters:

timestamp : int

The timestamp of the event

receiver : any hashable type

The receiver node requesting a content

content : any hashable type

The content identifier requested by the receiver

class PathStretchCollector(view, cdf=False)[source]

Bases: icarus.execution.collectors.DataCollector

Collector measuring the path stretch, i.e. the ratio between the actual path length and the shortest path length.

Methods

cache_hit(node) Reports that the requested content has been served by the cache at node node.
cache_miss(node) Reports that the cache at node node has been looked up for requested content but there was a cache miss.
content_hop(u, v[, main_path]) Reports that a content has traversed the link (u, v)
end_session([success]) Reports that the session is closed, i.e.
request_hop(u, v[, main_path]) Reports that a request has traversed the link (u, v)
results() Returns the aggregated results measured by the collector.
server_hit(node) Reports that the requested content has been served by the server at node node.
start_session(timestamp, receiver, content) Notifies the collector that a new network session started.
content_hop(u, v, main_path=True)[source]

Reports that a content has traversed the link (u, v)

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that this link is being traversed by content that will be delivered to the receiver. This is needed to calculate latency correctly in multicast cases. Default value is True

end_session(success=True)[source]

Reports that the session is closed, i.e. the content has been successfully delivered to the receiver or a failure blocked the execution of the request

Parameters:

success : bool, optional

True if the session was completed successfully, False otherwise

name = 'PATH_STRETCH'
request_hop(u, v, main_path=True)[source]

Reports that a request has traversed the link (u, v)

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that link link is on the main path that will lead to hit a content. It is normally used to calculate latency correctly in multicast cases. Default value is True

results()[source]

Returns the aggregated results measured by the collector.

Returns:

results : dict

Dictionary mapping metric with results.

start_session(timestamp, receiver, content)[source]

Notifies the collector that a new network session started.

A session refers to the retrieval of a content from a receiver, from the issuing of a content request to the delivery of the content.

Parameters:

timestamp : int

The timestamp of the event

receiver : any hashable type

The receiver node requesting a content

content : any hashable type

The content identifier requested by the receiver

class TestCollector(view)[source]

Bases: icarus.execution.collectors.DataCollector

Collector used for test cases only.

Methods

cache_hit(node) Reports that the requested content has been served by the cache at node node.
cache_miss(node) Reports that the cache at node node has been looked up for requested content but there was a cache miss.
content_hop(u, v[, main_path]) Reports that a content has traversed the link (u, v)
end_session([success]) Reports that the session is closed, i.e.
request_hop(u, v[, main_path]) Reports that a request has traversed the link (u, v)
results() Returns the aggregated results measured by the collector.
server_hit(node) Reports that the requested content has been served by the server at node node.
session_summary() Return a summary of latest session
start_session(timestamp, receiver, content) Notifies the collector that a new network session started.
cache_hit(node)[source]

Reports that the requested content has been served by the cache at node node.

Parameters:

node : any hashable type

The node whose cache served the content

cache_miss(node)[source]

Reports that the cache at node node has been looked up for requested content but there was a cache miss.

Parameters:

node : any hashable type

The node whose cache served the content

content_hop(u, v, main_path=True)[source]

Reports that a content has traversed the link (u, v)

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that this link is being traversed by content that will be delivered to the receiver. This is needed to calculate latency correctly in multicast cases. Default value is True

end_session(success=True)[source]

Reports that the session is closed, i.e. the content has been successfully delivered to the receiver or a failure blocked the execution of the request

Parameters:

success : bool, optional

True if the session was completed successfully, False otherwise

name = 'TEST'
request_hop(u, v, main_path=True)[source]

Reports that a request has traversed the link (u, v)

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that link link is on the main path that will lead to hit a content. It is normally used to calculate latency correctly in multicast cases. Default value is True

server_hit(node)[source]

Reports that the requested content has been served by the server at node node.

Parameters:

node : any hashable type

The server node which served the content

session_summary()[source]

Return a summary of latest session

Returns:

session : dict

Summary of session

start_session(timestamp, receiver, content)[source]

Notifies the collector that a new network session started.

A session refers to the retrieval of a content from a receiver, from the issuing of a content request to the delivery of the content.

Parameters:

timestamp : int

The timestamp of the event

receiver : any hashable type

The receiver node requesting a content

content : any hashable type

The content identifier requested by the receiver

icarus.execution.engine module

This module implements the simulation engine.

The simulation engine, given the parameters according to which a single experiments needs to be run, instantiates all the required classes and executes the experiment by iterating through the event provided by an event generator and providing them to a strategy instance.

exec_experiment(topology, workload, netconf, strategy, cache_policy, collectors)[source]

Execute the simulation of a specific scenario.

Parameters:

topology : Topology

The FNSS Topology object modelling the network topology on which experiments are run.

workload : iterable

An iterable object whose elements are (time, event) tuples, where time is a float type indicating the timestamp of the event to be executed and event is a dictionary storing all the attributes of the event to execute

netconf : dict

Dictionary of attributes to inizialize the network model

strategy : tree

Strategy definition. It is tree describing the name of the strategy to use and a list of initialization attributes

cache_policy : tree

Cache policy definition. It is tree describing the name of the cache policy to use and a list of initialization attributes

collectors: dict

The collectors to be used. It is a dictionary in which keys are the names of collectors to use and values are dictionaries of attributes for the collector they refer to.

Returns:

results : Tree

A tree with the aggregated simulation results from all collectors

icarus.execution.network module

Network Model-View-Controller (MVC)

This module contains classes providing an abstraction of the network shown to the strategy implementation. The network is modelled using an MVC design pattern.

A strategy performs actions on the network by calling methods of the NetworkController, that in turns updates the NetworkModel instance that updates the NetworkView instance. The strategy can get updated information about the network status by calling methods of the NetworkView instance.

The NetworkController is also responsible to notify a DataCollectorProxy of all relevant events.

class NetworkModel(topology, cache_policy, shortest_path=None)[source]

Bases: object

Models the internal state of the network.

This object should never be edited by strategies directly, but only through calls to the network controller.

class NetworkView(model)[source]

Bases: object

Network view

This class provides an interface that strategies and data collectors can use to know updated information about the status of the network. For example the network view provides information about shortest paths, characteristics of links and currently cached objects in nodes.

Methods

all_pairs_shortest_paths() Return all pairs shortest paths
cache_dump(node) Returns the dump of the content of a cache in a specific node
cache_lookup(node, content) Check if the cache of a node has a content object, without changing the internal state of the cache.
cache_nodes([size]) Returns a list of nodes with caching capability
cluster(v) Return cluster to which a node belongs, if any
content_locations(k) Return a set of all current locations of a specific content.
content_source(k) Return the node identifier where the content is persistently stored.
has_cache(node) Check if a node has a content cache.
link_delay(u, v) Return the delay of link (u, v).
link_type(u, v) Return the type of link (u, v).
local_cache_lookup(node, content) Check if the local cache of a node has a content object, without changing the internal state of the cache.
shortest_path(s, t) Return the shortest path from s to t
topology() Return the network topology
all_pairs_shortest_paths()[source]

Return all pairs shortest paths

cache_dump(node)[source]

Returns the dump of the content of a cache in a specific node

Parameters:

node : any hashable type

The node identifier

Returns:

dump : list

List of contents currently in the cache

cache_lookup(node, content)[source]

Check if the cache of a node has a content object, without changing the internal state of the cache.

This method is meant to be used by data collectors to calculate metrics. It should not be used by strategies to look up for contents during the simulation. Instead they should use NetworkController.get_content

Parameters:

node : any hashable type

The node identifier

content : any hashable type

The content identifier

Returns:

has_content : bool

True if the cache of the node has the content, False otherwise. If the node does not have a cache, return None

cache_nodes(size=False)[source]

Returns a list of nodes with caching capability

Parameters:

size: bool, opt

If True return dict mapping nodes with size

Returns:

cache_nodes : list or dict

If size parameter is False or not specified, it is a list of nodes with caches. Otherwise it is a dict mapping nodes with a cache and their size.

cluster(v)[source]

Return cluster to which a node belongs, if any

Parameters:

v : any hashable type

Node

Returns:

cluster : int

Cluster to which the node belongs, None if the topology is not clustered or the node does not belong to any cluster

content_locations(k)[source]

Return a set of all current locations of a specific content.

This include both persistent content sources and temporary caches.

Parameters:

k : any hashable type

The content identifier

Returns:

nodes : set

A set of all nodes currently storing the given content

content_source(k)[source]

Return the node identifier where the content is persistently stored.

Parameters:

k : any hashable type

The content identifier

Returns:

node : any hashable type

The node persistently storing the given content or None if the source is unavailable

has_cache(node)[source]

Check if a node has a content cache.

Parameters:

node : any hashable type

The node identifier

Returns:

has_cache : bool,

True if the node has a cache, False otherwise

Return the delay of link (u, v).

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

Returns:

delay : float

The link delay

Return the type of link (u, v).

Type can be either internal or external

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

Returns:

link_type : str

The link type

local_cache_lookup(node, content)[source]

Check if the local cache of a node has a content object, without changing the internal state of the cache.

The local cache is an area of the cache of a node reserved for uncoordinated caching. This is currently used only by hybrid hash-routing strategies.

This method is meant to be used by data collectors to calculate metrics. It should not be used by strategies to look up for contents during the simulation. Instead they should use NetworkController.get_content_local_cache.

Parameters:

node : any hashable type

The node identifier

content : any hashable type

The content identifier

Returns:

has_content : bool

True if the cache of the node has the content, False otherwise. If the node does not have a cache, return None

shortest_path(s, t)[source]

Return the shortest path from s to t

Parameters:

s : any hashable type

Origin node

t : any hashable type

Destination node

Returns:

shortest_path : list

List of nodes of the shortest path (origin and destination included)

topology()[source]

Return the network topology

Returns:

topology : fnss.Topology

The topology object

Notes

The topology object returned by this method must not be modified by the caller. This object can only be modified through the NetworkController. Changes to this object will lead to inconsistent network state.

class NetworkController(model)[source]

Bases: object

Network controller

This class is in charge of executing operations on the network model on behalf of a strategy implementation. It is also in charge of notifying data collectors of relevant events.

Methods

attach_collector(collector) Attach a data collector to which all events will be reported.
detach_collector() Detach the data collector.
end_session([success]) Close a session
forward_content_hop(u, v[, main_path]) Forward a content over link u -> v.
forward_content_path(u, v[, path, main_path]) Forward a content from node s to node t over the provided path.
forward_request_hop(u, v[, main_path]) Forward a request over link u -> v.
forward_request_path(s, t[, path, main_path]) Forward a request from node s to node t over the provided path.
get_content(node) Get a content from a server or a cache.
get_content_local_cache(node) Get content from local cache of node (if any)
put_content(node) Store content in the specified node.
put_content_local_cache(node) Put content into local cache of node (if any)
remove_content(node) Remove the content being handled from the cache
remove_link(u, v[, recompute_paths]) Remove a link from the topology and update the network model.
remove_node(v[, recompute_paths]) Remove a node from the topology and update the network model.
reserve_local_cache([ratio]) Reserve a fraction of cache as local.
restore_link(u, v[, recompute_paths]) Restore a previously-removed link and update the network model
restore_node(v[, recompute_paths]) Restore a previously-removed node and update the network model.
rewire_link(u, v, up, vp[, recompute_paths]) Rewire an existing link to new endpoints
start_session(timestamp, receiver, content, log) Instruct the controller to start a new session (i.e.
attach_collector(collector)[source]

Attach a data collector to which all events will be reported.

Parameters:

collector : DataCollector

The data collector

detach_collector()[source]

Detach the data collector.

end_session(success=True)[source]

Close a session

Parameters:

success : bool, optional

True if the session was completed successfully, False otherwise

forward_content_hop(u, v, main_path=True)[source]

Forward a content over link u -> v.

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that this link is being traversed by content that will be delivered to the receiver. This is needed to calculate latency correctly in multicast cases. Default value is True

forward_content_path(u, v, path=None, main_path=True)[source]

Forward a content from node s to node t over the provided path.

Parameters:

s : any hashable type

Origin node

t : any hashable type

Destination node

path : list, optional

The path to use. If not provided, shortest path is used

main_path : bool, optional

If True, indicates that this path is being traversed by content that will be delivered to the receiver. This is needed to calculate latency correctly in multicast cases. Default value is True

forward_request_hop(u, v, main_path=True)[source]

Forward a request over link u -> v.

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

main_path : bool, optional

If True, indicates that link link is on the main path that will lead to hit a content. It is normally used to calculate latency correctly in multicast cases. Default value is True

forward_request_path(s, t, path=None, main_path=True)[source]

Forward a request from node s to node t over the provided path.

Parameters:

s : any hashable type

Origin node

t : any hashable type

Destination node

path : list, optional

The path to use. If not provided, shortest path is used

main_path : bool, optional

If True, indicates that link path is on the main path that will lead to hit a content. It is normally used to calculate latency correctly in multicast cases. Default value is True

get_content(node)[source]

Get a content from a server or a cache.

Parameters:

node : any hashable type

The node where the content is retrieved

Returns:

content : bool

True if the content is available, False otherwise

get_content_local_cache(node)[source]

Get content from local cache of node (if any)

Get content from a local cache of a node. Local cache must be initialized with the reserve_local_cache method.

Parameters:

node : any hashable type

The node to query

put_content(node)[source]

Store content in the specified node.

The node must have a cache stack and the actual insertion of the content is executed according to the caching policy. If the caching policy has a selective insertion policy, then content may not be inserted.

Parameters:

node : any hashable type

The node where the content is inserted

Returns:

evicted : any hashable type

The evicted object or None if no contents were evicted.

put_content_local_cache(node)[source]

Put content into local cache of node (if any)

Put content into a local cache of a node. Local cache must be initialized with the reserve_local_cache method.

Parameters:

node : any hashable type

The node to query

remove_content(node)[source]

Remove the content being handled from the cache

Parameters:

node : any hashable type

The node where the cached content is removed

Returns:

removed : bool

True if the entry was in the cache, False if it was not.

Remove a link from the topology and update the network model.

Note well. With great power comes great responsibility. Be careful when using this method. In fact as a result of link removal, network partitions and other corner cases might occur. Ensure that the implementation of strategies using this method deal with all potential corner cases appropriately.

Also, note that, for these changes to be effective, the strategy must use fresh data provided by the network view and not storing local copies of network state because they won’t be updated by this method.

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

recompute_paths: bool, optional

If True, recompute all shortest paths

remove_node(v, recompute_paths=True)[source]

Remove a node from the topology and update the network model.

Note well. With great power comes great responsibility. Be careful when using this method. In fact, as a result of node removal, network partitions and other corner cases might occur. Ensure that the implementation of strategies using this method deal with all potential corner cases appropriately.

It should be noted that when this method is called, all links connected to the node to be removed are removed as well. These links are however restored when the node is restored. However, if a link attached to this node was previously removed using the remove_link method, restoring the node won’t restore that link as well. It will need to be restored with a call to restore_link.

This method is normally quite safe when applied to remove cache nodes or routers if this does not cause partitions. If used to remove content sources or receiver, special attention is required. In particular, if a source is removed, the content items stored by that source will no longer be available if not cached elsewhere.

Also, note that, for these changes to be effective, the strategy must use fresh data provided by the network view and not storing local copies of network state because they won’t be updated by this method.

Parameters:

v : any hashable type

Node to remove

recompute_paths: bool, optional

If True, recompute all shortest paths

reserve_local_cache(ratio=0.1)[source]

Reserve a fraction of cache as local.

This method reserves a fixed fraction of the cache of each caching node to act as local uncoodinated cache. Methods get_content and put_content will only operated to the coordinated cache. The reserved local cache can be accessed with methods get_content_local_cache and put_content_local_cache.

This function is currently used only by hybrid hash-routing strategies.

Parameters:

ratio : float

The ratio of cache space to be reserved as local cache.

Restore a previously-removed link and update the network model

Parameters:

u : any hashable type

Origin node

v : any hashable type

Destination node

recompute_paths: bool, optional

If True, recompute all shortest paths

restore_node(v, recompute_paths=True)[source]

Restore a previously-removed node and update the network model.

Parameters:

v : any hashable type

Node to restore

recompute_paths: bool, optional

If True, recompute all shortest paths

Rewire an existing link to new endpoints

This method can be used to model mobility patters, e.g., changing attachment points of sources and/or receivers.

Note well. With great power comes great responsibility. Be careful when using this method. In fact as a result of link rewiring, network partitions and other corner cases might occur. Ensure that the implementation of strategies using this method deal with all potential corner cases appropriately.

Parameters:

u, v : any hashable type

Endpoints of link before rewiring

up, vp : any hashable type

Endpoints of link after rewiring

start_session(timestamp, receiver, content, log)[source]

Instruct the controller to start a new session (i.e. the retrieval of a content).

Parameters:

timestamp : int

The timestamp of the event

receiver : any hashable type

The receiver node requesting a content

content : any hashable type

The content identifier requested by the receiver

log : bool

True if this session needs to be reported to the collector, False otherwise

Module contents

This package contains the code for the execution of a single experiment.