Switch debugging method, electronic equipment and computer readable storage medium

By establishing a UTP port network connection between the switch and the terminal device and using private protocol messages for interaction, the problem of being unable to debug the switch without a UART interface and SMI is solved, realizing switch debugging and debugging without powering off. Information acquisition.

CN119363689APending Publication Date: 2025-01-24苏州联芸科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411697505.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-25
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

The prior art cannot debug the switch without the UART interface and SMI, resulting in debugging difficulties and limited information acquisition.

Method used

Establish a UTP port network connection between the terminal device and the switch, use the private protocol packet for interaction, the terminal device indicates the switch execution operation through the command logo in the request message, and obtains the target information through the response message.

Benefits of technology

The switch is made without the UART interface and SMI, and the target information of the switch is obtained without disconnecting the power supply of the switch to avoid destroying the on -site environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119363689A_ABST
    Figure CN119363689A_ABST
Patent Text Reader

Abstract

The invention discloses a method for debugging a switch, electronic equipment and a computer readable storage medium, and belongs to the field of Internet. The method comprises the steps that under the condition that network connection is established between terminal equipment and a switch through a UTP port, the terminal equipment sends a target request message to the switch, and the target request message comprises a private protocol identifier and a command identifier; the private protocol identifier indicates that the message type of the target request message is a private protocol type, and the command identifier indicates an operation executed by the switch; the terminal device receives a target response message sent by the switch; wherein the target response message comprises the private protocol identifier and target information, and the target information is obtained based on the command identifier; and the terminal device obtains the target information contained in the target response message by analyzing the target response message. The method is used for debugging the switch.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of Internet, and specifically relates to a method for debugging a switch, an electronic device and a computer-readable storage medium. Background Art

[0002] Some switches currently on the market, such as dumb switches, are generally debugged through the Universal Asynchronous Receiver / Transmitter (UART) interface or the Serial Management Interface (SMI). However, after the final switch is mass-produced, similar debugging interfaces are generally no longer provided.

[0003] In the absence of a UART interface and SMI, related technologies cannot debug the switch. Summary of the invention

[0004] The embodiments of the present application provide a method for debugging a switch, an electronic device, and a computer-readable storage medium, which can solve the problem in the related art that the switch cannot be debugged without a UART interface and an SMI.

[0005] In a first aspect, an embodiment of the present application provides a method for debugging a switch, the method comprising: In a case where a network connection has been established between a terminal device and a switch through an unshielded twisted pair (UTP) port, the terminal device sends a target request message to the switch, wherein the target request message includes a private protocol identifier and a command identifier, wherein the private protocol identifier indicates that a message type of the target request message is a private protocol type, and the command identifier indicates an operation performed by the switch; The terminal device receives a target response message sent by the switch; wherein the target response message includes the private protocol identifier and target information, and the target information is obtained based on the command identifier; The terminal device obtains the target information contained in the target response message by parsing the target response message.

[0006] In a second aspect, an embodiment of the present application provides a method for debugging a switch, the method comprising: In the case that the switch and the terminal device have established a network connection through the UTP port, the switch receives a target request message sent by the terminal device, the target request message includes a private protocol identifier and a command identifier, the private protocol identifier indicates that the message type of the target request message is a private protocol type, and the command identifier indicates an operation performed by the switch; The switch responds to the target request message, executes the operation indicated by the command identifier, and obtains the target information; The switch generates a target response message based on the target information; wherein the target response message includes the private protocol identifier and the target information, and the target information is obtained based on the command identifier; The switch sends the target response message to the terminal device.

[0007] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect or the second aspect are implemented.

[0008] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed, the steps of the method described in the first aspect or the second aspect are implemented.

[0009] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the method described in the first aspect or the second aspect.

[0010] At least one of the above technical solutions provided in the embodiments of the present application can achieve the following technical effects: In an embodiment of the present application, the terminal device is connected to the switch through a UTP port, and is no longer connected through a UART interface or SMI. When the terminal device and the switch have established a network connection through the UTP port, the terminal device and the switch interact through private protocol messages, and obtain target information through a command identifier in the request message that is used to instruct the switch to perform an operation. There is no need to obtain information through a UART interface or SMI to debug the switch, which solves the problem that the related technology cannot debug the switch without a UART interface and SMI. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0012] Figure 1 This is a schematic diagram of the environment for debugging a switch provided in an embodiment of the present application; Figure 2 is a flow chart of a method for debugging a switch provided by an embodiment of the present application; Figure 3 is a flow chart of another method for debugging a switch provided by an embodiment of the present application; Figure 4 This is a schematic diagram of the interaction between a terminal device and a switch in an embodiment of the present application; Figure 5 is another schematic diagram of the interaction between the terminal device and the switch in the embodiment of the present application; Figure 6 is another schematic diagram of the interaction between the terminal device and the switch in the embodiment of the present application; Figure 7 It is a structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0013] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0014] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0015] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0016] As discussed in the background technology section, some current switches generally no longer provide debugging interfaces after mass production. Even if a few switches are equipped with debugging interfaces, it is generally necessary to first disconnect the power supply of the switch and then disassemble the switch casing, which will cause the on-site environment where the switch is running to be destroyed, and it is impossible to collect effective information to locate the problem of the switch during the debugging process.

[0017] In view of this, the embodiment of the present application provides a method for debugging a switch. The method can debug the switch by utilizing the network interface of the switch, such as the Unshielded Twisted Pair (UTP) interface, and by using private protocol messages without a debugging interface such as a UART interface or an SMI. It is not necessary to obtain information by using the UART interface or the SMI to debug the switch, thus solving the problem that the related art cannot debug the switch without the UART interface and the SMI. Moreover, the method for debugging the switch provided by the embodiment of the present application does not need to disconnect the power supply of the switch, and there will be no problem of damaging the on-site environment in which the switch is operated.

[0018] Figure 1 Schematic diagram of the debugging environment of the switch provided by the embodiment of the present application. Figure 1 , the method for debugging a switch provided in an embodiment of the present application may involve a terminal device and a switch. The terminal device and the switch interact with each other through private protocol messages. The private protocol message in the embodiment of the present application refers to a message containing a private protocol identifier. The private protocol identifier can be set in a message header to indicate that the message type is a private protocol type. In this way, after the terminal device and the switch identify the message containing the private protocol identifier, they can determine that the message is a message for debugging the switch.

[0019] The terminal device may be any device having a network interface, such as a UTP interface, such as a personal computer, a notebook computer, etc. The switch may be a network device having a message forwarding function in a local area network, such as a dumb switch.

[0020] The terminal device and the switch in the embodiment of the present application are in a master-slave communication mode. The terminal device actively sends a target request message (i.e., initiates a command), and then waits for the target response message of the switch. The switch only responds to the corresponding command and does not actively initiate a request. In addition, the terminal device supports a command timeout exit mechanism. If the terminal device does not receive a response from the switch within a period of time, it exits the waiting state.

[0021] The following describes in detail the method for debugging a switch provided by the embodiment of the present application through specific embodiments and application scenarios in conjunction with the accompanying drawings.

[0022] See also Figure 2 , Figure 2 1 is a flow chart of a method for debugging a switch provided by an embodiment of the present application. Figure 2 As shown, the method comprises the following steps: Step 210: When the terminal device and the switch have established a network connection through the UTP port, the terminal device sends a target request message to the switch, wherein the target request message includes a private protocol identifier and a command identifier, wherein the private protocol identifier indicates that the message type of the target request message is a private protocol type, and the command identifier indicates an operation performed by the switch; Step 220: The terminal device receives a target response message sent by the switch; wherein the target response message includes the private protocol identifier and target information, and the target information is obtained based on the command identifier; Step 230: The terminal device obtains the target information contained in the target response message by parsing the target response message.

[0023] In the embodiment of the present application, the target information may be information used to debug the switch. After acquiring the target information, the terminal device may display the target information for reference by relevant personnel.

[0024] In the method for debugging a switch provided in an embodiment of the present application, the terminal device is connected to the switch through a UTP port, and is no longer connected through a UART interface or an SMI. When the terminal device and the switch have established a network connection through the UTP port, the terminal device and the switch interact through private protocol messages, and obtain target information through a command identifier in the request message that is used to instruct the switch to perform an operation. There is no need to obtain information through a UART interface or SMI to debug the switch, which solves the problem that the related technology cannot debug the switch without a UART interface and an SMI.

[0025] In an embodiment of the present application, the target request message may include other identifiers in addition to the private protocol identifier and the command identifier. In a specific embodiment, the target request message also includes: a destination media access control (MAC) address, a source MAC address, a message sender identifier, and a switch type identifier. Among them, the destination MAC address of the target request message is the MAC address of the switch, the source MAC address is the MAC address of the terminal device, the message sender identifier indicates the sender of the message, that is, the terminal device; the switch type identifier indicates the type of the switch, and the type of the switch can be represented by the model of the switch.

[0026] Similarly, the target response message in the embodiment of the present application includes, in addition to the private protocol identifier and target information, the destination MAC address, the source MAC address, the message sender identifier, and the switch type identifier. The destination MAC address of the target response message is the MAC address of the terminal device, the source MAC address is the MAC address of the switch, the message sender identifier indicates the sender of the message, that is, the switch; the switch type identifier indicates the type of the switch, and the type of the switch can be represented by the model of the switch.

[0027] Since the terminal device does not know the MAC address of the switch when it initiates the request for the first time, in order to enable the switch to receive and process the request sent by the terminal device, in the embodiment of the present application, when the target request message is the request message initially initiated by the terminal device, the destination MAC address in the request can be a designated multicast address, and the designated multicast address is used to enable the switch to process the target request message. In this way, by setting a designated multicast address for processing the request between the terminal device and the switch, the switch can be easily allowed to process the target request message sent by the terminal device for the first time. In the specific implementation process, an access control list (ACL) can be configured on the switch, and the access control list is used to filter out messages containing the designated multicast address and the private protocol identifier. In this way, the switch can match the message containing the private protocol identifier and the designated multicast address according to the access control list, and then forward the message to the internal CPU for processing, parse the corresponding command word in the message, and reply to the corresponding response message. After receiving the response message, the terminal device can obtain the MAC address of the switch, and the subsequent messages sent by the terminal device can use the obtained switch MAC address as the DMAC address.

[0028] In addition, it should be noted that the command identifier in the embodiment of the present application can be an identifier indicating the execution of various commands. In one embodiment of the present application, the command identifier includes: any one of a first command identifier indicating version information query, a second command identifier indicating reading a switch register, and a third command identifier for setting a switch register.

[0029] Specifically, when the command identifier includes a first command identifier, the target information in the target response message includes version information; when the command identifier includes a second command identifier, the target request message also includes a register address, and the target information in the target response message includes a read result, and the read result includes a register value of the register address; when the command identifier includes a third command identifier, the target request message also includes a register address and a register value set for the register address, and the target information in the target response message includes a setting result. The read result and the setting result can be represented by an error code field. Different values ​​of the error code field are used to indicate different read results or different setting results.

[0030] See also Figure 3 , Figure 3 1 is a flow chart of a method for debugging a switch provided by an embodiment of the present application. Figure 3 As shown, the method comprises the following steps: Step 310: When the switch and the terminal device have established a network connection through the UTP port, the switch receives a target request message sent by the terminal device, wherein the target request message includes a private protocol identifier and a command identifier, wherein the private protocol identifier indicates that the message type of the target request message is a private protocol type, and the command identifier indicates an operation performed by the switch; Step 320: the switch responds to the target request message, executes the operation indicated by the command identifier, and obtains target information; Step 330: The switch generates a target response message based on the target information; wherein the target response message includes the private protocol identifier and the target information, and the target information is obtained based on the command identifier; Step 340: The switch sends the target response message to the terminal device.

[0031] In an embodiment of the present application, after receiving the target response message sent by the switch, the terminal device can parse the target response message to obtain the target information. The target information can be information used to debug the switch. After obtaining the target information, the terminal device can display the target information for reference by relevant personnel.

[0032] In the method for debugging a switch provided in an embodiment of the present application, the terminal device is connected to the switch through a UTP port, and is no longer connected through a UART interface or an SMI. When the terminal device and the switch have established a network connection through the UTP port, the terminal device and the switch interact through private protocol messages, and obtain target information through a command identifier in the request message that is used to instruct the switch to perform an operation. There is no need to obtain information through a UART interface or SMI to debug the switch, which solves the problem that the related technology cannot debug the switch without a UART interface and an SMI.

[0033] In an embodiment of the present application, the target request message may include other identifiers in addition to the private protocol identifier and the command identifier. In a specific embodiment, the target request message further includes: a destination MAC address, a source MAC address, a message sender identifier, and a switch type identifier. Among them, the destination MAC address of the target request message is the MAC address of the switch, the source MAC address is the MAC address of the terminal device, the message sender identifier indicates the sender of the message, that is, the terminal device; the switch type identifier indicates the type of the switch, and the type of the switch can be represented by the model of the switch.

[0034] Similarly, the target response message in the embodiment of the present application includes, in addition to the private protocol identifier and target information, the destination MAC address, the source MAC address, the message sender identifier, and the switch type identifier. The destination MAC address of the target response message is the MAC address of the terminal device, the source MAC address is the MAC address of the switch, the message sender identifier indicates the sender of the message, that is, the switch; the switch type identifier indicates the type of the switch, and the type of the switch can be represented by the model of the switch.

[0035] Since the terminal device does not know the MAC address of the switch when it initiates the request for the first time, at this time, in order to enable the switch to receive and process the request sent by the terminal device, in the embodiment of the present application, when the target request message is the request message initially initiated by the terminal device, the destination MAC address in the request can be a designated multicast address, and the designated multicast address is used to enable the switch to process the target request message. In this way, by setting a designated multicast address for processing the request between the terminal device and the switch, the switch can be conveniently allowed to process the target request message sent by the terminal device for the first time. In the specific implementation process, an access control list can be configured on the switch, and the access control list is used to filter out messages containing the designated multicast address and the private protocol identifier. In this way, the switch can match the message containing the private protocol identifier and the designated multicast address according to the access control list, and then forward the message to the internal CPU for processing, parse the corresponding command word in the message, and reply to the corresponding response message. After receiving the response message, the terminal device can obtain the MAC address of the switch, and the subsequent messages sent by the terminal device can use the obtained switch MAC address as the DMAC address.

[0036] In addition, it should be noted that the command identifier in the embodiment of the present application can be an identifier indicating the execution of various commands. In one embodiment of the present application, the command identifier includes: any one of a first command identifier indicating version information query, a second command identifier indicating reading a switch register, and a third command identifier for setting a switch register.

[0037] Specifically, when the command identifier includes a first command identifier, the target information in the target response message includes version information; when the command identifier includes a second command identifier, the target request message also includes a register address, and the target information in the target response message includes a read result, and the read result includes a register value of the register address; when the command identifier includes a third command identifier, the target request message also includes a register address and a register value set for the register address, and the target information in the target response message includes a setting result. The read result and the setting result can be represented by an error code field. Different values ​​of the error code field are used to indicate different read results or different setting results.

[0038] The message format in the embodiments of the present application is discussed in further detail below.

[0039] The following is an example of the message format sent by the terminal device:

[0040] Each row in the table above represents 4 bytes, and the number in the brackets indicates the total number of bytes occupied by this field. Taking DMAC(6) as an example, DMAC(6) indicates that the DMAC identifier occupies a total of 6 bytes, of which the DMAC in the first row occupies 4 bytes and the DMAC in the second row occupies 2 bytes. Taking DstAsic(10) as an example, DstAsic(10) indicates that the DMAC identifier occupies a total of 10 bytes, of which the DstAsic in the same row as EtherType occupies 1 byte, the DstAsic in the next two rows occupies 4 bytes each, and the DstAsic in the same row as CmdVer occupies 1 byte. In addition, it should be understood that since the Ethernet frame length is at least 64 bytes, 0 can be padded when the message length is insufficient.

[0041] In the embodiment of the present application, the CmdVer field, the RegisterAddr field, and the RegisterData field are optional fields. One or more of them can be selected according to the requirements of the command. For example, the getversion request message sent by the terminal device may not include the RegisterAddr field and the RegisterData field, and the read register message sent by the terminal device may not include the RegisterData field.

[0042] The explanation of the relevant fields in the message sent by the terminal device is as follows:

[0043] It should be understood that the values ​​in the above table are only examples and not limitations. Pad mentioned above indicates a padding field, CRC (Cyclic Redundancy Check) indicates a cyclic redundancy check field, and Reserved indicates a reserved field.

[0044] The format of the response message sent by the switch is as follows:

[0045] Each row in the table above represents 4 bytes, and the number in the brackets indicates the total number of bytes occupied by this field. Taking DMAC(6) as an example, DMAC(6) indicates that the DMAC identifier occupies a total of 6 bytes, of which the DMAC in the first row occupies 4 bytes and the DMAC in the second row occupies 2 bytes. Taking DstAsic(10) as an example, DstAsic(10) indicates that the DMAC identifier occupies a total of 10 bytes, of which the DstAsic in the same row as EtherType occupies 1 byte, the DstAsic in the next two rows occupies 4 bytes each, and the DstAsic in the same row as CmdVer occupies 1 byte.

[0046] The explanation of the relevant fields in the response message sent by the switch is as follows:

[0047] It should be understood that the values ​​in the above table are only examples and not limitations. Pad mentioned above indicates a padding field, CRC (Cyclic Redundancy Check) indicates a cyclic redundancy check field, and Reserved indicates a reserved field.

[0048] In the method for debugging a switch provided in an embodiment of the present application, a debugging tool can be pre-installed on the terminal device. This debugging tool supports username and password verification, which can reduce the potential harm caused by malicious attacks. When the switch receives a command message sent by the terminal device, it will check the message sender identifier (Subtype), command word version (CmdVer) and command word (Command) and other fields, and can handle the situation where the format of the command sent is illegal.

[0049] The debugging tool works in SMI mode by default and communicates with the switch through the SMI interface. After successfully switching to network (NET) mode through the command, it can communicate with the switch through the network. The specific switching process is as follows: enter the command to switch from SMI mode to network mode to the diagnostic tool, and pass in the parameters: network interface card (NIC) identification (ID) and switch type; after the diagnostic tool receives the command to switch from SMI mode to network mode, it prompts to enter the password; after receiving the password, the entered password is verified; if the password verification fails, the process ends; if the password verification succeeds, the MAC of the corresponding network card is obtained according to the NIC ID as the SMAC for initiating the command, and the obtained switch type is used as the target switch type for initiating the command, and then switch to network mode.

[0050] In the network mode, the terminal device can transmit messages with the switch to obtain the target information for debugging. In the embodiment of the present application, the command identifier may include: any one of: a first command identifier indicating version information query, a second command identifier indicating reading the switch register, and a third command identifier for setting the switch register. The target information may include version information, register reading results, or register setting results. The following are exemplary descriptions.

[0051] like Figure 4 As shown, in the case where the command identifier includes the first command identifier, the target information in the target response message includes version information. Specifically, when querying the version information, the debugging tool on the terminal device (such as a personal computer) can assemble a get version request message (i.e., a target request message) according to the sending message format mentioned above, SMAC is the MAC address of the network card connected to the switch on the terminal device, and DMAC is a designated multicast address, such as 01:00:5E:FF:AA:BB. After the message is assembled, a get version request message is sent to the switch through the network card, and a response message is waited for. After receiving the message, the switch parses and verifies the relevant fields of the message. If the parsing and verification are successful, the corresponding version information is obtained, and the obtained version information will be included in the response message, otherwise the error code in the response message will be set to the corresponding identifier. After the switch assembles the get version response message, it sends the get version response message to the terminal device. After receiving the response message, the terminal device parses the message to obtain the MAC address and version information of the switch. The MAC address of the switch is used as the DMAC in the message sent by the terminal device for subsequent interactions.

[0052] like Figure 5As shown, in the case where the command identifier includes the second command identifier, the target request message also includes a register address, and the target information in the target response message includes a read result, and the read result includes the register value of the register address. Specifically, when reading the switch register, the debugging tool on the terminal device (such as a personal computer) can assemble a read register (get register) request message (i.e., a target request message) according to the sending message format mentioned above, SMAC is the MAC address of the network card connected to the switch on the terminal device, and DMAC is the MAC of the switch. After the message is assembled, a read register (get register) request message is sent to the switch through the network card, and a response message is waited for. After receiving this message, the switch parses and verifies the relevant fields of the message. If the parsing and verification are successful, the register is read to obtain the corresponding register value, and the register reading result will be included in the response message, and this result may include the obtained register value. After the switch assembles the read register (get register) response message, it sends a read register (get register) response message to the terminal device. After receiving this response message, the terminal device parses the message to obtain the register value on the switch.

[0053] like Figure 6 As shown, in the case where the command identifier includes the third command identifier, the target request message also includes a register address and a register value set for the register address, and the target information in the target response message includes the setting result. Specifically, when setting the switch register, the debugging tool on the terminal device (such as a personal computer) can assemble a set register request message (i.e., a target request message) according to the sending message format mentioned above, SMAC is the MAC address of the network card connected to the switch on the terminal device, and DMAC is the MAC of the switch. After the message is assembled, a set register request message is sent to the switch through the network card, and a response message is waited for. After receiving the message, the switch parses and verifies the relevant fields of the message. If the parsing and verification are successful, the corresponding register value is set, and the response message includes the setting result of the register, for example, the error code field is set to 0, indicating that the setting is successful; the error code field is set to other specific values, indicating the reason for the setting failure. After the switch assembles the set register response message, it sends a set register response message to the terminal device. After receiving the response message, the terminal device parses the message and obtains the setting result of the register on the switch.

[0054] During the interaction between the terminal device and the switch, if the terminal device has not received a response message from the switch after sending a request to the switch within the set time threshold (it may be that the switch has not replied to the response message, or the replied response message has been lost), then the terminal device can exit the interaction. After ending the communication, the terminal device can continue to initiate the next command request. In other words, a timeout exit mechanism is provided for the terminal device in the embodiment of the present application.

[0055] In the embodiment of the present application, after obtaining the setting and query commands of the switch register, various configuration and query operations of the switch can be combined. On this basis, more command operations can be conveniently defined to expand the debugging commands, so that the switch can be debugged more conveniently.

[0056] In summary, in the method for debugging a switch provided in an embodiment of the present application, any UTP port of the switch can be connected to a terminal device via a network cable. A custom diagnostic tool is run on the terminal device, and a private protocol message is sent to the switch through the network card of the terminal device. After receiving and parsing the private message, the switch will reply with corresponding information in the format defined by the private protocol. After the diagnostic tool receives and parses the information replied by the switch, the result can be displayed on the screen for reference by relevant personnel. In this way, operations such as reading and setting the switch register can be realized through the private protocol, so that the operation of the switch is realized through network communication.

[0057] In particular, the customized private protocol message format defines the format of the command initiated by the terminal device and the format of the response message replied by the switch. Based on this request message format and response message format, the interaction between the terminal device and the switch can be easily realized during the switch debugging process. In addition, since the terminal device does not know the MAC address of the switch when it first initiates the command, the DMAC in the request message sent by the terminal device uses a specified multicast address, such as 01:00:5E:FF:AA:BB. When the switch receives this message, it can transfer this message to the internal CPU for processing. In the implementation process, an access control list (ACL) can be pre-configured on the switch. The rule is to match the message with the DMAC as the specified multicast address and the private protocol identifier (Ether Type) as the specified identifier (such as 0xAABB), and the action is to forward (trap) the matched message to the internal CPU of the switch. After parsing the corresponding command word, the switch replies with the corresponding message. After receiving the reply message, the terminal device learns the MAC address of the switch, and the DMAC in the subsequent messages sent by the terminal device is the address of the switch.

[0058] The method for debugging a switch provided in the embodiment of the present application can achieve the following technical effects: first, the existing UTP port of the switch is used for communication without disassembling the machine; second, private protocol communication is used, which can be quickly implemented by software without the need for adding new hardware functions; third, the read and write related operations of the switch are implemented using a private protocol, which has strong scalability and can continue to add command words to support more functions.

[0059] Figure 7 is a structural block diagram of an electronic device provided in an embodiment of the present application. Figure 7 As shown, an embodiment of the present application also provides an electronic device 700. The electronic device 700 includes: a processor 710 and a memory 720, and the memory 720 stores a program or instruction, and the program or instruction is executed by the processor 710 to implement the steps of any method described above. For example, when the program is executed by the processor 710, the following process is implemented: when the terminal device and the switch have established a network connection through the UTP port, a target request message is sent to the switch, and the target request message includes a private protocol identifier and a command identifier, and the private protocol identifier indicates that the message type of the target request message is a private protocol type, and the command identifier indicates the operation performed by the switch; receiving a target response message sent by the switch; wherein the target response message includes the private protocol identifier and target information, and the target information is obtained based on the command identifier; by parsing the target response message, the target information contained in the target response message is obtained. For another example, when the program is executed by the processor 710, the following process is implemented: when the switch and the terminal device have established a network connection through the UTP port, a target request message sent by the terminal device is received, the target request message includes a private protocol identifier and a command identifier, the private protocol identifier indicates that the message type of the target request message is a private protocol type, and the command identifier indicates the operation performed by the switch; in response to the target request message, the operation indicated by the command identifier is performed to obtain target information; based on the target information, a target response message is generated; wherein the target response message includes the private protocol identifier and the target information, and the target information is obtained based on the command identifier; and the target response message is sent to the terminal device. In this way, the terminal device and the switch are connected through the UTP port, and are no longer connected through the UART interface or SMI. When the terminal device and the switch have established a network connection through the UTP port, the terminal device and the switch interact through private protocol messages, and obtain target information through the command identifier in the request message that is used to instruct the switch to perform an operation. There is no need to obtain information through the UART interface or SMI to debug the switch, which solves the problem that the related technology cannot debug the switch without the UART interface and SMI.

[0060] An embodiment of the present application further provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of each embodiment of the method for debugging a switch are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0061] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0062] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0063] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0064] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0065] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0066] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A method for debugging a switch, applied to a terminal device, characterized in that: include: In the case where a network connection has been established between a terminal device and a switch through an unshielded twisted pair port, the terminal device sends a target request message to the switch, wherein the target request message includes a private protocol identifier and a command identifier, wherein the private protocol identifier indicates that a message type of the target request message is a private protocol type, and the command identifier indicates an operation performed by the switch; The terminal device receives a target response message sent by the switch; wherein the target response message includes the private protocol identifier and target information, and the target information is obtained based on the command identifier; The terminal device obtains the target information contained in the target response message by parsing the target response message.

2. The method according to claim 1, characterized in that The target request message and the target response message both further include: a destination media access control address, a source media access control address, a message sender identifier, and a switch type identifier; The message sender identifier indicates the sender of the message; and the switch type identifier indicates the type of the switch.

3. The method according to claim 2, characterized in that The target request message is a request message initially initiated by the terminal device, and the destination media access control address is a designated multicast address, and the designated multicast address is used to enable the switch to process the target request message.

4. The method according to any one of claims 1 to 3, characterized in that: The command identifier includes: any one of: a first command identifier for instructing to query version information, a second command identifier for instructing to read a switch register, and a third command identifier for setting a switch register; In a case where the command identifier includes the first command identifier, the target information in the target response message includes version information; In a case where the command identifier includes a second command identifier, the target request message further includes a register address, and the target information in the target response message includes a read result, and the read result includes a register value of the register address; In the case where the command identifier includes the third command identifier, the target request message further includes a register address and a register value set for the register address, and the target information in the target response message includes a setting result.

5. A method for debugging a switch, applied to a switch, characterized in that: include: In a case where a network connection has been established between the switch and the terminal device through an unshielded twisted pair port, the switch receives a target request message sent by the terminal device, the target request message includes a private protocol identifier and a command identifier, the private protocol identifier indicates that a message type of the target request message is a private protocol type, and the command identifier indicates an operation performed by the switch; The switch responds to the target request message, executes the operation indicated by the command identifier, and obtains the target information; The switch generates a target response message based on the target information; wherein the target response message includes the private protocol identifier and the target information, and the target information is obtained based on the command identifier; The switch sends the target response message to the terminal device.

6. The method according to claim 5, characterized in that The target request message and the target response message both further include: a destination media access control address, a source media access control address, a message sender identifier, and a switch type identifier; The message sender identifier indicates the sender of the message; and the switch type identifier indicates the type of the switch.

7. The method according to claim 6, characterized in that The destination media access control address in the target request message is a designated multicast address; the switch is configured with an access control list, and the access control list is used to filter out messages containing the designated multicast address and the private protocol identifier.

8. The method according to any one of claims 5 to 7, characterized in that: The command identifier includes: any one of: a first command identifier for instructing to query version information, a second command identifier for instructing to read a switch register, and a third command identifier for setting a switch register; In a case where the command identifier includes the first command identifier, the target information in the target response message includes version information; In a case where the command identifier includes a second command identifier, the target request message further includes a register address, and the target information in the target response message includes a read result, and the read result includes a register value of the register address; In the case where the command identifier includes the third command identifier, the target request message further includes a register address and a register value set for the register address, and the target information in the target response message includes a setting result.

9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction running on the processor, and when the program or instruction is executed by the processor, the steps of the method according to any one of claims 1 to 8 are implemented.

10. A computer-readable storage medium, characterized in that: The medium stores a program or an instruction, and when the program or the instruction is executed, the steps of the method according to any one of claims 1 to 8 are implemented.

11. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 8 when being executed by a processor.