-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supporting multiple network interfaces #134
Supporting multiple network interfaces #134
Conversation
Apologies for the delay in review. I have this queued up for tomorrow morning (08/15). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting started on this.
src/dns.rs
Outdated
fn to_ip_addr(&self, dns: &Dns) -> Option<IpAddr>; | ||
|
||
#[doc(hidden)] | ||
fn to_name(&self, dns: &Dns) -> String; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be in the right place given the name of and responsibilities of the trait.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is only temporarily necessary.
The problem is, that we need a name to create a dns mapping. However not all nodes have a name using the
current API since Sim::client
expects a impl ToIpAddr
. So to get a name for the dns registration,
this trait must temporarily be able to create such a name.
In the future all nodes should have explicit names, independent of their bound addresses, so this will only be temporary. Explicit names could be archived with the proposed builder API for node creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so you want to avoid a breaking change in this first change? If so, can you comment that here saying we'll remove this.
I'm inclined to just break things and work in a remote branch if that allows for less churn.
pub enum IpSubnetParsingError { | ||
AddrParseError(AddrParseError), | ||
IntParseError(ParseIntError), | ||
InvalidSubnetSyntax, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the variants necessary? Could we do something simpler like: https://doc.rust-lang.org/std/net/struct.AddrParseError.html ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this parsing implementation will not be used internally and is just for convenience, it's not strictly necessary.
Whether we should stick to a more complex, but more expressiv API or to a simple easy API, idk
|
||
#[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
pub(crate) struct NodeIdentifer { | ||
node_name: Arc<str>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if having something like a uuid or a u64 would be better as an internal identifier. I can't think of any places that break with str right now. It seems from the PR title you were considering uuid:
Adding internal UUIDs...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The advantage of using str is the fact, that a NodeIdentifier
not only acts as a unique identifier, but can also be used to create tracing spans. So for the time being, I think we should stick to strs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can have both, right? A uuid does all the network mapping and the host that is active in the sim loop still has a human readable hostname that is set on the span before each tick.
So in the spirit of breaking things, this PR fully supports multiple IP subnets, thus multiple bound addresses. Changes
Open questionsBuilder APIThe node builder API is somewhat cumbersome, when creating very simple nodes. Notably sim.node("my-simple-node").build_client(async { ... }); We could implement the API in such a way to allow these statements, sim.client("my-simple-node").build(async { ... });
sim.host("my-simple-host").build(async { ... }); but that would use up the fn names |
I've not gotten the time to review this, many applogies. Another issue just came up that can provide further motivation for prioritizing this work. See #153 |
Hi folks, any update here? This looks like a super useful feature for modeling systems in networking, where multi-interfaces are a must. Would be great to see this available in turmoil! |
Thanks for checking in. This is low priority at the moment. I've got a decent refactor underway for the net modules and after that is in I can pick up contributing to this or guiding the changes. Can you please elaborate on your use cases/requirements so that we take them into consideration? |
At a high level, doing some testing of a network routing protocol. Since the protocol uses a mix of tcp + udp, was hoping to use turmoil to remove networking non-determinism and enable contained testing + fault injection. Being able to treat routers as having multiple interfaces is pretty important (for link-local and loopback-to-loopback communication) |
Closing due to inactivity and because we need to refactor some core things for this to work. |
This PR changes:
NodeIdentifiers
to decouple node addresses and node identitiesIpSubnets
to model different subnets (subnets are not yet supported, see Support multiple network interfaces #132 for progress)1:n
mappings between names andIpAddr
indns.rs
ToIpAddr
traitrelates to #132