# Design and Implementation of Virtual Security Function Based on Multiple Enclaves
## 3 Background
### Click  
Click [10] is a famous modular routing software architecture proposed by MIT university to build flexible and configurable routers. It provides a modular router, allowing us to compose different elements for easily building different VNFs. Click consists of fine-grained packet processing modules called elements, each of which implements simple packet processing functions, such as packet classification, queuing, scheduling, and interface with network devices. Based on the modular and scalable architecture, users can also write new elements or combine existing elements according to their own needs. Click is extended as a Linux module on general purpose PC hardware. On the 700 MHz Pentium III, Click can achieve a maximum lossless forwarding rate of 333,000 64-byte packets per second. This is about four times the standard Linux router on the same hardware. It proves that Click's modularity and flexibility are compatible with good performance. The Click architecture is inspired by router properties in several ways. First, the packet switching along the connection can be initiated by the source (push processing) or the destination (pull processing). This allows for a clear simulation of the packet flow patterns of most routers, while pull processing can write a combinable packet scheduler. Second, the flow-based router context mechanism allows elements to automatically locate other elements it depends on. These features make individual elements more powerful and configurations easier to write. The element is the basic unit of packet processing in Click. Each Click element is often only responsible for a single routing function, and each element has multiple entries and exits. Multiple elements can be connected to each other's gateways to form a complex network function using Click's own configuration language. These connections that implement complex network functions are typically stored in a configuration file. Click can complete the initialization and operation of the network function by parsing the configuration file. The most important attributes of the element are as follows. Element class. Each Click element belongs to an element class. It specifies the configuration of the element, initialization, number of exits and entries, and processing of the packet. In addition to the underlying element class, Click also has a number of other components built into it for developers to implement a user-defined element after implementing these basic virtual functions. Port. Elements can have any number of input and output ports. Each connection goes from the output port on one element to the input port on another element. Different ports can have different semantics. For example, by default, the second output port of each element is used to send the wrong packet. Configuration string. Each element of Click needs to be configured successfully before it can be properly initialized. The configuration string usually includes all the parameters required for element initialization and the private state of each element. Elements can be initialized by reading this information from the configuration file. The new element is created in Click by defining a new class, and the input ports, output ports, and configuration strings are modified according to the function. Figure 2 shows how we diagram properties for a single element, EleClass(3). The triangular port is input port and rectangular ports are output ports. EleClass receives data from the input port and sends the processed data to two output ports. The '3' in the brackets represents the configuration string of EleClass, which represents the total number of input and output ports (3). Figure 2: A sample element in Click. The Click configuration is written in a simple Click language that consists of two important structures: a declaration to create elements and a connection. Among them, the connection statement defines the flow of packets between elements.