rozaliev / netdma-drivers

3 stars 0 forks source link

Question #1

Closed jaredmdobson closed 8 years ago

jaredmdobson commented 8 years ago

Hey @rozaliev Thank you so much for posting your your comment on reddit (https://www.reddit.com/r/rust/comments/4db897/seastar_clone/) I have been reading it and rereading and searching google trying to understand it all. I was just looking through your repositories to see if I could learn more about what you were trying to accomplish.

So you mentioned that you were writing a kernel bypass networking library and a coroutine library. Honestly that blows my mind I never even knew you could do that. Anyways I am sure you have moved onto other projects but I was just hoping i could get your opinion on these three projects:

https://github.com/libpnet/libpnet - low level networking stack in rust https://github.com/faern/librips - userspace tcp/ip stack in rust / under development. https://github.com/dpc/mioco - coroutine library (like monkeys?)

So i wanted to make an http server that does kernel bypass networking. Is that even a good idea on VMs? Are these three projects a good starting place for what I am looking for?

What should i read to understand more about this whole idea?

Thanks again for the comment and good luck to you! 😄

rozaliev commented 8 years ago

Hey @onesupercoder

Part of the reason that I started working on kernel bypass was to learn more about how fast would stuff work if we remove layers of abstractions and rewrite everything from scratch. It was never my intention to make a production ready system, because honestly I don't believe it's possible without investing thousands hours of developers time. It's also hard because most real life deployment environments are completely unsuitable for this kind of apps. It just doesn't make any sense to deploy in VM, but with the rise of cgroups/namespaces/etc (containers) kind of envs it might get better in the future. And one day we might have netmap support in docker out of the box. As for now kernel bypass is suitable for more niche tasks like routers, firewalls etc (https://blog.cloudflare.com/kernel-bypass/) then general purpose apps.

I have never used libs you mentioned, but as far as I can judge libpnet has netmap backend that you can use, which might be your starting point. mioco is relying heavily on mio and has synchronization used inside which is exactly what you want to avoid with this kind of apps. So you'll have to come up with something of your own or mb use monkeys, keep in mind that it is highly unstable and will require a lot of fixes.

There are different approaches depending on your goals. If you want to dive deeper into hardware, drivers etc then reading Snabb source might be a good place to start. Then read NIC's datasheets, then write your own drivers, and so on. Probably the hardest but most fun way in terms learning new things.

On the other hand if you want something more high level, then you can probably go with netmap and libpnet. librips might be ok, but you'll have to investigate how buffers are implemented and that there are no unnecessary copyings or inefficiencies.

There was also a guy on reddit working on DDOS mitigation with rust and netmap, you might wanna contact him and ask about his experience. Judging by by the recent comments from the post it's opensource now https://github.com/LTD-Beget/syncookied.

As for good overall reads — I don't think that there is one. You'll probably have to go through various articles like the one mentioned in my original comment on reddit, read seastar docs and mail list, dive deep into HPC community and their practices etc to get a solid vision.

It's a challenging but extremely interesting topic, so have fun ;)