Smart dual-redundancy driver for dual-port NICs Based on VxWorks

Source: Internet
Author: User

Abstract:For the PC104 SCM/deth dual-port ethernet card, an intelligent dual-redundancy Network Driver Based on the Vxworks system is designed, the driver provides functions such as network communication fault diagnosis and intelligent switching between NICs. By testing the performance of the smart dual-redundancy driver, the correctness and effectiveness of the design are verified.
Keywords:VxWorks operating system redundancy backup network interface card driver

With the maturity of network technology, ethernet with low price and convenient connection has become the main medium for interface interconnection of various control systems. As a general network data communication system, it has been widely used in the global computer network field. With the increasing informatization of modern ships, Ethernet technology is also applied to modern ship information systems, which not only requires fast information transmission speed, strong anti-interference ability, but also high stability and high reliability of the network, when the network is partially faulty or damaged, the entire system will not fail.
Redundancy Design, as an effective method to improve system reliability, has been widely used. For a single node in the network system, dual-redundancy backup is often required for the NIC, that is, each node uses two network interfaces, and two hubs or switches are used in the middle to interconnect, when the network adapter or line for normal communication fails, the node can automatically switch to the backup network adapter for communication.
Currently, most operating systems (such as Windows, UNIX, and Linux) support multiple NICs, but they are non-redundant. Each Nic has an independent physical address and IP address, supply systems in an independent form. To realize a real smart dual-redundancy network system, you must design a dedicated network driver and submit it to the High-Level application system in a transparent manner, so that the system does not feel the existence of the dual-nic. This article uses the SCM/deth 10 M dual-port ethernet card in the PC104 structure of shengbo Corporation to design and implement the smart dual-redundancy Network Driver Based on VxWorks.
1. network drive principle of VxWorks System
1.1 Introduction to the VxWorks System
The VxWorks operating system is a high-performance, customizable embedded real-time operating system launched by Wind River system. The operating system includes process management, storage management, device management, file system management, network protocols, and system applications. It only occupies a small amount of storage space and can be greatly reduced, this ensures that the system can run with high efficiency. It is widely used in fields with extremely high real-time requirements, such as communication, military, aviation, and aerospace, with its excellent reliability and excellent real-time performance.
VxWorks has the following features:
(1) A highly customizable operating system micro-kernel wind;
(2) It has excellent network processing capabilities and is suitable for TCP/IP protocol families of multiple physical media;
(3) It has an extremely rich BSP, supports multi-processor systems, and supports up to 20 CPUs;
(4) A friendly development and debugging environment for easy operation, configuration, and application development and debugging;
(5) It has good compatibility and supports posix1003.1b;
(6) multiple development and running environments are supported. Supports C, C ++, and Java virtual machines.
1.2 network-driven principles of the VxWorks System
VxWorks supports two types of network device drivers: bsd4.3 Network Driver and scalable enhanced network stack sens ). The bsd4.3 standard provides a close combination of network device drivers and IP protocols, while the sens protocol stack provides replaceable network device drivers, that is, the enhanced network driver end (enhanced networks driver ).
The sens model consists of three parts: protocol driver, multi-interface layer (MUX), and end-type network driver. It is independent of hardware device interfaces and refined network device drivers so that developers can focus on the development of drivers themselves. The smart dual-redundancy driver designed and implemented in this article is an end-type network driver that complies with the sens model standard. In the end-type network driver, it mainly implements Nic device loading, network chip initialization, network packet receiving and sending functions. After the system is started, the operating system calls the end-type network driver through the NIC loading function, during the loading process, network chip initialization, memory pool allocation, and nic device control structure are completed, finally, the control structure of the NIC device and 13 Nic control functions are submitted to the MUX layer through pointer transmission for upper-layer system to use when operating the NIC.
2. Intelligent Dual-redundancy driver implementation
2.1 implementation principle of smart dual-redundancy driver
The implementation principle of the smart dual-redundancy driver is 1. The dotted box contains the smart dual-redundancy driver. When the Vxworks system is started, you must first traverse the configuration file confignet. the network card device table enddevtbl [] in H. The device table contains configuration parameters such as the addresses and interruptions of the two network cards on the dual-port Nic. Then, the system calls sysdethend. sysdethenderson load (…) in C (...) Function. The configuration parameters of the two NICs are passed to the intelligent dual-redundancy driver's Loading Function dethenderson load (…) in the form of function entry parameters (...); The load function creates a control structure for each Nic device, parses the entry configuration parameters, and allocates a memory space for each Nic device. Two NICs must be initialized using the system configuration, at the same time, enter the control structure of the NIC device. Finally, the smart dual-redundancy driver submits the control structure pointer of the NIC device in the main channel to the MUX layer, initiate a Network Fault Diagnosis timer task and a Network Fault Diagnosis task.

The Network Fault Diagnosis timer task is executed in concert with the Network Fault Diagnosis task. The watchdog timer is used to complete the 1 ms timer, and one binary semaphore sem_netdiagnose is released once each scheduled time; the Network Fault Diagnosis task cyclically waits for sem_netdiagnose to receive the semaphores. After the semaphores are obtained, the system immediately determines the port status (connection/non-connection) of the main channel Nic device. When the port is in the connection status, task loop waits for the next semaphore. When the port is not connected, the Network Fault Diagnosis task switches the control structure content of the main channel and the standby channel. The NIC device of the standby Channel Changes to the NIC device of the main channel and starts to work, however, for upper-layer applications, the NIC control structure has not changed.
2.2 Nic Device Control Structure
In the smart dual-redundancy NIC driver, a control data structure is used to control a NIC device, the control structure contains the NIC interrupt vector, I/O base address, bus type, media type, physical address, and other characteristic information. Some of this information is stored in the NIC device table enddevtbl [] and transmitted to the driver as parameters of the driver Loading Function during system startup; some are stored in the ENI's prom, when the NIC Driver is initialized, these feature parameters are written to the NIC control structure.
The smart dual-redundancy NIC Driver defines a control structure for controlling a single Nic device, as shown below:
Typedef struct ne2000_device
{
......
Int unit;/* NIC unit number */
Int ilevel;/* interrupt priority */
Int byteaccess;/* byte storage mode */
Ulong base;/* base address */
Int offset;/* Memory alignment offset */
Volatile ulong imask;/* interrupt screen code */
Uchar enetaddr [6];/* Nic physical address */
......
} Dethenderson _device;
Two Nic device control structures are created in the driver to control the two NICs respectively. Upper-layer applications perform various operations on the NIC by operating the NIC control structure.
2.3 network communication fault diagnosis method
To implement intelligent switching of Network Ports and redundant backup between NICs, you must first diagnose whether the current network adapter is a network communication fault. Any network chip can automatically diagnose the connection status. It indicates whether the network adapter is connected normally or wrong by setting 0 or 1 in the corresponding position of a register of the network chip. It detects whether the network adapter is connected, that is, whether the entire network port from the local network port to the other end of the network cable is connected, it can detect errors such as network disconnection, loose network interfaces, and faults.
The SEM/deth dual-port ethernet card used in this article uses two RTL8019AS network chips. The register group of the network chip adopts paging storage, which is divided into four pages, all are mapped to 16 I/O address spaces. The B2 bits in the config0 register on page 1 indicate the automatic diagnosis result of the NIC connection status. If this bit is 1, the connection is incorrect. If this bit is 0, the connection is normal. The following code determines the network connection status of a smart dual-redundancy-driven Network Fault Diagnosis task:
Setting = sysinbyte (pdrvctrl-> base);/* read command register status */
Sysoutbyte (pdrvctrl-> base, (0xc0 | setting);/* select the register group on the 3rd page */
If (sysinbyte (pdrvctrl-> base + config0_reg) & 0x04)/* network connection Error */
{...... }
2.4 Single physical address implementation
To enable smart dual-redundancy backup for two NICs, they must have the same physical address and IP address. Otherwise, when one network adapter switches to another, if the IP address changes, the system will not be able to receive or send data normally. If the IP address does not change but only the physical address changes, although the system can still receive and send data normally after Nic switching, changes in the ARP binding table in the Protocol Stack may occur due to changes in the physical address, the relationship between the IP address and the physical address of the NIC in the ARP binding table is prolonged.
The system IP address exists in the network protocol stack of the system and is bound to the NIC after the system is started. Because the smart dual-redundancy driver designed and implemented in this article presents the characteristics of a single Nic for the application system and protocol stack, the switching between NICS is only completed in the driver, when a NIC is switched, the IP address of the system does not change.
For the physical address of the network adapter, each network adapter usually has a unique physical address in the world, which is stored in the prom of the network adapter. During Nic initialization, you need to read the physical address from the prom and store it in the appropriate register and data structure. Externally, the value in the register and data structure is the physical address of the NIC. In the smart dual-redundancy driver, when the driver is initialized, it only reads the physical address in a NIC prom, then, write the address to the physical address register of the two NICs and the Data Structure Variable pdrvctrl. In this way, the two NICs have a unified physical address. Because the driver has only one Enis and the other is used as a backup, there will be no conflict between the two physical addresses on the same network.
3. Performance Testing
3.1 Test Method
This article designs and implements a dual-port Nic smart dual-redundancy driver for performance testing. Compile the smart dual-redundancy driver into the VxWorks operating system, use a computer with an SEM/deth dual-port ethernet card as the target machine, and connect the target machine to the switch using two network cables. The application on the target machine sends UDP broadcast packets at a rate of 40 times per second. Use a common PC as the host system, run the Windows2000 operating system, and use the Sniffer Pro tool for network monitoring.
3.2 Test Results and Analysis
As shown in test result 2, the horizontal coordinates represent the number of packets, and the vertical coordinates represent the interval (in seconds) between two consecutive UDP packets in the UDP broadcast message of the target machine received by the host ). As shown in figure 2, the destination server broadcasts UDP packets at a rate of 40 times per second during normal operation. Therefore, the interval between each two packets is mostly about 25 ms. In Figure 2, the interval between eight broadcast packets received by the host is about Ms. This is because eight Nic switches are performed on the target host, packet loss occurs during Nic switching.


According to the test results, the smart dual-redundancy driver designed and implemented in this article can achieve the dual-port Nic Redundancy backup function, when detecting a connection error with the NIC of the primary channel, you can switch to the standby channel to continue network communication, and switch between the two NICs cyclically. At the same time, the driver is transparent to upper-layer users, presents the features of a single Nic, and implements redundant backup between NICs in the driver.
This article designed and implemented a dual-port Nic Intelligent Dual-redundancy Driver Based on VxWorks. In the driver, the network communication fault diagnosis and intelligent switching between NICs are realized, and the single Nic feature is presented to upper-layer applications. Performance tests are performed on the Smart dual-redundancy driver designed and implemented to verify the correctness and effectiveness of the design. However, the test results can also be seen, there is still a long switching time problem during Nic switching, and further research is required.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.