Design of universal software structure based on hardware abstraction layer of ACR / Tbit router

Based on the discussion of the basic structure of the hardware abstraction layer, this paper proposes a universal software structure design and implementation of HAL suitable for large-scale access to aggregation routers, providing efficient and reliable internal communication and targeting multi-user access In case of uncertain quantity, an implementation method of dynamically loading virtual driver modules is proposed to enhance the usability of the router's ACR-oriented access method.

1 Basic structure and function realization of the hardware abstraction layer

According to the scheme proposed in the literature, the high-performance router hardware abstraction layer can be divided into three major modules: internal communication, virtual driver and device management. These three parts cooperate with each other to complete the functional simulation of the actual user equipment interface and the shielding of hardware details. , And unified and coordinated management. The function simulation of the user equipment interface by the hardware abstraction layer is mainly completed by the virtual driver module, including the work of sending and receiving data packets and the preprocessing of protocol messages, which provides standard API functions for the upper layer protocol software; and the interface management of the user equipment It is managed and configured and monitored by the upper-layer network management software through the device management module; the internal communication module runs on the internal Ethernet network and coordinates the functional interfaces between the modules to ensure real-time and reliable data between each slave processing unit and the master processing unit transmission. Its basic structure is shown in Figure 1.


Figure 1 Schematic diagram of the basic structure of the hardware abstraction layer

According to the function of each module, the internal communication module of the hardware abstraction layer is an important transmission channel for information exchange between each sub-processing unit and the main processing unit. The internal communication module collects the data of each bottom device and distributes it to each upper processing module according to the type. At the same time, the data maintenance module maintains the virtual device and the processing information of each processing unit through the internal communication module. Therefore, which internal Ethernet-based data transmission implementation method is adopted by the internal communication module plays a vital role in the real-time, effective, and reliable transmission of the internal data of the router. At present, the internal communication module adopts the TCP transmission method based on the delimiter. A special format of the delimiter and the data length field are added to the beginning of the application layer data packet to solve the problem of packet stickiness caused by the Nagle algorithm. However, this method fails to solve the problems of excessive consumption and poor real-time performance of the TCP transmission method. At the same time, removing the splitter to restore the integrity of the message also increases the processing complexity of the application, which inevitably increases the system overhead and reduces the real-time nature of the system. The real-time nature of the system is an urgent problem to be solved for ACR routers where user services have increased dramatically. UDP is a message-oriented transmission protocol, and its maximum data buffer length is 8192 to 65536 bytes, which satisfies the condition of transmitting one complete message at a time. The use of UDP transmission in internal Ethernet has obvious advantages. However, due to the connectionlessness of the UDP protocol, it is an unreliable transmission. The second part of the article will discuss how to implement a reliable transmission mechanism for internal communication based on UDP.

The hardware abstraction layer simulates the function of the user equipment interface mainly through the virtual drive. The expansion of the router service type increases the number of user interfaces and presents the uncertainty of the access time, which brings difficulty to the management of user equipment. In view of this situation, the third part of the paper proposes an implementation method of dynamically loading virtual driver modules to enhance the usability of routers for multi-user access.

2 Reliability realization of internal communication based on UDP transmission

The internal communication module is at the bottom of the hardware abstraction layer, runs on the internal switching network, completes the data transmission of the bottom hardware and the upper control software, and realizes the preliminary shielding and separation of the bottom hardware; for the characteristics of the distributed architecture and the business needs of multi-user access The internal communication module runs on the main processing unit module and each line interface unit module in the manner of Client \ Server, and uses the UDP transmission protocol for communication, mainly based on the following considerations:

First, the UDP protocol is a connectionless protocol. Before transmitting data, the source and terminal do not need to establish a connection, so there is no need to maintain the connection status. In this way, the server can use one or several ports to send messages to multiple clients at the same time, which meets the requirements of the distributed architecture.

Second, the UDP packet is very short, only 8 bytes, compared with the 20-byte packet of TCP, the extra overhead is very small, which facilitates the rapid transmission of data.

Thirdly, the throughput is not regulated by the congestion control algorithm, and is only affected by the rate of data generated by the application software, the transmission bandwidth, and the performance of the computer. It is suitable for data transmission on the internal Ethernet network.

However, due to the connectionlessness of UDP, the reliability of UDP transmission is not strong. Reliability is the performance that the internal communication module must have, so consider the reliability guarantee of the UDP transmission method in the application software, mainly in the following ways:

2.1 Multi-thread connectionless C / S communication method

The server runs under the Linux operating system and uses multithreading to send and receive various types of data; the client runs on the Vxworks operating system and uses multitasking to send and receive various types of data. In this way, due to the characteristics of multi-thread and multi-task parallel operation, under the transmission conditions of internal Ethernet, the rate of sending and receiving data can meet the requirements of the system. The basic connectionless client / server communication program based on UDP protocol is shown in Figure 2.

Figure 2 Connectionless client / server communication program based on UDP protocol

The communication process uses multiple clients (each slave processing unit) to a server (master processing unit), so that multiple user interface modules can access the master control at different times. According to the different types of data transmitted, internal communication uses relatively fixed different port numbers, and different clients use different IP addresses to send and receive similar data from the same port. Through the select () system call on the server side, it can poll each socket port to receive data from different ports in time, and also functions as a timer. When the data is not received within the specified time, it can return in time and continue to wait in blocking mode, so that it can both send and receive data in time and reduce resource consumption.

2.2 Three-way handshake process

Before the real data transmission between the client and the server, a handshake establishment process is required, as shown in Figure 3. After the handshake process is successful, it means that the communication channel between the two parties is normal. Only after learning that the handshake is successful, the two parties can send and receive packets normally, thus overcoming the connectionlessness of UDP protocol. In order to detect and maintain the connectivity of both links at any time, each client and server must send KEEPALIVE messages to each other at a certain interval. If the KEEPALIVE message of the other party cannot be received within the stipulated time, it indicates that the link is broken, and the corresponding link processing should be performed.

Figure 3 Handshake establishment process

2.3 Receiver lost confirmation and sliding window

When sending a UDP message, add the serial number of the sent data to the custom internal data header.The receiving end sends a confirmation message after receiving it.If the sender does not receive the confirmation message within the specified time, it is considered that the packet is lost and will be The serial number of the original packet is resent.

The purpose of the sliding window is mainly to achieve flow control and prevent congestion. Each sender maintains a retransmission queue, which holds a certain number of packets that are sent without being confirmed. The size of the remaining space in the queue can limit the rate at which the application part sends packets. Since the UDP protocol is a message-based transmission protocol rather than a stream-based protocol, there is no need to consider how much data the sender can receive, just know whether it can receive data.

In short, the use of UDP transmission control method mainly considers the characteristics of simple and fast transmission and small additional overhead, but this is premised on sacrificing certain reliability, so a reliability protection mechanism must be added to the application. In practical applications, it is proved that the above method is reliable and efficient, and can maintain the orderly and fast data transmission of internal communication.

3 User access management based on multiple users

Under the Linux operating system, the system maps the device to a special device file, and the user program can read and write to the device file like other files. The virtual driver module runs under the Linux operating system and simulates the interface unit on the slave processing unit to form a hardware abstraction layer virtual interface unit with the function and number of sending and receiving protocol packets consistent with this. Therefore, each actual interface unit corresponds to a registered virtual device in the kernel, so that the upper-layer control software manages the data plane and interacts with the data.

3.1 Dynamic loading of multi-user virtual device drivers

The function of the virtual driver in the kernel is realized by dynamic loading. The usual dynamic loading method is to use the driver as a whole module, and then join the kernel when needed; due to the multi-user access method, the number of interface units registered in the kernel at a certain time is uncertain, and it will be redundant if one-time loading is implemented Too much is not conducive to the effective use of resources. Therefore, on the premise of loading a basic module in the kernel, the dynamic loading process of each virtual device is realized to achieve the function of controlling multiple device driver modules with a basic virtual device.

As shown in Figure 4, the control of the virtual drive device is completed by the internal communication module and the device management module. The device management module issues commands to load and unload the virtual drive through the internal communication module, and the control channel through the internal communication module and the virtual drive. The internal communication module uses different command words to complete the control process of the virtual drive module by calling ioctl ().

Figure 4 Module dynamic loading process

The basic driver module is loaded using the usual driver module loading method, that is, the module_init () function is called to perform the initialization of the basic module and the registration process in the kernel. Based on the basic driver module, when the internal communication module receives a command to load a user device interface, it registers a new driver device in the kernel by calling Base_ioctl () of the basic module. The virtual drive module corresponding to the interface unit, and the application program reading and writing user device data are all performed through the standard functions provided by these registered interface devices rather than the basic devices. This dynamic loading process allows only one basic virtual driver module to exist in the kernel when no device is loaded.Only users who need to register will load the corresponding virtual driver module of the device interface into the kernel, thereby reducing system redundancy. Easy to manage.

The data interaction between each user interface unit and the virtual driver is performed through the internal communication module and the data channel of the virtual driver, and the corresponding system call is dev_ioctl () of the registered device. In this function, data interaction between user space and kernel space is realized.

3.2 Management of virtual drivers for multi-user interface devices

In order to realize the one-to-one correspondence between the kernel virtual driver module and the actual interface unit, the naming principle of each driver module must be solved. Set the position of each actual interface unit in the access segment topology to different parameters. In internal communication, these parameters appear as header information for transmitting data. According to them, a unique string can be generated as a virtual corresponding to the interface unit Drive the device name, and according to the device name, the topology information of the actual interface unit can be restored for internal communication. In the kernel, a dynamic linked list composed of the names of registered devices is maintained. Each linked list node maintains a data queue for sending and receiving messages. The virtual driver interacts with other modules through this linked list.

3.3 The process of reading and writing data to the virtual device

The process of reading and writing data is mainly carried out between the virtual drive module, internal communication module and upper control software. The virtual driver module runs in the kernel space, and the internal communication module runs in the user space. Therefore, it mainly solves the problem of data transfer between the user space and the kernel space. Through memcpy_tofs () and memcpy_fromfs () system call user space and kernel space data interaction.

In the kernel, a dynamic linked list composed of the names of registered devices is maintained. Each linked list node maintains a data queue for sending and receiving messages. The virtual driver interacts with other modules through this linked list. Message receiving process: The internal communication module passes the message received from the interface unit to the virtual driver through the ioctl () call. This function finds the dev_ioctl () function function of the corresponding virtual device through the struct net_device * dev structure, calls memcpy_fromfs () to copy the data to the kernel space, and after processing, informs the upper layer protocol of the incoming data through the neTIf_rx () function. The process of sending messages: the virtual driver puts the data taken from the upper layer software into the data queue maintained by the virtual interface device name maintained by itself, and the internal communication module inquires whether the data queue of each interface device has data readable through ioctl (). If there is data, the virtual driver copies the data to the buffer provided by the user space through the memcpy_tofs () call.

In view of the characteristics of the large-scale user access method, a general software structure design and implementation method based on the hardware abstraction layer of the ACR / Tbit router is discussed, and its key technologies are studied, including internal communication based on the UDP transmission method. Reliability implementation and multi-user-based dynamic module loading technology are suitable for the expansion of routers to carry traffic and multi-user access features, and in the implementation of upper-layer software, the underlying hardware details can basically be ignored, enhancing the openness of the router And scalability.

Induction Coils

Induction Coils,Electronic Eye Induction Coils,Rectangular Induction Coils,Induction Coils For Medical Industry

Shenzhen Sichuangge Magneto-electric Co. , Ltd , https://www.scginductor.com