Skip to content

Network graph processing in Rust#1573

Merged
stevenengler merged 10 commits intoshadow:mainfrom
stevenengler:rust-gml
Aug 23, 2021
Merged

Network graph processing in Rust#1573
stevenengler merged 10 commits intoshadow:mainfrom
stevenengler:rust-gml

Conversation

@stevenengler
Copy link
Copy Markdown
Contributor

@stevenengler stevenengler commented Aug 12, 2021

This replaces shadow's topology parsing and processing with a Rust version. The GML is parsed using nom, and the graph processing is done using petgraph. The GML parser is in src/lib/gml-parser and the graph processing code is in src/main/routing. This also removes the igraph dependency. This PR will be easiest to review as individual commits.

Network graph changes:

  • ignore country_code, city_code, and ip_address node fields (these will be used by tornettools instead)
  • renamed bandwidth_down and bandwidth_up to host_bandwidth_down and host_bandwidth_up

Shadow config changes:

  • removed city_code_hint, country_code_hint, and ip_address_hint host fields
  • added ip_addr and network_node_id (required) host fields
  • added gml_lzma gml_xz graph type

For the GML parser, I'm not super happy with it as a general GML parser and with its memory usage. But it has all of the required functionality required for shadow, so I think it's good enough for now. I might re-visit this in the future. Shadow can also now read lzma-compressed xz-compressed network graph files.

In Shadow's routing code, the IP address assignment was moved out of the DNS type and into a new IpAssignment type. The hosts with the ip_addr field set are assigned their IP addresses first, and then the remaining hosts are assigned IP addresses starting at 11.0.0.1 (skipping any that end in .0 or .255). Shadow computes a lookup table (a RoutingInfo object) that contains computed latencies and packet loss fractions for all pairs of nodes that have hosts assigned to them. Rather than computing these values as-needed during the simulation, we now compute these all before the simulation starts. This lets us free the graph object before starting the simulation.

If the use_shortest_paths config option is true (the default), shadow will compute the shortest paths between all graph nodes that have hosts assigned to them (but using the full graph during the shortest path calculation). For the path from a node to the same node (the path from node X to node X), rather than using a latency of 0, shadow will find the shortest path that contains at least one edge. This is consistent with shadow's current behaviour (shadow's current behaviour technically has a bug when the graph is directed, but that's fixed in this rust version).

If the use_shortest_paths config option is false, the graph must be complete with self-loops (and have at most one edge between any two nodes), and shadow will simply use the direct edge between the two nodes.

The configuration conversion script will no longer generate a valid shadow 2.0 config (for example it doesn't compute the network_node_id fields). But the generated config file should still be useful if someone does need to convert a shadow 1.0 config, and will require a small amount of manual editing to get working. We think this is an okay compromise since the shadow config format has changed a lot, and we don't think the conversion scripts will be used very often.

This PR won't be merged until we have a tornettools PR that's also ready to merge.

@stevenengler stevenengler self-assigned this Aug 12, 2021
@github-actions github-actions bot added Component: Build Build/install tools and dependencies Component: Documentation In-repository documentation, under docs/ Component: Libraries Support functions like LD_PRELOAD and logging Component: Main Composing the core Shadow executable Component: Testing Unit and integration tests and frameworks labels Aug 12, 2021
@stevenengler stevenengler force-pushed the rust-gml branch 2 times, most recently from 03f6be2 to 464edcf Compare August 13, 2021 19:36
@github-actions github-actions bot added the Component: Tools Peripheral tools like parsing log files or visualizing results label Aug 13, 2021
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 13, 2021

Codecov Report

Merging #1573 (c6ce2e2) into main (d64d07c) will increase coverage by 1.82%.
The diff coverage is 59.79%.

❗ Current head c6ce2e2 differs from pull request most recent head 8db4e22. Consider uploading reports for the commit 8db4e22 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1573      +/-   ##
==========================================
+ Coverage   52.51%   54.33%   +1.82%     
==========================================
  Files         141      141              
  Lines       21286    18548    -2738     
  Branches     5380     4452     -928     
==========================================
- Hits        11178    10078    -1100     
+ Misses       7148     5810    -1338     
+ Partials     2960     2660     -300     
Flag Coverage Δ
tests 54.33% <59.79%> (+1.82%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/main/host/syscall/socket.c 78.42% <0.00%> (+0.11%) ⬆️
src/lib/gml-parser/src/gml.rs 19.73% <19.73%> (ø)
src/lib/gml-parser/src/lib.rs 40.00% <40.00%> (ø)
src/main/routing/dns.c 60.60% <57.14%> (-1.97%) ⬇️
src/main/core/controller.c 66.26% <57.69%> (-10.41%) ⬇️
src/main/core/manager.c 69.16% <62.50%> (-1.75%) ⬇️
src/lib/gml-parser/src/parser.rs 40.67% <70.71%> (ø)
src/main/host/host.c 69.96% <81.25%> (+1.06%) ⬆️
src/main/core/worker.c 74.75% <86.66%> (+0.09%) ⬆️
src/main/core/main.c 50.73% <100.00%> (+0.37%) ⬆️
... and 32 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d64d07c...8db4e22. Read the comment docs.

@stevenengler stevenengler marked this pull request as ready for review August 16, 2021 06:14
@sporksmith
Copy link
Copy Markdown
Contributor

added gml_lzma graph type
...
Shadow can also now read lzma-compressed xz-compressed network graph files.

Would it make more sense to decouple the compression type from the graph type? e.g. add a 'compression' attribute?

@stevenengler
Copy link
Copy Markdown
Contributor Author

stevenengler commented Aug 16, 2021

added gml_lzma graph type
...
Shadow can also now read lzma-compressed xz-compressed network graph files.

Would it make more sense to decouple the compression type from the graph type? e.g. add a 'compression' attribute?

I think it would make more sense generally, but also brings up weird situations like if someone specifies type: 1_gbit_switch, compression: xz, which wouldn't make sense. But we could just add more error log statements to cover those.

@stevenengler
Copy link
Copy Markdown
Contributor Author

added gml_lzma graph type
...
Shadow can also now read lzma-compressed xz-compressed network graph files.

Would it make more sense to decouple the compression type from the graph type? e.g. add a 'compression' attribute?

I think it would make more sense generally, but also brings up weird situations like if someone specifies type: 1_gbit_switch, compression: xz, which wouldn't make sense. But we could just add more error log statements to cover those.

@sporksmith What do you think about changing the config format from:

network:
  graph:
    type: gml_xz
    path: graph-compressed.gml.xz

to:

network:
  graph:
    type: gml
    file:
      path: graph-compressed.gml.xz
      compression: xz

Copy link
Copy Markdown
Contributor

@sporksmith sporksmith left a comment

Choose a reason for hiding this comment

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

Still reviewing a commit at a time - stopped at "f784149fe3329c3266e9520537d8ef9887eb1762 Add support for compressed network graphs"

@sporksmith
Copy link
Copy Markdown
Contributor

@sporksmith What do you think about changing the config format from:

LGTM. I just got to that commit in the review - maybe it makes sense for me to skip that commit for now, and you can push a fixup?

@stevenengler
Copy link
Copy Markdown
Contributor Author

@sporksmith What do you think about changing the config format from:

LGTM. I just got to that commit in the review - maybe it makes sense for me to skip that commit for now, and you can push a fixup?

I pushed it as a new commit rather than a fixup since it changes the old uncompressed behaviour as well.

Copy link
Copy Markdown
Contributor

@sporksmith sporksmith left a comment

Choose a reason for hiding this comment

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

Finished - no further comments :)

@stevenengler stevenengler merged commit bd13002 into shadow:main Aug 23, 2021
@stevenengler stevenengler deleted the rust-gml branch August 23, 2021 16:19
@stevenengler
Copy link
Copy Markdown
Contributor Author

The tornettools PR is shadow/tornettools/pull/31.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Build Build/install tools and dependencies Component: Documentation In-repository documentation, under docs/ Component: Libraries Support functions like LD_PRELOAD and logging Component: Main Composing the core Shadow executable Component: Testing Unit and integration tests and frameworks Component: Tools Peripheral tools like parsing log files or visualizing results

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants