uninett / pymetric Goto Github PK
View Code? Open in Web Editor NEWNetwork simulation and visualisation tool
License: GNU General Public License v2.0
Network simulation and visualisation tool
License: GNU General Public License v2.0
when executing the info [router]
command (or pressing a node in the plot) the neighbors statement only lists: <dictionary-keyiterator object at 0x11462b158>
full listing:
>>> info trd-gw
Information for node trd-gw:
name : trd-gw
degree : 9
eccentricity : 6
betweenness : 0.477 (100.00% of max, 1139.03% of avg)
neighbors : <dictionary-keyiterator object at 0x11462b158>
links : trd-narvik (15), trd-teknobyen2 (1), trd-stjordal (14), trd-
teknobyen (4), trd-oslo-100 (10), trd-gw.trd-
gw7-2 (1), trd-tromso (28), trd-gw.trd-gw2
(1), trd-hovedbygget (5)
longest paths : trd-gw <-> kake-gw1 (110.0), trd-gw <-> kake-gw2 (70.0), trd-gw
<-> rena-gw1 (62.0), trd-gw <-> evenstad-gw2
(62.0), trd-gw <-> karasjok-gw1 (61.0), trd-gw
<-> rena-gw2 (61.0), trd-gw <-> evenstad-gw3
(61.0), trd-gw <-> sogndal-gw2 (61.0)
Running on networkx 2.2
When loading a config with a isolated nodes (or one way link to a isolated node) a traceback is generated and pymetric fails.
--> $ python metrics.py ../../drift.uninett.no/htdocs/nett/ip-nett/isis-uninett.net
Initializing model....
Traceback (most recent call last):
File "metrics.py", line 42, in <module>
cli = MetricShell(filename=infile)
File "/Users/runarb/src/metric/pymetric/command.py", line 47, in __init__
self.model.refresh_from_file(self.filename)
File "/Users/runarb/src/metric/pymetric/model.py", line 605, in refresh_from_file
self._refresh_all_paths()
File "/Users/runarb/src/metric/pymetric/model.py", line 627, in _refresh_all_paths
self.nodes_and_paths_using_edge(edge[0], edge[1], self.G)
File "/Users/runarb/src/metric/pymetric/model.py", line 102, in nodes_and_paths_using_edge
for path in paths[1]:
TypeError: 'NoneType' object is not iterable
When a node is isolated with the linkfail command command pymetric throws a traceback and fail
(sim) >>> linkfail kake-gw2 stolav-gw3
Traceback (most recent call last):
File "metrics.py", line 45, in <module>
cli.cmdloop()
File "/Users/runarb/src/metric/pymetric/command.py", line 64, in cmdloop
Cmd.cmdloop(self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cmd.py", line 143, in cmdloop
stop = self.postcmd(stop, line)
File "/Users/runarb/src/metric/pymetric/command.py", line 86, in postcmd
difflen = nx.average_shortest_path_length(self.simulation.graph)\
File "/Library/Python/2.7/site-packages/networkx/algorithms/shortest_paths/generic.py", line 391, in average_shortest_path_length
raise nx.NetworkXError("Graph is not weakly connected.")
networkx.exception.NetworkXError: Graph is not weakly connected.
Pymetric fails to start when networkx version 2.1 is used.
The error is:
Initializing model....
Traceback (most recent call last):
File "/home/he/pymetric/metrics.py", line 42, in <module>
cli = MetricShell(filename=infile)
File "/home/he/pymetric/command.py", line 47, in __init__
self.model.refresh_from_file(self.filename)
File "/home/he/pymetric/model.py", line 591, in refresh_from_file
self.graph = read_pajek(filename)
File "/home/he/pymetric/pajek.py", line 27, in read_pajek
G=parse_pajek(lines)
File "/home/he/pymetric/pajek.py", line 90, in parse_pajek
G.add_edge(u,v,edge_data)
TypeError: add_edge() takes exactly 3 arguments (4 given)
%
The problem is apparently that the API of networkx has changed.
I have a proposed fix, I'll submit it as a pull request and link it to
this issue.
Lines 56 to 72 in b32bdde
An example implementation:
def cap2str(capacity):
if capacity < 1000:
s, i = "K", float(capacity)
elif capacity < 1000000:
s, i = "M", round(float(capacity)/1000.0, 1)
elif capacity < 1000000000:
s, i = "G", round(float(capacity)/1000000.0, 1)
elif capacity < 1000000000000:
s, i = "T", round(float(capacity)/1000000000.0,1)
if i % 1 == 0:
return "{:0.0f}{}bit/s".format(i, s)
else:
return "{:0.1f}{}bit/s".format(i, s)
This will produce:
600 : 600Kbit/s
1500 : 1.5Mbit/s
1984 : 2Mbit/s
34000 : 34Mbit/s
34010 : 34Mbit/s
100000 : 100Mbit/s
155000 : 155Mbit/s
1000000 : 1Gbit/s
2488000 : 2.5Gbit/s
2500000 : 2.5Gbit/s
5000000 : 5Gbit/s
10000000 : 10Gbit/s
20000000 : 20Gbit/s
25000000 : 25Gbit/s
40000000 : 40Gbit/s
50000000 : 50Gbit/s
100000000 : 100Gbit/s
200000000 : 200Gbit/s
400000000 : 400Gbit/s
800000000 : 800Gbit/s
1000000000 : 1Tbit/s
1200000000 : 1.2Tbit/s
When loading a pajek with a one-way link networkx failes computation with a keyError
Traceback (most recent call last):
File "metrics.py", line 45, in <module>
cli.cmdloop()
File "/Users/runarb/src/metric/pymetric/command.py", line 64, in cmdloop
Cmd.cmdloop(self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cmd.py", line 142, in cmdloop
stop = self.onecmd(line)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cmd.py", line 221, in onecmd
return func(arg)
File "/Users/runarb/src/metric/pymetric/command.py", line 424, in do_plot
self.gui.plot(G, graphdata, edge_cmap=cmap, edge_capa=capa)
File "/Users/runarb/src/metric/pymetric/plotting.py", line 292, in plot
pos=data['pos'])
File "/Users/runarb/src/metric/pymetric/plotting.py", line 350, in _plot_edge_labels
if d < 70 and G[v][u]['weight'] == w['weight']:
File "/Library/Python/2.7/site-packages/networkx/classes/coreviews.py", line 54, in __getitem__
return self._atlas[key]
KeyError: 'ifi2-gw4'
not as integers.
example:
longest paths : stolav-gw3 <-> karasjok-gw1 (91.0), stolav-gw3 <-> evenstad-gw3
(85.0), stolav-gw3 <-> evenstad-gw2 (84.0),
stolav-gw3 <-> forde-gw2 (80.0), stolav-gw3
<-> kake-gw1 (80.0), stolav-gw3 <-> sogndal-
gw1 (79.0), stolav-gw3 <-> sogndal-gw2 (78.0),
stolav-gw3 <-> longyear-gw4 (73.0)
The print statements for print "No valid path from %s to %s in model"
are lacking the formatting parameters, node names are displayed as %s instead of real names
Link speeds other than some special speeds are not supported. eg. 2,2.5,5,20,25,40gbit++ is not supported in the current implementation and failes with this error:
(sim) >>> plot with-load
Traceback (most recent call last):
File "/home/he/Desktop/pymetric/metrics.py", line 45, in <module>
cli.cmdloop()
File "/home/he/Desktop/pymetric/command.py", line 64, in cmdloop
Cmd.cmdloop(self)
File "/usr/pkg/lib/python2.7/cmd.py", line 142, in cmdloop
stop = self.onecmd(line)
File "/usr/pkg/lib/python2.7/cmd.py", line 221, in onecmd
return func(arg)
File "/home/he/Desktop/pymetric/command.py", line 424, in do_plot
self.gui.plot(G, graphdata, edge_cmap=cmap, edge_capa=capa)
File "/home/he/Desktop/pymetric/plotting.py", line 248, in plot
for i in range(len(edges))]
KeyError: 40000000
This comes by the line-width array be'ing a static mapping and not allows for dynamic scaling.
se:
Line 53 in b32bdde
When in sim mode the application presents a traceback when pressing a node in the plot-tree:
(sim) (1c/107:5:0n) >>> Information for node kjeller-gw1:
Exception in Tkinter callback
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1536, in __call__
return self.func(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/backends/backend_tkagg.py", line 395, in button_press_event
FigureCanvasBase.button_press_event(self, x, y, num, dblclick=dblclick, guiEvent=event)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/backend_bases.py", line 1785, in button_press_event
self.callbacks.process(s, mouseevent)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/cbook.py", line 527, in process
proxy(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/cbook.py", line 405, in __call__
return mtd(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/backend_bases.py", line 1671, in pick
self.figure.pick(mouseevent)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/artist.py", line 354, in pick
a.pick(mouseevent)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.py", line 3154, in pick
martist.Artist.pick(self, args[0])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/artist.py", line 354, in pick
a.pick(mouseevent)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/artist.py", line 343, in pick
self.figure.canvas.pick_event(mouseevent, self, **prop)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/backend_bases.py", line 1751, in pick_event
self.callbacks.process(s, event)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/cbook.py", line 527, in process
proxy(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/cbook.py", line 405, in __call__
return mtd(*args, **kwargs)
File "/Users/runarb/src/metric/pymetric/plotting.py", line 123, in picktest
self.command.fromui(nodes[i])
File "/Users/runarb/src/metric/pymetric/command.py", line 71, in fromui
self.do_info(node)
File "/Users/runarb/src/metric/pymetric/command.py", line 543, in do_info
infohash = model.get_node_info(args)
File "/Users/runarb/src/metric/pymetric/model.py", line 744, in get_node_info
G.edges(node, data=True))
File "/Users/runarb/src/metric/pymetric/model.py", line 743, in <lambda>
+ " (" + str(int(x[2])) + ")",
TypeError: int() argument must be a string or a number, not 'dict'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.