CN116684388A - Network card management method and device, electronic equipment and storage medium - Google Patents

Network card management method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116684388A
CN116684388A CN202310640074.0A CN202310640074A CN116684388A CN 116684388 A CN116684388 A CN 116684388A CN 202310640074 A CN202310640074 A CN 202310640074A CN 116684388 A CN116684388 A CN 116684388A
Authority
CN
China
Prior art keywords
network card
network
candidate
electronic device
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310640074.0A
Other languages
Chinese (zh)
Inventor
吴鹏
吴东
陈熙
王雷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ecoflow Technology Ltd
Original Assignee
Ecoflow Technology Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ecoflow Technology Ltd filed Critical Ecoflow Technology Ltd
Priority to CN202310640074.0A priority Critical patent/CN116684388A/en
Publication of CN116684388A publication Critical patent/CN116684388A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/10Packet switching elements characterised by the switching fabric construction
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/15Interconnection of switching modules
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The application relates to the technical field of communication, and provides a network card management method, a device, electronic equipment and a storage medium, wherein the method comprises the following steps: and the electronic equipment determines the available state of each network card by acquiring the IP address of each network card in each detection period, so as to determine the currently available candidate network card. And the electronic equipment determines a target network card to be started from the candidate network cards based on the priority of the candidate network cards, and uses the target network card to communicate. Therefore, the target network card capable of communicating is dynamically determined under the condition that the electronic equipment is configured with a plurality of network cards, and the working efficiency of the electronic equipment is ensured.

Description

Network card management method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of communications technologies, and in particular, to a network card management method, a device, an electronic device, and a storage medium.
Background
Along with the increasing application scenes of the internet of things, requirements on communication modes are gradually diversified as energy management, industrial automation and the like are carried out. In order to meet the use requirements of the internet of things equipment in different application scenes, the internet of things equipment needs to have flexible communication capability, and can be connected and interoperated with various types of networks. For example, the energy storage device generally needs to support ethernet communication to realize high-speed data transmission and real-time control, and may also support wireless communication schemes such as wireless fidelity (Wi-Fi) and bluetooth, so as to facilitate remote monitoring and control of the energy storage device by a user. Self-mobile devices often need to support Wi-Fi and bluetooth wireless communications to enable connections with other devices or networks.
Accordingly, in order to support different types of networks, the internet of things device needs to integrate multiple types of network cards, such as an ethernet network card, a Wi-Fi network card, and the like. The states of the network cards may be dynamically changed, and only one network card can provide internet service for the internet of things device at the same time. If the network card started by the internet of things equipment is improper, network interruption may be caused, so that the working efficiency of the internet of things equipment is affected.
Disclosure of Invention
In view of the above, the application provides a network card management method, a device, an electronic device and a storage medium, so as to solve the problem that the work efficiency of the internet of things device is affected due to improper network card starting of the internet of things device.
A first aspect of an embodiment of the present application provides a network card management method, where the network card management method includes: in each detection period, determining the network card with the IP address allocated in the electronic equipment as a candidate network card; determining a target network card from the candidate network cards based on the priorities corresponding to the candidate network cards; and using the target network card to communicate.
In the network card management method provided by the embodiment of the application, if the electronic device reads the IP address of the network card, it can be determined that the network card establishes physical connection with the corresponding network card interface in the electronic device, and that the network card establishes communication with the corresponding upper gateway device, that is, that the network card is activated, so that the electronic device determines the available state of each network card by acquiring the IP address of each network card in each detection period, thereby determining the currently available candidate network card. In addition, in each detection period, the electronic device can determine a plurality of candidate network cards, and only one network card can provide internet service for the electronic device at the same time, so that the electronic device determines a target network card to be started from the candidate network cards based on the priority of each candidate network card, and uses the target network card for communication. Therefore, the electronic equipment periodically and dynamically determines the target network card capable of communicating under the condition of configuring the multiple network cards, long-time network interruption caused by long-time use of the electronic equipment due to abnormal network cards is avoided to a certain extent, and the working efficiency of the electronic equipment is ensured.
A second aspect of an embodiment of the present application provides a network card management apparatus, including: the candidate network card determining module is used for determining the network card with the IP address allocated in the electronic equipment as a candidate network card in each detection period; the target network card determining module is used for determining a target network card from the candidate network cards based on the priority corresponding to the candidate network cards; and the communication module is used for communicating by using the target network card.
A third aspect of an embodiment of the present application provides an electronic device, including a memory, a processor, and computer readable instructions stored in the memory and executable on the processor, where the processor implements the network card management method described above when executing the computer readable instructions.
A fourth aspect of the embodiments of the present application provides a computer-readable storage medium storing computer-readable instructions that, when executed by a processor, implement the network card management method described above.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments of the present application will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is an application scenario diagram of a network card management method provided by an embodiment of the present application;
fig. 2 is an exemplary diagram of an application scenario of a network card management method according to an embodiment of the present application;
fig. 3 is a flowchart of an implementation of a network card management method according to an embodiment of the present application;
fig. 4 is a flowchart of an implementation of a method for determining a destination network card according to an embodiment of the present application;
fig. 5 is a flowchart of an implementation of a network card management method according to another embodiment of the present application;
fig. 6 is a flowchart of an implementation of a network card management method according to another embodiment of the present application;
fig. 7 is a schematic structural diagram of a network card management device according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
It should be noted that the terms "first" and "second" in the description and claims of the present application and the accompanying drawings are used to distinguish similar objects, and are not used to describe a specific order or sequence.
It should be further noted that, in the method disclosed in the embodiment of the present application or the method shown in the flowchart, one or more steps for implementing the method are included, and the execution order of the steps may be interchanged with each other, where some steps may be deleted without departing from the scope of the claims.
Some embodiments will be described below with reference to the accompanying drawings. The following embodiments and features of the embodiments may be combined with each other without conflict.
Referring to fig. 1, an application scenario diagram of a network card management method according to an embodiment of the present application is shown in fig. 1, where an electronic device 100 is communicatively connected to a server 200. The electronic device 100 periodically detects the availability status (or activation status) of the network cards and determines the network cards available (activated) in each detection period as candidate network cards.
In some embodiments of the present application, the electronic device 100 determines the available network cards by acquiring the IP addresses of the network cards in the electronic device 100 in each detection period, so as to determine the network card with the allocated IP address as a candidate network card.
When two or more candidate network cards are determined, the electronic device 100 can determine a target network card from the candidate network cards based on the priority of each candidate network card, and enable the target network card to establish communication connection with the server 200 for communication.
By setting the priority of the network card and dynamically switching the target network card, the problem that the network is interrupted for a long time due to the fact that the electronic equipment 100 uses the abnormal network card for a long time is avoided to a certain extent, and therefore the working efficiency of the electronic equipment 100 is affected.
In some embodiments of the present application, the communication connection includes, but is not limited to, any of a wired communication connection or a wireless communication connection.
Electronic device 100 includes, but is not limited to, any of an internet of things device, an energy storage device, a self-moving device, a power generation device, an intelligent home device, an intelligent wearable device, an industrial automation device, and the like.
The server 200 comprises a stand-alone server or a server cluster of multiple servers.
In other embodiments of the present application, the electronic device 100 may also communicate with other network devices to enable the target network card. The network device includes any one or more of a smart phone, a tablet, a computer and the like.
Fig. 2 is an exemplary diagram of an application scenario of a network card management method according to an embodiment of the present application. As shown in fig. 2, the internet of things module 10 is integrated in the electronic device 100, and the electronic device 100 is connected to the internet through the internet of things module 10, and communicates and interacts with the server 200 to realize information sharing and control. The internet of things module 10 includes a network card management unit 11, a data acquisition unit 12, and a plurality of network cards, where the plurality of network cards may include at least two of Wi-Fi network cards, local area network (LocalArea Network, LAN) network cards, and 4G network cards. The network card management unit 11 is used for managing and controlling a network card in the electronic device 100. As shown in fig. 2, the electronic device 100 controls the Wi-Fi network card to establish a communication connection with the server 200 through the network card management unit 11 of the internet of things module 10. The data acquisition unit 12 is used for acquiring and processing data acquired by sensors and the like, such as temperature data, illumination data, position data and the like. In some embodiments, the data collection unit 12 may transmit the collected data to the server 200 through the internet of things module 10. In some embodiments, server 200 includes database 20 and server 200 may store interaction data with electronic device 100 in database 20. Among other things, the server 200 may be a message transfer protocol (Message Queuing Telemetry Transport, MQTT) server or the like. Database 20 includes, but is not limited to, any of a relational database, a non-relational database, an in-memory database, and the like.
Referring to fig. 3, a flowchart of an implementation of a network card management method according to an embodiment of the present application is illustrated by taking an electronic device in fig. 1 as an example, and includes the following steps.
S11: and in each detection period, the network card with the IP address allocated in the electronic equipment is determined as a candidate network card.
In some embodiments, the network card is a network card configured in an electronic device. The network cards include, but are not limited to, any one or more of an ethernet card, a wireless network card, a bluetooth network card, etc.
In some embodiments, a network card slot is configured on a motherboard of the electronic device, and the network card is inserted into the network card slot to implement network card configuration of the electronic device. The network card may be a network card following different communication protocols, for example, a wired LAN network card for connecting the electronic device to a local area network, a Wi-Fi network card for connecting a wireless hotspot, and a mobile communication network card for performing communication based on a mobile communication network, such as a 4G network card, etc.
In some related aspects, the electronic device detects the activation status of each network card, that is, detects the availability status of each network card, by instructing each network card to send a network report probe (Packet Internet Groper, ping) command to the server. Wherein the ping command is a command for testing a network connection condition. The ping command is a service command of an application layer operating in a TCP/IP network architecture, and is used to send an ICMP (Internet Control Message Protocol, internet message control protocol) request message to a specific target server, so as to test whether access to the server is possible or not. However, since some electronic devices have a simpler operating system configured on a motherboard, such as a bare computer system with a single chip microcomputer, an operating environment for detecting the activation state of multiple network cards cannot be provided, so the technical scheme for detecting the activation state of each network card by indicating each network card to send a ping command to a server cannot be applied to such electronic devices with simpler operating systems.
Based on the above problems, in the present solution, the electronic device determines the activation status of each network card by reading the IP address of each network card. The IP address of each network card in the electronic equipment is configured by the superior gateway equipment corresponding to each network card. The electronic equipment can pre-configure the driving program of each network card, and after the electronic equipment is started, the driving program of each network card is executed to control each network card to access the corresponding superior gateway equipment so as to obtain the IP address configured by the corresponding superior gateway equipment for each network card. For example, the router is an upper gateway device of a LAN network card or a Wi-Fi network card, and may allocate an IP address to the LAN network card or the Wi-Fi network card; the base station is an upper gateway device of the mobile communication network card, and can allocate an IP address for the mobile communication network card.
If the electronic device reads the IP address of the network card, it is determined that the network card establishes physical connection with a corresponding network card interface in the electronic device, and it is determined that the network card establishes communication with a corresponding upper gateway device, that is, it is determined that the network card is activated. At this time, the electronic device determines the activated network card as a candidate network card.
In other embodiments, if the electronic device does not read the IP address of the network card, it is determined that the network card is not activated. When the network card does not establish physical connection with a corresponding network card interface in the electronic device or the network card does not establish communication connection with a gateway corresponding to the network card, the electronic device cannot acquire the IP address of the network card, that is, the network card is not activated and is in an unavailable state.
In order to ensure that the electronic equipment and the server normally communicate, the electronic equipment selects the activated network card as a candidate network card and does not process the unactivated network card.
In some embodiments of the present application, determining a network card with an allocated IP address in an electronic device as a candidate network card includes: and reading the IP address of each network card according to the network card interface address of each network card, and determining the network card corresponding to the read IP address as a candidate network card.
In some embodiments, the network card interface address includes a hardware address or a physical address of the network card, i.e., a media access control (Media Access Control, MAC) address. The network card interface address is used for uniquely identifying the network card.
In some embodiments, the IP address of each network card in the electronic device is configured by the superior gateway device corresponding to each network card. Therefore, the electronic device can control the network card to access the corresponding superior gateway device to request the superior gateway device to allocate an IP address for the network card.
In the process of acquiring the IP address of each network card, the electronic device may send the packet to the upper gateway device by packing the network card interface address for uniquely identifying the network card into a data packet. The upper gateway equipment receives the data packet, analyzes the data packet to obtain the network card interface address of the network card, allocates an IP address for the network card, and returns the IP address allocated for the network card to the network card according to the network card interface address of the network card. When the IP address returned by the superior gateway equipment is received, the network card is in an activated state.
However, if the physical connection between the network card and the corresponding network card interface in the electronic device is disconnected, or the communication connection between the network card and the corresponding upper gateway device is disconnected, the network card cannot acquire the corresponding IP address. At this time, the network card is in an inactive state.
In some embodiments, since the electronic device may enable the network card for communication only if the network card is activated, to ensure that the finally enabled network card is a network card in an available state, the electronic device determines only the network card in an activated state as a candidate network card.
S12: and determining the target network card from the candidate network cards based on the priorities corresponding to the candidate network cards.
In some embodiments, the priority is used to characterize the order in which the candidate network cards are enabled. The higher the priority candidate network cards, the more preferentially enabled. The target network card refers to the network card with the highest priority in the candidate network cards.
In some embodiments, the electronic device may determine a plurality of candidate network cards in each detection period. Each candidate network card establishes physical connection with a corresponding network card interface in the electronic equipment, and establishes communication with the superior gateway equipment corresponding to the candidate network card, namely, each candidate network card is an activated network card in an available state.
However, since the electronic device can only use one candidate network card to communicate with other network devices or servers at the same time, the electronic device needs to determine a target network card from the plurality of candidate network cards.
Based on this, the priority of each candidate network card may be preset in the electronic device. When the electronic device determines a plurality of candidate network cards, the target network card can be determined from the plurality of candidate network cards based on the priority of each candidate network card.
In some embodiments, the user may determine the priority of each candidate network card in the electronic device according to the communication stability and the communication cost of the candidate network card, where the more stable the communication and the lower the communication cost, the higher the priority.
In some embodiments of the present application, if the electronic device does not detect the network card with the allocated IP address, the first preset network card is determined as the target network card.
In some embodiments, there may be cases where all network cards of the electronic device are inactive. At this time, in order to ensure the normal operation of the electronic device, the electronic device starts the first preset network card as a target network card to perform communication. The first preset network card is a network card configured in the electronic device, including but not limited to a Wi-Fi network card, a bluetooth network card, and the like.
In some embodiments, in order to ensure the communication stability of the electronic device, the first preset network card may be a network card with the highest priority in the electronic device. For example, assuming that the priority of the ethernet card is set to be highest in the electronic device, the electronic device may determine the ethernet card as the target network card when the network card with the allocated IP address is not detected.
S13: and using the target network card to communicate.
In some embodiments, the target network card is a network card with the highest priority determined by the electronic device from the candidate network cards.
In some embodiments, after the electronic device determines the target network card, the electronic device enables the target network card to establish communication connection with other network devices or servers, so as to realize communication and data interaction. When data needs to be sent to other network devices or servers, the electronic device packages the data to be sent into network data packets, and sends the network data packets to the other network devices or servers through the target network card.
In the network card management method provided by the embodiment of the application, if the electronic device reads the IP address of the network card, it can be determined that the network card establishes physical connection with the corresponding network card interface in the electronic device, and that the network card establishes communication with the corresponding upper gateway device, that is, that the network card is activated, so that the electronic device determines the available state of each network card by acquiring the IP address of each network card in each detection period, thereby determining the currently available candidate network card. Because the electronic device may determine multiple candidate network cards in each detection period, and only one network card can provide internet service for the electronic device at the same time, the electronic device determines a target network card to be started from the candidate network cards based on the priority of each candidate network card, and uses the target network card for communication. Therefore, the electronic equipment periodically and dynamically determines the target network card capable of communicating under the condition of configuring the multiple network cards, long-time network interruption caused by long-time use of the electronic equipment due to abnormal network cards is avoided to a certain extent, and the working efficiency of the electronic equipment is ensured.
Fig. 4 is a flowchart of a method for determining a target network card according to an embodiment of the present application. As shown in fig. 4, determining the target network card from the candidate network cards based on the priorities corresponding to the candidate network cards includes the following steps.
S21: and determining a network card state digital sequence based on each candidate network card.
In some embodiments, the network card status digital sequence includes flag bits corresponding to different network cards, the value of the flag bit corresponding to each candidate network card is a first preset value, and the values of other flag bits are second preset values. Because the candidate network card is an activated network card in the electronic device, the first preset value is used for representing the activated network card, and the second preset value is used for representing the unactivated network card. For example, the first preset value may be represented by 1 and the second may be represented by 0.
In some embodiments, the electronic device manages all network cards in the electronic device by matching the network card status bitmap with the network card priority sequence. The network card state bitmap refers to a collection of network card state digital sequences, and is used for representing all states of all network cards of the electronic device. The number and types of network cards in the electronic device are different, and the corresponding network card status bitmaps are also different.
The electronic equipment is configured with 3 network cards, which are respectively: examples of Wi-Fi network card, LAN network card, 4G network card, the network card status bitmap of the electronic device is shown in Table 1 below.
Table 1 network card status bitmap
Wi-Fi network card 4G network card LAN network card
0 0 0
1 0 0
0 1 0
0 0 1
1 1 0
1 0 1
0 1 1
1 1 1
As shown in table 1, the Wi-Fi network card, the LAN network card, and the 4G network card respectively correspond to one flag bit, where the first flag bit indicates an activation state of the Wi-Fi network card, the second flag bit indicates an activation state of the 4G network card, and the third flag bit indicates an activation state of the LAN network card. Because each network card has only two states, namely activated and deactivated, as shown in table 1, the electronic device uses 0 to represent the state that the network card is not activated and uses 1 to represent the state that the network card is activated, so if three network cards are configured in the electronic device, the network card state bitmap of the electronic device comprises 2 x 2 states, namely 8 network card state digital sequences. As shown in table 1, the network card status bitmap includes 8 network card status number sequences of 000, 100, 010, 001, 110, 101, 011, 111, respectively. If the network card status number sequence is 000, it indicates that all network cards are not activated.
In some embodiments, since all the candidate network cards are all activated network cards determined by the electronic device, the electronic device may determine the activation status of all the network cards in the electronic device based on each candidate network card. The network card state bitmap refers to a collection of network card state digital sequences and is used for representing all states of all network cards of the electronic device, so that the electronic device can obtain the network card state digital sequences corresponding to candidate network cards in a matching manner from the network card state bitmap according to the activation states of all network cards. In the example shown in table 1, if the electronic device determines that the candidate network cards include the Wi-Fi network card and the 4G network card, the network card status digital sequence corresponding to each candidate network card is 110. If the electronic device does not detect the network card with the allocated IP address, that is, it is determined that all network cards are not activated, the network card status digital sequence of the electronic device is 000.
In some embodiments, the electronic device detects the activation state of each network card at regular time by starting a timer, and each detected activation state of each network card necessarily corresponds to a certain item in the network card status bitmap. The electronic device binds the network card status bitmap with the network card priority list, so that management of all network cards can be realized.
S22: and acquiring a network card priority sequence corresponding to the network card state digital sequence, and determining a target network card according to the network card priority sequence.
In some embodiments, each network card status number sequence corresponds to a network card priority sequence. The network card priority sequence is used for representing the priority of each activated network card in the corresponding network card state digital sequence. Because the candidate network cards may be different in different detection periods, the network card status number sequence corresponding to each candidate network card in different detection periods may also be different, and thus the corresponding network card priority sequence may also be different. That is, the network card priority sequence of the electronic device is dynamically updated as the candidate network card changes.
In some embodiments, the rule for determining the priority sequence of the network cards follows the communication stability and communication cost of each candidate network card, and the more stable the communication and the lower the communication cost of the candidate network card, the higher the priority.
In some embodiments, after determining the network card status digital sequence corresponding to each candidate network card, the electronic device determines the network card priority sequence corresponding to each candidate network card according to the corresponding relationship between the network card status digital sequence and the network card priority sequence. The electronic device can determine the priority of each candidate network card according to the network card priority sequence corresponding to each candidate network card, and determine the target network card according to the priority of each candidate network card.
Based on the above table 1 example, table 2 below shows a map of the correspondence between the network card status bitmap and the network card priority list. The network card priority list comprises 8 network card priority sequences, and each network card priority sequence corresponds to each network card state digital sequence in the table 1 one by one. The table 2 also includes a network card priority statement, where the network card priority statement is used to describe each network card priority sequence.
Table 2 correspondence chart between network card status bitmap and network card priority list
As shown in table 2, each network card status number sequence corresponds to a network card priority sequence and a corresponding network card priority statement. The network card priority sequence comprises the priority of each activated network card in the corresponding network card state number sequence, and the smaller the number is, the higher the priority is. For example, as shown in table 2, when determining that the network card status number sequence is 111, the electronic device determines that the corresponding network card priority sequence is 1.lan network card, 2.wi-Fi network card, 3.4G network card, and according to the network card priority statement, the LAN network card priority is highest, wi-Fi network card times, and 4G network card priority is lowest.
As can be seen from table 2, after determining the network card priority sequence corresponding to each candidate network card, the electronic device determines the priority of each candidate network card, so as to determine the target network card for communication according to the priority of each candidate network card.
In some embodiments of the present application, determining a target network card according to a network card priority sequence includes: and taking the candidate network card corresponding to the first priority in the network card priority sequence as a target network card.
In some embodiments, the first priority candidate network card is the highest priority candidate network card.
In some embodiments, after determining the network card priority sequence corresponding to each candidate network card, the electronic device determines the priority of each candidate network card, so as to ensure high-speed data transmission of the electronic device, and the candidate network card with the first priority is prioritized to be used as a target network card for communication. As shown in table 2 above, when the network card status number sequence is determined to be 111, the electronic device preferably selects the LAN network card with the first priority as the target network card for communication according to the corresponding network card priority sequence.
In some embodiments, if the electronic device detects only one network card with an allocated IP address, that is, determines a candidate network card, the candidate network card is a network card with a first priority, that is, a target network card, and the electronic device enables the candidate network card to communicate. As shown in table 2 above, when the network card status digital sequence is determined to be 100, since only the Wi-Fi network card is activated, the Wi-Fi network card in the corresponding network card priority sequence is the first priority, and the electronic device enables the Wi-Fi network card to communicate.
In some embodiments, a default network card (i.e., the first preset network card) is further provided in the electronic device. The default network card is a network card configured in the electronic device. When the electronic equipment does not detect the network card with the allocated IP address, namely, the electronic equipment determines that all the network cards are not activated, the electronic equipment takes the default network card as the network card with the first priority in the corresponding network card priority sequence, and starts the target network card to communicate. As shown in table 2 above, the electronic device determines the Wi-Fi network card as a default network card. And when the electronic equipment does not acquire the candidate network cards, namely, all the network cards are not activated, determining that the network card state digital sequence of the electronic equipment is 000. At this time, the network card of the first priority of the network card priority sequence corresponding to the network card status digital sequence is a Wi-Fi network card, and the electronic device enables the Wi-Fi network card to communicate.
In some embodiments, each network card in the electronic device may correspond to a particular priority. After determining the candidate network cards, the electronic device may directly query the priorities corresponding to the candidate network cards, and select the candidate network card with the highest priority as the target network card.
Fig. 5 is a flowchart of a network card management method according to another embodiment of the present application. As shown in fig. 5, the network card management method provided in this embodiment includes the following steps.
S31: and in each detection period, the network card with the IP address allocated in the electronic equipment is determined as a candidate network card.
S32: and determining the target network card from the candidate network cards based on the priorities corresponding to the candidate network cards.
S33: and using the target network card to communicate.
The specific implementation manner of step S31 to step S33 may refer to the content of the specific embodiment of step S11 to step S13 in fig. 3.
S34: and if the communication abnormality of the target network card is detected, taking the candidate network card corresponding to the next priority of the target network card in the network card priority sequence as a new target network card.
In some embodiments, the network card priority sequence includes priorities of the candidate network cards. As shown in table 2 above, when the network card status digital sequence is determined to be 111, the electronic device determines that the corresponding network card priority sequence is 1.lan network card, 2.wi-Fi network card, 3.4G network card, and according to the network card priority statement, at this time, the LAN network card priority is highest, wi-Fi network card times, and 4G network card priority is lowest.
However, the candidate network card of the first priority may not normally perform communication due to a network failure or a hardware failure. At this time, in order to ensure the working stability of the electronic device, the electronic device enables the candidate network card of the next priority in the network card state digital sequence as a new target network card.
Based on the above example, when the network card state number sequence is determined to be 111, the electronic device preferentially enables the LAN network card with the first priority to be used as the target network card for communication according to the corresponding network card priority sequence. When detecting that the LAN network card of the first priority fails and cannot normally communicate, the electronic equipment starts the Wi-Fi network card of the next priority as a new target network card to communicate. In some embodiments, in the same detection period, if the Wi-Fi network card of the next priority cannot normally communicate, the electronic device may switch to the 4G network card of the lower priority for communication.
In other embodiments of the present application, if the communication abnormality of the target network card is detected, and no candidate network card corresponding to the next priority exists in the network card priority sequence, the electronic device may trigger an alarm to prompt the user of the communication abnormality.
S35: and using the new target network card to communicate.
In some embodiments, if the electronic device determines a new target network card, the new target network card is controlled to establish a communication connection with other network devices or servers, and communicate with other network devices or servers.
Fig. 6 is a flowchart of a network card management method according to another embodiment of the present application. As shown in fig. 6, the network card management method provided in this embodiment includes the following steps.
S41: and in each detection period, the network card with the IP address allocated in the electronic equipment is determined as a candidate network card.
S42: and determining the target network card from the candidate network cards based on the priorities corresponding to the candidate network cards.
S43: and using the target network card to communicate.
The specific implementation manner of step S41 to step S43 may refer to the content of the specific embodiment of step S11 to step S13 in fig. 3.
S44: judging whether the target network card is a second preset network card or not.
In some embodiments, the second preset network card is a network card corresponding to a mobile communication network, such as a 4G network card. When a network card corresponding to a mobile communication network is configured in the electronic device, the network card is generally configured as a network card with the lowest priority because of higher tariffs of the mobile communication network.
In some embodiments, because the network card of the mobile communication network is generally used to communicate with a Wi-Fi network card or a LAN network card at a higher communication cost, in order to save the communication cost, the electronic device further determines whether the target network card is a network card of the mobile communication network after determining the target network card.
In some embodiments, if the target network card is detected to be a network card of the mobile communication network and it is determined that other network cards are not activated, the electronic device accelerates the network card detection frequency to determine whether the network card of the non-mobile communication network is activated as soon as possible, so as to switch to the network card of the other non-mobile communication network in time for free communication, thereby realizing control of communication cost.
S45: and when the target network card is a second preset network card, the detection period is adjusted to be a first duration.
In some embodiments, when the target network card is a network card of the mobile communication network, the electronic device may speed up the network card detection frequency by decreasing the duration of the detection period to the first duration. The first time length is set by user definition, and the value of the first time length is not limited by the application.
S46: and when the target network card is not the second preset network card, adjusting the detection period to be a second duration.
In some embodiments, when it is determined that the target network card is a network card of a non-mobile communication network, for example, a Wi-Fi network card, a LAN network card, or the like, the electronic device adjusts the detection period to a second duration. Because the target network card is the network card of the non-mobile communication network, the cost of using the target network card to communicate is lower, the electronic equipment does not need to accelerate the network card detection frequency, and the duration of the detection period can be recovered to be a second duration, and the second duration is longer than the first duration. The second time length is set by user definition, and the specific value of the second time length is not limited by the application.
In some embodiments, if a fixed detection period is preconfigured before determining whether the target network card is the second preset network card, when it is determined that the target network card is a network card of the non-mobile communication network, the electronic device maintains the preset detection period without adjusting the same.
In some embodiments, the electronic device may perform steps S44 to S46 after determining the target network card from the candidate network cards based on the priorities corresponding to the candidate network cards.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present application.
In one embodiment of the present application, a network card management device 700 is provided, where functions that can be implemented by the network card management device 700 correspond to the network card management methods in the foregoing embodiments one by one. As shown in fig. 7, the network card management device 700 includes a candidate network card determining module 701, a target network card determining module 702, and a communication module 703. The functional modules are described in detail as follows:
a candidate network card determining module 701, configured to determine, for each detection period, a network card to which an IP address has been allocated in the electronic device as a candidate network card;
the target network card determining module 702 is configured to determine a target network card from the candidate network cards based on the priorities corresponding to the candidate network cards;
and the communication module 703 is used for performing communication by using the target network card.
The specific limitation of the network card management device 700 may be referred to as limitation of the network card management method hereinabove, and will not be described herein. The respective modules in the network card management apparatus 700 may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or independent of a processor in the electronic device, or may be stored in software in a memory in the electronic device, so that the processor may call and execute operations corresponding to the above modules.
Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application. The electronic device 800 includes, but is not limited to, any of an internet of things energy storage device, a self-mobile device, a power generation device, an intelligent home device, an intelligent wearable device, an industrial automation device, and the like. The network in which the electronic device 800 is located includes, but is not limited to, the internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (Virtual Private Network, VPN), and the like.
As shown in fig. 8, the electronic device 800 includes a communication module 801, a memory 802, a processor 803, an Input/Output (I/O) interface 804, and a bus 805. The processor 803 is coupled to the communication module 801, the memory 802, and the I/O interface 804, respectively, via a bus 805.
The communication module 801 may be a wireless communication module or a mobile communication module. The wireless communication module may provide solutions for wireless communication including wireless local area network (wireless local area networks, WLAN) (e.g., wireless fidelity (wireless fidelity, wi-Fi) network), bluetooth (BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field wireless communication technology (near field communication, NFC), infrared technology (IR), etc., as applied to the electronic device 800. The mobile communication module may provide a solution for wireless communication including 2G/3G/4G/5G, etc., applied on the electronic device 800.
Memory 802 may include one or more random access memories (random access memory, RAM) and one or more non-volatile memories (NVM). Random access memory may be read directly from and written to by the processor 803, may be used to store executable programs (e.g., machine instructions) for an operating system or other on-the-fly programs, may also be used to store data for users and applications, and the like. The random access memory may include static random-access memory (SRAM), dynamic random-access memory (dynamic random access memory, DRAM), synchronous dynamic random-access memory (synchronous dynamic random access memory, SDRAM), double data rate synchronous dynamic random-access memory (double data rate synchronous dynamic random access memory, DDR SDRAM, e.g., fifth generation DDR SDRAM is commonly referred to as DDR5 SDRAM), etc.
The nonvolatile memory may store executable programs, store data of users and applications, and the like, and may be loaded in advance into the random access memory for the processor 803 to directly read and write. The nonvolatile memory may include a disk storage device, a flash memory (flash memory).
Memory 802 is used to store one or more computer programs. One or more computer programs are configured to be executed by the processor 803. The one or more computer programs include a plurality of instructions that when executed by the processor 803 implement a network card management method for execution on the electronic device 800.
In other embodiments, the electronic device 800 further includes an external memory interface for connecting to an external memory, so as to extend the storage capability of the electronic device 800.
The processor 803 may include one or more processing units, such as: the processor 803 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors.
The processor 803 provides computing and control capabilities, for example, the processor 803 is configured to execute computer programs stored in the memory 802 to implement the network card management methods described above.
The I/O interface 804 is used to provide a channel for user input or output, e.g., the I/O interface 804 may be used to connect various input/output devices, e.g., a mouse, keyboard, touch device, display screen, etc., so that a user may enter information, or visualize information.
The bus 805 is at least used to provide a channel for communication among the communication module 801, the memory 802, the processor 803, and the I/O interface 804 in the electronic device 800.
It should be understood that the illustrated structure of the embodiment of the present application does not constitute a specific limitation on the electronic device 800. In other embodiments of the application, electronic device 800 may include more or less components than illustrated, or certain components may be combined, or certain components may be split, or different arrangements of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Embodiments of the present application further provide a computer readable storage medium, where a computer program is stored, where the computer program includes program instructions, and a method implemented when the program instructions are executed may refer to the network card management method in the foregoing embodiments of the present application.
The computer readable storage medium may be an internal memory of the electronic device according to the above embodiment, for example, a hard disk or a memory of the electronic device. The computer readable storage medium may also be an external storage device of the electronic device, for example, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the electronic device.
Further, the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the electronic device, etc.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present application and not for limiting the same, and although the present application has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made to the technical solution of the present application without departing from the spirit and scope of the technical solution of the present application.

Claims (10)

1. The network card management method is applied to the electronic equipment and is characterized by comprising the following steps of:
in each detection period, determining the network card with the IP address allocated in the electronic equipment as a candidate network card;
determining a target network card from the candidate network cards based on the priorities corresponding to the candidate network cards;
and using the target network card to communicate.
2. The network card management method of claim 1, wherein the network card management method further comprises:
if the network card with the allocated IP address is not detected, the first preset network card is determined to be a target network card.
3. The network card management method as claimed in claim 1, wherein determining the target network card from the candidate network cards based on the priorities corresponding to the candidate network cards includes:
determining a network card state digital sequence based on each candidate network card; the network card state digital sequence comprises flag bits corresponding to different network cards, the value of the flag bit corresponding to each candidate network card is a first preset value, and the values of other flag bits are second preset values;
and acquiring a network card priority sequence corresponding to the network card state digital sequence, and determining a target network card according to the network card priority sequence.
4. The network card management method of claim 3, wherein the determining the target network card according to the network card priority sequence comprises:
and taking the candidate network card corresponding to the first priority in the network card priority sequence as the target network card.
5. The network card management method according to claim 4, wherein after the communication using the target network card, the network card management method further comprises:
if the communication abnormality of the target network card is detected, taking a candidate network card corresponding to the next priority of the target network card in the network card priority sequence as a new target network card;
and using the new target network card to communicate.
6. The network card management method according to claim 1, wherein the determining the network card to which the IP address has been allocated in the electronic device as the candidate network card includes:
and reading the IP address of each network card according to the network card interface address of each network card, and determining the network card corresponding to the read IP address as the candidate network card.
7. The network card management method of claim 1, wherein the network card management method further comprises:
when the target network card is a second preset network card, the detection period is adjusted to be a first duration;
and when the target network card is not a second preset network card, the detection period is adjusted to be a second duration, the second preset network card is a network card corresponding to the mobile communication network, and the first duration is smaller than the second duration.
8. A network card management apparatus applied to an electronic device, the network card management apparatus comprising:
the candidate network card determining module is used for determining the network card with the IP address allocated in the electronic equipment as a candidate network card in each detection period;
the target network card determining module is used for determining a target network card from the candidate network cards based on the priority corresponding to the candidate network cards;
and the communication module is used for communicating by using the target network card.
9. An electronic device comprising a memory, a processor, and computer readable instructions stored in the memory and executable on the processor, wherein the computer readable instructions when executed by the processor implement the network card management method of any one of claims 1 to 7.
10. A computer readable storage medium storing computer readable instructions which when executed by a processor implement the network card management method of any one of claims 1 to 7.
CN202310640074.0A 2023-05-31 2023-05-31 Network card management method and device, electronic equipment and storage medium Pending CN116684388A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310640074.0A CN116684388A (en) 2023-05-31 2023-05-31 Network card management method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310640074.0A CN116684388A (en) 2023-05-31 2023-05-31 Network card management method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116684388A true CN116684388A (en) 2023-09-01

Family

ID=87778532

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310640074.0A Pending CN116684388A (en) 2023-05-31 2023-05-31 Network card management method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116684388A (en)

Similar Documents

Publication Publication Date Title
US10602383B1 (en) Application of machine learning for building predictive models enabling smart fail over between different network media types
CN108924274B (en) Domain name system DNS processing method and device, storage medium and electronic equipment
US20230247388A1 (en) Communication system, method and device for miniature intelligent sensor
US9094483B2 (en) System and method for collecting and evaluating statistics to establish network connections
WO2022171083A1 (en) Information processing method based on internet-of-things device, and related device and storage medium
US20130235774A1 (en) Energy-saving mobile node control method using wireless multi-interfaces
KR20120046547A (en) The method of determining group owner in peer to peer network and the device thereof
US20130275588A1 (en) Methods, devices, and systems for allocating ip address
US12041688B2 (en) Screen projection method and system
CN112333017B (en) Service configuration method, device, equipment and storage medium
US20110105024A1 (en) Transport independent service discovery
EP2114056A1 (en) System and method for controlling connections between a wireless router and unlicensed mobile access capable mobile phones
CN112994936A (en) Networking information display method, device and system and routing equipment
CN116684388A (en) Network card management method and device, electronic equipment and storage medium
CN111935337B (en) MAC address keep-alive method, equipment and storage medium of aggregation link
WO2021134252A1 (en) Inter-device communication method and apparatus, and storage medium
US10732591B2 (en) Apparatus and method for establishing communication between an operation terminal and a controller when only one controller is connected
EP3041293B1 (en) Wtp access method, management method, apparatus and system
CN115242693A (en) Network detection method, device, equipment and storage medium
CN111464664B (en) Interactive access system, method and device of multi-access equipment and access equipment
CN110753921A (en) Query request processing method and device, computer equipment and storage medium
EP2317726A1 (en) Transport independent service discovery
CN103581171B (en) A kind of file transmitting method and device
CN115150282B (en) Bandwidth dynamic allocation method, router and computer readable storage medium
CN114253733B (en) Memory management method, device, computer equipment and storage medium

Legal Events

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