Netmap to VALE-from high-performance network framework to High-Performance Virtual Network Switch, netmapvale
As mentioned in the previous article, for full virtualization and semi-virtualization, a virtual network interface needs to be assigned to the virtual machine, which requires a vswitch (which can be used together with the hypervisor ), in this way, packets from virtual network interfaces are forwarded from physical interfaces. However, in complex systems, the performance of this vswitch is often poor. The open-source project netmap [1] has built a high-performance network framework and used this principle to design the High-Performance Virtual Network Switch vale [2], vale's performance is also very good in multiple scenarios [3.
Note:Due to project requirements, I often think about how a high-performance vswitch should be implemented. I have benefited a lot from the design and Discussion of netmap and Vale. I have recorded and shared my superficial understanding and hope to help you.
Netmap is described in detail on the official website. The Netmap framework is a channel for high-performance communication between network hardware and applications based on the shared memory mechanism. We can compare Netmap and Linux Network Programming [4] The system calling (read, write) They Need To Do. the functions they want to accomplish are similar. Compared with system calls, netmap has the following main features: the overhead of buffer Allocation and data replication is gone, because shared memory is used and buffer is allocated in advance.
The problem is how the program uses the netmap mechanism? Open a special file/dev/netmap in the program, get a file descriptor, and use ioctl () System Call to select a device. Then you can obtain a region, then, mmap () is used to map the file corresponding to the file descriptor to the region.
Netmap is implemented as a kernel module, mainly including two parts. First, the functions implement basic functions such as open, close, ioctl, poll/select. The other is the device-related part. netmap extends the driver's function to transmit data (as long as the metadata of the descriptor ring is transmitted ). Because zero copy is achieved, high performance can be achieved.
VALE principle Netmap mechanism is to implement VALE(Virtual local ethernet) is the core of high performance.
VALE is actually a virtual local Ethernet switch. It provides each user (hypervisor or process) with a virtual network interface (which can be accessed through the netmap api ). The core work is still on the netmap backend. You need to add the switch logic on the backend, such as the forwarding learning logic. And then further optimization.
As of now, Netmap has been included in the FreeBSD kernel, but it still needs to be compiled and loaded in linux.
References [1] http://info.iet.unipi.it /~ Luigi/netmap/[2] http://info.iet.unipi.it /~ Luigi/vale/
[3] http://info.iet.unipi.it /~ Luigi/papers/20121026-vale.pdf [4] Unix Network Programming
P.s.Because I have only read Vale's paper, and then browsed the webpage a little, I am not very familiar with it, and it is too simple to write. I should be able to learn more from the official website ~~