Skip to content

Commit

Permalink
Move link info to router page
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwanderer committed Jun 16, 2024
1 parent 16981cc commit 3f288ef
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 25 deletions.
12 changes: 11 additions & 1 deletion mnet/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ def root(request: Request):
good, total = context.frrt.update_monitor_stats()
routers = context.frrt.get_router_list()
links = context.frrt.get_link_list()
link_stats = {}
link_stats["count"] = len(links)
up_count = 0
for link in links:
up1, up2 = context.frrt.get_link_state(link[0], link[1])
if up1 and up2:
up_count += 1

link_stats["up_count"] = up_count

src_stats = context.frrt.get_stat_samples()
stats = []
for stat in src_stats:
Expand All @@ -136,7 +146,7 @@ def root(request: Request):
"current_time": current_time,
"run_time": run_time,
"routers": routers,
"links": links,
"link_stats": link_stats,
"events": events,
"stats": stats,
"ping_stats": ping_stats,
Expand Down
6 changes: 4 additions & 2 deletions mnet/frr_topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,11 @@ def get_router(self, name: str):
for neighbor in self.graph.adj[name].keys():
edge = self.graph.adj[name][neighbor]
result["neighbors"][neighbor] = {
"ip": edge["ip"][neighbor],
"ip_local": edge["ip"][name],
"ip_remote": edge["ip"][neighbor],
"up": self.get_link_state(name, neighbor),
"intf": edge["intf"][neighbor],
"intf_local": edge["intf"][name],
"intf_remote": edge["intf"][neighbor],
}
return result

Expand Down
31 changes: 17 additions & 14 deletions mnet/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ <H1>SatNetMiniSim</H1>
);
</script>

<h2>Links</h2>
<ul>
<li>Total: {{ info["link_stats"]["count"] }}</li>
<li>Up: {{ info["link_stats"]["up_count"] }}</li>
</ul>

<h2>Events</h2>
<ul>
{% if info["events"]|length == 0 %}
<i>None</i>
{% endif %}
{% for entry in info["events"] %}
<li> {{ entry[0] }}: {{ entry[1] }}
{% endfor %}
</ul>


<h2>Ground Stations</h2>
<ul>
{% for entry in info["stations"] %}
Expand Down Expand Up @@ -151,20 +168,6 @@ <h2>Routers ({{ info["routers"]|length }}) </h2>
{% endfor %}
</ul>

<h2>Links ({{ info["links"]| length}})</h2>
<ul>
{% for entry in info["links"] %}
<li> <a href="{{ url_for('view_link', node1=entry[0], node2=entry[1]) }}">
{{ entry[0] }}-{{ entry[1] }} </a> : {{ entry[2] }}
{% endfor %}
</ul>


<h2>Events</h2>
<ul>
{% for entry in info["events"] %}
<li> {{ entry[0] }}: {{ entry[1] }}
{% endfor %}
</ul>
</body>
</html>
18 changes: 10 additions & 8 deletions mnet/templates/router.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ <h1>Router {{ router["name"] }}</h1>
<h2>Interfaces</h2>
<ul>
{% if router.get("ip") %}
<li>loopback: {{ router["ip"] }}
{% endif %}
<li>loopback: {{ router["ip"] }}
{% endif %}
{% for neighbor in router["neighbors"] %}
<li>
{{ router["neighbors"][neighbor]["intf"] }}
{{ router["neighbors"][neighbor]["ip"] }} -
<a href="{{ url_for('view_router', node=neighbor) }}">
<li>
<a href="{{ url_for('view_router', node=neighbor) }}">
{{ neighbor }} </a> :
{{ router["neighbors"][neighbor]["up"][0] }} :
{{ router["neighbors"][neighbor]["up"][1] }}
{{ router["neighbors"][neighbor]["ip_local"] }}
({{ router["neighbors"][neighbor]["intf_local"] }}) -
{{ router["neighbors"][neighbor]["ip_remote"] }}
({{ router["neighbors"][neighbor]["intf_remote"] }})
[ {{ router["neighbors"][neighbor]["up"][0] }},
{{ router["neighbors"][neighbor]["up"][1] }} ]
{% endfor %}
</ul>
<h2> Connectivity </h2>
Expand Down

0 comments on commit 3f288ef

Please sign in to comment.