Software package transmission method and computer equipment

By negotiating the data transmission length and encrypting the package during the software package transmission process, the problem of low software package transmission efficiency in the prior art is solved, and the combination of encryption and efficient transmission is achieved.

CN119629165APending Publication Date: 2025-03-14WUHAN FS COM TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411670230.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-20
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

Although the prior art ensures the accuracy of data during the software package transmission process, the overall transmission process is long and affects efficiency.

Method used

By negotiating the data transmission length between the first device and the second device, the second device encrypts and encapsulates the software package into a plurality of software packets, and the first device obtains the target software package according to the combination of these packets.

Benefits of technology

While implementing encryption, the key determination process is simplified and the transmission speed and efficiency of software packages are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119629165A_ABST
    Figure CN119629165A_ABST
Patent Text Reader

Abstract

The embodiment of the invention is suitable for the technical field of data transmission, and provides a software package transmission method and computer equipment, and the method comprises the steps: sending a software package request message to second equipment; in response to a data transmission length negotiation message returned by the second device, a data transmission length determination message is returned to the second device, and the data transmission length determination message comprises the maximum data length during data transmission; receiving a plurality of software data packet messages transmitted by the second equipment according to the maximum data length, wherein the software data packet messages are encrypted and packaged by the second equipment according to the maximum data length transmission; and obtaining a target software package based on each software data package message. By means of the method, when the software package is transmitted, the data security can be guaranteed while the transmission rate is increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the technical field of data transmission, and in particular, relates to a software package transmission method and computer equipment. Background Art

[0002] During the remote software version upgrade of the first device, the software package needs to be transmitted, and the software package needs to be kept confidential during the transmission process to prevent tampering or theft.

[0003] At present, when the first device obtains the software data packet, it can use encrypted transmission, which may involve key negotiation, data encryption and decryption, and data packet integrity verification. Although encrypted transmission can ensure the accuracy of the data packet, the overall transmission process takes a long time. Software package transmission can also use a fixed md5 verification method. Compared with encrypted transmission, the fixed md5 verification method does not have a key negotiation and data encryption and decryption process in the middle, and the overall transmission process is faster and the transmission efficiency is higher. Summary of the invention

[0004] In view of this, an embodiment of the present application provides a software package transmission method and a computer device to improve the transmission efficiency of the software package.

[0005] A first aspect of an embodiment of the present application provides a software package transmission method, which is applied to a first device, and the method includes:

[0006] Sending a software package request message to the second device;

[0007] In response to the data transmission length negotiation message returned by the second device, returning a data transmission length determination message to the second device, wherein the data transmission length determination message includes a maximum data length during data transmission;

[0008] receiving a plurality of software data packet messages transmitted by the second device according to the maximum data length, the software data packet messages being encrypted and encapsulated by the second device according to the maximum data length transmission;

[0009] Based on each of the software data packet messages, a target software package is obtained.

[0010] A second aspect of an embodiment of the present application provides a software package transmission method, which is applied to a second device, and the method includes:

[0011] In response to a software package request message from the first device, returning a data transmission length negotiation message to the first device, wherein the data transmission length negotiation message includes a first data length supported by the second device;

[0012] receiving a data transmission length determination message returned by the first device, wherein the data transmission length determination message includes a maximum data length during data transmission;

[0013] Based on the maximum data length, encapsulating the target software package into a plurality of software data packet messages;

[0014] Send the plurality of software data packet messages to the first device.

[0015] A third aspect of an embodiment of the present application provides a software package transmission device, which is applied to a first device, and the device includes:

[0016] A software package request message sending module, used to send a software package request message to the second device;

[0017] a data transmission length determination message sending module, configured to return a data transmission length determination message to the second device in response to the data transmission length negotiation message returned by the second device, wherein the data transmission length determination message includes a maximum data length during data transmission;

[0018] a software data packet message receiving module, configured to receive a plurality of software data packet messages transmitted by the second device according to the maximum data length, the software data packet messages being encrypted and encapsulated by the second device according to the maximum data length transmission;

[0019] The target software package determination module is used to obtain the target software package based on each of the software data package messages.

[0020] A fourth aspect of an embodiment of the present application provides a software package transmission device, which is applied to a second device, and the device includes:

[0021] a data transmission length negotiation message sending module, configured to return a data transmission length negotiation message to the first device in response to a software package request message from the first device, wherein the data transmission length negotiation message includes a first data length supported by the second device;

[0022] A data transmission length determination message receiving module, used to receive a data transmission length determination message returned by the first device, wherein the data transmission length determination message includes a maximum data length during data transmission;

[0023] A software data packet message encapsulation module, used for encapsulating the target software package into a plurality of software data packet messages based on the maximum data length;

[0024] The software data packet message sending module is used to send a plurality of the software data packet messages to the first device.

[0025] A fifth aspect of an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method described in the first aspect or the second aspect above is implemented.

[0026] A sixth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect or the second aspect above is implemented.

[0027] A seventh aspect of the embodiments of the present application provides a computer program product. When the computer program product is run on a computer device, the computer device executes the method described in the first aspect or the second aspect.

[0028] Compared with the prior art, the embodiments of the present application have the following advantages:

[0029] By applying the method in the embodiment of the present application, the first device can obtain a software data packet from the second device. When transmitting the software package, the first device and the second device can first negotiate the data transmission length in the message. Based on the negotiated data transmission length, the second device can encrypt and encapsulate the software package into multiple software data packet messages. After the second device sends the multiple software data packet messages to the first device, the first device can obtain the software package based on the combination of the multiple software data packet messages. When transmitting the software data packet, the embodiment of the present application can divide the data in the software package into multiple software data packet messages based on the agreed data transmission length, and can encrypt the data based on the data transmission length. While achieving encryption, it can simplify the key determination process and improve the transmission speed of the software package. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art.

[0031] Figure 1 It is a schematic diagram of the steps of a software package transmission method provided in an embodiment of the present application;

[0032] Figure 2 This is a schematic diagram of a negotiation process for data transmission length provided in an embodiment of the present application;

[0033] Figure 3 is a schematic diagram of a target software package determination process provided by an embodiment of the present application;

[0034] Figure 4 It is a schematic diagram of the steps of another software package transmission method provided in an embodiment of the present application;

[0035] Figure 5 It is a schematic diagram of encapsulating a target software package into multiple software data package messages provided by an embodiment of the present application;

[0036] Figure 6 is a schematic diagram of another software package transmission method provided in an embodiment of the present application;

[0037] Figure 7 is a schematic diagram of a software package transmission device provided in an embodiment of the present application;

[0038] Figure 8 is a schematic diagram of another software package transmission device provided in an embodiment of the present application;

[0039] Fig. 9 It is a schematic diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0040] In the following description, specific details such as specific system structures, technologies, etc. are proposed for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from hindering the description of the present application.

[0041] The technical solution of the present application is described below through specific embodiments.

[0042] Reference Figure 1 , shows a schematic flow chart of a method for transmitting a software package provided in an embodiment of the present application, which may specifically include the following steps:

[0043] S101: Send a software package request message to a second device.

[0044] The execution subject of this embodiment may be a first device, and the first device may obtain a software data package from a second device. For example, the first device may be a switch, and the second device may be a remote server. When the switch needs to be updated, the software data package may be requested from the remote server. The first device may be a white box switch or other device, and this embodiment does not limit the specific type of the first device. The first device may obtain a binary software package from the second device. The method in this embodiment may be applied to the transmission scenario of a binary software package.

[0045] The second device and the first device may exchange information via a message. The message may be a data packet having a certain format. The message may include source information, destination information, message type, data length, transmission data, check code, etc. Table 1 shows a schematic diagram of the structure of a message provided in an embodiment of the present application.

[0046] Table 1:

[0047] 6 bytes 6 bytes 2 bytes 4 bytes 4 bytes 4 bytes 4 bytes To be negotiated 4 bytes d_mac s_mac etype d_ip s_ip type length data CRC

[0048] As shown in Table 1, the message between the second device and the first device may include d_mac, s_mac, etype, d_ip, s_ip, type, length, data, and CRC. Among them, d_mac is the destination physical address, s_mac is the source physical address, d_ip is the destination IP address, and s_ip is the source IP address. Taking the message sent from the first device to the second device as an example, d_mac in the message is the physical address of the second device, s_mac is the physical address of the first device, d_ip is the IP address of the second device, and s_ip is the IP address of the first device.

[0049] Among them, etype can be the Ethernet type, type can be the message type, length can be the length of the actual transmitted data, CRC can be the Ethernet check code, and data can be the actual transmitted data.

[0050] The above message type can be used to record identification information of the message, and the second device and the first device can determine the function of the message according to the message type. Exemplarily, the message type type can represent different purposes of the message through different values. For example, if the value of the message type is 0x01, it indicates that the message is a software package request message triggered by the first device; if the value of the message type is 0x02, it indicates that the message is a response message from the second device to the message from the first device, and the data of the message carries the maximum data length supported by the second device; if the value of the message type is 0x03, it indicates that the message is a message from the first device to the 0x02 message from the second device, and the data of the message carries the determined maximum data length; if the value of the message type is 0x04, it indicates that the message is a software package message sent by the second device, and the data of the message carries the software package data, and the data length is the data length confirmed by the 0x03 message; if the value of the message type is 0x05, it indicates that the message is a message from the first device to the 0x04 message from the second device; if the value of the message type is 0x06, it indicates that the message is a warning message sent by the first device to the log server. The specific introduction of each type of message can be referred to below, and it will not be repeated here.

[0051] When the first device needs to obtain a software package from the second device, it can send a software package request message to the second device. Exemplarily, d_mac of the software package request message is the physical address of the second device, s_mac is the physical address of the first device, d_ip is the IP address of the second device, s_ip is the IP address of the first device, the value of the message type can be 0x01, and data can carry the attribute information of the requested software package.

[0052] Based on the d_ip and d_mac of the software package request message, the software package request message can be sent to the second device. After receiving the software package request message, the second device can determine that the message is for requesting a software package based on the message type of 0x01, and return a response message to the first device based on s_mac and s_ip.

[0053] S102: In response to the data transmission length negotiation message returned by the second device, return a data transmission length determination message to the second device, where the data transmission length determination message includes a maximum data length during data transmission.

[0054] As shown in Table 1, each structure in the message may have its own length, for example, the Ethernet check code CRC may be represented by four bytes in the message. The data length in the message needs to be negotiated between the first device and the second device.

[0055] When the first device and the second device exchange data, the length of the message will be limited by the environment and the device. The second device and the first device can negotiate the maximum data length during the data transmission process.

[0056] In order to ensure the transmission effect, the device can set a maximum length, which can be the maximum length of the data transmitted during the data transmission process. During data transmission, the length of the transmitted data in the message is less than or equal to the maximum length.

[0057] After receiving the software request message, the second device may negotiate with the first device on the data transmission length. Figure 2 This is a schematic diagram of a negotiation process for data transmission length provided in an embodiment of the present application, referring to Figure 2 , the negotiation process of data transmission length can be as follows:

[0058] S201: Obtain a first data length supported by the second device from the data transmission length negotiation message.

[0059] After receiving the software package request message, the second device may return a data transmission length negotiation message to the first device in order to negotiate with the first device the length of the software package data in the message each time the software package data is transmitted. The data transmission length negotiation message may carry the maximum data length of the data transmission supported by the second device, that is, the first data length. The data transmission length negotiation message may also include the IP address of the second device, the physical address of the second device, the IP address of the first device, and the physical address of the first device. Among them, the second device can obtain the IP address of the first device and the physical address of the first device from the software package request message. The data transmission length negotiation message may represent the message by the value of the message type. For example, the message type value in the data transmission length negotiation message may be 0x02, and the data of the message may carry the maximum data length supported by the second device.

[0060] Based on the IP address of the first device and the physical address of the first device in the message, the data transmission length negotiation message can be sent to the first device. After the first device receives the data transmission length negotiation message, it can determine the maximum length of the message used for negotiating data transmission according to the value of the message type. The first device can obtain the above-mentioned first data length from the data of the message.

[0061] S202: Determine a maximum data length for data transmission based on the first data length and the second data length of the first device.

[0062] The first device may also be configured with a maximum data length supported for transmission, that is, a second data length. The first device may determine the maximum data length for data transmission according to the first data length and the second data length.

[0063] Exemplarily, the minimum value of the first data length and the second data length may be determined as the maximum data length during data transmission.

[0064] In another possible implementation manner, if the maximum data transmission length is not set in the first device, the first data length may be determined as the maximum data length during data transmission.

[0065] S203: Generate a data transmission length determination message according to the maximum data length, and send the data transmission length determination message to the second device.

[0066] After determining the maximum data length, the first device may generate a data transmission length determination message according to the maximum data length. In the data transmission length determination message, the message type value may be 0x03, and the data of the message may carry the determined maximum data length.

[0067] After generating the data transmission length determination message, the first device may send the data transmission length determination message to the second device.

[0068] S103, receiving a plurality of software data packet messages from the second device, wherein the software data packet messages are encrypted and encapsulated by the second device according to the maximum data length transmission.

[0069] After receiving the data transmission length determination message, the second device can obtain the maximum data length during the transmission from the data of the message. Based on the maximum data length, the second device can segment, encrypt and encapsulate the software package data to generate multiple software data package messages.

[0070] The second device may divide the target software package into a plurality of software package data blocks according to the maximum data length, and each software package data block may have a corresponding sequence value, and the sequence value is used to indicate the arrangement position of the software package data block in the target software package.

[0071] Based on the sequence value, the second device can encrypt each software package data block, thereby obtaining corresponding multiple transmission data. Exemplarily, when encrypting the software package data block, the second device can calculate a first verification value of the software package data block, for example, the first verification value can be a digest value calculated based on a digest algorithm, a hash value, etc. The first verification value can only be calculated through the software package data block, and the software package data block cannot be reversely obtained based on the first verification value. When the software package data block changes, the first verification value of the software package data block will also change. After calculating the first verification value of the software package data block, the second device can insert the first verification value into the software package data block, thereby encrypting the software package data block. The insertion position of the first verification value can be determined according to the sequence value of the software package data block.

[0072] After the first verification value is inserted into the software package data, the transmission data corresponding to the software package data block can be obtained, and the transmission data can be put into the data part of the software data package message. The message type value in the software data package message is 0x04.

[0073] After generating the software data package messages, the second device may send the software data package messages to the first device in sequence.

[0074] S104, obtaining a target software package based on each of the software data package messages.

[0075] After receiving the software data packet message, the first device can obtain the software package data block from the software data packet message, thereby assembling the target software package.

[0076] Figure 3is a schematic diagram of a target software package determination process provided by an embodiment of the present application, such as Figure 3 As shown:

[0077] S301, extracting a first verification value and a software package data block from each software package message.

[0078] The data of the software data packet message may include transmission data, and the transmission data is obtained by encrypting the software package data block by the second device. When encrypting, the first verification value is inserted into the software package data block. Therefore, the first device can extract the first verification value and the software package data block from the data of the software data packet.

[0079] In a possible implementation, the first device may obtain target transmission data from each software data packet message respectively, where the target transmission data is obtained by encrypting a software package data block by the second device, and a plurality of software package data blocks constitute a target software package.

[0080] The second device encrypts the software package data block according to the sequence value, so the first device can determine the sequence value of the software package data block. The sequence value can be the transmission sequence of the software package message, and the first device can determine the sequence value of the software package data block according to the sequence of the received software package messages.

[0081] After determining the sequence value of the software package data block, the first device may determine the insertion position of the first verification value in the target transmission data according to the sequence value. For example, the insertion position of the first verification value is the sequence value of the software package data block.

[0082] After determining the insertion position of the first verification value, the first device can extract the first verification value from the target transmission data. Exemplarily, the first device can extract data of a target length from the byte position corresponding to the sequence value in the target transmission data, thereby obtaining the first verification value; the software package data block is other data in the target transmission data except the first verification value. The target length is the length of the predetermined verification value.

[0083] S302: Calculate a second verification value according to the software package data block and verify the corresponding software data packet message by using the first verification value and the second verification value.

[0084] After extracting the first verification value and the software package data block, the first device can verify the software package data block. The first device can calculate the second verification value of the software package data block by a preset algorithm. The algorithm for calculating the first verification value and the second verification value is the same, so that when the software package data block has not changed, the first verification value and the second verification value are the same; when the software package data block has been tampered with or data is lost, the first verification value and the second verification value are different.

[0085] Therefore, the first device can verify the software package data block according to the first verification value and the second verification value of the software package data block.

[0086] S303, obtaining a target software package according to each of the software data package messages that have passed the verification.

[0087] When the first verification value and the second verification value of the software package data block are the same, it indicates that the software data packet message has passed the verification. After all software package data blocks have passed the verification, the first device can assemble the software package data blocks according to the sequence value to obtain the target software package.

[0088] When the first verification value and the second verification value of the software package data block are different, it indicates that the corresponding software package message verification fails. At this time, the first device can send an alarm message to the log server, where the message type of the alarm message is 0x06, and the data in the message can be the mac and ip of the second device, so that the administrator can determine the first device and server corresponding to the alarm message.

[0089] In this embodiment, the first device and the second device can negotiate the maximum data length during data transmission, and based on the maximum data length, the software package can be divided into multiple software package data blocks for transmission. When transmitting the software package data block, the verification value of the software package data block can be calculated, and the software package data block can be encrypted based on the verification value and the sequence value. In other words, in this embodiment, the verification value can be encrypted on the one hand, and can be used to verify whether the received software package data block is correct on the other hand, thereby ensuring data security during software package transmission. In this embodiment, when data is transmitted, the data required for encryption is simple, and dynamic encryption can be implemented, so that data security can be ensured while ensuring transmission speed.

[0090] Reference Figure 4 , shows a schematic flow chart of another method for transmitting a software package provided in an embodiment of the present application, which may specifically include the following steps:

[0091] S401: In response to a software package request message from a first device, return a data transmission length negotiation message to the first device, where the data transmission length negotiation message includes a first data length supported by the second device.

[0092] The execution subject of this embodiment may be the second device mentioned above, and the second device may store or obtain the software package required by the first device, thereby transmitting the software package to the first device. The second device may be a remote server, and the remote server may be a remote file server. This embodiment does not limit the type of the second device. The method in this embodiment may be applied to the transmission scenario of a binary software package. For example, a switch and a remote server may transmit a software package using the method in this embodiment.

[0093] The first device may send a software package request message to the second device. After receiving the software package request message, the second device may determine the function of the message according to the message type of the software package request message. After determining that the message is used to request a software package, the second device may send a data transmission length negotiation message to the first device, thereby negotiating with the first device the length of the data transmitted in the message. In the data transmission length negotiation message, the message type value may be 0x02, and data may carry the first data length supported by the second device.

[0094] S402: Receive a data transmission length determination message returned by the first device, where the data transmission length determination message includes a maximum data length during data transmission.

[0095] The first device receives the data transmission length negotiation message and can determine the maximum data length during data transmission according to the first data length in the data transmission length negotiation message, and generate a data transmission length determination message based on the maximum data length.

[0096] The second device may receive the data transmission length determination message returned by the first device, thereby acquiring the maximum data length from the data transmission length determination message.

[0097] S403: Encapsulate the target software package into multiple software data packet messages based on the maximum data length.

[0098] Figure 5 FIG. 1 is a schematic diagram of encapsulating a target software package into multiple software data package messages provided by an embodiment of the present application. Figure 5 As shown:

[0099] S501 : dividing a target software package into a plurality of software package data blocks based on the maximum data length, each of the software package data blocks having a corresponding sequence value, the sequence value being used to indicate an arrangement position of the software package data block in the software package.

[0100] The second device may divide the target software package to be sent to the first device into a plurality of software package data blocks according to the maximum data length. The target software package may be obtained by arranging the plurality of software package data blocks in a certain order. The arrangement order of each software package data block in the target software package is the sequence value of the software package data block.

[0101] S502: Encrypt each of the software package data blocks according to the sequence value to obtain a plurality of target transmission data.

[0102] In a possible implementation, the second device may calculate a first verification value of the software package data block and insert the first verification value into the software package data block, thereby encrypting the software package data block to obtain target transmission data.

[0103] The second device may calculate the first verification value of the software package data block by using a message-digest algorithm, for example, the first verification value may be the md5 value of the software package data block. The second device may also calculate the first verification value of the software package data block by using a hash algorithm, for example, the first verification value may be the SHA-512 value of the software package data block.

[0104] When inserting the first verification value into the software package data block, the insertion position of the first verification value may be determined according to a pre-set rule. Exemplarily, the insertion position of the first verification value may be determined according to the sequence value of the software package data block. The insertion position of the first verification value may be directly the position corresponding to the sequence value, or the insertion position of the first verification value may be obtained by transforming the sequence value. For example, the insertion position of the first verification value may be pre-set to be the position corresponding to the sequence value plus 2.

[0105] In a possible implementation, when the numerical value corresponding to the sequence value is greater than the length of the target transmission data, the value obtained by dividing the sequence value by the maximum data length may be used as the insertion position of the first verification value.

[0106] In another possible implementation, the sequence value may be directly inserted into the software package data block, thereby encrypting the software package data block.

[0107] S503, encapsulating each of the target transmission data respectively to obtain a plurality of the software data packet messages.

[0108] After obtaining each target transmission data, the second device may encapsulate the target transmission data to obtain a software data packet message. In the software data packet message, the message type is 0x04, and the data carries the target transmission data.

[0109] S504: Send the plurality of software data packet messages to the first device.

[0110] The second device may send each software package message to the first device according to the sequence value, so that the first device may determine the sequence value of the software package message according to the transmission sequence of the software package message.

[0111] In a possible implementation, the second device may send software package messages to the first device one by one in sequence. The second device may determine the target software package message to be sent in sequence. If the target software package message is the first software package message, the second device may directly send the software package message to the first device. If the target software package message is not the first software package message, the second device may send the target software package message to the first device after the first device returns a confirmation message of the previous software package message.

[0112] After the second device sends the target software package message to the first device, the first device can decrypt and verify the target software package message. If the target software package message passes the verification, the first device can return a confirmation message of the target software package message to the second device, and the message type value of the confirmation message is 0x05. If the second device receives the confirmation message, it can use the next software package message as the target software package message and continue to send the target software package message to the second device.

[0113] If the target software package message fails to pass the verification, the first device can send an alarm message to prompt the administrator to handle the error. When the target software package message fails to pass the verification, the sending of the software package message can be stopped, and the sending of the software package message can continue after the error of the target software package message is handled.

[0114] In this embodiment, when the second device encrypts the software package data, for each software package data block, the generated verification value is different, and the verification value is inserted in a different manner, so that the software package data can be dynamically encrypted to ensure data security during software package data transmission. During data transmission between the first device and the second device, the data encryption and decryption method is simple, and data verification can be achieved at the same time, so that data security can be ensured while ensuring data transmission speed.

[0115] It should be noted that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0116] In order to better illustrate the solution in the present application, the solution in the present application is illustrated below using a software package transmission scenario between a switch and a remote server.

[0117] The switch may be a white box switch, which can obtain software packages from a remote server. Figure 6 It is a schematic diagram of another software package transmission method provided in an embodiment of the present application.

[0118] like Figure 6 As shown in the figure, after the switch is powered on, it can enter the ONIE (Open Network Install Environment) mode. The ONIE built-in program checks whether the EEPROM information matches. When the EEPROM information does not match, the built-in program decompresses the initrd.img-4.9.95-onie software package, modifies ONIE-related files based on the script according to the EEPROM Product, Name, and Platform Name information; repackages the built-in program into the initrd.img-4.9.95-oni software package; reruns the initrd.img-4.9.95-onie software package; after the NIE system runs normally, the echo information is normal, and the white box switch ONIE adaptation is completed.

[0119] When the switch obtains the software package, the administrator operates on the switch to specify the IP address of the remote server and the IP address of the log server to trigger the remote upgrade of the switch. The switch sends a message with a type value of 0x01.

[0120] The remote server parses the switch 0x01 message and sends a 0x02 message to the switch, with the maximum data length supported for transmission encapsulated in the data.

[0121] The switch parses the remote server 0x02 message and obtains the maximum data length supported by the server. If the administrator has not configured a transmission limit, the switch responds with a 0x03 message with the same data length. If the administrator has configured a transmission limit and the configured transmission limit is less than the maximum data length supported by the server, the switch responds with a 0x03 message with the configured transmission limit. If the administrator has configured a transmission limit and the configured transmission limit is greater than or equal to the maximum data length supported by the server, the switch responds with a 0x03 message with the maximum data length supported by the server.

[0122] The remote server parses the switch 0x03 message, confirms the data length of each transmission with the switch, and encapsulates the specified data length (2 bytes of md5 value + the remaining actual data length). The server calculates the md5 value based on the actual data, and according to the N number of transmissions, inserts the md5 value after the Nth byte of the actual data, and finally sends the 0x04 message to the switch.

[0123] The switch parses the remote server 0x04 message, parses the actual data and the md5 value of this data according to the number of transmissions N, and calculates the md5 value based on the actual data. If the calculated md5 value is inconsistent with that in the message, it means that the message has been tampered with, and the upgrade is stopped. At the same time, a 0x06 message is sent to the log server to alert the administrator. If the calculated md5 value is consistent with that in the message, it means that the message is normal, and data can continue to be obtained, and a 0x05 message is sent to the remote server.

[0124] Repeat the sending and parsing of the 0x04 message so that the switch obtains a complete and correct software package and the switch is upgraded normally.

[0125] The method in the present application is a method for dynamically generating and inserting md5 in the process of software package transmission. Before the switch and the remote server transmit data, the transmission size of each data packet will be negotiated. Based on the size of each transmission, the number of transmissions can be determined. In addition to transmitting the data packet each time, the remote server will also insert the verification value of this data packet into the Nth (N=number of transmissions) byte of the data packet according to the number of transmissions. After each data packet is received, the switch unpacks the packet to obtain the verification value of this data packet, and then calculates and verifies whether this data packet has been tampered with. If the verification value verification fails, the upgrade is stopped, and the administrator is alerted through the log that there is an attacker during the transmission process.

[0126] The method in this application realizes the fast and safe transmission requirements during the remote transmission of the switch software package by dynamically generating verification values ​​and dynamically inserting the transmission software package and the verification value. The method in this application can be applied to the remote upgrade scenario of large-scale switches. Users (administrators) can use the method in this application to quickly and safely upgrade the switch software package to ensure transmission efficiency and data security. The method in this application is applicable to any scenario of remote transmission of binary software packages between preparations.

[0127] Reference Figure 7 , shows a schematic diagram of a software package transmission device provided in an embodiment of the present application, the device is applied to a first device, and specifically may include a software package request message sending module 71, a data transmission length determination message sending module 72, a software data packet message receiving module 73 and a target software package determination module 74, wherein:

[0128] A software package request message sending module 71, configured to send a software package request message to a second device;

[0129] a data transmission length determination message sending module 72, configured to return a data transmission length determination message to the second device in response to the data transmission length negotiation message returned by the second device, wherein the data transmission length determination message includes a maximum data length during data transmission;

[0130] A software data packet message receiving module 73, configured to receive a plurality of software data packet messages transmitted by the second device according to the maximum data length;

[0131] The target software package determination module 74 is used to obtain the target software package based on each of the software data package messages.

[0132] In a possible implementation, the target software package determination module 74 includes:

[0133] An extraction submodule, used to extract the first verification value and the software package data block from each of the software data package messages;

[0134] A verification submodule, configured to calculate a second verification value according to the software package data block and verify the corresponding software data package message using the first verification value and the second verification value;

[0135] The combining submodule is used to obtain the target software package according to each of the software data package messages that have passed the verification.

[0136] In a possible implementation, the extraction submodule includes:

[0137] a target transmission data acquisition unit, configured to acquire target transmission data from each of the software data packet messages, wherein the target transmission data is obtained by encrypting a software package data block by the second device, and a plurality of software package data blocks constitute the target software package;

[0138] A sequence value determination unit, used to determine a sequence value of the software data packet, wherein the sequence value is used to characterize a transmission sequence of the software data packet;

[0139] The first verification value extraction unit is used to extract data of a target length from the byte position corresponding to the sequence value in the target transmission data to obtain the first verification value; the software package data block is other data in the target transmission data except the first verification value.

[0140] In a possible implementation, the data transmission length determination message sending module 72 includes:

[0141] A first data length acquisition submodule, used to acquire a first data length supported by the second device from the data transmission length negotiation message;

[0142] a maximum data length determination submodule, configured to determine a maximum data length during data transmission based on the first data length and a second data length of the first device;

[0143] The data transmission length determination message generation submodule is used to generate a data transmission length determination message according to the maximum data length, and send the data transmission length determination message to the second device.

[0144] In a possible implementation, the second data length is a data length configured by the first device, and the maximum data length determination submodule includes:

[0145] A maximum data length determining unit is used to determine the minimum value between the first data length and the second data length as the maximum data length during the data transmission.

[0146] Reference Figure 8 , shows a schematic diagram of a software package transmission device provided in an embodiment of the present application, the device is applied to a second device, and specifically may include a data transmission length negotiation message sending module 81, a data transmission length determination message receiving module 82, a software data packet message encapsulation module 83 and a software data packet message sending module 84, wherein:

[0147] A data transmission length negotiation message sending module 81, configured to return a data transmission length negotiation message to the first device in response to a software package request message from the first device, wherein the data transmission length negotiation message includes a first data length supported by the second device;

[0148] A data transmission length determination message receiving module 82, configured to receive a data transmission length determination message returned by the first device, wherein the data transmission length determination message includes a maximum data length during data transmission;

[0149] A software data packet message encapsulation module 83, used for encapsulating the target software package into a plurality of software data packet messages based on the maximum data length;

[0150] The software data packet message sending module 84 is used to send a plurality of software data packet messages to the first device.

[0151] In a possible implementation, the software data packet message encapsulation module 83 includes:

[0152] a division submodule, configured to divide the target software package into a plurality of software package data blocks based on the maximum data length, each of the software package data blocks having a corresponding sequence value, the sequence value being used to characterize an arrangement position of the software package data block in the software package;

[0153] An encryption submodule, used for encrypting each of the software package data blocks according to the sequence value to obtain a plurality of the target transmission data;

[0154] The encapsulation submodule is used to encapsulate each of the target transmission data respectively to obtain a plurality of the software data packet messages.

[0155] In a possible implementation, the encryption submodule includes:

[0156] A first verification value calculation unit, configured to calculate a first verification value of the software package data block;

[0157] An interpolation unit is used to insert the first verification value into the position corresponding to the sequence value in the software package data block to obtain the target transmission data.

[0158] In a possible implementation, the software data packet message sending module 84 includes:

[0159] A sending submodule is used to send each of the software data packet messages to the first device according to the sequence value.

[0160] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment part.

[0161] Fig. 9 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Fig. 9 As shown, the computer device 9 of this embodiment includes: at least one processor 90 ( Fig. 9 Only one is shown in the figure), a memory 91, and a computer program 92 stored in the memory 91 and executable on the at least one processor 90, wherein the processor 90 implements the steps of any of the above-mentioned method embodiments when executing the computer program 92.

[0162] The computer device 9 may be the first device or the server mentioned above. The computer device may include, but is not limited to, a processor 90 and a memory 91. Those skilled in the art will appreciate that Fig. 9 It is only an example of the computer device 9 and does not constitute a limitation on the computer device 9. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.

[0163] The processor 90 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0164] In some embodiments, the memory 91 may be an internal storage unit of the computer device 9, such as a hard disk or memory of the computer device 9. In other embodiments, the memory 91 may also be an external storage device of the computer device 9, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device 9. Further, the memory 91 may also include both an internal storage unit of the computer device 9 and an external storage device. The memory 91 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program, etc. The memory 91 may also be used to temporarily store data that has been output or is to be output.

[0165] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0166] An embodiment of the present application provides a computer program product. When the computer program product is run on a computer device, the computer device can implement the steps in the above-mentioned method embodiments when executing the computer device.

[0167] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application is described in detail with reference to the above-mentioned embodiments, a person skilled in the art should understand that the technical solutions described in the above-mentioned embodiments can still be modified, or some of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A method for transmitting a software package, characterized in that: Applied to a first device, the method includes: Sending a software package request message to the second device; In response to the data transmission length negotiation message returned by the second device, returning a data transmission length determination message to the second device, wherein the data transmission length determination message includes a maximum data length during data transmission; receiving a plurality of software data packet messages from the second device, the software data packet messages being encrypted and encapsulated by the second device according to the maximum data length transmission; Based on each of the software data packet messages, a target software package is obtained.

2. The method according to claim 1, characterized in that The step of obtaining a target software package based on each of the software data package messages comprises: Extracting the first verification value and the software package data block from each of the software data package messages respectively; Calculating a second verification value according to the software package data block and verifying the corresponding software data package message using the first verification value and the second verification value; The target software package is obtained according to each of the software data package messages that have passed the verification.

3. The method according to claim 2, characterized in that The extracting the first verification value and the software package data block from each of the software data package messages respectively includes: respectively acquiring target transmission data from each of the software data packet messages, wherein the target transmission data is obtained by encrypting a software package data block by the second device, and a plurality of software package data blocks constitute the target software package; Determining a sequence value of the software data packet, wherein the sequence value is used to characterize a transmission sequence of the software data packet; Starting from the byte position corresponding to the sequence value in the target transmission data, data of target length is extracted to obtain the first verification value; the software package data block is other data in the target transmission data except the first verification value.

4. The method according to any one of claims 1 to 3, characterized in that: The step of returning a data transmission length determination message to the second device in response to the data transmission length negotiation message returned by the second device includes: Acquire a first data length supported by the second device from the data transmission length negotiation message; Determine a maximum data length for data transmission based on the first data length and a second data length of the first device; A data transmission length determination message is generated according to the maximum data length, and the data transmission length determination message is sent to the second device.

5. The method according to claim 4, characterized in that The second data length is a data length configured by the first device, and determining the maximum data length during data transmission based on the first data length and the second data length of the first device includes: The minimum value between the first data length and the second data length is determined as the maximum data length during the data transmission.

6. A method for transmitting a software package, characterized in that: Applied to the second device, the method includes: In response to a software package request message from a first device, returning a data transmission length negotiation message to the first device, wherein the data transmission length negotiation message includes a first data length supported by the second device; receiving a data transmission length determination message returned by the first device, wherein the data transmission length determination message includes a maximum data length during data transmission; Based on the maximum data length, encapsulating the target software package into a plurality of software data packet messages; Send the plurality of software data packet messages to the first device.

7. The method according to claim 6, characterized in that The step of encapsulating the target software package into a plurality of software data package messages based on the maximum data length includes: Based on the maximum data length, dividing the target software package into a plurality of software package data blocks, each of the software package data blocks having a corresponding sequence value, the sequence value being used to characterize an arrangement position of the software package data block in the software package; encrypting each of the software package data blocks according to the sequence value to obtain a plurality of target transmission data; Each of the target transmission data is encapsulated respectively to obtain a plurality of software data packet messages.

8. The method according to claim 7, characterized in that The step of encrypting each of the software data packets according to the sequence value to obtain a plurality of the target transmission data comprises: Calculating a first verification value of the software package data block; The first verification value is inserted into the position corresponding to the sequence value in the software package data block to obtain the target transmission data.

9. The method according to claim 7 or 8, characterized in that The sending of the plurality of software data packet messages to the first device comprises: Each of the software data packet messages is sent to the first device according to the sequence value.

10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 9 is implemented.