Implementation of Dual-redundancy Ethernet Card Technology in the underlying driver in VxWorks Environment

Source: Internet
Author: User
Introduction

With the gradual improvement of Ethernet stability, anti-interference and bandwidth problems, Ethernet is entering the industrial control field on a large scale. It is used in industrial process control, communication, spacecraft and navigation systems, and has extremely high requirements on the high speed of reliability and fault response. Currently, redundancy design has been widely used as an effective method to improve the reliability of devices. For a single node in the network system, dual-redundancy backup is often required for the network card, that is, each node uses two network cards (or two network ports), with a hub or switch interconnected in the middle, when the network card or line for normal communication fails, the node can automatically switch to the backup network card for communication. Figure 1 shows a typical connection mode for redundant networks.

Although the node with dual-redundancy Nic has two NICs and two channels, it still shows the characteristics of a single Nic for High-level application systems. Specifically, two NICs have one physical address and one IP address. Based on the TCP/IP Reference Model, TCP/IP protocol families can be divided into four layers: application layer, transmission layer, network layer, and link layer. Redundant Nic technology can be implemented at each layer.

VxWorks, MUX, and NIC Driver

The network protocol stack of the embedded real-time operating system VxWorks has two types of network device driver interfaces: one is the standard bsd4.4driver, which closely associates the driver with the protocol, it is not conducive to the support of multiple protocols. The other standard is unique to VxWorks. It isolates the driver and protocol stack so that the two are connected through a thin layer called MUX, this protects the network service from the impact of a specific network interface driver. Thus, the driver is independent of the specific Protocol to support multiple protocols, as shown in Relationship 2 between the three.

The current version of MUX supports two network driver interface modes: the enhanced Network Driver Interface (end) and the network protocol Toolkit (treaty) driver interface. The following uses the end NIC driver as an example to describe how to implement dual Nic Redundancy Design in the ne2000 compatible NIC Driver Under vxworks5.4. Under normal circumstances, the protocol driver submits a request through the NIC handle provided by the MUX layer, which is obtained by calling endload (). Then, the MUX layer calls the interface function in the NIC Driver, implement High-level protocol driver requests.

Analysis of Dual-redundancy Nic technology at the application layer

In the system, dual-redundancy backup is performed for the NIC, that is, one Nic is used normally, and the other Nic is used as a backup. The NIC used for backup is active. When a network card with normal communication fails or the system requires it, the Network Card Used for backup can be automatically switched to continue working in real time. Obviously, this requires that the two NICs only use the same physical address and the same IP address. From the perspective of the application, we can only see that one network card is working, and do not care which network card is working and how to switch.

In theory, the redundant Nic technology can be implemented in the OSI layers. The more at the underlying layer, the faster the detection and switching speed, the better the effect. Other methods to use the application layer to implement dual-redundancy NICs are to initiate tasks in the program and continuously judge the working status of the current Working Nic In the query mode, when it is determined that the currently used Nic is abnormal, the current Nic route will be deleted, the current host name will be deleted from the host list, and the nic and protocol will be unbound; configure the backup NIC: bind the protocol to the backup Nic and set the subnet mask and IP address. This method is used for actual testing. In the test, the host with dual-nic continuously sends broadcast packets and receives them using network analysis software. The average switching time between the two network ports is 120 ms. During the switching, many broadcast packets are lost. It can be seen that dual-nic Redundancy backup technology is implemented at the application layer, and nic switching is slow, which is not conducive to network reliability and real-time performance.

Implementation in the driver

In the Vxworks system, NICS of the same type use the same driver, and the NICS are differentiated by the handles provided by the driver. When MUX calls the interface function of the NIC driver, it will pass the NIC handle into the function. This provides the basis for implementing dual-nic Redundancy backup in the driver. Therefore, the best way to achieve dual-redundancy backup for NICS is to implement it in the NIC Driver.

Data Structure

The most critical data structure in the NIC driver is the data structure related to NIC features. Each network adapter has its own characteristics, including its unit number, interrupt vector, I/O base address, physical address, and so on.

When the system starts, In the NIC-driven Loading Function ne2000endload (), a data structure is initialized for the device, and a pointer is assigned to the structure. At this time, two global pointers are defined:

NE2000END-DEVICE * pDrvCtrl-0;
NE2000END-DEVICE * pDrvCtrl-1;

During Nic initialization, the two pointers point to the data structure of the two NICs respectively. With the definition of the two pointers, when MUX calls the interface function of the NIC driver, you can choose a pDrvCtrl-0 or pDrvCtrl-1 to adjust the working network card according to the quality of the network card or the needs of the system.

Sending and receiving

When the upper-layer driver calls the NIC Driver's sending function through MUX, it will pass in the NIC handle and specify the NIC to be used. Generally, the driver sends a command to the corresponding NIC based on the handle to send the packet. In the dual-nic Redundancy backup driver, specify the NIC used to send data as needed, instead of the NIC specified by MUX. For example, read the link signal registers of two NICs to determine whether the network connection is disconnected, and then decide which Nic is used to send data.

When receiving a message, it is usually processed during interruption. Because of the characteristics of Ethernet on the physical layer, two NICs can receive packets. The difference is that only the data received by the NICS bound to the high-level protocol can be transferred up. In the dual-nic Redundancy backup driver, data is not transferred up by the NIC handle specified by MUX, but is transferred up to the layer according to the working status of the current Nic, even if the data is received from another network card or the other network card is not bound to the high-level protocol.

Processing of a single physical address

Generally, each Nic has a unique physical address in the world, which is stored in the prom of the NIC. During Nic initialization, you need to read the physical address from the prom and store it in an appropriate register and data structure.

To enable mutual backup between two NICs, they must have the same physical address and IP address. You can use the physical address of one of the two Nic Redundancy backup drivers. There are two methods: Read-only the physical address of the prom of one Nic during driver initialization, or modify it in the ne2000enetaddrget () function of the NIC Driver, you can set any physical address for the network card (as long as it avoids conflicts in the same network ).

Single IP address Processing

When two NICs use the same IP address, you can achieve this: When two NICs are installed, only one Nic has an IP address, and the other Nic has no IP address. Because the IP address bound to the NIC is implemented at the network layer where the IP protocol is located, switching the NIC below the network layer is completely transparent to the upper layer. The application sees only one network adapter working from the beginning. Figure 3 shows dual-nic backup from the application perspective.

Performance Analysis

Through the comparison experiment, the average network adapter switching time for dual-nic Redundancy backup at the application layer is 120 ms, and the average network adapter switching time for dual-nic Redundancy backup at the driver layer is 5 ms, compared with the implementation at the application layer or other layers, the efficiency is high, which greatly shortens the switching time of the dual Nic, thus reducing the probability of packet loss during network communication.

Conclusion

This paper analyzes the network structure model of the Vxworks system, proposes an idea of implementing the dual-nic Redundancy backup function in the underlying driver of the system, and designs and implements it, at the same time, the implementation in the driver program and the implementation in the application layer are compared, it is proved that the driver can not only achieve the dual Nic Redundancy backup function, in addition, it improves the real-time and reliability of Ethernet, which is of some practical significance in today's booming industrial Ethernet.

Reference address: www.2beanet.com/bbs http://www.2beanet.com/

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.