-
Notifications
You must be signed in to change notification settings - Fork 68
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
Use somltcp #208
Comments
@ibigbug I think I might be of some help here, as I recently stabilized the netstack-smoltcp crate. |
yeah that'd be great. I think @VendettaReborn has been playing with it a bit lately, https://github.com/Watfaq/netstack-smoltcp/blob/main/examples/proxy.rs and it seems it's feasible to use tun crate for the device setup and use smoltcp's stack to deal with layer 4 logic. so we can replace lwip. is that something similar to what in your mind? |
Yes, you are right. I would like to clarify why this is layer 4 and not layer 3. Currently netstack based on smoltcp can work in most scenarios of layer 3. |
Well, I misunderstood you. It seems that you mean tcp/udp. |
yeah that's waht i meant |
@cavivie were you planning to creat a PR for this? |
I'd love to, but before that, can you add more about tun in ss, including unresolved problems and known problems and goals. |
I think the main goal is to replace the lwip w smoltcp, for performance boost, see https://github.com/Watfaq/netstack-smoltcp/blob/main/benchmark.md And adopting pure rust impls over foreign C bindings. This is only for the tun input, not much todo with ss. We already use smoltcp in the user space wirefuard, it consolidates the deps which is another good reason too. And thanks for you work. |
Thank you for your description. I think I will take time to integrate it recently. |
@cavivie @ibigbug i added some soem auto detect interface feature for rust-tun, and here is the example code: https://github.com/VendettaReborn/netstack-smoltcp/blob/f89b9e9b2e56a6abf1b2be9290e4cf63c7be3e11/examples/forward.rs#L142 . Basically, it's just a code version of route commands. And i've tested it on linux,macos & windows. Shall we extract the logic of auto-detect interface, auto setup routes into a independent crate? just like sing-tun? |
cc @Itsusinn |
i would like call it It will combine both https://crates.io/crates/net-route and https://crates.io/crates/tun |
any updates? cc @cavivie |
This comment was marked as outdated.
This comment was marked as outdated.
Ah, ah, first of all, I'm sorry for the reason why I've been busy recently. I want to disassemble the current steps here:
Are there any disassembled independent clates here? I want to do some work based on this. BTW, netstack-smoltcp may have some things that need to be changed. Can I think of anything else you need to add besides some refactoring of the udp part? |
hh, it's ok, and hope you can rejoin it whenever you're ready. for the first point, for example, the route's auto-configuration can be done via programming, here is a WIP version: (https://github.com/VendettaReborn/netstack-smoltcp/blob/auto-detect-interface/src/utils.rs), it can works in netstack-smoltcp's example, but need some extra work before adding it into clash-rs. What's your idea? |
Or wontun 😄 |
i've done some extra jobs on it:
and watfaq-tun may need some reviews and comments. We can make it more robust and user-friendly before putting into usage in clash-rs. |
Awesome work! Thanks! Will take a look |
@VendettaReborn i think we can start integrating your tun with #396 and improve it progressively, thoughts? |
I dont think we need net_route crate(at least on linux). It doesn't meet my requirement of impl auto-route(eg. no fwmark support). |
of course, global routing on linux is easy, your impl of fwmark is surely sufficient, but what about macos and windows? I don't expect most of our users to use linux. |
I could write my route impl on windows. But indeed i cant do the same for macos xD. So i would like take net-route as a platform-specific dep. |
I think we may be further along, since ipv6 local routing is supported after this MR, I have successfully tested ipv6 ping in |
For now, this means we can further work on IPv6 code. Nonetheless, this also seems to mean that the support of the ipv6 part of the smoltcp crate is not perfect enough. We may need to test more to find the problem. I am not sure what specific aspects we need to test for IPv6. Can you give me some advice? |
for the outbound handlers, we have the docker test suites, which will cover tcp&udp. For tun, we haven't figure out some good ways to test it on both ipv4 & ipv6. here is a brief thought: #362 (comment) @cavivie thoughts? |
Absolutely agree, usually routing is definitely an important point that hinders testing. |
yeah, i agree. rust-tun hasn't supported ipv6 yet, we can extend the ability and some other feature(like routing rules setup) in a separate crate.
|
What I mean is that we may need to use the |
oh, i see, that's better. |
To add tun feature, we want
Obviously, I think the first two are more reliable, and in particular, I think the second point is more needed. What do you think? |
that would be great |
After some time testing tun2 and various netstacks, I found that in terms of throughput:
In terms of stability, ipstack currently performs the worst, and even the throughput is unacceptable on win, about 0.2 to 0.3 Gbps., while the VPN scenario focuses more on netstack's read performance, followed by write performance, and finally stability. The above data is only a personal test on a specific device. Later, I will publish a test routine for you to test and compare. |
rust run pef test: https://github.com/automesh-network/rust-tun-perf.git |
Thanks for sharing. To me I think it's still worth adopting smoltcp even with similar bar of performance to lwip for simplicity and pure rust impl. |
No description provided.
The text was updated successfully, but these errors were encountered: