A fast and accurate KVM remote mouse synchronization method

Abstract: Aiming at the synchronization requirements of remotely controlled mouse and host mouse in keyboard monitor mouse (KVM), a mouse synchronization method based on high-speed USB2.0-HID class specification is proposed. In the traditional relative mouse synchronization method, adaptive "residual processing" is added to remove the cumulative error of relative offset, and an absolute mouse synchronization method is added to replace the traditional single-byte relative coordinate offset with double-byte absolute coordinate values. . The experimental results show that the method can reduce the synchronization delay time to less than 3 ms, which can effectively improve the accuracy and timeliness of synchronization.

This article refers to the address: http://

1 Overview

KVM is a combination of keyboard, display, and mouse [1]. Due to network delay or controlled machine resolution is not within the controllable range of KVM, traditional KVM exists in mouse synchronization. The position of the control mouse and the host mouse is too large, the mouse operation is delayed or even unable to respond. Therefore, improving the accuracy and timeliness of mouse synchronization has become an important part of the development of KVM technology. The USB interface that currently supports universal connection of devices and has a high transfer rate has become the mainstream way for peripherals to connect to PC hosts.

The USB 2.0 interface standard adds 480 Mb/s of high-speed support to the original 12 Mb/s and 1.5 Mb/s transfer rates, enabling more transaction data to be transferred and processed per unit of time. Devices such as keyboards and mice that support human interaction with computers are classified as Human Interface Devices (HIDs). They are the most widely used USB devices and have been well supported by built-in drivers for operating systems such as Windows/Linux. According to the HID class specification protocol, this paper sends the signaling data to the controlled machine to simulate the mouse operation through the hardware support of Hi-Speed ​​USB2.0.

2 mouse synchronization method

2.1 Implementation principle

KVM core technology manages multiple remotely controlled machines of KVM switch through proper configuration of keyboard, mouse and display, and realizes accessing and operating multiple controlled machines with one set of I/O peripherals. Figure 1 is a schematic diagram of its frame.

Figure 1 Schematic diagram of the KVM framework

Figure 1 Schematic diagram of the KVM framework

The information of the HID class device is stored in the device ROM as a descriptor, and the signaling and data transmission and acquisition between the device and the host are completed by setting and detecting the corresponding descriptor structure. Specific application data such as keyboard key values ​​and mouse pointer values ​​of HID class devices are mainly described by report descriptors. The report descriptor consists of multiple pieces of rules. The information of the entry consists of fragments, which can be customized by the HID class specification. The third digit of the main entry (Bit2{Absolute(0)|Relative(1)})) identifies whether the device operation uses absolute mode or relative mode, so that there are two methods of absolute synchronization and relative synchronization in the method of supporting mouse synchronization. The mouse data content includes the mouse button state, coordinate position, and scroll wheel scroll value.

The transmission mode adopts the interrupt transmission mode with strict time limit according to the characteristics of small amount of mouse application data, irregular timing, and limited delay. At the same time, Hi-Speed ​​USB 2.0 supports a single transaction to transmit a maximum packet size of 1 024 Bytes, a polling transaction interval of only 125 Fs, and a transfer rate of up to 24.5 Mb/s.

2.2 Relative mouse synchronization

The relative mouse synchronization is based on the difference between the two mouse coordinates before and after the calculation, and the current mouse position is offset. Since the entry is in 1 Byte, the relative synchronization of transferring single-byte coordinate offsets was first applied to mouse synchronization of KVM. The valid data area definitions for mouse synchronization are shown in Table 1.

Table 1 Relative mouse synchronization data area definition

Table 1 Relative mouse synchronization data area definition

The lower 3 bits of the byte, that is, 0 bit~2 bit, respectively indicate the state in which the scroll wheel, the right button, and the left button are pressed or bounced, that is, the button state.

The relative offset difference value ranges from ?127 to 127. When the difference is in the horizontal direction (X-axis) or the vertical direction (Y-axis) is greater than 127, it needs to be moved multiple times, that is, the difference data is sent multiple times. . The scroll wheel scrolls up or down by a line of ±1 and can accumulate scrolling numbers to support more page scrolling. The content of the report descriptor for the relative mouse synchronization defined in assembly language is shown in Table 2.

Table 2 Report descriptors relative to mouse synchronization

Table 2 Report descriptors relative to mouse synchronization

The mouse coordinate value obtained through the interface is in units of one pixel, which has a certain precision loss compared with the actual position. And each time the offset value is compared with the mouse synchronization, the above-mentioned coordinates are used as the reference, and the numerical loss will be continuously accumulated. Aiming at this problem, this paper adds adaptive error compensation in the relative synchronization mode, and detects and processes the accumulated error, that is, "residual processing". This processing method mainly uses coordinate value precision conversion, cumulative residual, and foot 1 compensation. The way to achieve the same, the specific implementation method is as follows:

(1) coordinate value precision conversion

The short double-byte numerical representation is used, with the upper left corner of the screen as the origin, and the coordinates of the lower right corner are defined as (32 767, 32 767) regardless of the resolution, and the coordinates acquired by the interface are converted proportionally according to the screen resolution. .

At the same time, the double-byte absolute coordinate position of this time is recorded as a reference for the next offset, and the cumulative error introduced based on the offset difference is reduced.

(2) Residual accumulation and compensation

Use the double variable to accumulate the fractional values ​​that are discarded each time the coordinate value is converted to a short integer. When the accumulated value is greater than 1, the current coordinate difference is added to 1 and then sent. At the same time, the frequency of the timing detection error integrated value is greater than 1, and when it exceeds a certain level, automatic resynchronization is adopted. That is, first perform 13 (?127,?127) coordinate offsets, move the mouse to the upper left corner of the screen, and then use one to many offsets to position the mouse to the last coordinate position of the control host record.

Then use 13 coordinate offsets. If the 1 920×1 080 resolution screen is the upper bound, you can move the mouse to the upper left corner of the screen in the current mainstream display.

2.3 Absolute mouse synchronization

Absolute mouse synchronization After each direct conversion, the synchronization of its double-byte absolute coordinate values ​​requires repositioning the mouse based on the origin to remove the association with the previous mouse position, thereby avoiding the relative offset. The accumulation of errors. The definition of its valid synchronous data area is shown in Table 3.

Table 3 Data area definition for absolute mouse synchronization

Table 3 Data area definition for absolute mouse synchronization

Absolute mouse synchronization has a more precise synchronization effect and requires 2 Bytes of space for report descriptor entries to represent coordinate values ​​(wheel values), so it must be supported by the operating system's built-in HID class driver. Absolute mouse mode is supported by operating systems such as the modern Windows series (XP/Win7/Vista, etc.), Mac OS 10.5, and Linux 2.6. The OS/2 system was also released in May 2010. xsmouse00.zip provides a mouse driver that supports this mode. program. Since the absolute mouse synchronization method uses double bytes to represent valid data, its report descriptor structure setting is different from the relative synchronization mode, and the descriptor contents are as shown in Table 4.

Table 4 Report descriptors for absolute mouse synchronization

Table 4 Report descriptors for absolute mouse synchronization

3 KVM system overall structure

This paper designs and implements a KVM system based on the mouse synchronization method, which is mainly divided into three modules: (1) a client running on the control host; (2) a KVM switching system connecting multiple controlled machines; (3) The USB interface is connected to the controlled machine and can simulate the control module of the HID device. The overall structure of the KVM system is shown in Figure 2.

Figure 2 KVM system overall structure

Figure 2 KVM system overall structure

The three module functions of the KVM system are defined as follows:

(1) Control host client

The KVM system designed in this paper is based on the B/S framework. The control host combines I/O devices such as mouse, keyboard and display, and calls the operation interface through the web page.

The interface receives the screen of the controlled machine via the TCP/IP network and decodes the display. At the same time, it detects the local mouse and keyboard events and sends the data to the KVM switching system. Since the video stream transmission load of the controlled machine reaches 5 Mb/s~10 Mb/s, in order to avoid mouse data delay, the system uses a separate TCP/IP connection to send mouse and keyboard data.

(2) KVM switching system

The core of the KVM switching system is: an embedded processor that runs the main kernel program and server program, and connects multiple controlled machines through the HPI interface for switching control. The processor network receives the mouse data and completes the coordinate processing algorithm and sends the data to the HID device control module connected to the corresponding controlled machine.

(3) HID device control module

It is connected to the controlled computer with USB2.0 interface and supports transmission rate of 480 Mb/s. The HPI receives the mouse data of the KVM switching system and sets the report descriptor structure, and transmits it to the controlled machine through the interrupt transmission mode to realize the analog control of the mouse device. This module is the core module for completing HID device data communication in the KVM system.

4 Experiment and result analysis

4.1 Delay test

This article tests the overall delay time of the KVM mouse operation and the delay time of the synchronization method module, as defined below:

(1) Overall delay

This article uses the "loopback mode" to test the overall delay. The loopback mode mainly obtains a response time difference between the master and the controlled machine to obtain a delay time. The specific implementation method is as follows: running a test client on the host computer and the controlled machine at the same time, clicking the client interface of the host computer, the interface responds to the event and issues a UDP packet identification time; the event is transmitted to the controlled client. After that, the hosted client also responds to the event and issues a UDP packet. The two UDP packets are captured by the network tool, and the time difference between the two is calculated, that is, the overall mouse delay is obtained.

The implementation process of the mouse overall delay test is shown in Figure 3.

Figure 3 overall delay test

Figure 3 overall delay test

(2) Synchronization method delay

Considering the unfixed factors such as control host performance and network environment, this paper also tests the delay time of the mouse synchronization method. Synchronous method delay test mainly uses hardware interrupt mode. Also run one client on each of the master and the controlled machine, and perform a mouse click on the host client. When the mouse operation data is transmitted from the host client to the processor, the processor generates an interrupt and pulls a high level; the controlled client receives the mouse operation data, sends a UDP packet as a response, and when the processor receives the control The UDP packet on the machine side is pulled low to form a time pulse. Ignoring the network transmission time of the UDP packet, the time pulse width can be approximated as the delay time of the synchronization method. The implementation process of the synchronization method delay test is shown in Figure 4.

Figure 4 synchronization method delay test

Figure 4 synchronization method delay test

The overall mouse delay and synchronization method delay test results obtained in the "loopback mode" test are shown in Table 5.

Table 5 Delay test results

Table 5 Delay test results

4.2 Synchronization accuracy

The KVM test runs for 12 h and plays MKV video on the controlled machine to increase the network transmission load. The mouse is operated regularly and the operation time is maintained for more than 30 h. After testing and evaluation, in the absolute mouse synchronization mode, the position deviation will not occur when the mouse is used for a long time; in the relative mouse synchronization mode, the normal state operation of the mouse does not cause positional unsynchronization, but when the mouse is moved quickly in a wide range of intervals There will be a positional deviation of about 1 mm, but the mouse can automatically correct to re-engage on the move.

5 Conclusion

This paper presents a fast and accurate KVM remote mouse synchronization method. The USB2.0 interface is used to realize high-speed data transmission. By adding adaptive "residual processing" and double-byte coordinate representation to improve the traditional relative mouse synchronization mode, the mouse synchronization mode is absolute. The test results show that the method can improve the accuracy of mouse positioning, and the system can process mouse transactions faster. In the future, the method will be optimized to achieve a better fusion of high speed and high precision.

Super Silent Cummins Diesel Generator

Cummins Genset,Super Silent Cummins Diesel Generator,Diesel Generator With Cummins Engine,Cummins Silent Diesel Generator

Jiangsu Lingyu Generator CO.,LTD , https://www.lygenset.com