Skip to content

Refactor D2 graph generation#2547

Merged
ipspace merged 2 commits intodevfrom
graph
Jul 26, 2025
Merged

Refactor D2 graph generation#2547
ipspace merged 2 commits intodevfrom
graph

Conversation

@ipspace
Copy link
Owner

@ipspace ipspace commented Jul 22, 2025

Implementing ideas from #2535, add code that creates generic graph data structure for topology and BGP graphs, and use that data structure to generate D2 graphs with generic primitives (d2_cluster, d2_node, and d2_edge)

@ipspace ipspace self-assigned this Jul 22, 2025
@ipspace ipspace marked this pull request as draft July 22, 2025 17:43
@ipspace
Copy link
Owner Author

ipspace commented Jul 22, 2025

This needs tons of testing (I probably broke a few things that worked in the past).

It will close #2534 and #2535 for D2.

@DanPartelly
Copy link
Collaborator

@ipspace Tested it. the graph topology looks cleaner, but now we are missing IP prefixes under node names, and device type in r1[device] .

Maybe sometimes in the future we could use dashed lines -- or a similar stye for tunnel links to make them apart ? Up to you, ofc.

@ipspace
Copy link
Owner Author

ipspace commented Jul 23, 2025

@ipspace Tested it. the graph topology looks cleaner, but now we are missing IP prefixes under node names, and device type in r1[device] .

Thank you, will fix.

Maybe sometimes in the future we could use dashed lines -- or a similar stye for tunnel links to make them apart ? Up to you, ofc.

Sure. I just have to apply the BGP session type logic to link types.

@ipspace ipspace force-pushed the graph branch 2 times, most recently from 21fa5d0 to cc8b8f5 Compare July 25, 2025 15:18
Implementing ideas from #2535, add code that creates generic graph
data structure for topology and BGP graphs, and use that data structure
to generate D2 graphs with generic primitives (d2_cluster, d2_node, and
d2_edge)
@ipspace ipspace marked this pull request as ready for review July 26, 2025 06:17
@ipspace ipspace requested a review from DanPartelly July 26, 2025 06:17
@ipspace
Copy link
Owner Author

ipspace commented Jul 26, 2025

This should be equivalent to the old functionality, but refactored to use the shared "create graph" functions. Once this is merged, I'll redo the GraphViz graphs, and then start adding new functionality (like the tunnel links)

Copy link
Collaborator

@DanPartelly DanPartelly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very nice, and it's getting to a stage where you can drop it in a lab as topology illustration and be done with it.

An observation: if you add a stub LAN to one of the devices in AS 6500, it will be rendered outside the AS. Maybe we should find another way to represent router stubs which have no device attached. See png below.

Ideas for further improvements: if we add different styles to links according to their netlab role, people who used netlab enough will start to have a fair initial idea how IGPs, if any, advertise in the topology.

Second, I know I said maybe we should put the networks on the links as labels, but it was a bad idea. First, you seldom care, and second, it really bloats the topology.

d2(1)

@ipspace
Copy link
Owner Author

ipspace commented Jul 26, 2025

This looks very nice, and it's getting to a stage where you can drop it in a lab as topology illustration and be done with it.

BTW, how do you get nice lines in your diagrams? My D2 diagrams have weird splines line this:

image

@ipspace
Copy link
Owner Author

ipspace commented Jul 26, 2025

An observation: if you add a stub LAN to one of the devices in AS 6500, it will be rendered outside the AS. Maybe we should find another way to represent router stubs which have no device attached. See png below.

To make this work, we'd have to trace the real extent of an AS (explore the connectivity graph until you hit links with role set to external... assuming the user hasn't changed that role). Not sure I want to go there (yet)

@ipspace ipspace merged commit 0683329 into dev Jul 26, 2025
10 checks passed
@ipspace ipspace deleted the graph branch July 26, 2025 07:34
@ipspace
Copy link
Owner Author

ipspace commented Jul 26, 2025

BTW, how do you get nice lines in your diagrams? My D2 diagrams have weird splines line this:

Found it. Have to use elk layout

ipspace added a commit that referenced this pull request Jul 27, 2025
* Implements ideas from #2535 and #2547 for Graphviz graphs
* Adds generic 'object style' mechanism that replaces old 'colors'
  and 'margins' settings
* Corrects #2534 for Graphviz
ipspace added a commit that referenced this pull request Jul 29, 2025
* Implements ideas from #2535 and #2547 for Graphviz graphs
* Adds generic 'object style' mechanism that replaces old 'colors'
  and 'margins' settings
* Corrects #2534 for Graphviz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants