Skip to content

Commit

Permalink
Remove the low-level networking library and use Tekton instead
Browse files Browse the repository at this point in the history
Also, update to use networkx version 2.1.
  • Loading branch information
ahassany committed May 4, 2018
1 parent 6fd1781 commit 50018af
Show file tree
Hide file tree
Showing 34 changed files with 207 additions and 2,802 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
### Install

Install network graph library dependency first

```
pip install -e git+git@github.com:nsg-ethz/tekton.git#egg=Tekton
# Or from a local clone
pip install -e .
```

Install dependencies

```
pip install -r
```

### Running BGP

Expand Down
32 changes: 16 additions & 16 deletions eval_scripts/new_ebgp_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@

from synet.synthesis.connected import ConnectedSyn
from synet.synthesis.new_propagation import EBGPPropagation
from synet.topo.bgp import Access
from synet.topo.bgp import ActionSetCommunity
from synet.topo.bgp import ActionSetLocalPref
from synet.topo.bgp import Announcement
from synet.topo.bgp import BGP_ATTRS_ORIGIN
from synet.topo.bgp import Community
from synet.topo.bgp import CommunityList
from synet.topo.bgp import MatchCommunitiesList
from synet.topo.bgp import RouteMap
from synet.topo.bgp import RouteMapLine
from synet.topo.bgp import IpPrefixList
from synet.topo.bgp import MatchIpPrefixListList
from synet.topo.bgp import MatchNextHop
from synet.topo.bgp import MatchSelectOne
from synet.topo.graph import NetworkGraph
from tekton.bgp import Access
from tekton.bgp import ActionSetCommunity
from tekton.bgp import ActionSetLocalPref
from tekton.bgp import Announcement
from tekton.bgp import BGP_ATTRS_ORIGIN
from tekton.bgp import Community
from tekton.bgp import CommunityList
from tekton.bgp import MatchCommunitiesList
from tekton.bgp import RouteMap
from tekton.bgp import RouteMapLine
from tekton.bgp import IpPrefixList
from tekton.bgp import MatchIpPrefixListList
from tekton.bgp import MatchNextHop
from tekton.bgp import MatchSelectOne
from tekton.graph import NetworkGraph
from synet.utils.common import ECMPPathsReq
from synet.utils.common import KConnectedPathsReq
from synet.utils.common import PathOrderReq
Expand Down Expand Up @@ -1083,7 +1083,7 @@ def main():
p.update_network_graph()


from synet.topo.gns3 import GNS3Topo
from tekton.gns3 import GNS3Topo
gns3 = GNS3Topo(topo)

out_dir = 'out-configs/%s_%d' % (out_name, rand.randint(0, 1000))
Expand Down
2 changes: 1 addition & 1 deletion eval_scripts/ospf_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def main():
for node in topo.nodes():
topo.enable_ospf(node, 100)
# Initially all costs are empty
for src, dst in topo.edges_iter():
for src, dst in topo.edges():
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
# how many is fixed
fixed_edges = ospfRand.sample(vals, int(round(len(vals) * fixed)))
Expand Down
18 changes: 9 additions & 9 deletions eval_scripts/ospf_generate_reqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def generate_ecmp_reqs(topo, reqsize, ecmp, rand):
def generate_ordered_reqs(topo, reqsize, ordered, rand):
"""Generate reqsize of PathOrderReq each has ordered paths"""
graph = nx.DiGraph()
for src, dst in topo.edges_iter():
for src, dst in topo.edges():
graph.add_edge(src, dst)

computed_paths = {}
Expand Down Expand Up @@ -203,7 +203,7 @@ def get_simple_reqs(topo, reqsize, rand):
generated = False
while not generated:
# All OSPF Costs are initially empty
for src, dst in topo.edges_iter():
for src, dst in topo.edges():
if not topo.is_local_router_edge(src, dst):
continue
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
Expand All @@ -227,7 +227,7 @@ def get_simple_reqs(topo, reqsize, rand):
out_file += "]\n\n"
vals_name = "edges_cost_simple_%d" % reqsize
out_file += "%s = [\n" % vals_name
for src, dst in topo.edges_iter():
for src, dst in topo.edges():
out_file += ' ("%s", "%s", %d),\n' % (
src, dst, topo.get_edge_ospf_cost(src, dst))
out_file += "]\n\n"
Expand All @@ -241,7 +241,7 @@ def get_ecmp_reqs(topo, reqsize, ecmp, rand):
generated = False
while not generated:
# All OSPF Costs are intially empty
for src, dst in topo.edges_iter():
for src, dst in topo.edges():
if not topo.is_local_router_edge(src, dst):
continue
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
Expand All @@ -267,7 +267,7 @@ def get_ecmp_reqs(topo, reqsize, ecmp, rand):
out_file += "]\n\n"
vals_name = "edges_cost_ecmp_%d_%d" % (reqsize, ecmp)
out_file += "%s = [\n" % vals_name
for src, dst in topo.edges_iter():
for src, dst in topo.edges():
out_file += ' ("%s", "%s", %d),\n' % (
src, dst, topo.get_edge_ospf_cost(src, dst))
out_file += "]\n\n"
Expand All @@ -278,7 +278,7 @@ def get_kconnected(topo, ecmp_reqs, reqsize, k, rand):
out_file = ""
print "X" * 40
print "Generating KConneced for reqsize=%d, k=%d" % (reqsize, k)
for src, dst in topo.edges_iter():
for src, dst in topo.edges():
if not topo.is_local_router_edge(src, dst):
continue
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
Expand All @@ -299,7 +299,7 @@ def get_kconnected(topo, ecmp_reqs, reqsize, k, rand):
out_file += "]\n\n"
vals_name = "edges_cost_kconnected_%d_%d" % (reqsize, k)
out_file += "%s = [\n" % vals_name
for src, dst in topo.edges_iter():
for src, dst in topo.edges():
out_file += ' ("%s", "%s", %d),\n' % (
src, dst, topo.get_edge_ospf_cost(src, dst))
out_file += "]\n\n"
Expand All @@ -311,7 +311,7 @@ def get_path_order(topo, reqsize, pathorder, rand):
generated = False
while not generated:
# All OSPF Costs are intially empty
for src, dst in topo.edges_iter():
for src, dst in topo.edges():
if not topo.is_local_router_edge(src, dst):
continue
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
Expand All @@ -338,7 +338,7 @@ def get_path_order(topo, reqsize, pathorder, rand):
out_file += "]\n\n"
vals_name = "edges_cost_order_%d_%d" % (reqsize, pathorder)
out_file += "%s = [\n" % vals_name
for src, dst in topo.edges_iter():
for src, dst in topo.edges():
out_file += ' ("%s", "%s", %d),\n' % (
src, dst, topo.get_edge_ospf_cost(src, dst))
out_file += "]\n\n"
Expand Down
42 changes: 21 additions & 21 deletions eval_scripts/synet_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
from synet.synthesis.ospf import OSPFSyn as OSPFConcrete
from synet.synthesis.static import StaticSyn
from synet.synthesis.connected import ConnectedSyn
from synet.topo.bgp import Announcement
from synet.topo.bgp import BGP_ATTRS_ORIGIN
from synet.topo.bgp import Community
from tekton.bgp import Announcement
from tekton.bgp import BGP_ATTRS_ORIGIN
from tekton.bgp import Community
from synet.synthesis.new_propagation import EBGPPropagation

from synet.utils.fnfree_smt_context import SolverContext
Expand All @@ -27,21 +27,21 @@

from synet.utils.bgp_utils import compute_next_hop_map
from synet.utils.bgp_utils import extract_all_next_hops
from synet.topo.bgp import Access
from synet.topo.bgp import ActionSetCommunity
from synet.topo.bgp import ActionSetLocalPref
from synet.topo.bgp import Announcement
from synet.topo.bgp import BGP_ATTRS_ORIGIN
from synet.topo.bgp import Community
from synet.topo.bgp import CommunityList
from synet.topo.bgp import MatchCommunitiesList
from synet.topo.bgp import RouteMap
from synet.topo.bgp import RouteMapLine
from synet.topo.bgp import IpPrefixList
from synet.topo.bgp import MatchIpPrefixListList
from synet.topo.bgp import MatchNextHop
from synet.topo.bgp import MatchSelectOne
from synet.topo.bgp import ActionSetOne
from tekton.bgp import Access
from tekton.bgp import ActionSetCommunity
from tekton.bgp import ActionSetLocalPref
from tekton.bgp import Announcement
from tekton.bgp import BGP_ATTRS_ORIGIN
from tekton.bgp import Community
from tekton.bgp import CommunityList
from tekton.bgp import MatchCommunitiesList
from tekton.bgp import RouteMap
from tekton.bgp import RouteMapLine
from tekton.bgp import IpPrefixList
from tekton.bgp import MatchIpPrefixListList
from tekton.bgp import MatchNextHop
from tekton.bgp import MatchSelectOne
from tekton.bgp import ActionSetOne



Expand Down Expand Up @@ -164,7 +164,7 @@ def ospf(n, nreqs=10):
topo.enable_ospf(node, 100)
# Initially all costs are empty
topo.set_static_routes_empty(node)
for src, dst in topo.edges_iter():
for src, dst in topo.edges():
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
conn = ConnectedSyn([], topo, full=True)
conn.synthesize()
Expand All @@ -187,7 +187,7 @@ def static(n, nreqs=10):
topo.enable_ospf(node, 100)
# Initially all costs are empty
topo.set_static_routes_empty(node)
for src, dst in topo.edges_iter():
for src, dst in topo.edges():
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
conn = ConnectedSyn([], topo, full=True)
conn.synthesize()
Expand All @@ -211,7 +211,7 @@ def bgp(n, nreqs=10):
# Initially all costs are empty
topo.set_static_routes_empty(node)

for src, dst in topo.edges_iter():
for src, dst in topo.edges():
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)

peer = 'ATT'
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ipaddress
enum34
networkx==1.11
networkx==2.1
nose
nose-timer
6 changes: 3 additions & 3 deletions synet/drivers/ospf_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def main():
for node in g.local_routers_iter():
g.enable_ospf(node, 100)
# Initially assume all costs are empty
for src, dst in g.edges_iter():
for src, dst in g.edges():
if not g.is_ospf_enabled(src):
continue
if not g.is_ospf_enabled(dst):
Expand Down Expand Up @@ -123,7 +123,7 @@ def main():
print "Done generating random paths for requirements"
if fixed > 0:
weights = []
for src, dst in g.edges_iter():
for src, dst in g.edges():
weights.append((src, dst, g[src][dst][tmp_weight_name]))
population = int(round(len(weights) * fixed))
sampled = ospfRand.sample(weights, population)
Expand Down Expand Up @@ -159,7 +159,7 @@ def main():
ospf.synthesize(retries_before_rest=10)
ospf.update_network_graph()
print "OSPF Edge cost"
for src, dst in g.edges_iter():
for src, dst in g.edges():
print src, dst, g.get_edge_ospf_cost(src, dst)


Expand Down
32 changes: 16 additions & 16 deletions synet/examples/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@

from synet.synthesis.connected import ConnectedSyn
from synet.synthesis.new_propagation import EBGPPropagation
from synet.topo.bgp import Access
from synet.topo.bgp import ActionSetCommunity
from synet.topo.bgp import ActionSetLocalPref
from synet.topo.bgp import Announcement
from synet.topo.bgp import BGP_ATTRS_ORIGIN
from synet.topo.bgp import Community
from synet.topo.bgp import CommunityList
from synet.topo.bgp import IpPrefixList
from synet.topo.bgp import MatchAsPath
from synet.topo.bgp import MatchCommunitiesList
from synet.topo.bgp import MatchIpPrefixListList
from synet.topo.bgp import MatchNextHop
from synet.topo.bgp import RouteMap
from synet.topo.bgp import RouteMapLine
from synet.topo.gns3 import GNS3Topo
from synet.topo.graph import NetworkGraph
from tekton.bgp import Access
from tekton.bgp import ActionSetCommunity
from tekton.bgp import ActionSetLocalPref
from tekton.bgp import Announcement
from tekton.bgp import BGP_ATTRS_ORIGIN
from tekton.bgp import Community
from tekton.bgp import CommunityList
from tekton.bgp import IpPrefixList
from tekton.bgp import MatchAsPath
from tekton.bgp import MatchCommunitiesList
from tekton.bgp import MatchIpPrefixListList
from tekton.bgp import MatchNextHop
from tekton.bgp import RouteMap
from tekton.bgp import RouteMapLine
from tekton.gns3 import GNS3Topo
from tekton.graph import NetworkGraph
from synet.utils.bgp_utils import compute_next_hop_map
from synet.utils.bgp_utils import extract_all_next_hops
from synet.utils.common import PathReq
Expand Down
6 changes: 3 additions & 3 deletions synet/synthesis/connected.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ipaddress import ip_interface
from ipaddress import ip_network

from synet.topo.graph import NetworkGraph
from tekton.graph import NetworkGraph
from synet.utils.common import ECMPPathsReq
from synet.utils.common import KConnectedPathsReq
from synet.utils.common import PathOrderReq
Expand Down Expand Up @@ -213,7 +213,7 @@ def synthesize(self):
# Assign iface names between edges (if needed)
self.g.set_iface_names()
if self.full:
for src, dst in self.g.edges_iter():
for src, dst in self.g.edges():
if not self.g.is_router(src):
continue
if not self.g.is_router(dst):
Expand All @@ -229,7 +229,7 @@ def synthesize(self):
for src, dst in sorted(connected_pairs):
self.synthesize_connection(src, dst)
edges_to_remove = []
for src, dst in self.g.edges_iter():
for src, dst in self.g.edges():
if (src, dst) not in connected_pairs:
if self.is_connnected(src, dst):
continue
Expand Down
2 changes: 1 addition & 1 deletion synet/synthesis/ebgpy_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class EBGPVerify(object):

def __init__(self, network_graph, reqs):
"""
:param network_graph: synet.topo.graph.NetworkGraph
:param network_graph: tekton.graph.NetworkGraph
:param reqs: list of BGP paths preferences
"""
self.network_graph = network_graph
Expand Down
4 changes: 2 additions & 2 deletions synet/synthesis/new_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import networkx as nx
import z3

from synet.topo.bgp import Announcement
from synet.topo.graph import NetworkGraph
from tekton.bgp import Announcement
from tekton.graph import NetworkGraph
from synet.utils.fnfree_policy import SMTRouteMap
from synet.utils.fnfree_smt_context import ASPATH_SORT
from synet.utils.fnfree_smt_context import AnnouncementsContext
Expand Down
2 changes: 1 addition & 1 deletion synet/synthesis/new_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from synet.synthesis.ebgpy_verify import EBGPVerify
from synet.synthesis.new_bgp import BGP
from synet.topo.graph import NetworkGraph
from tekton.graph import NetworkGraph
from synet.utils.bgp_utils import PropagatedInfo
from synet.utils.bgp_utils import annotate_graph
from synet.utils.bgp_utils import compute_next_hop_map
Expand Down
2 changes: 1 addition & 1 deletion synet/synthesis/ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import networkx as nx
import z3

from synet.topo.graph import NetworkGraph
from tekton.graph import NetworkGraph
from synet.utils.common import ECMPPathsReq
from synet.utils.common import KConnectedPathsReq
from synet.utils.common import PathOrderReq
Expand Down
6 changes: 3 additions & 3 deletions synet/synthesis/ospf_heuristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import networkx as nx
import z3

from synet.topo.graph import NetworkGraph
from tekton.graph import NetworkGraph
from synet.utils.common import ECMPPathsReq
from synet.utils.common import KConnectedPathsReq
from synet.utils.common import PathOrderReq
Expand Down Expand Up @@ -548,7 +548,7 @@ def _check_order_path_req(self, out_graph, req):
"""
sat = True
req_paths = [r.path for r in req.paths]
all_edges = [(None, None)] + list(out_graph.edges_iter())
all_edges = [(None, None)] + list(out_graph.edges())
primary = req_paths[0]
for src, dst in all_edges:
out_copy = out_graph.copy()
Expand Down Expand Up @@ -589,7 +589,7 @@ def _check_kconnected_req(self, out_graph, req):
"""
sat = True
req_paths = [r.path for r in req.paths]
all_edges = [(None, None)] + list(out_graph.edges_iter())
all_edges = [(None, None)] + list(out_graph.edges())
primary = req_paths[0]
for src, dst in all_edges:
out_copy = out_graph.copy()
Expand Down
Loading

0 comments on commit 50018af

Please sign in to comment.