Network card switching method and device, POS terminal and storage medium

By obtaining the target network card information in the POS terminal and modifying the routing and DNS information according to priority for switching, the problem of low network card switching efficiency is solved, and fast and seamless network card switching is achieved.

CN115988595BActive Publication Date: 2026-03-10SHENZHEN XINGUODU TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-12
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Existing POS terminals suffer from low network card switching efficiency and significant time loss when multiple networks are present, making it impossible to quickly switch to another network card for network communication.

Method used

By obtaining information about the target network interface card (NIC), we determine whether the target NIC's information exists in the routing table and DNS file. Based on the usage priority, we modify the target routing information and DNS information to switch the current NIC to the target NIC, thus avoiding shutting down the current NIC.

Benefits of technology

It improves the efficiency of network card switching, reduces network card switching time, and ensures the continuity and stability of network communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115988595B_ABST
    Figure CN115988595B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a network card switching method and device, a POS terminal and a storage medium. The method comprises: obtaining first network card information of a target network card; determining whether target routing information corresponding to the target network card exists in a routing table and whether target DNS information corresponding to the target network card exists in a DNS file according to the first network card information; determining a use priority of the target network card when the target routing information corresponding to the target network card exists in the routing table and the target DNS information corresponding to the target network card exists in the DNS file; and modifying the target routing information and the target DNS information according to the use priority, so that the current network card is switched to the target network card. In other words, when it is necessary to switch the current network card to the target network card for network communication, the current network card does not need to be closed, and only the target routing information and the target DNS information need to be modified according to the use priority. Therefore, the embodiments of the present application can improve the efficiency of network card switching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of network communication technology, and in particular to a network card switching method, device, POS terminal and storage medium. Background Technology

[0002] Currently, for existing POS terminals, when multiple networks exist, if the communication quality of the current network card is poor and it is necessary to switch to another network card for network communication, the current network card must first be turned off, and then the other network card to be used must be turned on before network communication can be carried out. However, this network card switching method is inefficient and time-consuming. Summary of the Invention

[0003] This application provides a network card switching method, apparatus, POS terminal, and storage medium, which can improve the efficiency of network card switching.

[0004] In a first aspect, embodiments of this application provide a network card switching method, applied to a POS terminal, comprising:

[0005] Obtain the first network interface card (NIC) information of the target NIC;

[0006] Based on the first network interface card information, determine whether the target routing information corresponding to the target network interface card exists in the routing table and whether the target DNS information corresponding to the target network interface card exists in the DNS file;

[0007] If the target route information exists in the routing table and the target DNS information exists in the DNS file, the usage priority of the target network card is determined.

[0008] The target routing information and the target DNS information are modified according to the usage priority, so that the current network card is switched to the target network card.

[0009] Optionally, in one embodiment of this application, before determining whether target routing information corresponding to the target network card exists in the routing table and whether target DNS information corresponding to the target network card exists in the DNS file based on the first network card information, the network card switching method further includes:

[0010] Obtain the second network interface card (NIC) information from the routing table, whereby the second NIC information includes the default routes for each NIC.

[0011] Delete the default route for all network interfaces in the routing table;

[0012] Determine the routing information of the backup network card, and write the second routing information of the backup network card and the target routing information into the routing table;

[0013] When the network nodes corresponding to each of the network cards are successfully activated by Dynamic Host Configuration Protocol (DHCP) or Packet Data Protocol (PDP), the DNS server addresses corresponding to each of the network nodes are obtained.

[0014] Each of the DNS server addresses is labeled to obtain labeling information, wherein the labeling information includes the correspondence between each of the DNS server addresses and each of the network interface cards.

[0015] Optionally, in one embodiment of this application, the step of labeling each of the DNS server addresses to obtain labeling information includes:

[0016] Store each of the DNS server addresses into the DNS file;

[0017] The DNS server addresses in the DNS file are labeled to obtain the labeling information.

[0018] Optionally, in one embodiment of this application, the target DNS information includes a target DNS server address, and modifying the target routing information and the target DNS information according to the usage priority includes:

[0019] When the usage priority is not a preset priority, the target DNS server address corresponding to the target network card is obtained from the DNS file according to the first network card information and the annotation information, and the target routing information corresponding to the target network card is obtained from the routing table according to the first network card information;

[0020] The target DNS server address corresponding to the target network card is arranged in the first preset arrangement position in the DNS file, wherein the first preset arrangement position corresponds to the usage priority;

[0021] The target routing information corresponding to the target network card is arranged in a second preset arrangement position in the routing table, wherein the second preset arrangement position corresponds to the usage priority.

[0022] Optionally, in one embodiment of this application, obtaining the first network card information of the target network card includes:

[0023] When the network quality score of the current network card is lower than a preset threshold, a network card switching instruction is obtained from the application process of the POS terminal. The network card switching instruction is used to instruct the current network card to be switched to the target network card.

[0024] The first network card information of the target network card is obtained according to the network card switching instruction.

[0025] Optionally, in one embodiment of this application, obtaining the first network card information of the target network card includes:

[0026] When the routing information corresponding to any network card in the routing table changes, and / or the DNS information corresponding to any network card in the DNS file changes, the first network card information of the target network card is obtained.

[0027] Optionally, in one embodiment of this application, the target routing information includes at least one of the following:

[0028] IP address, default route, subnet mask.

[0029] Secondly, embodiments of this application also provide a network card switching device, including:

[0030] The information acquisition module is used to acquire the first network card information of the target network card, the first network card information including the network card name;

[0031] The network interface card (NIC) determination module is used to determine, based on the first NIC information, whether target routing information corresponding to the target NIC exists in the routing table and whether target DNS information corresponding to the target NIC exists in the DNS file;

[0032] The priority determination module is used to determine the usage priority of the target network card when the target routing information exists in the routing table and the target DNS information exists in the DNS file.

[0033] The switching module is used to modify the target routing information and the target DNS information according to the usage priority, so that the current network card is switched to the target network card.

[0034] Thirdly, embodiments of this application also provide a POS terminal, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the network card switching method described above.

[0035] Fourthly, embodiments of this application also provide a computer-readable storage medium storing computer-executable instructions for performing the network card switching method described above.

[0036] Fifthly, embodiments of this application also provide a computer program product, including a computer program or computer instructions, wherein the computer program or computer instructions are stored in a computer-readable storage medium, a processor of a computer device reads the computer program or computer instructions from the computer-readable storage medium, and the processor executes the computer program or computer instructions to cause the computer device to perform the network card switching method as described above.

[0037] This application embodiment includes: firstly, obtaining the first network card information of the target network card, the first network card information including the network card name; then, determining whether there is target routing information corresponding to the target network card in the routing table and target DNS information corresponding to the target network card in the DNS file based on the first network card information; if there is target routing information in the routing table and target DNS information in the DNS file, determining the usage priority of the target network card; and modifying the target routing information and target DNS information according to the usage priority, so that the current network card is switched to the target network card. That is to say, when it is necessary to switch the current network card to the target network card for network communication, it is not necessary to turn off the current network card; it is only necessary to modify the target routing information and target DNS information according to the usage priority. Therefore, the efficiency of network card switching can be improved. Attached Figure Description

[0038] Figure 1 This is a flowchart of a network card switching method provided in one embodiment of this application;

[0039] Figure 2 This is a flowchart of a network card switching method provided in another embodiment of this application;

[0040] Figure 3 yes Figure 2 A flowchart of a specific method for step S250;

[0041] Figure 4 yes Figure 1 A flowchart of a specific method for step S140;

[0042] Figure 5 This is a schematic diagram of the structure of a POS terminal provided in one embodiment of this application. Detailed Implementation

[0043] To make the objectives, technical solutions, and advantages of this application clearer, the following describes this application in detail, optionally in one embodiment, with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0044] It should be noted that although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0045] This application provides a network interface card (NIC) switching method, apparatus, POS terminal, and storage medium. First, the first NIC information of the target NIC is obtained. Then, based on the first NIC information, it is determined whether target routing information corresponding to the target NIC exists in the routing table and whether target DNS information corresponding to the target NIC exists in the DNS file. If the target routing information exists in the routing table and the target DNS information exists in the DNS file, the usage priority of the target NIC is determined. The target routing information and target DNS information are modified according to the usage priority to switch the current NIC to the target NIC. That is, when it is necessary to switch the current NIC to the target NIC for network communication, it is not necessary to shut down the current NIC; only the target routing information and target DNS information need to be modified according to the usage priority. Therefore, the efficiency of NIC switching can be improved.

[0046] The embodiments of this application will be further described below with reference to the accompanying drawings.

[0047] Reference Figure 1 , Figure 1 This is a flowchart of a network card switching method provided in one embodiment of this application. The network card switching method can be applied to a POS terminal. The network card switching method includes, but is not limited to, steps S110, S120, S130 and S140.

[0048] Step S110: Obtain the first network card information of the target network card.

[0049] The first network interface card (NIC) information may include the network name. It is understood that the first NIC information may include other information besides the NIC name, which will not be listed here.

[0050] In one embodiment, when the network quality score of the current network card is lower than a preset threshold, a network card switching instruction from the application process of the POS terminal is obtained. The network card switching instruction is used to instruct the current network card to be switched to the target network card. Then, the first network card information of the target network card is obtained according to the network card switching instruction. Specifically, the upper-layer process (i.e., the application process) of the POS terminal can obtain information such as network latency and data packet loss rate over a period of time. This information is then used to score network quality proportionally, resulting in a network quality score. If the network quality score of the currently used network interface (i.e., the current network card) is lower than a preset threshold, the application process of the POS terminal sends a network card switching command to the lower-layer process. When the lower-layer process of the POS terminal receives the network card switching command from the application process, it can obtain the first network card information of the target network card based on the command, facilitating the switching of the target network card in subsequent steps. Therefore, this embodiment does not require the fixed use of a single network card for communication. The network quality can be judged based on the network quality score, thus ensuring communication quality by switching network interfaces. Furthermore, when switching networks, there is no need to go through the time-consuming process of shutting down the current network card and restarting the target network card. Instead, the network card is switched directly by setting the priority of the target network card in the routing table and DNS file, improving network card switching efficiency.

[0051] For example, assuming that the network quality is scored with a ratio of 2:1 for network latency and data packet loss rate, the network quality score is 80 points. If the preset threshold is 90 points, then the network quality score of the current network card is lower than the preset threshold. The network card switching instruction from the application process of the POS terminal can be obtained, and then the first network card information of the target network card can be obtained according to the network card switching instruction. This application embodiment does not impose specific limitations on this.

[0052] In another embodiment, when the routing information corresponding to any network interface card in the routing table changes, and / or the DNS information corresponding to any network interface card in the DNS (Domain Name System) file changes, the first network interface card information of the target network interface card can be obtained so that subsequent steps can determine whether the target routing information corresponding to the target network interface card exists in the routing table and whether the target DNS information corresponding to the target network interface card exists in the DNS file based on the first network interface card information. For example, when the IP (Internet Protocol) address of a network interface expires or is blocked by a router, the IP address becomes invalid. In this case, different network interfaces can reacquire dynamic IP addresses, network cards, default routes, subnet masks, and other information in different ways. This will also trigger changes in the routing information of the current network card in the routing table and the DNS information of the current network card in the DNS file. That is, the routing information corresponding to any network card in the routing table changes, and / or the DNS (Domain Name System) information corresponding to any network card in the DNS file changes. At this time, the first network card information of the target network card can be obtained. Different network interfaces can reacquire dynamic IP addresses, network cards, default routes, subnet masks, and other information through PDP (Packet Data Protocol) activation; or, different network interfaces can obtain dynamic IP addresses, network cards, default routes, subnet masks, and other information issued by DHCP (Dynamic Host Configuration Protocol). This application embodiment does not impose specific limitations on this.

[0053] Step S120: Determine whether the target routing information corresponding to the target network card exists in the routing table and whether the target DNS information corresponding to the target network card exists in the DNS file based on the first network card information.

[0054] In one embodiment, the target routing information may include IP address, default route, subnet mask, etc., without specific limitations. The target DNS information may include target DNS server address and other information, without specific limitations.

[0055] It is understandable that the routing table is the one currently in use.

[0056] Step S130: If the target routing information exists in the routing table and the target DNS information corresponding to the target network card exists in the DNS file, determine the usage priority of the target network card.

[0057] It should be noted that the priority of the target network interface card (NIC) is closely related to the target routing information and the target DNS information corresponding to the target NIC.

[0058] Step S140: Modify the target routing information and target DNS information according to the usage priority to switch the current network card to the target network card.

[0059] In this embodiment, by employing the network card switching method including steps S110 to S140 described above, the first network card information of the target network card is first obtained. The first network card information may include the network card name. Then, based on the first network card information, it is determined whether there is target route information corresponding to the target network card in the routing table and whether there is target DNS information corresponding to the target network card in the DNS file. If there is target route information corresponding to the target network card in the routing table and target DNS information corresponding to the target network card in the DNS file, the usage priority of the target network card is determined. The target route information and target DNS information are modified according to the usage priority so that the current network card is switched to the target network card. That is to say, when it is necessary to switch the current network card to the target network card for network communication, it is not necessary to shut down the current network card. It is only necessary to modify the target route information and target DNS information according to the usage priority. Therefore, the efficiency of network card switching can be improved.

[0060] It is worth noting that the relevant technologies do not differentiate between the DNS server addresses stored in the DNS file for network interface cards (NICs). In other words, all NICs use the same set of DNS server addresses. However, for NICs to switch freely, the DNS server addresses in the DNS file need to be managed, because different NICs may not use the same DNS server addresses.

[0061] Based on this, refer to Figure 2 In one embodiment of this application, before performing step S120, the network switching method may include, but is not limited to, steps S210, S220, S230, S240 and S250.

[0062] Step S210: Obtain the second network interface information in the routing table. The second network interface information includes the default routes of each network interface.

[0063] Step S220: Delete the default routes for all network cards in the routing table.

[0064] It is understandable that the routing table stores default routes corresponding to several network cards. The number of network cards is unlimited; it can be 1, 2, 5, or more. No specific restrictions are imposed here.

[0065] In one embodiment, before deleting the default routes of all network cards in the routing table, the default routes of all network cards in the routing table can be stored in a buffer to save data.

[0066] Step S230: Determine the routing information of the backup network card, and write the second routing information of the backup network card and the target routing information of the target network card into the routing table.

[0067] In this step, the backup network card is a non-designated network card, and the target network card is a designated network card.

[0068] In one embodiment, the number of backup network interface cards (NICs) is not limited; it can be one or more. Correspondingly, the number of routing information entries for each backup NIC can also be one or more; this embodiment does not impose specific limitations on this. It should be noted that the number of routing information entries for each backup NIC corresponds one-to-one with the number of backup NICs.

[0069] In one embodiment, the routing information of the backup network card and the target routing information of the target network card may include IP address, default route, subnet mask, etc., without specific limitations.

[0070] Step S240: When the network nodes corresponding to each network card are successfully activated via DHCP or PDP, obtain the DNS server address corresponding to each network node.

[0071] In step S240, each network interface card (NIC) includes a target NIC and a backup NIC, etc. The network used to connect each network node can be a virtual network node, such as Wi-Fi (Wireless-Fidelity), Ethernet, GPRS (General Packet Radio Service), etc., without specific limitations.

[0072] In one embodiment, when the IP (Internet Protocol) address of a network interface expires or is blocked by a router, causing the IP address to become invalid, the network interface can be activated via PDP to reacquire information such as dynamic IP address, network card, default route, and subnet mask. This triggers changes to the routing information of the current network card in the routing table and the DNS information of the current network card in the DNS file. At this time, the second network card information in the routing table can be obtained, which includes the default routes of each network card. Then, the default routes of all network cards in the routing table are stored in a buffer. Next, the default routes of all network cards in the routing table are deleted, and the routing information of the backup network card and the target route information of the target network card are written into the routing table. After the network nodes corresponding to each network card are successfully activated via PDP, the DNS server addresses corresponding to each network node can be obtained for subsequent steps to mark each DNS server address. This embodiment of the application does not impose specific limitations on this.

[0073] In another embodiment, when the IP address of a network interface expires or is blocked by a router, causing the IP address to become invalid, the network interface can obtain information such as the dynamic IP address, network card, default route, and subnet mask issued by DHCP. Then, it triggers changes to the routing information of the current network card in the routing table and the DNS information of the current network card in the DNS file. At this time, the second network card information in the routing table can be obtained, and the default routes of all network cards in the routing table are stored in the buffer. Then, the default routes of all network cards in the routing table are deleted, and the routing information of the backup network card and the target route information of the target network card are written into the routing table. After the network nodes corresponding to each network card are issued via DHCP, the DNS server addresses corresponding to each network node can be obtained so that each DNS server address can be marked in subsequent steps. This embodiment of the application does not impose specific limitations on this.

[0074] Step S250: Label each DNS server address to obtain labeling information, wherein the labeling information includes the correspondence between each DNS server address and each network card.

[0075] It is understandable that the correspondence between DNS server addresses and network cards is one-to-one. For example, network card A corresponds to the first DNS server address, and network card B corresponds to the second DNS server address. No specific restrictions are made here.

[0076] In this embodiment, by employing the network card switching method including steps S210 to S250, before determining whether there is target route information corresponding to the target network card in the routing table and target DNS information corresponding to the target network card in the DNS file based on the first network card information, the second network card information, including the default routes of each network card, can be obtained from the routing table. Then, the default routes of all network cards in the routing table are deleted. Next, the routing information of the backup network card and the target route information of the target network card are written into the routing table. When the network nodes corresponding to each network card are successfully activated through DHCP or PDP, the DNS server addresses corresponding to each network node are obtained, and each DNS server address is marked to obtain the marking information. The marking information includes the correspondence between the DNS server address and the network card, so that the target DNS server address corresponding to the target network card can be queried based on the correspondence between the DNS server address and the network card (i.e., the marking information).

[0077] refer to Figure 3 In one embodiment of this application, step S250 is further described. Step S250 may include, but is not limited to, steps S310 and S320.

[0078] Step S310: Store the addresses of each DNS server in the DNS file.

[0079] Step S320: Mark each DNS server address in the DNS file to obtain the marking information.

[0080] In this embodiment, by adopting the network card switching method including the above steps S310 to S320, each DNS server address can be stored in a DNS file, and then each DNS server address in the DNS file can be marked to obtain marking information, so that the DNS server address corresponding to the target network card can be queried according to the correspondence between DNS server address and network card (i.e., marking information).

[0081] refer to Figure 4 In one embodiment of this application, step S140 is further described. When the target DNS information includes the target DNS server address, step S140 may include, but is not limited to, steps S410, S420 and S430.

[0082] Step S410: When the priority used is not the preset priority, obtain the target DNS server address corresponding to the target network card from the DNS file according to the first network card information and the labeling information, and obtain the target routing information corresponding to the target network card from the routing table according to the first network card information.

[0083] In this step, different network cards have different usage priorities, which can be set according to the actual situation; no specific restrictions are imposed here. Additionally, the preset priority can be the highest priority, the second highest priority, etc., which can be set according to the actual situation; no specific restrictions are imposed here.

[0084] Understandably, the higher the priority, the earlier the target network card will be used.

[0085] For example, assuming the target network interface card (NIC) has the second-highest priority, while the default priority is the highest, then the usage priority is not the default priority. Therefore, the target DNS server address corresponding to the target NIC can be obtained from the DNS server addresses corresponding to multiple NICs (including the target NIC and / or the backup NIC) in the DNS file based on the first NIC information and the annotation information. Simultaneously, the target routing information corresponding to the target NIC can also be obtained from the routing table based on the first NIC information.

[0086] Step S420: Arrange the target DNS server address corresponding to the target network card in the first preset arrangement position of the DNS file, wherein the first preset arrangement position corresponds to the usage priority.

[0087] In this step, the first preset arrangement position is the first arrangement position in the DNS file, without specific restrictions. The first preset arrangement position corresponds to the usage priority; that is, the earlier the first preset arrangement position appears, the higher the usage priority, and the later the first preset arrangement position appears, the lower the usage priority. For example, if the first preset arrangement position is the first arrangement position in the DNS file, then the usage priority corresponding to the first preset arrangement position is the highest.

[0088] It is understandable that in the DNS file, different positions correspond to different DNS server addresses for different network cards. The earlier the position is in the list, the earlier the DNS server address corresponding to that position is used, and the earlier the network card corresponding to that DNS server address is used. In other words, the network card corresponding to the DNS server address has a higher priority.

[0089] Step S430: Arrange the target routing information corresponding to the target network card in the second preset arrangement position in the routing table, wherein the second preset arrangement position corresponds to the usage priority.

[0090] In this step, the second preset arrangement position is the first arrangement position in the routing table, without specific restrictions. The second preset arrangement position corresponds to the usage priority; that is, the earlier the second preset arrangement position appears, the higher the usage priority, and the later the second preset arrangement position appears, the lower the usage priority. For example, if the second preset arrangement position is the first arrangement position in the routing table, then the usage priority corresponding to the second preset arrangement position is the highest.

[0091] It is understandable that in the routing table, different positions correspond to different network cards with different routing information. The earlier the position is in the list, the earlier the routing information corresponding to that position is used, and the earlier the network card corresponding to that routing information is used. In other words, the network card corresponding to the routing information has a higher priority.

[0092] It is understood that the routing information may include the target routing information of the target network card, the routing information of the backup network card, and the routing information of the current network card, without any specific restrictions.

[0093] In this embodiment, by employing the network card switching method including steps S410 to S430, when the priority used is not the preset priority, the target DNS server address corresponding to the target network card can be obtained from the DNS file according to the first network card information and the annotation information, and the target routing information corresponding to the target network card can be obtained from the routing table according to the first network card information. Then, the target DNS server address corresponding to the target network card is arranged in the first preset arrangement position of the DNS file, and the target routing information corresponding to the target network card is arranged in the second preset arrangement position of the routing table. That is to say, by modifying the arrangement position of the target DNS server address corresponding to the target network card in the DNS file and the arrangement position of the target routing information corresponding to the target network card in the routing table, the priority of the target network card in the routing table and the DNS file can be increased, thereby achieving the purpose of switching the network card.

[0094] In addition, one embodiment of this application also provides a network card switching device, which includes:

[0095] The first information acquisition module is used to acquire the first network card information of the target network card;

[0096] The network interface card (NIC) determination module is used to determine whether target routing information corresponding to the target NIC exists in the routing table and whether target DNS information corresponding to the target NIC exists in the DNS file based on the first NIC information.

[0097] The priority determination module is used to determine the usage priority of the target network interface when the target routing information exists in the routing table and the target DNS information exists in the DNS file.

[0098] The switching module is used to modify the target routing information and target DNS information according to the usage priority, so that the current network card is switched to the target network card.

[0099] Furthermore, before determining whether target route information exists in the routing table and whether target DNS information corresponding to the target network card exists in the DNS file based on the first network card information, the aforementioned network card switching module also includes:

[0100] The second information acquisition module is used to acquire the second network interface card (NIC) information in the routing table. The second NIC information includes the default routes of each NIC.

[0101] The delete module is used to delete the default routes of all network cards in the routing table;

[0102] The writing module is used to determine the routing information of the backup network card and write the second routing information and the target routing information of the backup network card into the routing table;

[0103] The third information acquisition module is used to obtain the DNS server address corresponding to each network node when the network node corresponding to each network card is successfully activated by Dynamic Host Configuration Protocol (DHCP) or Packet Data Protocol (PDP).

[0104] The annotation module is used to annotate each DNS server address to obtain annotation information, which includes the correspondence between each DNS server address and each network interface card.

[0105] Furthermore, the aforementioned annotation module specifically includes:

[0106] The storage module is used to store the addresses of each DNS server into a DNS file;

[0107] The annotation submodule is used to annotate each DNS server address in the DNS file to obtain annotation information.

[0108] Furthermore, when the target DNS information includes the target DNS server address, the aforementioned switching module specifically includes:

[0109] The fourth information acquisition module is used to obtain the target DNS server address corresponding to the target network card from the DNS file based on the first network card information and the labeling information when the priority is not the preset priority, and to obtain the target routing information from the routing table based on the first network card information;

[0110] The first modification submodule is used to arrange the target DNS server address corresponding to the target network card in the first preset arrangement position of the DNS file, wherein the first preset arrangement position corresponds to the usage priority;

[0111] The second modification submodule is used to arrange the target routing information in a second preset arrangement position in the routing table, wherein the second preset arrangement position corresponds to the usage priority.

[0112] Furthermore, the aforementioned first information acquisition module specifically includes:

[0113] The instruction acquisition module is used to acquire a network card switching instruction from the application process of the POS terminal when the network quality score of the current network card is lower than a preset threshold. The network card switching instruction is used to instruct the current network card to be switched to the target network card.

[0114] The first information acquisition submodule is used to obtain the first network card information of the target network card according to the network card switching command.

[0115] Furthermore, the aforementioned first information acquisition module specifically includes:

[0116] The second information acquisition submodule is used to acquire the first network card information of the target network card when the routing information corresponding to any network card in the routing table changes, and / or the DNS information corresponding to any network card in the DNS file changes.

[0117] Additionally, refer to Figure 5 An embodiment of this application also provides a POS terminal, the POS terminal 200 including a memory 202, a processor 201 and a computer program stored on the memory 202 and executable on the processor 201.

[0118] The processor 201 and the memory 202 can be connected via a bus or other means.

[0119] Memory 202, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory 202 may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory 202 may optionally include memory remotely located relative to processor 201, and these remote memories can be connected to processor 201 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0120] The non-transient software program and instructions required to implement the network card switching method of the above embodiments are stored in the memory 202. When executed by the processor 201, the network card switching method in the above embodiments is executed, for example, the method described above is executed. Figure 1 Method steps S110 to S140 in the text Figure 2 Method steps S210 to S250 Figure 3 Method steps S310 to S320 Figure 4 Method steps S410 to S430.

[0121] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0122] Furthermore, one embodiment of this application also provides a computer-readable storage medium storing computer-executable instructions that are executed by a processor or controller, for example, by a processor in the above-described device embodiment, causing the processor to execute the network interface card switching method described above, and perform the above-described actions. Figure 1 Method steps S110 to S140 in the text Figure 2 Method steps S210 to S250 Figure 3 Method steps S310 to S320 Figure 4 Method steps S410 to S430.

[0123] Furthermore, one embodiment of this application also provides a computer program product, including a computer program or computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer program or computer instructions from the computer-readable storage medium and executes the computer program or computer instructions, causing the computer device to perform the network interface card (NIC) switching method described in the above embodiment, for example, performing the above-described... Figure 1 Method steps S110 to S140 in the text Figure 2 Method steps S210 to S250 Figure 3 Method steps S310 to S320 Figure 4 Method steps S410 to S430.

[0124] It will be understood by those skilled in the art that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

Claims

1. A network card switching method applied to a POS terminal, characterized in that, The method comprises the following steps: obtaining first network card information of a target network card; obtaining second network card information in a routing table, wherein the second network card information comprises default routes of each network card, deleting the default routes of all the network cards in the routing table, determining routing information of a backup network card, writing the routing information of the backup network card and target routing information into the routing table, obtaining DNS server addresses corresponding to each network node when the network node is activated successfully through a dynamic host configuration protocol (DHCP) or a packet data protocol (PDP), storing each of the DNS server addresses into a DNS file, marking each of the DNS server addresses in the DNS file to obtain marking information, and determining whether the target routing information corresponding to the target network card exists in the routing table and whether target DNS information corresponding to the target network card exists in the DNS file according to the first network card information, wherein the marking information comprises a correspondence between each of the DNS server addresses and each of the network cards, and the target DNS information comprises a target DNS server address; determining a use priority of the target network card when the target routing information exists in the routing table and the target DNS information exists in the DNS file; when the use priority is not a preset priority, obtaining the target DNS server address corresponding to the target network card from the DNS file according to the first network card information and the marking information, obtaining the target routing information corresponding to the target network card from the routing table according to the first network card information, arranging the target DNS server address corresponding to the target network card at a first preset arrangement position of the DNS file, arranging the target routing information corresponding to the target network card at a second preset arrangement position in the routing table, and switching a current network card to the target network card, wherein the first preset arrangement position corresponds to the use priority, and the second preset arrangement position corresponds to the use priority.

2. The method of claim 1, wherein, The method comprises the following steps: when the network quality score of the current network card is lower than a preset threshold, obtaining a network card switching instruction from an application process of the POS terminal, wherein the network card switching instruction is used to indicate that the current network card is switched to the target network card; obtaining the first network card information of the target network card according to the network card switching instruction.

3. The method of claim 1, wherein, The method comprises the following steps: when routing information corresponding to any one of the network cards in the routing table changes and / or DNS information corresponding to any one of the network cards in the DNS file changes, obtaining the first network card information of the target network card.

4. The method of claim 1, wherein, The target routing information at least comprises one of the following: an IP address, a default route, and a subnet mask.

5. A network card switching apparatus, characterized by comprising: The method comprises the following steps: an information acquisition module, configured to obtain first network card information of a target network card; The network card determination module is configured to: acquire second network card information in a routing table, the second network card information including default routes of each network card; delete the default routes of all network cards in the routing table; determine routing information of a backup network card; write the routing information of the backup network card and target routing information into the routing table; when each network node corresponding to each network card is activated successfully through a dynamic host configuration protocol (DHCP) or a packet data protocol (PDP), acquire a DNS server address corresponding to each network node; store each DNS server address to a DNS file; mark each DNS server address in the DNS file to obtain marking information; and determine whether the target routing information corresponding to the target network card exists in the routing table and whether target DNS information corresponding to the target network card exists in the DNS file according to the first network card information, wherein the marking information includes a correspondence between each DNS server address and each network card. The priority determination module is configured to determine a use priority of the target network card when the target routing information exists in the routing table and the target DNS information exists in the DNS file. The switching module is configured to: when the use priority is not a preset priority, acquire a target DNS server address corresponding to the target network card from the DNS file according to the first network card information and the marking information; acquire the target routing information corresponding to the target network card from the routing table according to the first network card information; arrange the target DNS server address corresponding to the target network card at a first preset arrangement position of the DNS file and arrange the target routing information corresponding to the target network card at a second preset arrangement position in the routing table; and switch a current network card to the target network card, wherein the first preset arrangement position corresponds to the use priority, and the second preset arrangement position corresponds to the use priority.

6. A POS terminal comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the network card switching method of any one of claims 1 to 4 when executing the computer program.

7. A computer readable storage medium storing computer executable instructions for performing the network card switching method of any one of claims 1 to 4.

Citation Information

Patent Citations

  • Network connection method and terminal equipment

    CN103368977A

  • Method and system for automatic IP address information configuration by multi-network card server

    CN107592209A