This repository has been archived by the owner on Jun 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
Accessing Topology
joshreich edited this page Dec 5, 2014
·
6 revisions
Changes to the network topology are one of the most fundamental sources of dynamism. Consequently, all dynamic policies have a set_network
method which is automatically called by the runtime every time the network changes. By overriding this method, dynamic policies can access the updated network and its associated topology. Below is a simplified version of Pyretic's flood
policy that recalculates the minimum spanning tree each time set_network
is called and updates its internal policy to flood on that minimum spanning tree.
class flood(DynamicPolicy):
"""
Policy that floods packets on a minimum spanning tree, recalculated
every time the network is updated (set_network).
"""
def __init__(self):
self.mst = None
super(flood,self).__init__()
def set_network(self, network):
updated_mst = Topology.minimum_spanning_tree(network.topology)
self.policy = parallel([
match(switch=switch) >>
parallel(map(xfwd,ports))
for switch,ports
in self.mst.switch_with_port_ids_list()])
The following videos provide additional examples and details as to how the Pyretic runtime implements this feature:
- An example that uses the topology to flood over a minimum spanning tree
- An example that introduces the topology/network object and shows how to print it
- An in-depth dive into runtime support for network/topology access