As I mentioned in the previous article, for full virtualization and para-virtualization, a virtual network interface that needs to be assigned to a virtual machine requires a virtual Switch vswitch (which can be used with hypervisor) to forward the packets from the virtual network interface to the physical interface. But in a complex system, the performance of this virtual switch is often not good. Open source project Netmap[1] made a high-performance network framework, and also used this principle to complete the high-performance virtual network switch vale design [2], in a variety of scenarios, vale measurement performance [3] is also very good.
Note:Because of the project needs, I often think about what a high-performance virtual switch should do. I have benefited from the design and exposition of Netmap and Vale, and I have recorded and shared my superficial understanding and hope to help you.
Netmap because the official online introduction has been very detailed, I briefly describe here. The NETMAP framework is a channel for high-performance communication of network hardware and applications, based on a shared-memory mechanism. The Netmap and Linux network programming [4] need to use the system calls (Read,write) to compare, they want to complete the function is similar. The main feature of Netmap, relative to system calls, is that the overhead of buffer allocation and data replication is lost because shared memory is used and buffer is allocated in advance.
So the question is, how does the program use the NETMAP mechanism? By opening a special file in the program/dev/netmap, get a file descriptor, and use the IOCTL () system call to select a device, then you should be able to obtain a region, and then use Mmap () to the file descriptor corresponding file corresponding to that region.
Netmap is implemented as a kernel module, consisting mainly of two parts. One is the function, realizes those open,close,ioctl,poll/select and so on basic function. The other is the device-related section, which netmap extends the driver's function and is responsible for transmitting the data (as long as it transmits the metadata of the descriptor ring). Because it achieves zero copy, it can achieve high performance.
The netmap mechanism of the Vale principle is the realization of Vale
(Virtual Local Ethernet) is the core of high performance.
Vale is actually a virtual local Ethernet switch. It gives each of its users (hypervisor or process) a virtual network interface (which can be accessed through the Netmap API). The core work is still on the Netmap backend side, which requires the logic of the switch to be added to the backend, such as forwarding learning logic. and then further optimization.
So far Netmap has been included in the FreeBSD kernel, but it is necessary to compile the module and load it under 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 only looked at the Vale of the paper, and then slightly browse the next page, the understanding is not deep, write too simple. Want to learn more about the official website should be able to learn a lot ~ ~
Netmap to vale--from high-performance network frameworks to high-performance virtual network switches