Skip to content

Commit 50018af

Browse files
committed
Remove the low-level networking library and use Tekton instead
Also, update to use networkx version 2.1.
1 parent 6fd1781 commit 50018af

34 files changed

+207
-2802
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1+
### Install
12

3+
Install network graph library dependency first
4+
5+
```
6+
pip install -e [email protected]:nsg-ethz/tekton.git#egg=Tekton
7+
# Or from a local clone
8+
pip install -e .
9+
```
10+
11+
Install dependencies
12+
13+
```
14+
pip install -r
15+
```
216

317
### Running BGP
418

eval_scripts/new_ebgp_eval.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@
1515

1616
from synet.synthesis.connected import ConnectedSyn
1717
from synet.synthesis.new_propagation import EBGPPropagation
18-
from synet.topo.bgp import Access
19-
from synet.topo.bgp import ActionSetCommunity
20-
from synet.topo.bgp import ActionSetLocalPref
21-
from synet.topo.bgp import Announcement
22-
from synet.topo.bgp import BGP_ATTRS_ORIGIN
23-
from synet.topo.bgp import Community
24-
from synet.topo.bgp import CommunityList
25-
from synet.topo.bgp import MatchCommunitiesList
26-
from synet.topo.bgp import RouteMap
27-
from synet.topo.bgp import RouteMapLine
28-
from synet.topo.bgp import IpPrefixList
29-
from synet.topo.bgp import MatchIpPrefixListList
30-
from synet.topo.bgp import MatchNextHop
31-
from synet.topo.bgp import MatchSelectOne
32-
from synet.topo.graph import NetworkGraph
18+
from tekton.bgp import Access
19+
from tekton.bgp import ActionSetCommunity
20+
from tekton.bgp import ActionSetLocalPref
21+
from tekton.bgp import Announcement
22+
from tekton.bgp import BGP_ATTRS_ORIGIN
23+
from tekton.bgp import Community
24+
from tekton.bgp import CommunityList
25+
from tekton.bgp import MatchCommunitiesList
26+
from tekton.bgp import RouteMap
27+
from tekton.bgp import RouteMapLine
28+
from tekton.bgp import IpPrefixList
29+
from tekton.bgp import MatchIpPrefixListList
30+
from tekton.bgp import MatchNextHop
31+
from tekton.bgp import MatchSelectOne
32+
from tekton.graph import NetworkGraph
3333
from synet.utils.common import ECMPPathsReq
3434
from synet.utils.common import KConnectedPathsReq
3535
from synet.utils.common import PathOrderReq
@@ -1083,7 +1083,7 @@ def main():
10831083
p.update_network_graph()
10841084

10851085

1086-
from synet.topo.gns3 import GNS3Topo
1086+
from tekton.gns3 import GNS3Topo
10871087
gns3 = GNS3Topo(topo)
10881088

10891089
out_dir = 'out-configs/%s_%d' % (out_name, rand.randint(0, 1000))

eval_scripts/ospf_eval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def main():
103103
for node in topo.nodes():
104104
topo.enable_ospf(node, 100)
105105
# Initially all costs are empty
106-
for src, dst in topo.edges_iter():
106+
for src, dst in topo.edges():
107107
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
108108
# how many is fixed
109109
fixed_edges = ospfRand.sample(vals, int(round(len(vals) * fixed)))

eval_scripts/ospf_generate_reqs.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def generate_ecmp_reqs(topo, reqsize, ecmp, rand):
151151
def generate_ordered_reqs(topo, reqsize, ordered, rand):
152152
"""Generate reqsize of PathOrderReq each has ordered paths"""
153153
graph = nx.DiGraph()
154-
for src, dst in topo.edges_iter():
154+
for src, dst in topo.edges():
155155
graph.add_edge(src, dst)
156156

157157
computed_paths = {}
@@ -203,7 +203,7 @@ def get_simple_reqs(topo, reqsize, rand):
203203
generated = False
204204
while not generated:
205205
# All OSPF Costs are initially empty
206-
for src, dst in topo.edges_iter():
206+
for src, dst in topo.edges():
207207
if not topo.is_local_router_edge(src, dst):
208208
continue
209209
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
@@ -227,7 +227,7 @@ def get_simple_reqs(topo, reqsize, rand):
227227
out_file += "]\n\n"
228228
vals_name = "edges_cost_simple_%d" % reqsize
229229
out_file += "%s = [\n" % vals_name
230-
for src, dst in topo.edges_iter():
230+
for src, dst in topo.edges():
231231
out_file += ' ("%s", "%s", %d),\n' % (
232232
src, dst, topo.get_edge_ospf_cost(src, dst))
233233
out_file += "]\n\n"
@@ -241,7 +241,7 @@ def get_ecmp_reqs(topo, reqsize, ecmp, rand):
241241
generated = False
242242
while not generated:
243243
# All OSPF Costs are intially empty
244-
for src, dst in topo.edges_iter():
244+
for src, dst in topo.edges():
245245
if not topo.is_local_router_edge(src, dst):
246246
continue
247247
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
@@ -267,7 +267,7 @@ def get_ecmp_reqs(topo, reqsize, ecmp, rand):
267267
out_file += "]\n\n"
268268
vals_name = "edges_cost_ecmp_%d_%d" % (reqsize, ecmp)
269269
out_file += "%s = [\n" % vals_name
270-
for src, dst in topo.edges_iter():
270+
for src, dst in topo.edges():
271271
out_file += ' ("%s", "%s", %d),\n' % (
272272
src, dst, topo.get_edge_ospf_cost(src, dst))
273273
out_file += "]\n\n"
@@ -278,7 +278,7 @@ def get_kconnected(topo, ecmp_reqs, reqsize, k, rand):
278278
out_file = ""
279279
print "X" * 40
280280
print "Generating KConneced for reqsize=%d, k=%d" % (reqsize, k)
281-
for src, dst in topo.edges_iter():
281+
for src, dst in topo.edges():
282282
if not topo.is_local_router_edge(src, dst):
283283
continue
284284
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
@@ -299,7 +299,7 @@ def get_kconnected(topo, ecmp_reqs, reqsize, k, rand):
299299
out_file += "]\n\n"
300300
vals_name = "edges_cost_kconnected_%d_%d" % (reqsize, k)
301301
out_file += "%s = [\n" % vals_name
302-
for src, dst in topo.edges_iter():
302+
for src, dst in topo.edges():
303303
out_file += ' ("%s", "%s", %d),\n' % (
304304
src, dst, topo.get_edge_ospf_cost(src, dst))
305305
out_file += "]\n\n"
@@ -311,7 +311,7 @@ def get_path_order(topo, reqsize, pathorder, rand):
311311
generated = False
312312
while not generated:
313313
# All OSPF Costs are intially empty
314-
for src, dst in topo.edges_iter():
314+
for src, dst in topo.edges():
315315
if not topo.is_local_router_edge(src, dst):
316316
continue
317317
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
@@ -338,7 +338,7 @@ def get_path_order(topo, reqsize, pathorder, rand):
338338
out_file += "]\n\n"
339339
vals_name = "edges_cost_order_%d_%d" % (reqsize, pathorder)
340340
out_file += "%s = [\n" % vals_name
341-
for src, dst in topo.edges_iter():
341+
for src, dst in topo.edges():
342342
out_file += ' ("%s", "%s", %d),\n' % (
343343
src, dst, topo.get_edge_ospf_cost(src, dst))
344344
out_file += "]\n\n"

eval_scripts/synet_compare.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
from synet.synthesis.ospf import OSPFSyn as OSPFConcrete
1616
from synet.synthesis.static import StaticSyn
1717
from synet.synthesis.connected import ConnectedSyn
18-
from synet.topo.bgp import Announcement
19-
from synet.topo.bgp import BGP_ATTRS_ORIGIN
20-
from synet.topo.bgp import Community
18+
from tekton.bgp import Announcement
19+
from tekton.bgp import BGP_ATTRS_ORIGIN
20+
from tekton.bgp import Community
2121
from synet.synthesis.new_propagation import EBGPPropagation
2222

2323
from synet.utils.fnfree_smt_context import SolverContext
@@ -27,21 +27,21 @@
2727

2828
from synet.utils.bgp_utils import compute_next_hop_map
2929
from synet.utils.bgp_utils import extract_all_next_hops
30-
from synet.topo.bgp import Access
31-
from synet.topo.bgp import ActionSetCommunity
32-
from synet.topo.bgp import ActionSetLocalPref
33-
from synet.topo.bgp import Announcement
34-
from synet.topo.bgp import BGP_ATTRS_ORIGIN
35-
from synet.topo.bgp import Community
36-
from synet.topo.bgp import CommunityList
37-
from synet.topo.bgp import MatchCommunitiesList
38-
from synet.topo.bgp import RouteMap
39-
from synet.topo.bgp import RouteMapLine
40-
from synet.topo.bgp import IpPrefixList
41-
from synet.topo.bgp import MatchIpPrefixListList
42-
from synet.topo.bgp import MatchNextHop
43-
from synet.topo.bgp import MatchSelectOne
44-
from synet.topo.bgp import ActionSetOne
30+
from tekton.bgp import Access
31+
from tekton.bgp import ActionSetCommunity
32+
from tekton.bgp import ActionSetLocalPref
33+
from tekton.bgp import Announcement
34+
from tekton.bgp import BGP_ATTRS_ORIGIN
35+
from tekton.bgp import Community
36+
from tekton.bgp import CommunityList
37+
from tekton.bgp import MatchCommunitiesList
38+
from tekton.bgp import RouteMap
39+
from tekton.bgp import RouteMapLine
40+
from tekton.bgp import IpPrefixList
41+
from tekton.bgp import MatchIpPrefixListList
42+
from tekton.bgp import MatchNextHop
43+
from tekton.bgp import MatchSelectOne
44+
from tekton.bgp import ActionSetOne
4545

4646

4747

@@ -164,7 +164,7 @@ def ospf(n, nreqs=10):
164164
topo.enable_ospf(node, 100)
165165
# Initially all costs are empty
166166
topo.set_static_routes_empty(node)
167-
for src, dst in topo.edges_iter():
167+
for src, dst in topo.edges():
168168
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
169169
conn = ConnectedSyn([], topo, full=True)
170170
conn.synthesize()
@@ -187,7 +187,7 @@ def static(n, nreqs=10):
187187
topo.enable_ospf(node, 100)
188188
# Initially all costs are empty
189189
topo.set_static_routes_empty(node)
190-
for src, dst in topo.edges_iter():
190+
for src, dst in topo.edges():
191191
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
192192
conn = ConnectedSyn([], topo, full=True)
193193
conn.synthesize()
@@ -211,7 +211,7 @@ def bgp(n, nreqs=10):
211211
# Initially all costs are empty
212212
topo.set_static_routes_empty(node)
213213

214-
for src, dst in topo.edges_iter():
214+
for src, dst in topo.edges():
215215
topo.set_edge_ospf_cost(src, dst, VALUENOTSET)
216216

217217
peer = 'ATT'

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ipaddress
22
enum34
3-
networkx==1.11
3+
networkx==2.1
44
nose
55
nose-timer

synet/drivers/ospf_driver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def main():
9191
for node in g.local_routers_iter():
9292
g.enable_ospf(node, 100)
9393
# Initially assume all costs are empty
94-
for src, dst in g.edges_iter():
94+
for src, dst in g.edges():
9595
if not g.is_ospf_enabled(src):
9696
continue
9797
if not g.is_ospf_enabled(dst):
@@ -123,7 +123,7 @@ def main():
123123
print "Done generating random paths for requirements"
124124
if fixed > 0:
125125
weights = []
126-
for src, dst in g.edges_iter():
126+
for src, dst in g.edges():
127127
weights.append((src, dst, g[src][dst][tmp_weight_name]))
128128
population = int(round(len(weights) * fixed))
129129
sampled = ospfRand.sample(weights, population)
@@ -159,7 +159,7 @@ def main():
159159
ospf.synthesize(retries_before_rest=10)
160160
ospf.update_network_graph()
161161
print "OSPF Edge cost"
162-
for src, dst in g.edges_iter():
162+
for src, dst in g.edges():
163163
print src, dst, g.get_edge_ospf_cost(src, dst)
164164

165165

synet/examples/simple.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@
1111

1212
from synet.synthesis.connected import ConnectedSyn
1313
from synet.synthesis.new_propagation import EBGPPropagation
14-
from synet.topo.bgp import Access
15-
from synet.topo.bgp import ActionSetCommunity
16-
from synet.topo.bgp import ActionSetLocalPref
17-
from synet.topo.bgp import Announcement
18-
from synet.topo.bgp import BGP_ATTRS_ORIGIN
19-
from synet.topo.bgp import Community
20-
from synet.topo.bgp import CommunityList
21-
from synet.topo.bgp import IpPrefixList
22-
from synet.topo.bgp import MatchAsPath
23-
from synet.topo.bgp import MatchCommunitiesList
24-
from synet.topo.bgp import MatchIpPrefixListList
25-
from synet.topo.bgp import MatchNextHop
26-
from synet.topo.bgp import RouteMap
27-
from synet.topo.bgp import RouteMapLine
28-
from synet.topo.gns3 import GNS3Topo
29-
from synet.topo.graph import NetworkGraph
14+
from tekton.bgp import Access
15+
from tekton.bgp import ActionSetCommunity
16+
from tekton.bgp import ActionSetLocalPref
17+
from tekton.bgp import Announcement
18+
from tekton.bgp import BGP_ATTRS_ORIGIN
19+
from tekton.bgp import Community
20+
from tekton.bgp import CommunityList
21+
from tekton.bgp import IpPrefixList
22+
from tekton.bgp import MatchAsPath
23+
from tekton.bgp import MatchCommunitiesList
24+
from tekton.bgp import MatchIpPrefixListList
25+
from tekton.bgp import MatchNextHop
26+
from tekton.bgp import RouteMap
27+
from tekton.bgp import RouteMapLine
28+
from tekton.gns3 import GNS3Topo
29+
from tekton.graph import NetworkGraph
3030
from synet.utils.bgp_utils import compute_next_hop_map
3131
from synet.utils.bgp_utils import extract_all_next_hops
3232
from synet.utils.common import PathReq

synet/synthesis/connected.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ipaddress import ip_interface
1010
from ipaddress import ip_network
1111

12-
from synet.topo.graph import NetworkGraph
12+
from tekton.graph import NetworkGraph
1313
from synet.utils.common import ECMPPathsReq
1414
from synet.utils.common import KConnectedPathsReq
1515
from synet.utils.common import PathOrderReq
@@ -213,7 +213,7 @@ def synthesize(self):
213213
# Assign iface names between edges (if needed)
214214
self.g.set_iface_names()
215215
if self.full:
216-
for src, dst in self.g.edges_iter():
216+
for src, dst in self.g.edges():
217217
if not self.g.is_router(src):
218218
continue
219219
if not self.g.is_router(dst):
@@ -229,7 +229,7 @@ def synthesize(self):
229229
for src, dst in sorted(connected_pairs):
230230
self.synthesize_connection(src, dst)
231231
edges_to_remove = []
232-
for src, dst in self.g.edges_iter():
232+
for src, dst in self.g.edges():
233233
if (src, dst) not in connected_pairs:
234234
if self.is_connnected(src, dst):
235235
continue

synet/synthesis/ebgpy_verify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class EBGPVerify(object):
1616

1717
def __init__(self, network_graph, reqs):
1818
"""
19-
:param network_graph: synet.topo.graph.NetworkGraph
19+
:param network_graph: tekton.graph.NetworkGraph
2020
:param reqs: list of BGP paths preferences
2121
"""
2222
self.network_graph = network_graph

0 commit comments

Comments
 (0)