Communication method and related device

By checking and sorting the transmission control layer packets at the receiver, the problems of wrong packets, packet loss and out of order in USB data transmission are solved, and the accuracy of data transmission and system security are improved.

CN119921900APending Publication Date: 2025-05-02SUPCON TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411984679.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

The prior art has rate limits, reliability limits and ease of use limits when using USB cables for data interaction, making it difficult to effectively solve the problems of wrong packets, packet loss and out of order in data transmission.

Method used

A communication method is provided to checksum ordering transmission control layer packets by the receiver, merging packets to ensure correctness, and sending retransmission requests if necessary to resolve packet errors and packet loss issues.

Benefits of technology

Through this method, the accuracy of data transmission and the security of the system are ensured, and the reliability and efficiency of data transmission are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119921900A_ABST
    Figure CN119921900A_ABST
Patent Text Reader

Abstract

The invention discloses a communication method and a related device, and the method comprises the steps: further judging whether a current transmission control layer data packet is application layer data or not after a receiver receives data and transmits the data to a transmission control layer and verifies the data packet to be correct, and if the current transmission control layer data packet is the application layer data, judging whether a wrong packet, a lost packet or an out-of-order condition exists or not, and if the current transmission control layer data packet is the application layer data; if the serial number of the data packet is correct, after all the transmission control layer data packets are received, data merging is carried out to obtain application layer data, and the application layer data are transmitted to an application layer. And if a wrong packet or a lost packet exists, a sender is immediately requested to carry out retransmission. And if the received data packets are out of order, continuing to receive and cache the data packets of the transmission control layer, and after caching for a certain time, judging whether the data packets of the target serial number are received or not. Through the fault-tolerant and retransmission mechanism of the transmission control layer, the accuracy of transmitting and receiving data and the security of the system can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a communication method and related devices. Background Art

[0002] For devices that are inconvenient or unable to use Ethernet for data exchange, you can try to use a Universal Serial Bus (USB) cable to connect. For example, each slave computer is connected to the host computer via a USB cable to form a USB network for data exchange.

[0003] USB data transmission supports multiple device types, including USB ACM (Abstract Control Model) serial ports, USB ECM (Ethernet Control Message Protocol) Ethernet cards, mass storage devices, USB HID devices, etc. However, this type of data transmission solution has major limitations, such as rate limits, reliability limits, or usability limits. Summary of the invention

[0004] In view of the above problems, the present application provides a communication method and related devices to solve at least part of the above technical problems. The specific solution is as follows:

[0005] A first aspect of the present application provides a communication method, applied to a receiving party, the method comprising:

[0006] Get the transport control layer data packet;

[0007] After verifying that the transmission control layer data packet is correct and determining that the transmission control layer data packet is application layer data, determining whether the currently received transmission control layer data packet is out of order;

[0008] Sending a retransmission request for a transport control layer data packet that is incorrectly verified, wherein the retransmission request carries a sequence number of the transport control layer data packet that is incorrectly verified;

[0009] After determining that the received transmission control layer data packets are not out of order, or after determining that the received transmission control layer data packets are out of order and after waiting for a preset time, determining that the transmission control layer data packet with the target sequence number is received, all received transmission control layer data packets are merged to obtain an application layer data packet;

[0010] Sending the application layer data packet to the application layer;

[0011] It is determined that the received transmission control layer data packets are out of order, and after waiting for a preset time, it is determined that the transmission control layer data packet with the target sequence number is not received, and a retransmission request is sent.

[0012] In a possible implementation, verifying that the transmission control layer data packet is correct includes:

[0013] Verify whether the content of each field in the transmission control layer data packet is consistent with the meaning of the corresponding field, and if the content of at least one field is inconsistent with the meaning of the corresponding field, determine that the transmission control layer data packet is abnormal;

[0014] After determining that the content of each field of the transmission control layer data packet is the same as the meaning of the corresponding field, a CRC check is performed on the transmission control layer data packet. If the CRC check is incorrect, it is determined that the transmission control layer data packet check is incorrect. If the CRC check is correct, it is determined that the transmission control layer data packet check is correct.

[0015] In a possible implementation, the determining whether a currently received transmission control layer data packet is out of order includes:

[0016] Determine whether the sequence number in the currently received transmission control layer data packet is consistent with the sequence number recorded locally. If they are consistent, it is determined that no disorder has occurred. If they are inconsistent, it is determined that the received transmission control layer data packet is disordered.

[0017] In a possible implementation manner, determining that the received transmission control layer data packets are out of order, and determining that the transmission control layer data packet with the target sequence number is received after waiting for a first preset time, includes:

[0018] After determining that the received transmission control layer data packets are out of order, storing the currently received transmission control layer data packets in a buffer, and receiving n transmission control layer data packets within the first preset time length and storing them in the buffer;

[0019] Sorting all the transport control layer data packets in the buffer, and determining whether there is a transport control layer data packet with a target sequence number, wherein the target sequence number is a missing sequence number;

[0020] If the transmission control layer data packet of the target sequence number exists in the buffer, determining that the transmission control layer data packet of the target sequence number is received;

[0021] If the transmission control layer data packet of the target sequence number does not exist in the buffer, it is determined that the transmission control layer data packet of the target sequence number has not been received.

[0022] In a possible implementation, the receiving party is a lower computer, and obtaining a transmission control layer data packet includes:

[0023] Receive a USB link layer data packet, and extract a USB EEM link layer data packet from the USB link layer data packet;

[0024] Extract the transmission control layer data packet from the verified USB EEM link layer data packet.

[0025] In a possible implementation, the method further includes:

[0026] After determining that the transmission control layer data packet is a reset request packet, responding to the reset request to restore the USB EEM connection link to an initial state, and sending a reset success reply message to the sender;

[0027] or,

[0028] After determining that the transmission control layer data packet is a heartbeat packet, reset the heartbeat timeout timer.

[0029] A second aspect of the present application provides a communication method, applied to a sender, the method comprising:

[0030] Acquire application data to be sent, add header information corresponding to the application layer to the application data to be sent, and obtain an application layer data packet;

[0031] Subpacketizing the application layer data packet, and adding header information and tail information corresponding to the transmission control layer to obtain a transmission control layer data packet;

[0032] Adding header information of a virtual Ethernet link layer to the outer layer of the transmission control layer data packet to obtain a virtual Ethernet link layer data packet;

[0033] Adding the header information and the tail information of the USB EEM link layer to the outer layer of the virtual Ethernet link layer data packet to obtain the USB EEM link layer data packet;

[0034] The USB EEM link layer data packet is sent through the hardware link layer.

[0035] In a possible implementation, before obtaining the application data to be sent, the method further includes:

[0036] After determining that a retransmission request packet has been received, obtaining the data to be retransmitted based on the target sequence number carried in the retransmission request, and assembling a retransmission data packet according to the data to be retransmitted;

[0037] Adding header information of the virtual Ethernet link layer and header information and tail information of the USBEEM link layer in sequence to the outer layer of the assembled retransmission data packet to obtain the retransmission data packet to be sent;

[0038] The retransmission data packet to be sent is sent through the hardware link layer.

[0039] In a possible implementation manner, obtaining the data to be retransmitted based on the target sequence number carried in the retransmission request includes:

[0040] Determine all service data starting from the target sequence number as the data to be retransmitted;

[0041] or,

[0042] The service data corresponding to the target sequence number is determined as the data to be retransmitted.

[0043] In a possible implementation, the sender is a host computer, and before obtaining the application data to be sent, the method further includes:

[0044] After determining that the USB EEM connection link is abnormal, sending a reset request to the lower computer, wherein the reset request is used to enable the lower computer to reset the USB EEM link;

[0045] After receiving the reset success reply message sent by the lower computer, it is determined that the USB EEM connection link is restored successfully.

[0046] In a possible implementation, determining that an abnormality occurs in the USB EEM connection link includes:

[0047] After receiving the retransmission request packet, the sender fails to obtain a data packet corresponding to the target sequence number carried in the retransmission request packet, and determines that the USB EEM connection link is abnormal;

[0048] or,

[0049] The sender does not receive the heartbeat packet within the second preset time period, and determines that the USB EEM connection link is abnormal.

[0050] A third aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:

[0051] The memory is used to store computer programs;

[0052] The processor is used to execute the computer program so that the electronic device can implement the communication method as described in any one of the first aspects.

[0053] A fourth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the communication method as described in any one of the first aspects.

[0054] The fifth aspect of the present application provides a computer program product, including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the communication method of any implementation manner of the first aspect.

[0055] The communication method provided by the present application is that after the receiving party receives the data and passes it to the transmission control layer, after verifying the data packet correctly, it further determines whether the current transmission control layer data packet is application layer data. If it is application layer data, it determines whether there is an error packet, packet loss or disorder. If the sequence number of the data packet is correct, after receiving all the transmission control layer data packets, the data is merged to obtain the application layer data, and the application layer data is passed to the application layer. If there is an error packet or packet loss, the sender is immediately requested to retransmit. If the received data packet is disordered, the transmission control layer data packet continues to be received and cached. After caching for a certain period of time, it is determined whether the data packet with the target sequence number is received. Through the above-mentioned fault tolerance and retransmission mechanism of the transmission control layer, the accuracy of the sent and received data and the security of the system can be ensured. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0057] Figure 1 A schematic diagram of the structure of a communication system provided for this application;

[0058] Figure 2 A schematic diagram of the data structure of each communication layer of a host computer or a slave computer provided in this application;

[0059] Figure 3 A flow chart of a communication method provided by the present application;

[0060] Figure 4 A schematic diagram of a process for a lower computer to receive application data from an upper computer provided in this application;

[0061] Figure 5 A schematic diagram of a process for a lower computer to send application data to an upper computer provided in this application;

[0062] Figure 6 A schematic diagram of a process for a host computer to receive application data sent by a slave computer provided in this application;

[0063] Figure 7 A schematic diagram of a process of a host computer sending application data to a slave computer provided in this application;

[0064] Figure 8 A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION

[0065] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.

[0066] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0067] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0068] See also Figure 1 , shows a schematic diagram of the structure of a communication system provided by the present application. Figure 1 As shown, the system includes an upper computer and n lower computers, wherein n is a positive integer greater than 1.

[0069] The host computer (USB Host) refers to a terminal device that controls the data link and commands. The host computer can be a terminal device running the Windows operating system.

[0070] The lower computer (USB Device) refers to a device that receives control commands and data from the upper computer. The lower computer can be an embedded device.

[0071] In the embodiment of the present application, each slave computer is connected to the host computer via a USB cable. In the embodiment of the present application, the host computer adopts a USB EEM class device, that is, a device that supports the USB EEM communication protocol.

[0072] The USB EEM protocol does not extend the interface on the USB bus, but treats the USB bus as a tool for moving Ethernet data packets. That is, the USB EEM device does not extend the control to the USB slave device (i.e., the lower computer), but only treats the USB slave device as the network terminal of the Ethernet peer. Both ends are equal, flexible enough, and can be driven and used normally under Windows without a special driver.

[0073] The program running on the host computer can use the slave device as a standard Ethernet card and use a custom transmission protocol for data exchange, ensuring system security while having fault tolerance. The custom transmission protocol is a transmission control scheme designed by the present application based on the USB EEM virtual Ethernet method.

[0074] See also Figure 2 , showing a schematic diagram of the data structure of each layer for data interaction between the upper computer and the lower computer provided by the present application.

[0075] like Figure 2 As shown in the figure, the data transmission between the upper computer and the lower computer is divided into seven layers, from bottom to top: hardware link layer and physical layer, USB driver layer, USB link layer, USB EEM link layer, virtual Ethernet link layer, transmission control layer, and application layer. The following will introduce the role and data structure of each layer respectively:

[0076] (1) Hardware link layer and physical layer

[0077] The hardware link layer and physical layer are used to carry USB connection data and provide basic fault tolerance functions, building the foundation of USB communication. This layer can be based on USB2.0, USB3.0, USB3.1, USB3.2, USB4 and other USB communication protocols including USB EEM class, and the physical interface form is not limited, including but not limited to Micro B, Mini USB, Type C, etc. or future new interface forms.

[0078] The USB PHY chip or related control chip of the host and slave computers controls the sending and receiving of data. This layer supports full-duplex communication and transmits bit streams.

[0079] (2) USB driver layer

[0080] The USB driver layer is used to control the behavior of the hardware link layer. The USB driver layer transmits fixed-length data segments. For USB2.0 devices, it supports data segments of no more than 512 bytes. For USB3.0 and above devices, it supports 1024 or 2048 bytes. That is, the length of the Bulk allowed to be transmitted at the connection point.

[0081] When establishing a connection, both the host and the slave need to establish two pairs of endpoints, one pair of which is the control endpoint and the other pair of which is the block transfer endpoint. At the same time, the slave will declare itself as a USB EEM device and complete the enumeration interaction. During the enumeration process, the slave needs to inform the host that the interface descriptor established by the host has bNumEndPoints as 0x02, bInterfaceClass as 0x0C, and bInterfaceProtocol as 0x07. The host should be able to correctly enumerate the device and complete the corresponding protocol interaction.

[0082] For the host computer, the USB driver integrated by the Windows operating system implements the functions of the USB driver layer. The USB driver in the host computer enumerates the USB device information, and after detecting that the lower computer declares itself as a USB EEM device, it notifies the operating system (Windows operating system) to select the usbnet.sys driver for subsequent interaction with the lower computer.

[0083] (3) USB link layer

[0084] The USB link layer provides basic control of USB transmission and controls the accurate sending and receiving of basic transmission units. Each transmission unit is up to 19KB, which is larger than the maximum length limit of the USB EEM Ethernet frame. Therefore, each transmission unit may contain multiple USB EEM link layer data frames. The USB link layer transmits the merged USB EEM link layer data packets.

[0085] When there are multiple USB EEM link layer data frames, all the included USB EEM link layer data frames should be extracted and parsed separately and transmitted to the USB EEM link layer for processing in sequence.

[0086] (4) USB EEM link layer

[0087] The USB EEM link layer is used to transmit USB EEM link layer data frames. The USB EEM link layer data frames are obtained by extracting the USB EEM driver from the USB link layer data to obtain standard Ethernet frames, and then adding headers and tails to the standard Ethernet frames to obtain the frames.

[0088] The USB EEM link layer data frame consists of three parts: header, standard Ethernet frame and tail. The contents of each part are as follows:

[0089] The header includes frame type, check switch, and frame length.

[0090] The frame type occupies 1 bit. When its value is 0, it indicates that the frame is a data frame. When its value is 1, it indicates that the frame is a signaling frame.

[0091] The check switch can be CRC32, and this field can occupy 1 bit. When its value is 1, the tail CRC32 value takes effect, and the sender should fill in the correct CRC32 value. The receiver can check whether the CRC32 value is correct after receiving this frame, and perform corresponding operations based on the check result. For example, if the CRC32 value is incorrect, it can be discarded or requested to retransmit.

[0092] The frame length field is used to record the length of the USB EEM link layer data frame. This length does not include the length of the two fields at the head, but includes the length of the tail CRC32 field. The frame length field occupies 14 bits.

[0093] The tail is the CRC32 value, which occupies 4 bytes. When the check switch field is 0, this field is filled with the default value 0xDE, 0xAD, 0xBE or 0xEF; when the check switch field is 1, this field should calculate and fill in the actual CRC32 value. The CRC32 coverage range is the standard Ethernet frame in the middle.

[0094] Standard Ethernet frame: This field contains the content of the next virtual Ethernet link layer. The standard length of this field is 1514 bytes and the maximum length is 16375 bytes.

[0095] For the host computer, the operating system of the host computer is integrated with a USB Ethernet driver, which is responsible for providing a USB EEM Ethernet card device on the system (i.e., registering the lower computer as an independent Ethernet card), and sending the data received by the USB EEM Ethernet card device through the USB link, or forwarding the USB EEM data received on the USB link to the USB EEM Ethernet card device of the system. That is, it plays the role of mutual conversion between virtual Ethernet link layer data and USB EEM link layer data.

[0096] (5) Virtual Ethernet Link Layer

[0097] The virtual Ethernet link layer transmits standard Ethernet data packets. The data frame consists of the following four parts: destination MAC address (DMAC), source MAC address (SMAC), Ethernet protocol number, and transmission control layer data.

[0098] Destination MAC address: This field is used to specify the MAC address of the current frame exchange destination. The length is fixed at 6 bytes.

[0099] For data frames sent from the host computer to the slave computer, the destination MAC address field should be specified as a value that the slave computer can capture and parse. For data frames sent from the slave computer to the host computer, the destination MAC address field should be specified as a value that the host computer can capture and parse.

[0100] In the scenario where the upper computer sends a data frame to the lower computer, if the upper computer's own MAC address is a random value, the lower computer only needs to resolve the destination MAC address.

[0101] Source MAC address: specifies the MAC address of the current frame exchange source. The length is fixed at 6 bytes.

[0102] For data frames sent from the host computer to the slave computer, the source MAC address field should be specified as a value that the slave computer can capture and parse. In this scenario, if the host computer's own MAC address is a random value, the slave computer does not need to parse the source MAC address.

[0103] For data frames sent from the lower computer to the upper computer, the source MAC address field should be specified as a value that can be captured and parsed by the upper computer.

[0104] Ethernet protocol number: specifies the Ethernet protocol used by the current frame. This field should avoid all Ethernet protocols that may exist in the environment, such as TCP / IP, ICMP, SNMP, etc. The upper and lower computers should be able to identify and parse the protocol number here. Multiple types of communication protocols can be sent and received at the same time by setting multiple different protocol numbers.

[0105] For the host computer, the security protection mechanism of Windows in the host computer does not allow the program to directly send and receive virtual Ethernet link layer data packets, and modifying the Ethernet card driver is difficult and there are security risks. Therefore, you can use an Ethernet data packet sending and receiving tool that can run on the operating system (such as Winpcap or Npcap) to send and receive custom Ethernet data packets on the virtual Ethernet link. In other words, the Ethernet data packet sending and receiving tool allows custom Ethernet data packets to be transmitted normally on the virtual Ethernet link.

[0106] (6) Transmission Control Layer

[0107] The transmission control layer is used to transmit the fragments of the application layer data. The transmission control layer is used to perform transmission control and error control on the application layer data to ensure that the application layer data is delivered to the application layer without errors.

[0108] In the embodiment of the present application, the transmission control layer and the application layer are adjusted by the developer and are not restricted by standard protocols.

[0109] In some embodiments, the transmission control layer data packet may include the following five parts: a fixed header identifier, the current transmission control layer data packet length, the current transmission control layer sequence number, the type of application layer data transmitted by the current transmission control layer, application layer data fragmentation, and CRC check value (optional).

[0110] Head fixed mark (ie Figure 2The handle field in the Ethernet data frame): This field is used to reconfirm that the Ethernet data frame is the data that needs to be processed for the current transmission. The content can be defined by the device manufacturer, such as the manufacturer name, product model code, etc. Its length can be controlled as needed.

[0111] A handle is usually a digital tag (number) through which the corresponding data packet or other resource can be accessed and operated.

[0112] Current transport control layer data packet length (Len): The recommended length is 4 bytes, which can be increased or decreased as needed. This field is used to record the complete length of the current transport control layer data packet.

[0113] Current transmission control layer serial number (serial_num): used to record the global serial number of the current frame after the upper and lower computers establish a connection. The length of this field can be 4 bytes and can be increased or decreased as needed. When the length is 4 bytes, the maximum value can reach 4,294,967,295 (0xFFFFFFFF). When a certain value is reached, both parties can automatically clear or overflow. When overflow occurs, a verification mechanism needs to be set to ensure synchronization.

[0114] The current transmission control layer sequence number is only used to record the sequence number of the application layer data. For other types of data, this field can be specified as a default value.

[0115] The upper computer and the lower computer respectively record the numbers of the data frames they send and the numbers of the data frames sent by the other party. Each time the upper computer or the lower computer sends data, it increases its own number by 1. At the same time, when the received data is correct, it increases the number of the data frame sent by the other party by 1. When the sequence number of the received frame does not meet the expectations, it should enter the error handling process.

[0116] Type of data transmitted by the current transport control layer (type): Define multiple types of transport control layer data packets as needed, for example, including application layer data, retransmission request, heartbeat keep-alive, upper computer reset connection, lower computer reset completion reply, etc. Each type occupies a number, and this field can occupy 4 bytes in length, which can be increased or decreased according to needs.

[0117] CRC: The CRC check value corresponding to the content of the transmission control layer except CRC. The upper and lower computers calculate the actual CRC check value and fill it in before sending the data packet. The receiver should check the CRC check value. If the actual CRC value is inconsistent with the CRC standard value, enter the error handling process. In addition, if the CRC32 check of the USB EEM virtual Ethernet link layer is enabled, the CRC check of the transmission control layer can be omitted.

[0118] Application layer data fragment (AppData): The length of application layer data may be long, so the application layer data may be split into multiple data fragments for transmission. Among them, only the first data fragment contains the basic information of the application layer data, such as the fixed header identifier, length, instruction, sequence number, etc.

[0119] Usually, the length of each data fragment is the difference between the length of the Ethernet frame and the length of the remaining items. For example, the fixed identification field in the header occupies t1 bytes, the current transmission control layer data packet length field occupies t2 bytes, the current transmission control layer sequence number field occupies t3 bytes, the current transmission control layer transmission data type field occupies t4 bytes, and the CRC field occupies t5. The maximum length of the AppData field is: (1500-t1-t2-t3-t4-t5) bytes.

[0120] For the host computer, the functions of the transmission control layer are controlled by the transmission control layer interface program, which is developed and compiled by the developer to complete all the interactive functions of the transmission control layer. Specifically, after obtaining complete and correct application layer data, it is delivered to the application software for subsequent processing. When there are packet errors, packet loss / disorder, heartbeat confirmation timeout, etc., the corresponding disposal is initiated. When the request cannot be responded, the current link should be reset. When the connection is completed and the communication begins, the host computer can send a signal as a sign of the start of the connection.

[0121] (7) Application layer

[0122] The application layer transmits business data. This layer transmits complete application layer data packets that can be passed to the application for processing. It is composed of fragments of data received by the transmission control layer.

[0123] The application layer data packet may include the following five parts: application layer data packet length, control instruction unique identifier, transmission sequence identifier, header fixed identifier and application data fragment. In addition, some fields may be added or deleted, or some fields may be redefined according to the transmission service requirements. This application does not impose any special restrictions on the number of fields contained in the application layer data packet and the meaning of each field.

[0124] Application layer data packet length (Len): This field is used to record the complete length of the current application layer data packet. The recommended length is 4 bytes and can be increased or decreased as needed.

[0125] Control instruction unique identifier (CmdID): This field is the unique identifier of the control instruction, and the type of the control instruction in the current application layer data packet can be determined through this field.

[0126] Data packet sequence number (sequence): This field indicates the sequence number corresponding to the application layer data packet.

[0127] Header fixed identifier (handle): This field has the same meaning as the header fixed identifier of the transmission control layer and is not repeated here.

[0128] Application data segment (Appdata): This field is application layer data.

[0129] The above seven layers can be increased or decreased according to the actual business situation, and this application does not impose any special restrictions on this.

[0130] See also Figure 3 , shows a flow chart of a communication method provided in an embodiment of the present application, the method is applied to Figure 1 In the communication system shown in the figure, the upper computer and the lower computer adopt Figure 2 The communication protocol layers and data packet structures shown are used for data exchange.

[0131] like Figure 3 As shown, the method may include the following steps:

[0132] S100, the upper computer packages the first target application data to be sent to the lower computer in a top-down order of the communication layer to obtain a first data packet.

[0133] The upper computer runs the application to obtain the application data that needs to be sent to the lower computer, that is, the first target application data, and then Figure 2 The seven layers shown pack the data from top to bottom to obtain a data packet that can be sent based on the hardware link layer and the physical layer, which can be called a first data packet.

[0134] S200: The upper computer sends a first data packet to the lower computer via a USB hardware link.

[0135] The upper computer sends a first data packet via the USB bus between the upper computer and the lower computer.

[0136] S300, the lower computer parses the first data packet layer by layer according to the communication layer to obtain the first target application data.

[0137] After receiving the first data packet sent by the upper computer through the hardware link layer and the physical layer, the lower computer parses the data packet layer by layer to obtain the first target application data.

[0138] S400: The application in the lower computer performs corresponding processing based on the first target application data.

[0139] The lower computer parses the first data packet to obtain corresponding application data (ie, first target application data), and sends the data to the application program, and the application program performs corresponding processing based on the application data.

[0140] S100 to S400 are the process of the upper computer sending data to the lower computer. The following S105 to S108 are the process of the lower computer sending data to the upper computer:

[0141] S500, the lower computer packages the second target application data to be sent to the upper computer in a top-down order of the communication layer to obtain a second data packet.

[0142] S600: The lower computer sends a second data packet to the upper computer via the USB hardware link.

[0143] S700: The host computer parses the second data packet layer by layer to obtain second target application data.

[0144] S800: The application in the host computer performs corresponding processing based on the second target application data.

[0145] The implementation process of S500 to S800 is the same as the implementation process of S10 to S400 described above, and will not be repeated here.

[0146] The following will be combined Figure 4 and Figure 5 This paper introduces in detail the detailed process of the lower computer receiving data sent by the upper computer, and the lower computer sending data to the upper computer.

[0147] See also Figure 4 , shows a schematic diagram of a process of a lower computer receiving application data from an upper computer provided in an embodiment of the present application, the method is applied to the lower computer, and in this embodiment, the lower computer is the receiver and the upper computer is the sender. Figure 4 As shown, this process may include the following steps:

[0148] S101, newly establish or restore a USB EEM connection link.

[0149] S102, waiting for receiving data interruption.

[0150] After a USB driver layer data packet is received, a receive data interrupt is generated. This interrupt is used to notify that there is data to be received.

[0151] S103, determine whether the heartbeat packet has timed out; if not, execute S104; if yes, execute S101.

[0152] The heartbeat keep-alive mechanism is a mechanism in which the upper computer and the lower computer periodically send a heartbeat packet to each other to let the other party know that they are still alive, so as to ensure the validity of the connection.

[0153] In some embodiments, a timer is started after receiving a heartbeat packet, and the timing duration of the timer is greater than or equal to the heartbeat interval (such as the timing duration is a positive integer multiple of the heartbeat interval). If no new heartbeat packet is received when the timer expires, the link is determined to be abnormal. In this scenario, an attempt should be made to detect or reset the link. If a new heartbeat packet is received before the timer expires, S104 is continued to be executed, and at the same time, the heartbeat timeout is waited again.

[0154] S104, reading data from the USB receiving buffer.

[0155] Each time a data receiving interrupt occurs, the lower computer reads all current USB link layer data from the USB receiving buffer in units of 512 bytes.

[0156] S105, determine whether the data has been received; if yes, execute S106; if not, execute S104.

[0157] The capacity of each transmission unit of the USB link layer is greater than the maximum length limit of the USB EEM link layer data frame, so the USB link layer data packet may include multiple USB EEM link layer data. In this scenario, all USB EEM link layer data frames are extracted and parsed respectively and then passed to the USB EEM link layer for processing. Therefore, in this scenario, the lower computer needs to identify whether all USB EMM link layer data frames have been received, wherein the lower computer can determine whether the length of the data read from the USB receive buffer is 512 bytes, and if so, continue to determine whether the data is the last USB link layer data frame. If the currently read data is the last USB link layer data frame, it indicates that the data has been received. If the length of the currently read data is less than 512 bytes, it indicates that the USB link layer data has been received.

[0158] S106, extracting USB EEM link layer data from the USB link layer data.

[0159] The USB EEM driver extracts the USB EEM link layer data from the USB link layer data to obtain the USB EEM link layer data, that is, the standard Ethernet data frame.

[0160] S107, extracting virtual Ethernet link layer data from the verified USB EEM link layer data packet, and extracting transmission control layer data from the virtual Ethernet link layer data.

[0161] The extracted USB EEM0 link layer data is verified, that is, the CRC32 value at the end of the USB EEM link layer data frame is determined to be consistent with the CRC32 calculated value of the standard Ethernet data frame in the USB EEM link layer data frame. If they are inconsistent, the verification is incorrect; if they are consistent, the verification is correct.

[0162] Furthermore, for the USB EEM link layer data packet that has been verified to be correct, the virtual Ethernet link layer data, namely the standard Ethernet data frame, is extracted therefrom, and the transmission control layer data is further extracted from the standard Ethernet data frame.

[0163] S108, verify whether the transmission control layer data is correct; if the verification is correct, execute S109; if the verification is incorrect, execute S117.

[0164] The transmission control layer data frame includes a CRC check value. After receiving the transmission control layer data packet, the actual CRC value of the data in the transmission control layer data packet other than the CRC check value is calculated. If the actual CRC value is inconsistent with the CRC check value in the data packet, it indicates that the transmission control layer data packet is incorrectly checked. If the two CRC values ​​are consistent, it indicates that the transmission control layer data packet is correctly checked.

[0165] In addition, if any field in the header fixed identifier, current transmission control layer sequence number, type, application layer data fragmentation, or CRC of the received transmission control layer data packet is abnormal, the current transmission control layer data packet is considered abnormal and a retransmission request is immediately initiated.

[0166] S109, determine whether the transmission control layer data packet is application layer data; if yes, execute S110; if not, execute S119.

[0167] After the transport control layer data packet is verified to be correct, the data type (type) field content in the transport control layer data packet is identified, that is, the data type of the transport control layer data packet is identified. If the transport control layer data packet is application layer data, S110 is executed.

[0168] S110, determine whether the sequence number of the transmission control layer data packet is correct; if the sequence number is incorrect, execute S111; if the sequence number is correct, execute S113.

[0169] As mentioned above, when the lower computer receives the data frame sent by the upper computer, it will record the sequence number of the current data frame (the heartbeat packet does not occupy the sequence number of the transmission control layer data packet). If the sequence number is inconsistent with the sequence number field in the data frame, but other information (such as CRC check value) is correct, it is determined that the transmission control layer data packet is out of order. If the sequence number of the transmission control layer data packet recorded by the lower computer is consistent with the sequence number in the data packet, it indicates that the sequence number is correct.

[0170] S111, cache n transport control layer data packets and sort subsequent data packets.

[0171] When the lower computer determines that the transmission control layer data packets are out of order, it can cache the currently received transmission control layer data packets, and continue to receive n transmission control layer data packets and cache them or sort the cached data packets after a certain period of time.

[0172] For example, the order of the received data packets is 3, 4, 7, 8, 6, 5, 10. If the out-of-order cache window that the program can handle (such as the time to transmit n data packets mentioned above) exceeds the out-of-order range, normal transmission can be maintained after sorting and verification; if the program's out-of-order cache window is smaller than the out-of-order range, or packet loss does occur, retransmission is requested immediately.

[0173] S112, determine whether the transmission control layer data packet of the target sequence number is received. If yes, execute S113; if not, execute S117.

[0174] When the number of cached transport control layer packets reaches a certain number, the cached transport control layer packets are reordered and the cached packets are searched to see if they contain the packet with the target sequence number, i.e., the missing packet. For example, after receiving the 5th packet, the 7th packet is received, but the 6th packet is not received at this time, so the target sequence number is 6.

[0175] S113, merging all received transport control layer data packets.

[0176] If it is determined that the transmission control layer data packet of the target sequence number is received, a merging operation is performed on all received transmission control layer data packets.

[0177] S114, whether the merging process is completed; if yes, execute S115; if not, execute S102.

[0178] S115, sending application data to the application layer.

[0179] After all the transport control layer data packets are merged, the merged data is sent to the application layer.

[0180] S116, the application program in the lower computer waits for the next application layer data.

[0181] After the lower computer sends the application data to the application, the application waits for the next layer of application layer data. Meanwhile, the lower computer returns to execute S102, waiting for the generation of the next data reception interrupt.

[0182] S117, sending a retransmission request to the upper computer.

[0183] If the data packet verification of the transmission control layer is incorrect, a retransmission request packet is sent to the host computer to request the host computer to retransmit the data.

[0184] In another scenario, if the transmission control layer data packets are out of order and the transmission control layer data packet with the target sequence number is not received after waiting for a certain period of time, a retransmission request packet will also be sent to the upper computer.

[0185] The retransmission request packet carries the target sequence number, that is, the sequence number of the data packet that the sender is requested to retransmit.

[0186] S118, waiting for the host computer to respond to the retransmission request.

[0187] The sender can respond to the retransmission request according to the actual link situation and business requirements. One response method is that the sender restarts sending data packets starting from the sequence number requested for retransmission; another response method is to retransmit only one requested data packet.

[0188] S119, determine whether it is a retransmission request packet; if yes, execute S121; if not, execute S120.

[0189] If the current transmission control layer data packet is not a data packet, continue to determine whether it is a reset request packet or a heartbeat packet, which can be determined based on the data type in the transmission control layer data packet.

[0190] S120, determining whether the data packet is a reset request packet or a heartbeat packet, responding to the current data packet, and returning to execute S102.

[0191] In this embodiment, the reset request is initiated by the upper computer. In other embodiments, the reset request can be initiated by the lower computer according to business requirements. This application does not impose any special restrictions on this.

[0192] When the upper computer confirms that the link is abnormal, it sends a reset request, which is used to enable the lower computer to restore the connection link to the initial state.

[0193] For example, when the host computer as the receiver determines that an error packet or packet loss occurs, and still does not receive the retransmitted data packet after requesting retransmission for a certain period of time, the host computer attempts to reset the link and sends a reset request packet to the subordinate computer. Alternatively, if the host computer does not receive a heartbeat packet within a certain period of time, it considers that the link is abnormal and sends a reset request to the subordinate computer.

[0194] After the lower computer determines that the current transmission control layer data packet is a reset request packet, it immediately responds to the reset request packet, clears all received resources (such as clearing the sequence number of the recorded received data packet), and restores the connection to the initial state. After completing the link reset, it replies to the upper computer with a successful reset reply message and waits for the upper computer to initiate the first data transmission.

[0195] If the current transmission control layer data packet is a heartbeat packet, respond to the heartbeat packet immediately, such as resetting the heartbeat timeout timer.

[0196] S121, move the sending queue pointer or directly resend the requested data packet, and return to execute S102.

[0197] This step is performed when the lower computer acts as the sender.

[0198] If the current transmission control layer data packet is a retransmission request packet, the sending queue pointer is returned to the sequence number of the retransmission request and all subsequent data packets are resent, or only the data packet requested for retransmission is sent.

[0199] The process of receiving application data by the lower computer provided in this embodiment, after receiving the data and passing it to the transmission control layer, after verifying the data packet correctly, further judge whether the current transmission control layer data packet is application layer data, if it is application layer data, judge whether there is an error packet, packet loss or disorder, if the sequence number of the data packet is correct, after receiving all the transmission control layer data packets, data merging is performed to obtain application layer data, and the application layer data is passed to the application layer. If there is an error packet or packet loss, the sender is immediately requested to retransmit. If the received data packet is disordered, the transmission control layer data packet continues to be received and cached. After caching for a certain period of time, it is judged whether the data packet with the target sequence number is received. Through the above-mentioned fault tolerance and retransmission mechanism of the transmission control layer, the accuracy of the sent and received data and the security of the system can be ensured.

[0200] See also Figure 5 , shows a schematic diagram of the process of sending application data from a lower computer to an upper computer provided in an embodiment of the present application. The method is applied to the lower computer. In this embodiment, the lower computer is the sender and the upper computer is the receiver. Figure 5 As shown, this process may include the following steps:

[0201] S201, newly establish or restore a USB EEM connection link.

[0202] S202, waiting for sending new data.

[0203] S203, determine whether it is necessary to respond to the retransmission request; if so, assemble the retransmission data packet and execute S209; if not, execute S204.

[0204] When the lower computer is waiting to send new data, it first determines whether it has received a retransmission request from the receiver. The receiver immediately initiates a retransmission request when it verifies that the received data is abnormal (such as wrong packets, packet loss, etc.). Alternatively, if the data packets received by the receiver are out of order and the data packet with the target sequence number is not received after waiting for a certain period of time, the receiver will also initiate a retransmission request.

[0205] The sender can respond to the retransmission request according to the actual link situation and business requirements. One response method is that the sender restarts sending data packets starting from the sequence number requested for retransmission; another response method is to retransmit only one requested data packet.

[0206] After assembling the retransmitted data packet according to any of the above response modes, S209 is executed, that is, a header of a virtual Ethernet link layer, that is, a destination MAC address, a source MAC address and an Ethernet protocol number is added to the outer layer of the retransmitted data packet.

[0207] S204, determine whether a heartbeat packet needs to be sent; if so, assemble the heartbeat packet and execute S209; if not, execute S205.

[0208] The lower computer determines whether the heartbeat packet needs to be sent at the current moment according to the sending time interval of the heartbeat packet. Exemplarily, a timer is started after each sending of the heartbeat packet, and the timing duration of the timer is the heartbeat packet sending interval. After the timer expires, it is considered that the heartbeat packet needs to be sent at the current moment. After the heartbeat packet is assembled, S209 is executed again, that is, the header of the virtual Ethernet link layer is added to the outer layer of the heartbeat packet.

[0209] S205, determine whether a reset reply needs to be sent; if so, assemble a reset reply packet and execute S209; if not, execute S206.

[0210] The lower computer can determine whether it has received a reset request from the upper computer. If it has received a reset request, it will respond to the reset request immediately. For the process of responding to a reset request, please refer to Figure 4 The relevant contents of S120 will not be repeated here.

[0211] After assembling the reset reply packet, S209 is executed, that is, a header of a virtual Ethernet link layer is added to the outer layer of the reset reply packet.

[0212] S206, determine whether application data needs to be sent; if yes, execute S207; if no, execute S202.

[0213] When the lower computer receives the application data generated by the application program and generates a sending interrupt, it determines that the application data needs to be sent.

[0214] S207, add an application layer header.

[0215] After the application layer generates the application data that needs to be sent, add the application layer header, for example, Figure 2 The application layer data structure shown includes Len (the complete length of the currently transmitted application data packet), CmdID (control instruction ID), sequence (sequence number of the data packet) and a fixed header identifier (handle). The meaning of the fixed header identifier here is the same as that of the fixed header identifier in the transmission control layer data packet.

[0216] S208, data is divided into packets and a transport control layer header and trailer are added.

[0217] The transmission control layer divides the application layer data packet into packets and adds the header and tail of the transmission control layer, namely, the fixed header identifier, the current transmission control layer data packet length, the current transmission control layer sequence number, the type of application layer data transmitted by the current transmission control layer, and the CRC check value.

[0218] S209, adding a virtual Ethernet link layer header.

[0219] The virtual Ethernet link layer adds a header of the virtual Ethernet link layer, namely the destination MAC address (DMAC), the source MAC address (SMAC), and the Ethernet protocol number, to the outer layer of the transmission control layer data packet transmitted downward by the transmission control layer. Further, the virtual Ethernet link layer data packet is transmitted downward to the USB EEM link layer.

[0220] S210, adding the header and tail of the USB EEM link layer.

[0221] After the USB EEM link layer receives the virtual Ethernet link layer data packet transmitted by the virtual Ethernet link layer, it obtains the USB EEM link layer data packet at the head and tail of the USB EEM link layer in the outer layer of the data packet and stores the data packet in the USB send buffer.

[0222] S211, store in USB sending buffer.

[0223] S212, sending the data to be sent in the USB sending buffer.

[0224] After the lower computer determines that there is new data to be sent in the USB send buffer, it reads the data to be sent in the USB send buffer and transmits it to the receiver through the USB hardware link layer.

[0225] S213, whether the data to be sent is sent successfully; if so, execute S202; if not, execute S201.

[0226] The lower computer determines whether the application layer data is sent successfully. If it is sent successfully, it continues to wait for the next application layer data to be sent. If it fails to send, it determines that the link of the hardware link layer is abnormal, and tries to reset the link, that is, sends a reset request to the upper computer, and waits to send the first application data after receiving the reset success message from the upper computer.

[0227] The process of sending application data by the lower computer provided in this embodiment ensures the accuracy of the interactive data between the upper computer and the lower computer and the security of the communication system through a retransmission mechanism, a link reset mechanism, etc.

[0228] See also Figure 6, shows a schematic diagram of a process of a host computer receiving application data sent by a slave computer provided in an embodiment of the present application. The method is applied to a host computer, in which the host computer in this embodiment is a receiver and the slave computer is a sender.

[0229] The software services on the host computer can only directly act on the layers above the virtual Ethernet link layer, namely the transmission control layer and the application layer. Therefore, the data processing flow of the host computer does not involve the data processing process of the virtual Ethernet link layer and the layers below. The data processing process of the virtual Ethernet link layer and the layers below is completed by the host computer's operating system and driver. That is, Figure 6 The process shown does not involve the data processing of virtual Ethernet and lower layers.

[0230] like Figure 6 As shown, the method may include the following steps:

[0231] S301, newly establish or restore a USB EEM connection link.

[0232] S302, receiving an Ethernet data packet from a lower computer.

[0233] S303, determine whether the heartbeat packet has timed out; if not, execute S304; if yes, execute S301.

[0234] S304, check whether the data is correct; if so, execute S305; if not, execute S313.

[0235] S305, determine whether the transmission control layer data packet is application layer data; if so, execute S306; if not, execute S315.

[0236] S306, determine whether the sequence number of the transmission control layer data packet is correct; if the sequence number is incorrect, execute S307; if the sequence number is correct, execute S309.

[0237] S307, cache n transport control layer data packets and sort subsequent data packets.

[0238] S308, determine whether the transmission control layer data packet of the target sequence number is received. If yes, execute S309; ​​if not, execute S313.

[0239] S309, merging all received transport control layer data packets.

[0240] S310, whether the merging process is completed; if yes, execute S311; if not, execute S302.

[0241] S311, sending application data to the application layer.

[0242] S312, the application program in the host computer waits for the next application layer data.

[0243] S313, sending a retransmission request to the lower computer.

[0244] S314, waiting for the lower computer to respond to the retransmission request.

[0245] S315, determine whether it is a retransmission request packet; if yes, execute S317; if not, execute S316.

[0246] S316, determine whether the data packet is a reset request packet or a heartbeat packet, respond to the current data packet, and return to execute S302.

[0247] S317, move the sending queue pointer or directly resend the requested data packet, and return to execute S302.

[0248] The implementation process of each step in this embodiment is similar to Figure 4 The implementation process of the corresponding steps in the illustrated embodiments is the same and will not be repeated here.

[0249] See also Figure 7 , shows a schematic diagram of the process of sending application data from a host computer to a slave computer provided in an embodiment of the present application. The method is applied to the host computer, and the host computer is the sender and the slave computer is the receiver. Figure 7 As shown, the method may include the following steps:

[0250] S401, newly establish or restore a USB EEM connection link.

[0251] S402, waiting for sending new data.

[0252] S403, determine whether it is necessary to respond to the retransmission request; if so, assemble the retransmission data packet and execute S409; if not, execute S404.

[0253] S404, determine whether a heartbeat packet needs to be sent; if so, assemble the heartbeat packet and execute S409; if not, execute S405.

[0254] S405, determine whether a reset reply needs to be sent; if so, assemble a reset reply packet and execute S409; if not, execute S406.

[0255] S406, determine whether application data needs to be sent; if yes, execute S407; if no, execute S402.

[0256] S407, add an application layer header.

[0257] S408, data packetization and adding transport control layer header and tail

[0258] S409, adding a virtual Ethernet link layer header.

[0259] S410, adding the header and the tail of the USB EEM link layer.

[0260] S411, store in USB sending buffer.

[0261] S412, sending the data to be sent in the USB sending buffer.

[0262] S413, whether the data to be sent is sent successfully; if yes, execute S402; if no, execute S401.

[0263] The implementation process of each step in this embodiment is similar to Figure 5 The implementation process of the corresponding steps in the illustrated embodiments is the same and will not be repeated here.

[0264] The present application also provides an electronic device in an embodiment. Figure 8 As shown, it shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present application. The electronic device in the embodiments of the present application may include but is not limited to fixed terminals such as mobile phones, notebook computers, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 8 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0265] like Figure 8 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0266] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0267] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any one of the communication methods provided in the embodiments of the present application.

[0268] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any communication method provided in the embodiment of the present application.

[0269] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.

[0270] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0271] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0272] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

Claims

1. A communication method, characterized in that: Applied to a receiving party, the method comprises: Get the transport control layer data packet; After verifying that the transmission control layer data packet is correct and determining that the transmission control layer data packet is application layer data, determining whether the currently received transmission control layer data packet is out of order; Sending a retransmission request for a transport control layer data packet that is incorrectly verified, wherein the retransmission request carries a sequence number of the transport control layer data packet that is incorrectly verified; After determining that the received transmission control layer data packets are not out of order, or after determining that the received transmission control layer data packets are out of order and after waiting for a preset time, determining that the transmission control layer data packet with the target sequence number is received, all received transmission control layer data packets are merged to obtain an application layer data packet; Sending the application layer data packet to the application layer; It is determined that the received transmission control layer data packets are out of order, and after waiting for a preset time, it is determined that the transmission control layer data packet with the target sequence number is not received, and a retransmission request is sent.

2. The method according to claim 1, characterized in that Verifying that the transmission control layer data packet is correct includes: Verify whether the content of each field in the transmission control layer data packet is consistent with the meaning of the corresponding field, and if the content of at least one field is inconsistent with the meaning of the corresponding field, determine that the transmission control layer data packet is abnormal; After determining that the content of each field of the transmission control layer data packet is the same as the meaning of the corresponding field, a CRC check is performed on the transmission control layer data packet. If the CRC check is incorrect, it is determined that the transmission control layer data packet check is incorrect. If the CRC check is correct, it is determined that the transmission control layer data packet check is correct.

3. The method according to claim 1 or 2, characterized in that: The determining whether the currently received transmission control layer data packets are out of order comprises: Determine whether the sequence number in the currently received transmission control layer data packet is consistent with the sequence number recorded locally. If they are consistent, it is determined that no disorder has occurred. If they are inconsistent, it is determined that the received transmission control layer data packet is disordered.

4. The method according to claim 3, characterized in that The step of determining that the received transmission control layer data packets are out of order and determining that the transmission control layer data packet with the target sequence number is received after waiting for a first preset time period includes: After determining that the received transmission control layer data packets are out of order, storing the currently received transmission control layer data packets in a buffer, and receiving n transmission control layer data packets within the first preset time length and storing them in the buffer; Sorting all the transport control layer data packets in the buffer, and determining whether there is a transport control layer data packet with a target sequence number, wherein the target sequence number is a missing sequence number; If the transmission control layer data packet of the target sequence number exists in the buffer, determining that the transmission control layer data packet of the target sequence number is received; If the transmission control layer data packet of the target sequence number does not exist in the buffer, it is determined that the transmission control layer data packet of the target sequence number has not been received.

5. The method according to claim 1, characterized in that The receiving party is a lower computer, and the obtaining of a transmission control layer data packet includes: Receive a USB link layer data packet, and extract a USB EEM link layer data packet from the USB link layer data packet; Extract the transmission control layer data packet from the verified USB EEM link layer data packet.

6. The method according to claim 1, characterized in that The method further comprises: After determining that the transmission control layer data packet is a reset request packet, responding to the reset request to restore the USB EEM connection link to an initial state, and sending a reset success reply message to the sender; or, After determining that the transmission control layer data packet is a heartbeat packet, reset the heartbeat timeout timer.

7. A communication method, characterized in that: Applied to the sender, the method includes: Acquire application data to be sent, add header information corresponding to the application layer to the application data to be sent, and obtain an application layer data packet; Subpacketizing the application layer data packet, and adding header information and tail information corresponding to the transmission control layer to obtain a transmission control layer data packet; Adding header information of a virtual Ethernet link layer to the outer layer of the transmission control layer data packet to obtain a virtual Ethernet link layer data packet; Adding the header information and the tail information of the USB EEM link layer to the outer layer of the virtual Ethernet link layer data packet to obtain the USB EEM link layer data packet; The USB EEM link layer data packet is sent through the hardware link layer.

8. The method according to claim 7, characterized in that Before obtaining the application data to be sent, the method further includes: After determining that a retransmission request packet has been received, obtaining the data to be retransmitted based on the target sequence number carried in the retransmission request, and assembling a retransmission data packet according to the data to be retransmitted; Adding header information of the virtual Ethernet link layer and header information and tail information of the USB EEM link layer in sequence to the outer layer of the assembled retransmission data packet to obtain the retransmission data packet to be sent; The retransmission data packet to be sent is sent through the hardware link layer.

9. The method according to claim 8, characterized in that The obtaining the data to be retransmitted based on the target sequence number carried in the retransmission request includes: Determine all service data starting from the target sequence number as the data to be retransmitted; or, The service data corresponding to the target sequence number is determined as the data to be retransmitted.

10. The method according to claim 7, characterized in that The sender is a host computer, and before obtaining the application data to be sent, the method further includes: After determining that the USB EEM connection link is abnormal, sending a reset request to the lower computer, wherein the reset request is used to enable the lower computer to reset the USB EEM link; After receiving the reset success reply message sent by the lower computer, it is determined that the USB EEM connection link is restored successfully.

11. The method according to claim 10, characterized in that Determining that the USB EEM connection link is abnormal includes: After receiving the retransmission request packet, the sender fails to obtain a data packet corresponding to the target sequence number carried in the retransmission request packet, and determines that the USB EEM connection link is abnormal; or, The sender does not receive the heartbeat packet within the second preset time period, and determines that the USB EEM connection link is abnormal.

12. An electronic device, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the communication method according to any one of claims 1 to 11.

13. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the communication method as described in any one of claims 1 to 11.

Citation Information

Cited By

  • Text transmission method and device, equipment and medium

    CN122226121A