CN117493248B - USB data transmission method, device, system, electronic equipment and storage medium - Google Patents

USB data transmission method, device, system, electronic equipment and storage medium Download PDF

Info

Publication number
CN117493248B
CN117493248B CN202311850453.9A CN202311850453A CN117493248B CN 117493248 B CN117493248 B CN 117493248B CN 202311850453 A CN202311850453 A CN 202311850453A CN 117493248 B CN117493248 B CN 117493248B
Authority
CN
China
Prior art keywords
data
usb
data packet
transmitted
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311850453.9A
Other languages
Chinese (zh)
Other versions
CN117493248A (en
Inventor
曹江城
满宏涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Metabrain Intelligent Technology Co Ltd
Original Assignee
Suzhou Metabrain Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Metabrain Intelligent Technology Co Ltd filed Critical Suzhou Metabrain Intelligent Technology Co Ltd
Priority to CN202311850453.9A priority Critical patent/CN117493248B/en
Publication of CN117493248A publication Critical patent/CN117493248A/en
Application granted granted Critical
Publication of CN117493248B publication Critical patent/CN117493248B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4004Coupling between buses
    • G06F13/4009Coupling between buses with data restructuring
    • G06F13/4013Coupling between buses with data restructuring with data re-ordering, e.g. Endian conversion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0042Universal serial bus [USB]
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Systems (AREA)

Abstract

The invention provides a USB data transmission method, a device, a system, electronic equipment and a storage medium, and relates to the technical field of data communication, wherein the method comprises the following steps: acquiring a data stream to be transmitted, which is to be transmitted to a USB data receiving end by a USB data transmitting end; generating a data packet sequence corresponding to a data stream to be transmitted, wherein the data packet sequence comprises a plurality of target data packets in a preset format which are arranged according to a time sequence; and sequentially sending each target data packet in the data packet sequence to the USB data receiving end. The USB data transmission method, the device, the system, the electronic equipment and the storage medium can improve the transmission rate of USB data transmission on the basis of ensuring the safety of USB data transmission and not increasing the design complexity, and can reduce the delay rate of USB data transmission, increase the bandwidth utilization rate of a data link and reduce the occupation of computing resources.

Description

USB data transmission method, device, system, electronic equipment and storage medium
Technical Field
The present invention relates to the field of data communications technologies, and in particular, to a method, an apparatus, a system, an electronic device, and a storage medium for USB data transmission.
Background
A universal serial bus (Universal Serial Bus, abbreviated as USB) is a serial bus standard for connecting a computer to an external device. The USB technology, which is a computer peripheral interconnection technology, has advantages of high speed, hot plug, scalability, and multi-device support, and is widely used in various electronic devices such as computers, televisions, audio, video, storage devices, game machines, and the like.
USB data transmission refers to a process of exchanging data using a USB interface. In order to ensure the security of USB data transmission, a cyclic redundancy check (cyclic redundancy check, CRC) technique is generally used in the related art to detect and correct errors that may occur during USB data transmission.
However, the CRC technique is used to detect and correct errors that may occur during the transmission of USB data, which may adversely affect the transmission rate of the USB data transmission. Therefore, how to improve the transmission rate of USB data transmission on the basis of ensuring the security of USB data transmission is a technical problem to be solved in the art.
Disclosure of Invention
The invention provides a USB data transmission method, a device, a system, electronic equipment and a storage medium, which are used for solving the defect that the transmission rate of USB data transmission is adversely affected by detecting and correcting errors possibly occurring in the USB data transmission process by adopting a CRC technology in the prior art, and improving the transmission rate of USB data transmission on the basis of ensuring the safety of USB data transmission.
The invention provides a USB data transmission method, which comprises the following steps:
under the condition that a USB data sending end is effectively connected with a USB data receiving end, acquiring a data stream to be transmitted, which is to be sent to the USB data receiving end by the USB data sending end;
generating a data packet sequence corresponding to the data stream to be transmitted, wherein the data packet sequence comprises a plurality of target data packets in a preset format which are arranged according to a time sequence;
and sequentially sending each target data packet in the data packet sequence to a USB data receiving end.
According to the method for transmitting USB data provided by the present invention, before each target data packet in the data packet sequence is sequentially transmitted to a USB data receiving end, the method further includes:
constructing a main communication link and a bypass communication link between the USB data transmitting end and the USB data receiving end;
the step of sequentially sending each target data packet in the data packet sequence to a USB data receiving end includes:
and sequentially transmitting the target data packets in the data packet sequence to a USB data receiving end through the main communication link, and sequentially transmitting the target data packets in the data packet sequence to the USB data receiving end through the bypass communication link if the main communication link is abnormal, according to the sequence of the target data packets which are not transmitted and remain in the data packet sequence, if the main communication link is abnormal, transmitting the target data packets which are not transmitted and remain in the data packet sequence to the USB data receiving end through the bypass communication link.
According to the method for transmitting USB data provided by the invention, the blank data packet in the preset format comprises a blank data packet head with a first length, a blank data block with a second length and a blank check code block with a third length which are sequentially arranged, wherein the blank data packet head is used for storing a field for indicating the type of the data packet, the blank data block is used for storing data to be transmitted in the data stream to be transmitted, and the blank check code block is used for storing a check code for checking the data to be transmitted.
According to the method for transmitting USB data provided by the invention, the front target number bits of the data packet header in the blank data packet with the preset format are used for storing the field indicating the type of the data packet.
According to the method for transmitting USB data provided by the present invention, the generating a data packet sequence corresponding to the data stream to be transmitted includes:
sequentially storing the data to be transmitted in the data stream to be transmitted to a target storage space according to the transmission time sequence of the USB data transmitting end;
extracting the data to be transmitted with the second length from the target storage space in sequence according to the storage time sequence stored in the target storage space, filling the data into the data blocks in the blank data packet with the preset format until all the data to be transmitted in the target storage space are filled into the data blocks in the blank data packet with the preset format, obtaining a plurality of original data packets,
Filling a front target number of bits of each of the original data packets according to the type of each of the original data packets,
generating a check code corresponding to each original data packet according to a target algorithm, and filling the check code corresponding to each original data packet into a check code block of each original data packet to obtain each target data packet;
and arranging all the target data packets according to the time sequence of the filling data blocks to obtain a data packet sequence corresponding to the data stream to be transmitted.
According to the method for transmitting USB data provided by the present invention, the constructing a bypass communication link between the USB data transmitting end and the USB data receiving end includes:
and sending a bypass communication interface signal corresponding to the USB data sending end to the USB data receiving end so that the USB data receiving end responds to the bypass communication interface signal to establish a bypass communication link with the USB data sending end.
According to the present invention, there is provided a USB data transmission method, the bypass communication interface signal includes: an output signal, an output clock signal, an input clock signal, and an output input status signal; the output signal and the input signal are used for constructing the bypass communication link, and the output clock signal and the input clock signal are used for synchronizing clocks of the USB data receiving end and the USB data transmitting end; the output-input status signal is used to indicate a communication status of the bypass communication link.
According to the method for transmitting USB data provided by the present invention, the generating a check code corresponding to each original data packet according to a target algorithm, filling the check code corresponding to each original data packet into a check code block of each original data packet, and obtaining each target data packet includes:
generating a cyclic redundancy check code corresponding to each original data packet according to a cyclic redundancy check algorithm;
and filling the cyclic redundancy check code corresponding to each original data packet into the check code block of each original data packet.
According to the method for transmitting USB data provided in the present invention, after the data to be transmitted in the data stream to be transmitted is sequentially stored in a target storage space according to the transmission timing sequence of the USB data transmitting end, the data block of the second length of data to be transmitted in one blank data packet in the preset format is sequentially extracted from the target storage space according to the storage timing sequence stored in the target storage space until all the data to be transmitted in the target storage space are filled in the data block of the blank data packet in the preset format, and before obtaining a plurality of original data packets, the method further includes:
And eliminating redundant data in the data to be transmitted from the target storage space.
According to the USB data transmission method provided by the invention, the USB data transmission mode is realized based on the USB 3.0 protocol.
According to the method for transmitting USB data provided by the invention, the acquisition of the data stream to be transmitted, which is to be transmitted by the USB data transmitting end to the USB data receiving end, is completed by a physical layer in a USB 3.0 protocol;
the generation of the data packet sequence corresponding to the data stream to be transmitted is completed in a protocol layer and a data link layer in a USB 3.0 protocol;
and the step of sequentially sending each target data packet in the data packet sequence to the USB data receiving end is completed by a physical layer in the USB 3.0 protocol.
According to the method for transmitting USB data provided by the invention, the physical layer, the data link layer and the protocol layer in the USB 3.0 protocol execute the following specific steps:
the physical layer acquires the data stream to be transmitted and sends the data stream to be transmitted to the data link layer;
the data link layer sequentially stores the data to be transmitted in the data stream to be transmitted to a target storage space under the condition that the data link layer receives the data stream to be transmitted sent by the physical layer;
The protocol layer sequentially extracts data to be transmitted with the second length from the target storage space to be filled into data blocks in blank data packets with the preset format according to the storage time sequence stored in the target storage space until all the data to be transmitted in the target storage space are filled into the data blocks in the blank data packets with the preset format, obtains a plurality of original data packets, fills the front target number bit of the data packet head of each original data packet according to the type of each original data packet, generates a check code corresponding to each original data packet according to a target algorithm, fills the check code corresponding to each original data packet into the check code block of each original data packet, obtains each target data packet, arranges each target data packet according to the time sequence of the filled data blocks, obtains the data packet sequence, and sends the data packet sequence to the data link layer;
the data link layer sends the data packet sequence to the physical layer under the condition that the data packet sequence is received;
and the physical layer sequentially sends each target data packet in the data packet sequence to a USB data receiving end under the condition that the data packet sequence is received.
According to the USB data transmission method provided by the invention, judging whether the main communication link is abnormal or not comprises the following steps:
under the condition of receiving error information sent by a USB data receiving end, determining that the main communication link is abnormal;
the error information is used for indicating that any data packet in the data packet sequence fails data verification and/or any data packet in the data packet sequence is lost.
According to the USB data transmission method provided by the invention, judging whether the main communication link is abnormal or not comprises the following steps:
and determining that the main communication link is abnormal under the condition that the data transmission rate in the main communication link is smaller than a rate threshold value and/or the transmission delay rate of the main communication link is larger than a delay rate threshold value.
The invention also provides a USB data transmission device, which comprises:
the data stream acquisition module is used for acquiring a data stream to be transmitted, which is to be transmitted to the USB data receiving end by the USB data transmitting end, under the condition that the USB data transmitting end is effectively connected with the USB data receiving end;
a data packet sequence acquisition module, configured to generate a data packet sequence corresponding to the data stream to be transmitted, where the data packet sequence includes a plurality of target data packets in a preset format that are arranged according to a time sequence;
And the data packet sending module is used for sequentially sending each target data packet in the data packet sequence to the USB data receiving end.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing any one of the above mentioned USB data transmission methods when executing the program.
According to the electronic equipment provided by the invention, the electronic equipment comprises a computer and peripheral equipment.
The invention also provides a USB data transmission system, which comprises: a USB data transmitting end, a USB data receiving end and the electronic equipment; the USB data transmitting end is electrically connected with the electronic equipment; the USB data receiving end is electrically connected with the electronic equipment.
The invention also provides a USB data transmission system, which comprises: a USB data transmitting end and a USB data receiving end;
the USB data transmitting end is the electronic equipment, or the USB data receiving end is the electronic equipment.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a USB data transmission method as described in any one of the above.
The invention also provides a computer program product comprising a computer program which when executed by a processor implements a USB data transmission method as described in any one of the above.
According to the USB data transmission method, device, system, electronic equipment and storage medium, through converting the data stream to be transmitted, which is to be transmitted by the USB data transmitting end to the USB data receiving end, into a plurality of data packets which are arranged according to the time sequence and have the same format and the same length, each data packet in the data packet sequence is sequentially transmitted to the USB data receiving end according to the time sequence of each data packet in the data packet sequence, the data stream between the USB data transmitting end and the USB data receiving end can be unified, the data control logic can be simplified, the need of re-reading the data packet length when the data is checked by adopting the cyclic redundancy check code technology can be avoided, the logic complexity of a protocol layer and a data link layer can be reduced, the data processing speed can be improved, the transmission rate of USB data transmission can be improved on the basis of ensuring the safety of USB data transmission and not increasing the design complexity, the delay rate of USB data transmission can be reduced, the bandwidth utilization rate of a data link can be increased, and the occupation of calculation resources can be reduced.
Drawings
In order to more clearly illustrate the invention or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a USB data transmission method provided by the invention;
FIG. 2 is a schematic diagram of a blank packet with a predetermined format in the USB data transmission method according to the present invention;
FIG. 3 is a schematic diagram of the structure and data interaction of the layers in the USB 3.0 protocol;
FIG. 4 is a flow chart of constructing a target data packet in the USB data transmission method according to the present invention;
fig. 5 is a schematic structural diagram of a main communication module and a bypass communication module in a data link layer in the USB data transmission method according to the present invention;
FIG. 6 is a schematic diagram of a USB data transmission device according to the present invention;
fig. 7 is a schematic structural diagram of an electronic device provided by the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the description of the invention, it should be noted that, unless explicitly stated and limited otherwise, the terms "mounted," "connected," and "connected" are to be construed broadly, and may be, for example, fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; can be directly connected or indirectly connected through an intermediate medium, and can be communication between two elements. The specific meaning of the above terms in the present invention can be understood by those of ordinary skill in the art according to the specific circumstances.
In the description of the present application, the terms "first," "second," and the like are used for distinguishing between similar objects and not for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged, as appropriate, such that embodiments of the present application may be implemented in sequences other than those illustrated or described herein, and that the objects identified by "first," "second," etc. are generally of a type and not limited to the number of objects, e.g., the first object may be one or more. In addition, in the description of the present application, "and/or" means at least one of the connected objects, and the character "/", generally means a relationship in which the front and rear associated objects are one kind of "or".
It should be noted that the rapid development of artificial intelligence, the internet and the mobile terminal brings about a great opportunity and challenge to the server market, and a great deal of data storage, data calculation and data communication need to be completed by a server. The server is similar to microcomputer in structure and is composed of processor, hard disk, memory, system bus, etc., but with the development of data computing technology, the requirements for data bandwidth, transmission rate, data security, etc. of information system are also increasing. At present, peripheral devices (such as a keyboard, a mouse or other storage devices and the like) in communication with a server are interconnected with the server through a USB interface protocol, and the USB interface protocol supports hot plug, plug and play and is convenient to carry, so that the peripheral devices are increasingly applied by clients in the industry.
USB is a serial bus standard for connecting a computer to an external device, and can be used for standardizing the connection and communication between the computer and the external device. USB technology, which is also known as Universal Serial Bus (USB), is widely used in various electronic devices such as computers, televisions, audio, video, storage devices, and game consoles, because of its advantages of easy availability, fast speed, flexibility, high speed, hot plug, scalability, and multi-device support.
With the increasing development of artificial intelligence technology and big data technology, video data and storage devices are increasing, so that the demands of high-performance storage capacity and high bandwidth are increasing.
In the related art, USB technology may initially provide a low-speed transmission rate for peripheral devices. With the development of computing power of computers, computers can process larger amounts of data, and more data is required to interact with the computer through USB technology. The USB 2.0 protocol may provide faster transmission rates (480 Mb/s) while maintaining backward compatibility.
With the development of wireless communication technology, wireless USB (Wireless USB) technology can connect USB devices to computers or other host devices wirelessly without using a conventional wired USB connection.
With the development of computer technology, the application of USB technology has far exceeded the way in which a computer is connected as a peripheral. The printer can be directly connected with the camera by utilizing USB technology; the computer connects the keyboard and the mouse using USB technology. Also, the definition of USB On-The-Go (OTG) provides a way for two dual role capable devices to interconnect and negotiate which one will operate as a "host".
USB, a serial bus standard, is also used in many non-traditional applications, such as industrial automation. With the continued advancement of technological innovation, new devices, media formats, and inexpensive mass storage are emerging with ever increasing demands on the bandwidth of USB data transmissions. For example, a high definition camera will have hundreds of GB of storage content that needs to be migrated to a computer end for editing, viewing, and packaging by a user using USB technology.
Further, the storage capacity of various electronic devices such as digital cameras and the like is becoming larger, and downloading hundreds or even thousands of raw pictures of 10MB or more from a digital camera is a very time-consuming process unless the USB data transfer rate is increased.
The maximum transmission bandwidth of the USB 3.0 protocol can reach 5.0Gbps, and the USB 3.0 protocol is matched with the application and equipment of the mass storage by increasing the higher transmission rate, so that the requirement on the bandwidth of USB data transmission is better met. Thus, USB technology remains the best solution to the connectivity problem between computers and peripherals, and mobile architectures of peripherals and peripherals.
The goal of the USB 3.0 protocol is still to enable interoperability under this open architecture between devices of different vendors while maintaining and utilizing existing USB infrastructure (device drivers, software interfaces, etc.). Product functional diversity and market indexing are met without retaining outdated interfaces or losing compatibility.
With the development of information technology, in order to meet the increasing demands of communication and computation, USB data transmission has evolved from a traditional parallel transmission mode to high-speed serial transmission, and the requirements on the data processing capability of an information system are also increasing.
In USB data transmission, errors are generated in USB data due to the influence of various kinds of interference, such as impulse interference, random noise interference, artificial interference, and the like. In order to be able to control errors in the transmission process, efficient measures need to be taken to control the generation of errors. Cyclic redundancy check (cyclic redundancy check, CRC) is a fairly powerful error detection, correction code, and the circuitry to implement the coding and the detection is relatively simple, so the USB protocol provides protection against occasional errors, and both packet framing (packet framing) and link commands (link commands) have enough redundancy information to tolerate a single bit error (single-bit errors).
In the related art, a cyclic redundancy check (cyclic redundancy check, CRC) technique is generally used to detect and correct errors that may occur during USB data transmission. However, although the USB3.0 protocol supports 5.0Gbps at the highest, the size of the data packet sent each time when USB data transmission is performed under the USB3.0 protocol is not necessarily the same, and if the CRC technique is used to detect and correct errors possibly occurring in the USB data transmission process, each data packet needs to re-read the length of the data packet, which results in complex protocol layer data logic, further results in reduced transmission efficiency of USB data transmission, increased data transmission delay rate, and increased occupied space of the controller. In addition, in the conventional USB data transmission method, the byte bits in the USB data stream generally include a lot of redundant data, which also adversely affects the transmission efficiency of the USB data transmission.
In addition, in the case of performing functions such as link training and management, and register access for link initialization and debugging, since there is only one communication link for USB data transmission, if management and configuration of the communication link are performed, it is necessary to interrupt effective data transmission, resulting in a decrease in bandwidth utilization of USB data transmission.
Therefore, in order to improve the transmission rate of USB data and reduce the delay rate of data transmission and the occupation of computing resources on the basis of ensuring the safety of USB data transmission, the invention provides a USB data transmission method. According to the USB data transmission method provided by the invention, the bypass channel and the data with the self-defined fixed format are added, so that the USB3.0 protocol digital logic is simplified, the optimization is performed at the protocol layer and the data link layer, the working rapid communication of the USB3.0 equipment is realized, and the overall performance is improved.
Fig. 1 is a flow chart of a USB data transmission method according to the present invention. The USB data transmission method of the present invention is described below with reference to fig. 1. As shown in fig. 1, the method includes: step 101, under the condition that the USB data sending end is effectively connected with the USB data receiving end, obtaining a data stream to be transmitted, which is to be sent to the USB data receiving end by the USB data sending end.
It should be noted that, the execution body of the embodiment of the present invention is a USB data transmission device.
Specifically, a data stream to be transmitted, which is to be transmitted by a USB data transmitting end to a USB data receiving end, is a transmission object of the USB data transmission method provided by the present invention. Based on the USB data transmission method provided by the invention, the transmission rate of the data stream to be transmitted can be improved on the basis of ensuring the transmission safety of the data stream to be transmitted.
It should be noted that, in the embodiment of the present invention, the USB data receiving end and the USB data transmitting end may be determined based on actual requirements. In the embodiment of the invention, the USB data receiving end and the USB data transmitting end are not particularly limited.
It can be understood that, in the embodiment of the present invention, the USB data receiving end and the USB data transmitting end may be any one of a computer, a server, and a peripheral device. The peripheral device (Peripheral Device) is a device connected to a computer or other main device and extending its functions, and is generally used for inputting, outputting, storing, communicating, etc. operations to meet specific demands of users on the computer system. Peripheral devices may include, but are not limited to, keyboards, mice, printers, displays, scanners, digital cameras, external storage devices, speakers, and the like.
It can be understood that the USB data transmitting end and the USB data receiving end in the embodiment of the present invention are effectively connected, including that the USB data transmitting end and the USB data receiving end are connected by a USB cable or by a wireless USB technology.
In the embodiment of the invention, the data stream to be transmitted, which is to be sent to the USB data receiving end by the USB data sending end, can be obtained in various modes, for example: the data stream to be transmitted, which is to be sent to the USB data receiving end by the USB data sending end, can be obtained through a data interception mode.
Step 102, generating a data packet sequence corresponding to the data stream to be transmitted, wherein the data packet sequence comprises a plurality of target data packets in a preset format which are arranged according to a time sequence.
Specifically, after a data stream to be transmitted, which is to be transmitted by a USB data transmitting end to a USB data receiving end, is obtained, a data packet sequence corresponding to the data stream to be transmitted may be obtained by performing data processing on the data stream to be transmitted, where the data packet sequence includes a plurality of target data packets arranged according to a time sequence, and a format of each target data packet is a preset format.
The data processing may include at least one of data caching, data extraction, redundant data removal, and data simplification.
It can be understood that, since the format of each target packet in the packet sequence is a predetermined format, the length of each target packet in the packet sequence is the same.
As an optional embodiment, the blank data packet in the preset format includes a blank data packet header of a first length, a blank data block of a second length, and a blank check code block of a third length, which are sequentially arranged, where the blank data packet header is used to store a field for indicating a type of the data packet, the blank data block is used to store data to be transmitted in a data stream to be transmitted, and the blank check code block is used to store a check code for performing data check on the data to be transmitted.
Specifically, fig. 2 is a schematic diagram of a blank data packet with a preset format in the USB data transmission method according to the present invention. Blank packets of a predetermined format are shown in fig. 2.
It should be noted that, in the embodiment of the present invention, the first length, the second length, and the third length may be determined based on a priori knowledge and/or actual situations. In the embodiment of the invention, specific values of the first length, the second length and the third length are not limited.
Correspondingly, for any one of the target data packets in the data packet sequence, the target data packet comprises a data packet head, a data block and a check code block which are sequentially arranged, a field for indicating the type of the data packet is filled in the data packet head in the target data packet, data to be transmitted in the data stream to be transmitted is filled in the data block of the target data packet, and a check code for checking the data to be transmitted is filled in the check code block of the target data packet.
As an alternative embodiment, the first length is 12 bytes, the second length is 50 bytes, and the third length is 2 bytes.
As an alternative embodiment, the front target number of bits of the header of the blank packet in the preset format is used to store a field indicating the type of packet.
Specifically, as shown in fig. 2, the front target number of bits of the header of the blank packet in the preset format in the embodiment of the present invention is used to store a field for indicating the type of the packet.
It should be noted that, the number of targets in the embodiment of the present invention may be determined according to a priori knowledge and/or actual situations. The specific value of the target number in the embodiment of the invention is not limited.
Optionally, the target number is 5.
It should be noted that, in the embodiment of the present invention, the contents of the remainder of the data packet header except the front target number of bits may be defined according to the needs of the user, and in the embodiment of the present invention, the contents of the remainder of the data packet header except the front target number of bits are not specifically limited.
As an optional embodiment, generating a data packet sequence corresponding to a data stream to be transmitted includes: and sequentially storing the data to be transmitted in the data stream to be transmitted into a target storage space according to the transmission time sequence of the USB data transmitting end.
And sequentially extracting data to be transmitted with a second length from the target storage space according to the storage time sequence stored in the target storage space, filling the data to be transmitted into data blocks in a blank data packet with a preset format until all the data to be transmitted in the target storage space are filled into the data blocks in the blank data packet with the preset format, obtaining a plurality of original data packets, filling the front target number bits of the data packet head of each original data packet according to the type of each original data packet, generating a check code corresponding to each original data packet according to a target algorithm, and filling the check code corresponding to each original data packet into the check code block of each original data packet to obtain each target data packet.
Specifically, the target algorithm in the embodiment of the invention can be a verification algorithm for data verification, which is determined based on priori knowledge and/or actual conditions. For example, the target algorithm in the embodiment of the present invention may be a cyclic redundancy check algorithm, a hash algorithm, or the like. The target algorithm in the embodiment of the invention is not particularly limited.
As an optional embodiment, generating a check code corresponding to each original data packet according to a target algorithm, filling the check code corresponding to each original data packet into a check code block of each original data packet, including: and generating a cyclic redundancy check code corresponding to each original data packet according to a cyclic redundancy check algorithm.
And filling the cyclic redundancy check code corresponding to each original data packet into the check code block of each original data packet.
It should be noted that, because the cyclic redundancy check algorithm has the advantages of fast calculation speed and small occupied storage space, the cyclic redundancy check algorithm is adopted in the embodiment of the invention to generate the cyclic redundancy check code corresponding to each original data packet, and the generated cyclic redundancy check code corresponding to each original data packet is filled into the check code block of each original data packet.
And arranging all the target data packets according to the time sequence of the filling data blocks to obtain a data packet sequence corresponding to the data stream to be transmitted.
Specifically, after obtaining a plurality of target data packets, each target data packet may be arranged according to a time sequence of the filling data block, so as to obtain a data packet sequence corresponding to the data stream to be transmitted.
As an optional embodiment, after sequentially storing the data to be transmitted in the data stream to be transmitted to the target storage space according to the sending timing sequence of the USB data sending end, sequentially extracting the data to be transmitted with the second length from the target storage space according to the storage timing sequence stored to the target storage space, and filling the data to be transmitted in a data block in a blank data packet with a preset format until all the data to be transmitted in the target storage space are filled in the data block in the blank data packet with the preset format, and before obtaining a plurality of original data packets, the method further includes: and eliminating redundant data in the data to be transmitted from the target storage space.
It should be noted that, when the conventional USB data transmission method is adopted to perform USB data transmission, byte bits in a USB data stream between the USB data receiving end and the USB data transmitting end generally include more redundant data, and the redundant data occupies a transmission bandwidth of a communication link between the USB data receiving end and the USB data transmitting end, so as to reduce a transmission rate of the USB data transmission.
Therefore, in the embodiment of the invention, after the data to be transmitted in the data stream to be transmitted is sequentially stored in the target storage space according to the sending time sequence of the USB data sending end, redundant data in the data to be transmitted can be removed from the target storage space.
Specifically, in the embodiment of the present invention, redundant data in data to be transmitted may be removed from a target storage space in a plurality of manners, for example, in the embodiment of the present invention, redundant data in data to be transmitted may be removed from a target storage space in manners of deduplication, data compression, feature extraction, data mining, and the like.
Wherein deduplication may determine whether duplicate items are present by comparing the content or characteristics of the data, and cull the duplicate data. Common deduplication algorithms include, but are not limited to, hash functions, fingerprinting algorithms, and the like;
Data compression may remove redundant information from the data, thereby reducing the size of the data. Compression algorithms typically utilize repetitive patterns or statistical properties in the data to reduce memory space. Common compression algorithms include LZ77, huffman coding, and the like.
For structured data or text data, feature extraction may identify and reject redundant data by means of feature extraction. Feature extraction can reduce redundancy of data by selecting key features, dimension reduction, and the like.
Data mining may be used to discover patterns and rules in data and to cull redundant data. For example, association rule mining can identify frequently occurring combinations, and thereby eliminate redundant terms therein.
After removing redundant data in the data to be transmitted from the target storage space, sequentially extracting the data to be transmitted with the second length from the target storage space according to the storage time sequence stored in the target storage space, and filling the data to be transmitted into the data blocks in the blank data packet with the preset format until all the data to be transmitted in the target storage space are filled into the data blocks in the blank data packet with the preset format, so as to obtain a plurality of original data packets.
According to the embodiment of the invention, the data to be transmitted in the data stream to be transmitted is sequentially stored in the target storage space according to the sending time sequence of the USB data sending end, and then the redundant data in the data to be transmitted is removed from the target storage space, so that the redundant data in the byte bit can be prevented from occupying the transmission bandwidth of a communication link between the USB data receiving end and the USB data sending end, and the transmission rate of USB data transmission can be further improved.
Step 103, sequentially sending each target data packet in the data packet sequence to the USB data receiving end.
Specifically, after the data packet sequence corresponding to the data stream to be transmitted, which is to be sent to the USB data receiving end by the USB data sending end, is obtained, each data packet in the data packet sequence may be sent to the USB data receiving end through a communication link between the USB data sending end and the USB data receiving end according to the implementation order of each target data packet in the data packet sequence.
As an alternative embodiment, the USB data transfer mode is implemented based on the USB 3.0 protocol.
As an alternative embodiment, the obtaining of the data stream to be transmitted by the USB data transmitting end to the USB data receiving end is done in the physical layer of the USB 3.0 protocol;
generating a data packet sequence corresponding to a data stream to be transmitted, wherein the data packet sequence comprises a plurality of target data packets which are arranged according to a time sequence, and the data packet sequence is completed by a protocol layer and a data link layer in a USB 3.0 protocol;
the sequential sending of each target data packet in the sequence of data packets to the USB data receiver is done at the physical layer in the USB 3.0 protocol.
As an alternative embodiment, the specific steps performed by the physical layer, the data link layer and the protocol layer in the USB 3.0 protocol include: the physical layer acquires a data stream to be transmitted and sends the data stream to be transmitted to the data link layer;
Under the condition that the data link layer receives the data stream to be transmitted sent by the physical layer, the data link layer sequentially stores the data to be transmitted in the data stream to be transmitted into a target storage space;
the protocol layer sequentially extracts data to be transmitted with a second length from the target storage space according to the storage time sequence stored in the target storage space and fills the data into a data block in a blank data packet with a preset format until all the data to be transmitted in the target storage space are filled into the data block in the blank data packet with the preset format, a plurality of original data packets are obtained, the front target number bits of the data packet head of each original data packet are filled according to the type of each original data packet, the check code corresponding to each original data packet is generated according to a target algorithm, the check code corresponding to each original data packet is filled into the check code block of each original data packet, each target data packet is obtained, the data packet sequences are arranged according to the time sequence of the filled data blocks, and the data packet sequences are sent to the data link layer;
the data link layer sends the data packet sequence to the physical layer under the condition of receiving the data packet sequence;
And under the condition that the physical layer receives the data packet sequence, sequentially sending each target data packet in the data packet sequence to the USB data receiving end.
It should be noted that the USB data transmission method provided by the present invention is applied to the USB 3.0 protocol.
Fig. 3 is a schematic structural diagram and a schematic data interaction diagram of each layer in the USB 3.0 protocol. As shown in fig. 3, a Physical Layer (Physical Layer) in the USB 3.0 protocol is the bottommost Layer of the USB 3.0 protocol, and the Physical Layer defines a super-high speed bus signal technology, so as to implement connection of a link chip to chip, and has functions of data transmission, encoding and decoding, data clock recovery, elastic buffering, and the like. The data Link Layer (Link Layer) performs Link connection based on the data packet and the Link command, so that communication between two Link partners can be realized. The Protocol Layer (Protocol Layer) is mainly responsible for managing end-to-end data communication between the host and the device on the premise that the link Layer can ensure correct transmission of the data packet. The layered structure in the USB 3.0 protocol is convenient for standardization and expansion.
Fig. 4 is a flow chart of constructing a target data packet in the USB data transmission method according to the present invention. The specific flow of constructing the target packet is shown in fig. 4.
The protocol layer and the data link layer in the USB 3.0 protocol are properly changed, and the physical layer is not changed, so that the logic complexity of data processing is simplified, the information data is processed and communicated more quickly, and the transmission rate of data transmission between USB devices and the integrity of link data are ensured.
In the embodiment of the invention, the data stream to be transmitted, which is to be transmitted by the USB data transmitting end to the USB data receiving end, is converted into a plurality of data packets which are arranged according to the time sequence and have the same format and the same length, and then each data packet in the data packet sequence is sequentially transmitted to the USB data receiving end according to the time sequence of each data packet in the data packet sequence.
As an alternative embodiment, before sequentially sending each target data packet in the sequence of data packets to the USB data receiving end, the method further includes: and constructing a main communication link and a bypass communication link between the USB data transmitting end and the USB data receiving end.
It should be noted that, in the conventional USB data transmission method, there is only one communication link for USB data transmission, and if the communication link is abnormal or the management and configuration of the access link are performed, the USB data transmission is interrupted, so as to affect the user perception.
Therefore, in the embodiment of the invention, before the data packets in the data packet sequence are sequentially sent to the USB data receiving end according to the time sequence of the data packets in the data packet sequence, the main communication link and the bypass communication link between the USB data sending end and the USB data receiving end are constructed, and under the condition that the main communication link is abnormal, the transmission of USB data can be continued through the bypass communication link, so that the interruption of USB data transmission caused by the abnormal occurrence of the communication link is avoided.
Fig. 5 is a schematic structural diagram of a main communication module and a bypass communication module in a data link layer in the USB data transmission method according to the present invention. As shown in fig. 5, the communication of the data link layer in the embodiment of the present invention mainly depends on the main communication link. The main communication module in the data link layer comprises an initial/training module, an interruption/configuration module and a data processing module. In order to meet the requirement of high bandwidth of data processing, a plurality of data processing modules can be flexibly configured in the main communication module. The bypass communication module in the data link layer includes a data processing module.
As an alternative embodiment, constructing a bypass communication link between a USB data sender and a USB data receiver, includes: and sending a bypass communication interface signal corresponding to the USB data sending end to the USB data receiving end so that the USB data receiving end can respond to the bypass communication interface signal to establish a bypass communication link with the USB data sending end.
Specifically, in the embodiment of the invention, a bypass communication link between the USB data transmitting end and the USB data receiving end can be constructed by sending a bypass communication interface signal to the USB data receiving end.
As an alternative embodiment, bypassing the communication interface signal, comprises: an output signal, an output clock signal, an input clock signal, and an output input status signal; the output signal and the input signal are used for constructing a bypass communication link, and the output clock signal and the input clock signal are used for synchronizing clocks of the USB data receiving end and the USB data transmitting end; the output-input status signal is used to indicate the communication status of the bypass communication link.
Specifically, the bypass communication interface signal in the embodiment of the present invention is composed of an output signal sb_tx, an output clock signal sb_tx_clk, an input signal sb_rx, an input clock signal sb_rx_clk, and output input state information sb_state. The output signal sb_tx, the output clock signal sb_tx_clk, the input signal sb_rx and the input clock signal sb_rx_clk are 1-bit wide, and the output input state information sb_state is 2-bit wide.
It should be noted that, in the embodiment of the present invention, the output signal sb_tx is used to send data on the USB serial bus from the USB data sending end to the USB data receiving end. The output signal sb_tx may drive a differential output pair or may drive a single ended output.
The output clock signal sb_tx_clk in the embodiment of the present invention may be used to drive the output signal sb_tx signal for data transmission. To ensure stability and reliability of data transfer, the output clock signal sb_tx_clk signal needs to be clock synchronized with the input clock signal sb_rx_clk at the USB data receiving end.
The input signal sb_rx in the embodiment of the invention is used for receiving data on the USB serial bus from the USB data receiving end to the USB data sending end. The input signal sb_rx may accept a differential input pair or may accept a single ended input.
The input clock signal sb_rx_clk in the embodiment of the present invention is used for driving the input signal sb_rx signal to perform data reception. To ensure stability and reliability of data transfer, the input clock signal sb_rx_clk signal needs to be clock synchronized with the output signal sb_tx_clk at the USB data transmitting end.
The input-output status signal sb_state in the embodiment of the present invention is used to indicate the communication status of the bypass communication link. This signal is typically used to control and monitor the operation of the serial bus, such as starting or ending a transmission, detecting transmission errors, etc.
Sequentially sending each target data packet in the data packet sequence to a USB data receiving end, including: and sequentially transmitting the target data packets in the data packet sequence to the USB data receiving end through the main communication link, and sequentially transmitting the remaining unsent target data packets in the data packet sequence to the USB data receiving end through the bypass communication link according to the time sequence arrangement sequence of the remaining unsent target data packets in the data packet sequence if the main communication link is abnormal.
Specifically, after a main communication link and a bypass communication link between the USB data receiving end and the USB data transmitting end are constructed, a target data packet in the data packet sequence may be sequentially transmitted to the USB data receiving end through the main communication link.
In the embodiment of the invention, whether the main communication link is abnormal or not can be judged in real time in the process of sequentially sending the target data packet in the data packet sequence to the USB data receiving end through the main communication link. Wherein an anomaly in the primary communication link may include, but is not limited to, a disruption in primary communication link communication or an error.
If it is determined that the main communication link is abnormal, the remaining unsent target data packets in the data packet sequence can be sequentially sent to the USB data receiving end through the bypass communication link according to the time sequence of the remaining unsent target data packets in the data packet sequence, so that under the condition that the main communication link is abnormal, the main communication link does not need to be reconstructed through initializing the main communication link, and further the sending of the target data packets does not need to be interrupted.
As an alternative embodiment, determining whether an anomaly has occurred in the primary communication link includes: under the condition of receiving error information sent by a USB data receiving end, determining that a main communication link is abnormal;
the error information is used for indicating that any target data packet fails the data verification, and/or any target data packet in the data packet sequence is lost.
Specifically, after receiving any one of the target data packets in the data packet sequence, the USB data receiving end may verify the data to be transmitted in the target data packet based on the verification code in the target data packet.
When it is determined that the data to be transmitted in the target data packet does not pass the verification based on the verification code in the target data packet, it may be determined that the target data packet has a transmission error, and the USB data receiving end returns error information indicating that the target data packet does not pass the data verification.
When the USB data receiving end determines that any one of the target data packets in the data packet sequence is lost, the USB data receiving end returns error information indicating that the target data packet is lost.
Any target data packet in the data packet sequence is lost and/or fails to pass the data verification, which indicates that the main communication link between the USB data receiving end and the USB data transmitting end is abnormal.
As an alternative embodiment, determining whether an anomaly has occurred in the primary communication link includes: and determining that the main communication link is abnormal under the condition that the data transmission rate in the main communication link is smaller than the rate threshold value and/or the transmission delay rate of the main communication link is larger than the delay rate threshold value.
Specifically, if the data transmission rate of the main communication link between the USB data transmitting end and the USB data receiving end is smaller than the rate threshold, and/or the transmission delay rate of the main communication link is larger than the delay rate threshold, it may be indicated that the main communication link between the USB data receiving end and the USB data transmitting end is abnormal.
It should be noted that, in the embodiment of the present invention, the values of the rate threshold and the delay rate threshold may be determined according to priori knowledge and/or actual situations. The specific values of the rate threshold and the delay rate threshold in the embodiment of the invention are not limited.
According to the embodiment of the invention, before the data packets in the data packet sequence are sequentially sent to the USB data receiving end according to the time sequence arrangement sequence of the data packets in the data packet sequence, a main communication link and a bypass communication link between the USB data sending end and the USB data receiving end are constructed, after the data packet sequence corresponding to the data flow to be transmitted is acquired, the target data packets in the data packet sequence are sequentially sent to the USB data receiving end through the main communication link, and in the process of sequentially sending the target data packets in the data packet sequence to the USB data receiving end through the main communication link, if the main communication link is abnormal, the rest of the unsent target data packets in the data packet sequence are sequentially sent to the USB data receiving end through the bypass communication link, so that under the condition that the main communication link is abnormal, the transmission of the target data packets is continued through the main communication link, the transmission interruption caused by the occurrence of the abnormality can be avoided, the control of the flow of a protocol layer and the data link layer can be ensured through the construction of the bypass communication link, the data link layer can be controlled and the data link layer can be conveniently used for expanding the compatibility of the communication interface after the communication link is designed, the bandwidth is improved, and the compatibility of the communication device can be improved by using the bypass signal layer is improved.
Fig. 6 is a schematic structural diagram of a USB data transmission device according to the present invention. The USB data transmission apparatus provided by the present invention will be described below with reference to fig. 6, and the USB data transmission apparatus described below and the USB data transmission method provided by the present invention described above may be referred to correspondingly. As shown in fig. 6, a data stream acquisition module 601, a data packet sequence acquisition module 602, and a data packet transmission module 603.
The data stream obtaining module 601 is configured to obtain a data stream to be transmitted, which is to be sent by the USB data sending end to the USB data receiving end, when the USB data sending end is effectively connected to the USB data receiving end;
the data packet sequence obtaining module 602 is configured to generate a data packet sequence corresponding to a data stream to be transmitted, where the data packet sequence includes a plurality of target data packets in a preset format arranged according to a time sequence;
the data packet sending module 603 is configured to send each target data packet in the data packet sequence to the USB data receiving end in sequence.
Specifically, the data stream acquiring module 601, the data packet sequence acquiring module 602, and the data packet transmitting module 603 are electrically connected.
According to the USB transmission device, the data stream to be transmitted, which is to be transmitted by the USB data transmitting end to the USB data receiving end, is converted into a plurality of data packets which are arranged according to time sequence and have the same format and the same length, and then each data packet in the data packet sequence is sequentially transmitted to the USB data receiving end according to the time sequence arrangement sequence of each data packet in the data packet sequence.
Fig. 7 illustrates a physical schematic diagram of an electronic device, as shown in fig. 7, which may include: processor 710, communication interface (Communications Interface) 720, memory 730, and communication bus 740, wherein processor 710, communication interface 720, memory 730 communicate with each other via communication bus 740. Processor 710 may invoke logic instructions in memory 730 to perform a USB data transfer method comprising: under the condition that the USB data sending end is effectively connected with the USB data receiving end, obtaining a data stream to be transmitted, which is to be sent to the USB data receiving end by the USB data sending end; generating a data packet sequence corresponding to a data stream to be transmitted, wherein the data packet sequence comprises a plurality of target data packets in a preset format which are arranged according to a time sequence; and sequentially sending each target data packet in the data packet sequence to the USB data receiving end.
Further, the logic instructions in the memory 730 described above may be implemented in the form of software functional units and may be stored in a computer readable storage medium when sold or used as a stand alone product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
As an alternative embodiment, the electronic device includes a computer and a peripheral device.
Specifically, if the electronic device is a computer or a peripheral device, and the electronic device needs to send USB data to other electronic devices or the other electronic devices need to send USB data to the electronic device, the processor in the electronic device may implement USB data transmission with other electronic devices by executing the USB data transmission method provided by the present invention.
Based on the foregoing content of each embodiment, a USB data transmission system includes: a USB data transmitting end, a USB data receiving end and the electronic equipment; the USB data transmitting end is electrically connected with the electronic equipment; the USB data receiving end is electrically connected with the electronic equipment.
Specifically, the USB data transmitting end and the USB data transmitting end in the embodiment of the invention realize USB data transmission through the electronic equipment.
Based on the foregoing content of each embodiment, a USB data transmission system includes: a USB data transmitting end and a USB data receiving end;
the USB data transmitting end is the electronic equipment, or the USB data receiving end is the electronic equipment.
It may be understood that the USB data transmitting end in the embodiment of the present invention may be a computer or a peripheral device, where the USB data transmitting end includes a memory, a processor, and a computer program stored on the memory and capable of running on the processor, and the processor implements the USB data transmission method as described above when executing the program.
Alternatively, the USB data receiving end in the embodiment of the present invention may be a computer or a peripheral device, where the USB data receiving end includes a memory, a processor, and a computer program stored on the memory and capable of running on the processor, and the processor implements the USB data transmission method as described above when executing the program.
In another aspect, the present invention also provides a computer program product, the computer program product comprising a computer program, the computer program being storable on a non-transitory computer readable storage medium, the computer program, when executed by a processor, being capable of performing the USB data transmission method provided by the above methods, the method comprising: under the condition that the USB data sending end is effectively connected with the USB data receiving end, obtaining a data stream to be transmitted, which is to be sent to the USB data receiving end by the USB data sending end; generating a data packet sequence corresponding to a data stream to be transmitted, wherein the data packet sequence comprises a plurality of target data packets in a preset format which are arranged according to a time sequence; and sequentially sending each target data packet in the data packet sequence to the USB data receiving end.
In yet another aspect, the present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, is implemented to perform the USB data transmission method provided by the above methods, the method comprising: under the condition that the USB data sending end is effectively connected with the USB data receiving end, obtaining a data stream to be transmitted, which is to be sent to the USB data receiving end by the USB data sending end; generating a data packet sequence corresponding to a data stream to be transmitted, wherein the data packet sequence comprises a plurality of target data packets in a preset format which are arranged according to a time sequence; and sequentially sending each target data packet in the data packet sequence to the USB data receiving end.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (16)

1. A USB data transmission method, comprising:
under the condition that a USB data sending end is effectively connected with a USB data receiving end, acquiring a data stream to be transmitted, which is to be sent to the USB data receiving end by the USB data sending end;
generating a data packet sequence corresponding to the data stream to be transmitted, wherein the data packet sequence comprises a plurality of target data packets in a preset format which are arranged according to a time sequence;
sequentially sending each target data packet in the data packet sequence to a USB data receiving end;
the USB data receiving end is any one of a computer, a server and peripheral equipment; the USB data transmitting end is any one of a computer, a server and peripheral equipment; the peripheral equipment is equipment which is connected with a computer or other main equipment and expands the functions of the peripheral equipment;
the blank data packet in the preset format comprises a blank data packet head with a first length, a blank data block with a second length and a blank check code block with a third length which are sequentially arranged, wherein the blank data packet head is used for storing a field for indicating the type of the data packet, the blank data block is used for storing data to be transmitted in the data stream to be transmitted, and the blank check code block is used for storing a check code for checking the data to be transmitted;
Before the target data packets in the data packet sequence are sequentially sent to the USB data receiving end, the method further comprises:
constructing a main communication link and a bypass communication link between the USB data transmitting end and the USB data receiving end;
the step of sequentially sending each target data packet in the data packet sequence to a USB data receiving end includes:
sequentially sending the target data packets in the data packet sequence to a USB data receiving end through the main communication link, and sequentially sending the target data packets in the data packet sequence to the USB data receiving end through the bypass communication link if the main communication link is abnormal;
the front target number bits of the data packet header in the blank data packet with the preset format are used for storing a field for indicating the type of the data packet;
the generating the data packet sequence corresponding to the data stream to be transmitted includes:
Sequentially storing the data to be transmitted in the data stream to be transmitted to a target storage space according to the transmission time sequence of the USB data transmitting end;
extracting the data to be transmitted with the second length from the target storage space in sequence according to the storage time sequence stored in the target storage space, filling the data into the data blocks in the blank data packet with the preset format until all the data to be transmitted in the target storage space are filled into the data blocks in the blank data packet with the preset format, obtaining a plurality of original data packets,
filling the front target number of bits of the data packet header of each original data packet according to the type of each original data packet,
generating a check code corresponding to each original data packet according to a target algorithm, and filling the check code corresponding to each original data packet into a check code block of each original data packet to obtain each target data packet;
and arranging all the target data packets according to the time sequence of the filling data blocks to obtain a data packet sequence corresponding to the data stream to be transmitted.
2. The USB data transmission method according to claim 1, wherein constructing a bypass communication link between the USB data transmitting end and the USB data receiving end includes:
And sending a bypass communication interface signal corresponding to the USB data sending end to the USB data receiving end so that the USB data receiving end responds to the bypass communication interface signal to establish a bypass communication link with the USB data sending end.
3. The USB data transfer method of claim 2, wherein the bypass communication interface signal comprises: an output signal, an output clock signal, an input clock signal, and an output input status signal; the output signal and the input signal are used for constructing the bypass communication link, and the output clock signal and the input clock signal are used for synchronizing clocks of the USB data receiving end and the USB data transmitting end; the output-input status signal is used to indicate a communication status of the bypass communication link.
4. The USB data transmission method according to claim 1, wherein the generating the check code corresponding to each of the original data packets according to the target algorithm, filling the check code corresponding to each of the original data packets into the check code block of each of the original data packets, and obtaining each of the target data packets includes:
Generating a cyclic redundancy check code corresponding to each original data packet according to a cyclic redundancy check algorithm;
and filling the cyclic redundancy check code corresponding to each original data packet into the check code block of each original data packet.
5. The USB data transmission method according to claim 1, wherein after the data to be transmitted in the data stream to be transmitted is sequentially stored in the target storage space according to the transmission timing sequence of the USB data transmitting end, the data block of the blank data packet of the preset format is sequentially extracted from the target storage space according to the storage timing sequence stored in the target storage space until all the data to be transmitted in the target storage space are filled in the data block of the blank data packet of the preset format, and before obtaining a plurality of original data packets, the method further includes:
and eliminating redundant data in the data to be transmitted from the target storage space.
6. The USB data transfer method of claim 1, wherein the USB data transfer mode is implemented based on a USB 3.0 protocol.
7. The method for USB data transmission according to claim 6, wherein the obtaining the data stream to be transmitted from the USB data transmitting end to the USB data receiving end is performed by a physical layer in a USB 3.0 protocol;
the generation of the data packet sequence corresponding to the data stream to be transmitted is completed in a protocol layer and a data link layer in a USB 3.0 protocol;
and the step of sequentially sending each target data packet in the data packet sequence to the USB data receiving end is completed by a physical layer in the USB 3.0 protocol.
8. The method for USB data transfer according to claim 7, wherein the specific steps performed by the physical layer, the data link layer and the protocol layer in the USB 3.0 protocol include:
the physical layer acquires the data stream to be transmitted and sends the data stream to be transmitted to the data link layer;
the data link layer sequentially stores the data to be transmitted in the data stream to be transmitted to a target storage space under the condition that the data link layer receives the data stream to be transmitted sent by the physical layer;
the protocol layer sequentially extracts data to be transmitted with the second length from the target storage space to be filled into data blocks in blank data packets with the preset format according to the storage time sequence stored in the target storage space until all the data to be transmitted in the target storage space are filled into the data blocks in the blank data packets with the preset format, obtains a plurality of original data packets, fills the front target number bit of the data packet head of each original data packet according to the type of each original data packet, generates a check code corresponding to each original data packet according to a target algorithm, fills the check code corresponding to each original data packet into the check code block of each original data packet, obtains each target data packet, arranges each target data packet according to the time sequence of the filled data blocks, obtains the data packet sequence, and sends the data packet sequence to the data link layer;
The data link layer sends the data packet sequence to the physical layer under the condition that the data packet sequence is received;
and the physical layer sequentially sends each target data packet in the data packet sequence to a USB data receiving end under the condition that the data packet sequence is received.
9. The USB data transfer method according to claim 1, wherein determining whether an abnormality occurs in the main communication link includes:
under the condition of receiving error information sent by a USB data receiving end, determining that the main communication link is abnormal;
the error information is used for indicating that any data packet in the data packet sequence fails data verification and/or any data packet in the data packet sequence is lost.
10. The USB data transfer method according to claim 1, wherein determining whether an abnormality occurs in the main communication link includes:
and determining that the main communication link is abnormal under the condition that the data transmission rate in the main communication link is smaller than a rate threshold value and/or the transmission delay rate of the main communication link is larger than a delay rate threshold value.
11. A USB data transfer device, comprising:
The data stream acquisition module is used for acquiring a data stream to be transmitted, which is to be transmitted to the USB data receiving end by the USB data transmitting end, under the condition that the USB data transmitting end is effectively connected with the USB data receiving end;
a data packet sequence acquisition module, configured to generate a data packet sequence corresponding to the data stream to be transmitted, where the data packet sequence includes a plurality of target data packets in a preset format that are arranged according to a time sequence;
the data packet sending module is used for sequentially sending each target data packet in the data packet sequence to the USB data receiving end;
the USB data receiving end is any one of a computer, a server and peripheral equipment; the USB data transmitting end is any one of a computer, a server and peripheral equipment; the peripheral equipment is equipment which is connected with a computer or other main equipment and expands the functions of the peripheral equipment;
the blank data packet in the preset format comprises a blank data packet head with a first length, a blank data block with a second length and a blank check code block with a third length which are sequentially arranged, wherein the blank data packet head is used for storing a field for indicating the type of the data packet, the blank data block is used for storing data to be transmitted in the data stream to be transmitted, and the blank check code block is used for storing a check code for checking the data to be transmitted;
The data packet sending module is further configured to, before sequentially sending each target data packet in the data packet sequence to the USB data receiving end:
constructing a main communication link and a bypass communication link between the USB data transmitting end and the USB data receiving end;
the data packet sending module sends each target data packet in the data packet sequence to a USB data receiving end in sequence, and the data packet sending module comprises:
sequentially sending the target data packets in the data packet sequence to a USB data receiving end through the main communication link, and sequentially sending the target data packets in the data packet sequence to the USB data receiving end through the bypass communication link if the main communication link is abnormal;
the front target number bits of the data packet header in the blank data packet with the preset format are used for storing a field for indicating the type of the data packet;
the data packet sequence obtaining module generates a data packet sequence corresponding to the data stream to be transmitted, including:
Sequentially storing the data to be transmitted in the data stream to be transmitted to a target storage space according to the transmission time sequence of the USB data transmitting end;
extracting the data to be transmitted with the second length from the target storage space in sequence according to the storage time sequence stored in the target storage space, filling the data into the data blocks in the blank data packet with the preset format until all the data to be transmitted in the target storage space are filled into the data blocks in the blank data packet with the preset format, obtaining a plurality of original data packets,
filling the front target number of bits of the data packet header of each original data packet according to the type of each original data packet,
generating a check code corresponding to each original data packet according to a target algorithm, and filling the check code corresponding to each original data packet into a check code block of each original data packet to obtain each target data packet;
and arranging all the target data packets according to the time sequence of the filling data blocks to obtain a data packet sequence corresponding to the data stream to be transmitted.
12. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the USB data transfer method according to any one of claims 1 to 10 when the program is executed by the processor.
13. The electronic device of claim 12, wherein the electronic device comprises a computer and a peripheral device.
14. A USB data transmission system, comprising: a USB data transmitting end, a USB data receiving end, and the electronic device according to claim 12; the USB data transmitting end is electrically connected with the electronic equipment; the USB data receiving end is electrically connected with the electronic equipment.
15. A USB data transmission system, comprising: a USB data transmitting end and a USB data receiving end;
the USB data transmitting end is the electronic device according to claim 13, or the USB data receiving end is the electronic device according to claim 13.
16. A non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor implements a USB data transmission method according to any one of claims 1 to 10.
CN202311850453.9A 2023-12-29 2023-12-29 USB data transmission method, device, system, electronic equipment and storage medium Active CN117493248B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311850453.9A CN117493248B (en) 2023-12-29 2023-12-29 USB data transmission method, device, system, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311850453.9A CN117493248B (en) 2023-12-29 2023-12-29 USB data transmission method, device, system, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117493248A CN117493248A (en) 2024-02-02
CN117493248B true CN117493248B (en) 2024-04-05

Family

ID=89685342

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311850453.9A Active CN117493248B (en) 2023-12-29 2023-12-29 USB data transmission method, device, system, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117493248B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101136722A (en) * 2007-10-15 2008-03-05 北京交通大学 Data transmitting method and transmitting equipment suitable for high speed mobile terminal
CN110769465A (en) * 2019-10-24 2020-02-07 Oppo(重庆)智能科技有限公司 Data transmission method and device, electronic equipment and readable storage medium
CN113986785A (en) * 2021-11-03 2022-01-28 深圳市鑫鑫达电子有限公司 USB data transmission based method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8261175B2 (en) * 2008-11-14 2012-09-04 Intel Mobile Communications GmbH Method and apparatus for performing a CRC check

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101136722A (en) * 2007-10-15 2008-03-05 北京交通大学 Data transmitting method and transmitting equipment suitable for high speed mobile terminal
CN110769465A (en) * 2019-10-24 2020-02-07 Oppo(重庆)智能科技有限公司 Data transmission method and device, electronic equipment and readable storage medium
CN113986785A (en) * 2021-11-03 2022-01-28 深圳市鑫鑫达电子有限公司 USB data transmission based method

Also Published As

Publication number Publication date
CN117493248A (en) 2024-02-02

Similar Documents

Publication Publication Date Title
US20210152183A1 (en) Data compression method, data decompression method, and related apparatus, electronic device, and system
US8370716B2 (en) USB device and correction method thereof
CN109426636B (en) Method and device for transmitting high-bit-width data between FPGA (field programmable Gate array) chips
US11023412B2 (en) RDMA data sending and receiving methods, electronic device, and readable storage medium
US9252812B2 (en) Low latency serial data encoding scheme for enhanced burst error immunity and long term reliability
WO2017012517A1 (en) Hybrid physical coding sub-layer and method for transmitting and receiving data, and storage medium
CN113176850B (en) Shared storage disk based on SRIO interface and access method thereof
EP3229138B1 (en) Method and device for data backup in a storage system
CN1322444C (en) Method for transmitting and processing command and data
TWI445374B (en) Remote management system and remote management method
JP3996928B2 (en) How to handle corrupted data
CN115395961A (en) Data lossless compression and encrypted transmission method based on joint middleware
US20190042354A1 (en) Technologies for error recovery in compressed data streams
CN117493248B (en) USB data transmission method, device, system, electronic equipment and storage medium
CN106716392B (en) Stack timing adjustment for serial communication
CN110381050B (en) Multi-protocol conversion and verification method and device for data packet
JP4413806B2 (en) Fault isolation method, communication apparatus and program having fault isolation function
US20160147706A1 (en) System and method for improving the efficiency of a serial interface protocol
CN115129509A (en) Data transmission method, device and medium
JP2010183196A (en) Data transfer system, data transmitting apparatus, data receiving apparatus, and data transfer method
CN112312396B (en) NoC tracking data generation method and related device
US8331788B2 (en) Encapsulation scheme for optical over Ethernet
US20050154968A1 (en) Detection of errors
WO2024001874A1 (en) Mode negotiation method and apparatus, device, system, and computer readable storage medium
CN115378756B (en) Monitoring Controller Area Network (CAN) XL node

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant