Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail below with reference to the accompanying drawings and examples.
Referring to fig. 1, fig. 1 is a flowchart of a method for modifying the configuration of an ethernet switch according to an embodiment of the present invention, including the following steps:
step 101, presetting configuration modification conditions, wherein the configuration modification conditions are corresponding relations of port PHY states, configuration function items and configuration options of the Ethernet switch.
The port PHY state described herein refers to the combination of all port states in the ethernet switch. In the ethernet, the ethernet ports include three network ports of RJ45, BNC and AUI according to different transmission media. Each port state is determined by one or more combinations of its duplex state, operating rate, and enable state, depending on the port. Taking the RJ45 port of a gigabit ethernet as an example, each RJ45 port has three operating rates: 10M, 100M, 1000M; two duplex states: half duplex and full duplex; two enabled states: an enabled (UP) state and a not enabled (DOWN); when the enabling state of the RJ45 port is not enabled, only one DOWN state is available, and when the enabling state of the RJ45 port is enabled, 6 states of 10M/Half duplex (Half), 10M/Full duplex (Full), 100M/Half, 100M/Full, 1000M/Half, and 1000M/Full exist, so that 7 port states are available for each RJ45 port of gigabit Ethernet. Assuming 24 RJ45 ports in an ethernet switch, the ethernet switch has a total port state combination of power 24 of 7. Note that the port according to the present invention is not limited to the RJ45 port.
The configuration function item is also a configurable function item of the ethernet switch, such as a flow control function; for any configuration function item, a specific configuration option corresponding to the configuration function item is required, for example, the configuration options for flow control may be: enable flow control, or disable flow control.
The specific meaning of the corresponding relationship among the port PHY state, the configuration function item and the configuration option of the Ethernet switch is as follows: when the port PHY state of the Ethernet switch is the same as the port PHY state in the corresponding relation, the configuration of the configuration function item in the corresponding relation is modified into the configuration option in the corresponding relation.
And 102, when the configuration of the Ethernet switch needs to be modified, setting the port physical layer (PHY) state of the Ethernet switch according to a preset configuration modification condition.
In this step, after the port PHY state of the ethernet switch is set, the staff needs to wait for at least a preset time to allow the port PHY state of the ethernet switch to be changed, otherwise, it may cause a failure in modifying the configuration of the ethernet switch. Here, the preset time is a time interval for detecting the PHY state of the port of the ethernet.
Step 103, the ethernet switch detects the PHY state of its own port once every preset time, and determines whether the detected PHY state of the port meets the configuration modification condition, and if so, modifies the configuration of the configuration function item in the configuration modification condition to the configuration option in the configuration modification condition.
In this step, the ethernet switch periodically detects the PHY status of its own port, and modifies the configuration of the ethernet switch when the PHY status of its port meets the preset configuration modification condition. Here, the method for determining whether the detected port PHY state satisfies the configuration modification condition includes: and searching the preset configuration modification condition according to the port PHY state, wherein if the port PHY state in one configuration modification condition is the same as the detected port PHY state, the detected port PHY state meets the configuration modification condition.
In addition, before modifying the configuration of the configuration function item in the configuration modification condition, it may be determined whether the current configuration of the configuration function item in the configuration modification condition is the same as the configuration option in the configuration modification condition, if so, the configuration of the configuration function item in the configuration modification condition does not need to be modified, and the current configuration is still maintained, and if not, the configuration of the configuration function item in the configuration modification condition is modified to the configuration option in the configuration modification condition.
In fig. 1, the ethernet switch detects the PHY status of its own port at fixed time intervals, and triggers configuration modification when it is determined that configuration modification is required. In fact, a manner of immediately triggering the ethernet switch to perform configuration modification may also be adopted, for example, a trigger signal is preset, and is manually triggered after the port PHY state is set, and after receiving the trigger signal, the ethernet switch immediately detects its own port PHY state, and performs corresponding configuration modification according to the detection result. However, since the setting of the trigger signal also requires additional software and hardware support, the scheme shown in fig. 1 is mainly further described in the present invention.
In the technical solution of the present invention shown in fig. 1, a configuration switch may be further provided. Before modifying the configuration of the ethernet switch, further comprising: starting a configuration switch to allow the configuration of the Ethernet switch to be modified; before modifying the configuration of the configuration function item in the configuration modification condition, further judging whether a configuration switch is turned on, if so, modifying the configuration of the configuration function item in the configuration modification condition to configure the configuration item in the configuration modification condition, otherwise, still keeping the current configuration of the configuration function item in the configuration modification condition unchanged; after the configuration modification of the ethernet switch is completed, further comprising: and closing the configuration switch and forbidding modifying the configuration of the Ethernet switch. The configuration switch is arranged, so that abnormal change of the configuration of the switch caused by non-active operation of a user can be avoided, and the times of non-forced erasing of the memory can be reduced.
The enabling condition of the configuration switch may be that the port of the ethernet switch is negotiated to a specified PHY state, that is, a corresponding relationship between the opening of the configuration switch and the PHY state of the port of the ethernet switch, and a corresponding relationship between the closing of the configuration switch and the PHY state of the port of the ethernet switch are preset.
The method for turning on the configuration switch comprises the following steps: setting the port PHY state of the Ethernet switch as a port PHY state corresponding to the starting of the configuration switch, and waiting for at least preset time; and when the Ethernet switch detects that the port PHY state is the state that the corresponding port PHY is started by the configuration switch, setting the configuration switch to be in the starting state.
The method for closing the configuration switch comprises the following steps: setting the port PHY state of the Ethernet switch as the port PHY state corresponding to the closing of the configuration switch, and waiting for at least preset time; and when the Ethernet switch detects that the port PHY state is the port PHY state corresponding to the closing of the configuration switch, the configuration switch is set to be in the closing state.
The invention can also preset the configuration validation mode. The configuration validation mode comprises immediate validation and validation after restart. The immediate effect mode is simple and quick, and is suitable for the configuration of the network-administration-free type switch. The effective mode after restarting can avoid the problems of network instantaneous interruption and network topology oscillation caused by configuration modification, and is suitable for the configuration of the network management type switch.
The invention also presets the parameters corresponding to the configuration switch.
In the immediate effect mode, the method for setting the configuration switch to the on state is as follows: setting the parameter corresponding to the configuration switch as a value corresponding to the opening of the configuration switch, for example, the value corresponding to the opening of the configuration switch is 1; the method for setting the configuration switch to be in the closed state comprises the following steps: and setting the parameter corresponding to the configuration switch to a value corresponding to the closing of the configuration switch, for example, the value corresponding to the closing of the configuration switch is 0.
In general, for a non-network management type switch, the value of the MAC register corresponding to each configuration function item can be directly modified. Therefore, in an immediate effect manner, for the network-managed switch, the method for modifying the configuration of the configuration function item in the configuration modification condition to the configuration option in the configuration modification condition in step 102 is as follows: modifying the value of the MAC register corresponding to the configuration function item in the configuration modification condition into the value corresponding to the configuration option in the configuration modification condition, for example, the value corresponding to the configuration modification condition is 1 when the configuration is enabled, and the value corresponding to the configuration modification condition is 0 when the configuration is not enabled; for the network management type switch, it is generally not allowed to directly modify the MAC register value corresponding to each configuration function item. However, since the network management system operating in the network management type switch has configuration parameters corresponding to each configuration function item, the purpose of modifying the configuration of the configuration function item can be indirectly achieved by modifying the parameters corresponding to the configuration function item in the network management system. Therefore, in an immediate effect manner, for the network management type switch, the method for modifying the configuration of the configuration function item in the configuration modification condition to the configuration option in the configuration modification condition in step 102 is as follows: and modifying the configuration parameters in the network management system corresponding to the configuration function items in the configuration modification conditions into values corresponding to the configuration options in the configuration modification conditions. The parameters in the network management system are modified, for example, the technical scheme of the invention is realized in the network management system, and the direct modification of various parameters in the network management system is supported, which belongs to the problem of specific implementation and is not described any more.
If the configuration validation mode is set to be valid after the restart, step 102 sets a port physical layer PHY state of the ethernet switch according to a preset configuration modification condition, and waits for at least a preset time, further includes: restarting the Ethernet switch after power down; the method for modifying the configuration of the configuration function item of the configuration modification condition as the configuration option of the configuration modification condition in step 103 is: and modifying the value of the MAC register in the configuration file stored in the memory space of the Ethernet switch corresponding to the configuration function item of the configuration modification condition into the value corresponding to the configuration option in the configuration modification condition.
In an effective manner after the restart, in a process of starting the configuration switch, setting the port PHY state of the ethernet switch to a port PHY state corresponding to the start of the configuration switch, and waiting for at least a preset time, further comprising: restarting the Ethernet switch after power down; the method for setting the configuration switch to be in the opening state comprises the following steps: modifying the value corresponding to the configuration switch in the configuration file stored in the memory space of the Ethernet switch into the value corresponding to the opening of the configuration switch; in the process of closing the configuration switch, the setting the port PHY state of the ethernet switch to the port PHY state corresponding to the closing of the configuration switch, and waiting for at least a preset time, further includes: restarting the Ethernet switch after power down; the method for setting the configuration switch to be in the closed state by the Ethernet switch comprises the following steps: and modifying the value corresponding to the configuration switch in the configuration file stored in the memory space of the Ethernet switch into the value corresponding to the closing of the configuration switch.
In the effective mode after restarting, the Ethernet switch can realize the purposes of opening and closing the configuration switch, modifying the configuration and the like by reading the updated configuration file in the memory in the power-off restarting process.
The configuration validation mode can be preset by the manufacturer of the Ethernet switch or can be selected by the user. When the user selects the configuration effective mode, the invention also presets the parameter corresponding to the configuration effective mode, and also presets the corresponding relation between the configuration effective mode and the port PHY state, namely the corresponding relation between the port PHY state of the Ethernet switch and the immediate effective mode, and the corresponding relation between the port PHY state of the Ethernet switch and the effective mode after restarting; before the configuration switch is turned on, a configuration validation mode can be further set, and the specific setting method comprises the following steps: and setting the port PHY state of the Ethernet switch as the port PHY state corresponding to the required configuration effective mode, waiting for at least preset time, and setting the parameter corresponding to the configuration effective mode as the value corresponding to the immediate effective mode or the effective mode after restarting when the Ethernet switch detects that the port PHY state corresponds to the immediate effective mode or the effective mode after restarting. Here, the setting configuration validation manner only needs to be set once.
It should be noted that, in the above method for modifying the configuration of the ethernet switch, the waiting time is at least a preset time because: the time interval for detecting the port PHY state of the ethernet switch is the preset time, and if the waiting time is less than the preset time, it is possible that the port PHY state before the change is not detected before the change. For example, after the port PHY state setting configuration switch is turned on, and before the ethernet switch detects the port PHY state, the port PHY state is set to the state corresponding to the enable traffic control, and the configuration switch is not actually turned on at this time.
The following describes the method for modifying the configuration of the ethernet switch by taking the example of modifying the flow control function of the most common ethernet-type switch without network management, which has 24 RJ45 ports. Suppose that the ethernet switch leaves the factory as follows:
1. the default flow control function of the switch is in a closed state, namely, an disabled state; configuring the switch to be in a closed state; the configuration effective mode of the switch is an immediate effective mode;
2. when the P1-P21 ports are in a Down state and the P22-P24 ports are in a 10M/Half state, the specific configuration of the flow control function of the exchanger is modified to enable flow control;
3. the P1-P8 ports are in a 10M/half state, and when other ports are in a Down state, the configuration switch of the switch is modified to be in an open state, so that the configuration of the switch is allowed to be modified;
4. when the P9-P16 port is in a 10M/Half state and other ports are in a Down state, modifying the configuration switch of the switch to be in a closed state, and forbidding modifying the configuration of the switch;
5. when the P17-P24 port is 10M/Half, and other ports are in a Down state, the configuration effective mode of the modified switch is effective after restarting.
If a user wants to modify the configuration validation mode of the switch into validation after restarting, and modify the configuration of the flow control function of the switch into enabling flow control, assuming that the period of detecting the port PHY state by the Ethernet switch is 5 seconds, the specific configuration steps are as follows:
A. connecting P17-P24 ports of the switch with a HUB (HUB) with 8 ports and a working speed of 10M by using a common twisted pair, connecting other ports with no network cable, waiting for at least 5 seconds after the connection is finished, and modifying the configuration effective mode of the switch into effective mode after restarting; and in the waiting time, the Ethernet switch detects the state of the port PHY, and modifies the configuration effective mode into the effective mode after restarting according to the state of the port PHY.
B. Connecting the P1-P8 ports of the switch with a HUB (HUB) with 8 ports and working speed of 10M by using a common twisted pair, not connecting the other ports with a network cable, waiting for at least 5 seconds after the connection is completed, and powering down the switch for restarting. And in the waiting time, the Ethernet switch detects the PHY state of the port, modifies the value corresponding to the configuration switch in the configuration file stored in the storage space of the Ethernet switch into the value corresponding to the open configuration switch according to the PHY state of the port, and takes effect after the switch is restarted. So far, a configuration switch of the switch is turned on, and the configuration of the switch is allowed to be modified;
C. connecting the P22-P24 ports of the switch with a HUB (HUB) with 8 ports and working speed of 10M by using a common twisted pair, not connecting the other ports with a network cable, waiting for at least 5 seconds after the connection is completed, and powering down the switch for restarting. And in the waiting time, the Ethernet switch detects the PHY state of the port, modifies the value corresponding to the flow control function in the configuration file stored in the storage space of the Ethernet switch into the value corresponding to the enabled flow control according to the PHY state of the port, and takes effect after the switch is restarted. At this point, the flow control function of the switch is started, namely enabled;
D. connecting the P9-P16 ports of the switch with a HUB (HUB) with 8 ports and working speed of 10M by using a common twisted pair, not connecting the other ports with a network cable, waiting for at least 5 seconds after the connection is completed, and powering down the switch for restarting. And in the waiting time, the Ethernet switch detects the PHY state of the port, modifies the value corresponding to the configuration switch in the configuration file stored in the storage space of the Ethernet switch into the value corresponding to the closed configuration switch according to the PHY state of the port, and takes effect after the switch is restarted. At this point, the configuration switch of the switch is closed, prohibiting the configuration of the switch from being modified.
Through the A, B, C, D steps, the user can modify the configuration of the flow control function of the Ethernet exchanger without the help of a computer. Because a gigabit ethernet switch with 24 RJ45 ports has 24 port state combinations of power 7, the basic function setting of the switch, the factory default setting restoration, and the like are completely satisfied, and in the case of enough ports, some more complex functions, such as the division of Virtual Local Area Networks (VLANs), and the like, can be theoretically realized by different port PHY state combinations.
The present invention also provides an ethernet switch that supports a configuration of the ethernet switch that can be modified without the aid of a computer.
Referring to fig. 2, fig. 2 is a schematic structural diagram of an ethernet switch according to an embodiment of the present invention. The Ethernet switch includes: a configuration unit 210, a detection unit 220; wherein,
a configuration unit 210, configured to preset configuration modification conditions, where the configuration modification conditions are the corresponding relationships between port PHY states, configuration function items, and configuration options of the ethernet switch;
a detecting unit 220, configured to detect a port PHY state of the ethernet switch, and determine whether the detected port PHY state meets a configuration modification condition preset by the configuration unit 210, and if so, modify the configuration of the configuration function item in the configuration modification condition to a configuration option in the configuration modification condition.
The detecting unit 220 includes: a detection subunit 221, a judgment unit 222, and an execution unit 223;
the detection subunit 221, configured to detect the PHY status of the own port every other time, and notify the determination unit 222 of the detection result;
the determining unit 222 is configured to determine whether the port PHY status detected by the detecting sub-unit 221 meets a configuration modification condition preset by the configuration unit 210, and if yes, notify the executing unit 223 to modify the configuration of the configuration function item in the configuration modification condition;
the executing unit 223 is configured to modify the configuration of the configuration function item in the configuration modification condition into the configuration option in the configuration modification condition after receiving the notification of the determining unit 222.
When the determining unit 222 determines whether the port PHY status detected by the detecting sub-unit 221 satisfies the configuration modification condition preset by the configuration unit 210, it is configured to: and searching the preset configuration modification condition according to the detected port PHY state, wherein if the port PHY state corresponding to one of the configuration modification conditions is the same as the detected port PHY state, the detected port PHY state meets the configuration modification condition.
Before the determining unit 222 notifies the executing unit 223 to modify the configuration of the configuration function item in the configuration modification condition, the determining unit is further configured to: and judging whether the current configuration of the configuration function item of the configuration modification condition is the same as the configuration option in the configuration modification condition, and if so, not notifying the execution unit 223.
The configuration unit 210 is also configured with a configuration switch in advance, a corresponding relationship between the opening of the configuration switch and the PHY state of the port, and a corresponding relationship between the closing of the configuration switch and the PHY state of the port;
the determining unit 222 is further configured to determine whether the port PHY state detected by the detecting subunit 221 is the same as the port PHY state corresponding to the configuration switch being turned on or the configuration switch being turned off, and if the port PHY state corresponding to the configuration switch being turned on is the same as the port PHY state corresponding to the configuration switch being turned on, notify the executing unit 223 to turn on the configuration switch; if the port PHY state corresponding to the configuration switch closing is the same, the execution unit 223 is notified to close the configuration switch;
the executing unit 223 is further configured to set the configuration switch to the on state when receiving the notification of turning on the configuration switch of the determining unit 222, and set the configuration switch to the off state when receiving the notification of turning off the configuration switch of the determining unit 222.
The determining unit 222 further notifies the executing unit 223 to modify the configuration of the configuration function item in the configuration modification condition before: and judging whether the configuration switch is turned on, and if not, not informing the execution unit 223.
The configuration unit 210 also presets a configuration validation mode, where the configuration validation mode includes an immediate validation mode and an after-restart validation mode; presetting a corresponding relation between a port PHY state of an Ethernet switch and an immediate effective mode and a corresponding relation between the port PHY state of the Ethernet switch and an effective mode after restarting;
the determining unit 222 is further configured to determine whether the port PHY state detected by the detecting subunit 221 is the same as the port PHY state corresponding to the immediate-effect mode or the post-restart-effect mode, and if the port PHY state is the same as the port PHY state corresponding to the immediate-effect mode, notify the executing unit 223 to modify the configuration-effect mode to be immediately effective; if the port PHY state corresponding to the post-restart validation method is the same, the notification execution unit 223 sets the configuration validation method to be valid after restart;
the execution unit 223 is configured to modify the configuration validation manner into an immediate validation manner after receiving the notification of modifying the configuration validation manner into the immediate validation manner from the determination unit 222; after receiving the notification of the determining unit 222 that the configuration validation manner is modified to the restart validation manner, the configuration validation manner is modified to the power-off restart validation.
The configuration unit 210 sets the configuration validation mode to be immediate validation in advance;
when the execution unit 223 sets the configuration switch to the on state, it is configured to: setting the parameter value corresponding to the configuration switch as a value corresponding to the opening of the configuration switch;
when the execution unit 223 sets the configuration switch to the off state, it is configured to: and setting the parameter value corresponding to the configuration switch as a value corresponding to the closing of the configuration switch.
The Ethernet switch is a network-administration-free switch;
when the executing unit 223 modifies the configuration of the configuration function item in the configuration modification condition to the configuration option in the configuration modification condition, it is configured to: modifying the value of the MAC register corresponding to the configuration function item in the configuration modification condition into the value corresponding to the configuration option in the configuration modification condition;
or,
the Ethernet switch is a network management type switch;
when the executing unit 223 modifies the configuration of the configuration function item in the configuration modification condition to a configuration option in the configuration modification condition, the executing unit is configured to: and modifying the value of the configuration parameter in the network management system corresponding to the configuration function item in the configuration modification condition into the value corresponding to the configuration option in the configuration modification condition.
The configuration unit 210 also presets a configuration validation mode to be valid after restarting;
when the executing unit 223 modifies the configuration of the configuration function item in the configuration modification condition to the configuration option in the configuration modification condition, it is configured to: modifying the value of the MAC register in the configuration file stored in the memory space of the Ethernet switch corresponding to the configuration function item of the configuration modification condition into the value corresponding to the configuration option in the configuration modification condition;
when the execution unit 223 sets the configuration switch to the on state, it is configured to: modifying the value corresponding to the configuration switch in the configuration file stored in the memory space of the Ethernet switch into the value corresponding to the opening of the configuration switch;
when the execution unit 223 sets the configuration switch to the off state, it is configured to: and modifying the value corresponding to the configuration switch in the configuration file stored in the memory space of the Ethernet switch into the value corresponding to the closing of the configuration switch.
According to the technical scheme, the method for modifying the configuration of the Ethernet switch is characterized in that the corresponding relation among the PHY state of the port of the Ethernet switch, the configuration function items and the configuration options is preset, when the configuration of a certain configuration function item of the Ethernet switch needs to be modified, the port of the Ethernet switch is set to be in the corresponding PHY state of the port, and when the PHY state of the port is detected by the Ethernet switch, the configuration of the corresponding configuration function item is modified, so that the purpose of modifying the configuration of the Ethernet switch without a computer is achieved; in addition, the invention also presets a configuration switch, when the configuration of the Ethernet switch needs to be modified, the configuration switch is started, and after the configuration modification is finished, the configuration switch is closed, thereby avoiding the abnormal modification of the configuration of the Ethernet switch caused by the user non-active operation, and reducing the times of unforced erasing and writing of the storage space; in addition, the invention can also support the user to select the mode for the configuration to be effective.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.