CN116827777A - Data acquisition method and network configuration method suitable for n target devices with same IP addresses, electronic device and data acquisition system - Google Patents

Data acquisition method and network configuration method suitable for n target devices with same IP addresses, electronic device and data acquisition system Download PDF

Info

Publication number
CN116827777A
CN116827777A CN202310480535.2A CN202310480535A CN116827777A CN 116827777 A CN116827777 A CN 116827777A CN 202310480535 A CN202310480535 A CN 202310480535A CN 116827777 A CN116827777 A CN 116827777A
Authority
CN
China
Prior art keywords
virtual network
network card
address
data acquisition
space
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.)
Granted
Application number
CN202310480535.2A
Other languages
Chinese (zh)
Other versions
CN116827777B (en
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.)
Beijing Xushui Interconnection Technology Co ltd
Original Assignee
Beijing Xushui Interconnection Technology Co 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 Beijing Xushui Interconnection Technology Co ltd filed Critical Beijing Xushui Interconnection Technology Co ltd
Priority to CN202310480535.2A priority Critical patent/CN116827777B/en
Priority claimed from CN202310480535.2A external-priority patent/CN116827777B/en
Publication of CN116827777A publication Critical patent/CN116827777A/en
Application granted granted Critical
Publication of CN116827777B publication Critical patent/CN116827777B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a network configuration method, a data acquisition method and electronic equipment using the same, wherein the electronic equipment can be used for data acquisition of n target equipment with the same IP address, and n is a positive integer greater than or equal to 2; the electronic equipment defines n access paths which are communicated with n target devices in a one-to-one correspondence mode between a host network naming space and n virtual network spaces of the electronic equipment through n virtual network space and n virtual network card pairs arranged in the electronic equipment, and the electronic equipment respectively performs data acquisition on the n target devices with the same IP address through the n access paths. The scheme of the embodiment of the invention not only can realize real-time and synchronous data acquisition of n target devices with the same IP address by the same electronic device, but also can not increase hardware cost and ensure the data acquisition efficiency of the n target devices with the same IP address.

Description

Data acquisition method and network configuration method suitable for n target devices with same IP addresses, electronic device and data acquisition system
Technical Field
The present invention relates to the field of network communication technologies, and in particular, to a data acquisition method and a network configuration method suitable for n target devices with the same IP address, an electronic device applying the network configuration method, a data acquisition system applying the electronic device, a storage medium and a computer program product.
Background
In an actual application scene, the situation that the IP address segments where a plurality of target devices are located conflict, or even a large number of IP addresses contained in the segments directly conflict and cannot be changed often occurs, and the reason for the situation is many, for example, some target devices solidify the IP addresses in the original design stage, so that the IP addresses cannot be modified; if the software and hardware required for changing the key or authorization of the network configuration of the target device is lost or expired, the IP address of the target device cannot be modified; in other cases, the reason why the IP address of the target device cannot be changed may also be that the implementation cost of changing the IP is too high, for example, in the case that n target devices are connected to m terminals that rely on the IP address, if the IP address is changed for n target devices, the n×m target devices all need to change the opposite-end IP address correspondingly, which is obviously very high.
Because the IP addresses of the target devices are identical and cannot be changed, in the field of wide operation of the internet of things and embedded devices such as smart home, medical informatization and robot factories, the situation that the relevant network configurations such as a plurality of IP addresses and subnet masks need to be collected and important data on the target devices cannot be changed often occurs. In the prior art, in order to realize data acquisition of n target devices with the same IP address, two common methods are: firstly, n collectors are used, each collector collects data of one target device, and then the collected data of the target device are collected and stored; and secondly, using one collector to collect data on n target devices when repeatedly plugging and unplugging. The former can realize real-time simultaneous acquisition, but the hardware cost of data acquisition is very high, the program is tedious and the reliability is poor, and the latter can save the hardware cost of data acquisition, but cannot realize real-time synchronous acquisition of data of all target devices. It can be seen that there is a need in the art to provide a new solution to effectively address the scenario where n target devices with the same IP address need to be data collected.
Disclosure of Invention
The embodiment of the invention provides a network configuration and data acquisition scheme, which at least solves the problems encountered when data acquisition is carried out on n target devices with the same IP addresses in the prior art.
In a first aspect, an embodiment of the present invention provides an electronic device, which may be used for data acquisition of n target devices, where the n target devices have the same IP address, and n is a positive integer greater than or equal to 2;
the electronic equipment defines n access paths which are communicated with n target equipment in a one-to-one correspondence manner between a host network naming space and n virtual network spaces of the electronic equipment through n virtual network spaces and n groups of virtual network card pairs arranged in the electronic equipment, wherein each access path is defined by the host network naming space, a group of virtual network cards and one virtual network space;
each access path is in one-to-one communication with one of the target devices having the same IP address via the virtual network space defining the access path.
In a second aspect, an embodiment of the present invention provides a data acquisition system, which can be used for data acquisition of n target devices, where the n target devices have the same IP address, and n is a positive integer greater than or equal to 2; the system comprises:
A switch; and
the agent is connected to a corresponding network interface of the switch, wherein the agent is the electronic equipment provided by the embodiment of the invention, and the n target equipment is correspondingly communicated with n access paths of the electronic equipment one by one through the corresponding network interface of the switch;
and the data acquisition equipment is connected to the corresponding network interface of the switch and is used for acquiring data of the n target devices through the electronic equipment.
In a third aspect, an embodiment of the present invention provides a data acquisition system, which may be used for data acquisition of n target devices, where the n target devices have the same IP address, and n is a positive integer greater than or equal to 2; the system comprises:
a switch; and
the data collector is connected to a corresponding network interface of the switch, wherein the data collector is the electronic equipment provided by the embodiment of the invention, and the n target devices are correspondingly communicated with n access paths of the electronic equipment one by one through the corresponding network interfaces of the switch.
In a fourth aspect, an embodiment of the present invention provides a network configuration method suitable for data collection of n target devices with the same IP address, including:
Creating n virtual network spaces, and respectively distributing a first network card for each virtual network space;
respectively creating n groups of virtual network card pairs, wherein each group of virtual network card pairs comprises a first virtual network card and a second virtual network card which are mutually communicated;
respectively connecting a first virtual network card in each group of virtual network card pairs to a host network naming space, and respectively connecting a second virtual network card in each group of virtual network card pairs with one virtual network space in a one-to-one correspondence manner so as to define n access paths by the host network naming space, n groups of virtual network cards and n virtual network spaces, wherein each access path is defined by the host network naming space, one group of virtual network cards and one virtual network space;
setting IP addresses for each first network card, each first virtual network card and each second virtual network card respectively, wherein the first network card is set to have the same IP address section with the target equipment connected with the virtual network space where the first network card is positioned, the IP address section of the first network card is not overlapped with the IP address sections of the first virtual network card and the second virtual network card in each group of virtual network card pairs, the first virtual network card and the second virtual network card in the same group of virtual network card pairs have the same IP address section, and the IP address section of the first network card and the IP address section of the first virtual network card and the second virtual network card in each group of virtual network card pairs are also not overlapped with the IP address section of the host network card;
And connecting each virtual network space to one target device in a one-to-one correspondence manner, so as to communicate each access path with n target devices in a one-to-one correspondence manner.
In a fifth aspect, an embodiment of the present invention provides a data collection method applicable to n target devices with the same IP address, including:
performing network configuration based on the network configuration method described in the fourth aspect;
mapping the ports to be acquired of the n target devices to second virtual network cards corresponding to virtual network spaces connected with the corresponding target devices one by one respectively so as to form first mapping ports corresponding to the ports to be acquired one by one on the second virtual network cards;
the first mapping ports are mapped to host network cards of the host network namespaces one by one through the first virtual network cards which are communicated with the corresponding second virtual network cards one by one respectively so as to form second mapping ports which are in one-to-one correspondence with the first mapping ports on the host network cards, wherein the second mapping ports are different from the ports to be acquired and are different from each other;
and respectively carrying out data acquisition on the corresponding target equipment on the data acquisition equipment through each second mapping port of the host network card.
In a sixth aspect, an embodiment of the present invention provides a data collection method applicable to n target devices with the same IP address, including:
performing network configuration based on the network configuration method described in the fourth aspect;
a first program unit for data acquisition is respectively installed in each virtual network space;
and operating a first program unit in each virtual network space to acquire data of the corresponding target device, and outputting the acquired data to the target storage module through a corresponding first virtual network card communicated with the corresponding virtual network space.
In a seventh aspect, an embodiment of the present invention provides an electronic device, including:
a memory for storing executable instructions; and
a processor for executing executable instructions stored in a memory that when executed by the processor implement method steps of any of the embodiments of the present invention.
In an eighth aspect, the present invention provides a storage medium having stored thereon a computer program which when executed by a processor performs the steps of the above method.
In a ninth aspect, the present invention provides a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, cause the computer to perform the method according to any of the embodiments of the present invention.
The embodiment of the invention has the beneficial effects that: according to the scheme provided by the embodiment of the invention, through combining the virtual network space and the virtual network card pair, n access paths which are respectively communicated with n target devices with the same IP addresses in a one-to-one correspondence manner are constructed on the same electronic device (also called a host machine in the embodiment of the invention), so that the data acquisition of the n target devices with the same IP addresses is possible through the same electronic device through the n access paths, thereby not only realizing the real-time and synchronous data acquisition of the n target devices with the same IP addresses, but also not increasing the hardware cost and ensuring the data acquisition efficiency of the n target devices with the same IP addresses; meanwhile, the data acquisition of each target device is realized through an independent access path separated by different virtual network spaces, and the different virtual network spaces are connected to the host network naming space of the electronic device through a virtual network card specially adapted to the virtual network spaces, so that the defined n access paths are isolated from each other and do not interfere with each other, and the reliability of data acquisition of a plurality of target devices with the same IP address is higher.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a network configuration method suitable for data collection of n target devices with the same IP address according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method flow for data collection of n target devices with the same IP address according to an embodiment of the present invention;
FIG. 3 schematically shows a flow chart of a method of data acquisition for n target devices of the same IP address according to another embodiment of the invention;
FIG. 4 schematically illustrates a functional block diagram of an electronic device in accordance with an embodiment of the present invention;
FIG. 5 schematically illustrates a functional block diagram of an electronic device in accordance with another embodiment of the present invention;
FIG. 6 schematically illustrates a functional block diagram of an application of an electronic device in accordance with an embodiment of the present invention;
FIG. 7 schematically illustrates a frame structure of a data acquisition system to which the electronic device shown in FIG. 6 is applied, according to an embodiment of the present invention;
FIG. 8 schematically illustrates a functional block diagram of an application of another embodiment of the present invention to an electronic device;
FIG. 9 schematically illustrates a frame structure of a data acquisition system to which the electronic device shown in FIG. 8 is applied, according to an embodiment of the present invention;
FIG. 10 schematically illustrates a functional block diagram of an application of the electronic device according to another embodiment of the present invention;
FIG. 11 schematically illustrates a functional block diagram of a data link of a data acquisition system employing the electronic device shown in FIG. 10 in accordance with an embodiment of the present invention;
FIG. 12 schematically illustrates a functional block diagram of a system architecture of a data acquisition system employing the electronic device illustrated in FIG. 10 in accordance with an embodiment of the present invention;
FIG. 13 schematically shows a functional block diagram of an application of the electronic device according to another embodiment of the present invention;
FIG. 14 is a functional block diagram of a system architecture of a data acquisition system employing the electronic device shown in FIG. 13 in accordance with an embodiment of the present invention;
fig. 15 is a functional block diagram of an electronic device according to yet another embodiment of the present invention;
fig. 16 is a schematic structural diagram of an electronic device according to an embodiment of the invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be noted that, without conflict, the embodiments of the present application and features of the embodiments may be combined with each other.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
In the present application, "module," "device," "system," and the like refer to a related entity, either hardware, a combination of hardware and software, or software in execution, as applied to a computer. In particular, for example, an element may be, but is not limited to being, a process running on a processor, an object, an executable, a thread of execution, a program, and/or a computer. Also, the application or script running on the server, the server may be an element. One or more elements may be in processes and/or threads of execution, and elements may be localized on one computer and/or distributed between two or more computers, and may be run by various computer readable media. The elements may also communicate by way of local and/or remote processes in accordance with a signal having one or more data packets, e.g., a signal from one data packet interacting with another element in a local system, distributed system, and/or across a network of the internet with other systems by way of the signal.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," comprising, "or" includes not only those elements but also other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
In order to solve the problems that in the prior art, when n pieces of target equipment with the same IP address are subjected to data acquisition, hardware cost is too high or real-time performance is difficult to guarantee, and an acquisition flow is complex, the embodiment of the invention aims to provide a solution for simultaneously carrying out data acquisition on n pieces of target equipment with the same IP address by using one data acquisition device. In the original design, the inventor thought that a plurality of network cards are arranged in one data collector, and different IP is allocated to each network card respectively, so that one data collector is connected to n target devices respectively through the plurality of network cards, but in practice, the inventor found that under the scheme, since the IP addresses of n target devices are identical, and routes to the same IP address are one and only one in the routing table of the data collector of the plurality of network cards (more arrangement can cause coverage), even if one data collector can be connected to n target devices with the same IP address respectively through the multi-network card design, in this design, only one target device can be actually used for normal data collection at the same time. Therefore, how to realize reliable data acquisition of n target devices with the same IP address at the same time under the condition that only one data acquisition device is used is a key technical problem to be solved. In order to solve the problem, the inventor finally researches a solution based on the virtual network space technology and the virtual network equipment technology through a great amount of experiments and verification. The virtual network space technology mentioned in the embodiment of the present invention includes, but is not limited to, a technology of creating virtual network spaces isolated from each other on a network by means of a network namespace or a virtual machine, etc., and thus, the "virtual network space" mentioned in the embodiment of the present invention may refer to a network namespace isolated from each other on a network, or may refer to a virtual machine isolated from each other on a network, etc. The solution will be described in detail below in connection with specific embodiments.
In order to more clearly describe the technical conception and implementation of the solution proposed by the inventor, the solution of the embodiment of the present invention will be first described in detail from the viewpoint of implementation method in conjunction with the accompanying drawings of the specification.
Fig. 1 schematically illustrates a network configuration method according to an embodiment of the present invention, where an execution subject of the method may be a processor or a control module of an electronic device, and the electronic device may be a smart tablet, a personal PC, a computer, a cloud server, a gateway device, an agent, a data collector, or the like. By applying the network configuration method to the electronic equipment, n mutually isolated and mutually noninterfere access paths can be constructed on the electronic equipment, so that the data acquisition equipment can respectively acquire real-time and synchronous data of n target equipment with the same IP address by utilizing the constructed n access paths, and further, the data acquisition of the n target equipment with the same IP address based on one data acquisition equipment becomes possible, the cost of data acquisition of the n target equipment with the same IP address is reduced, the acquisition flow is simplified, and the acquisition efficiency and the data transmission reliability are improved. As shown in fig. 1, a network configuration method applicable to data collection of n target devices with the same IP address in an embodiment of the present invention includes:
Step S11: creating n virtual network spaces, and respectively distributing a first network card for each virtual network space;
step S12: respectively creating n groups of virtual network card pairs, wherein each group of virtual network card pairs comprises a first virtual network card and a second virtual network card which are mutually communicated;
step S13: respectively connecting a first virtual network card in each group of virtual network card pairs to a host network naming space, and respectively connecting a second virtual network card in each group of virtual network card pairs with one virtual network space in a one-to-one correspondence manner so as to define n access paths by the host network naming space, n groups of virtual network cards and n virtual network spaces, wherein each access path is defined by the host network naming space, one group of virtual network cards and one virtual network space;
step S14: setting IP addresses for each first network card, each first virtual network card and each second virtual network card respectively, wherein the first network card is set to have the same IP address section with the target equipment connected with the virtual space where the first network card is positioned, the IP address section of the first network card is not overlapped with the IP address sections of the first virtual network card and the second virtual network card in each group of virtual network card pairs, the first virtual network card and the second virtual network card in the same group of virtual network card pairs are set to have the same IP address section, and the IP address section of the first network card and the IP address section of the first virtual network card and the second virtual network card in each group of virtual network card pairs are also set to be not overlapped with the IP address section of the host network card;
Step S15: and connecting each virtual network space to one target device in a one-to-one correspondence manner, so as to communicate each access path with n target devices in a one-to-one correspondence manner.
In step S11, the virtual network space may be n network namespaces created by adopting a Linux Network Namespace (network namespaces, hereinafter referred to as NM) technology, where NM technology is a technology for implementing network environment isolation, and since each network namespace has an independent network protocol, each network namespace can be isolated from each other, and not interfere with each other. In other possible embodiments, the virtual network space may also be formed by installing virtual machines on a host machine, where each virtual machine forms a virtual network space, and n virtual network spaces may be created by installing n virtual machines. After creating the virtual network space, the embodiment of the invention also allocates a first network card for each virtual network space, that is, each virtual network space corresponds to a first network card, and the total number of the configured first network cards is n. Taking the numbers #2 to #n+1 of the n virtual network spaces as an example, it may be specifically implemented that the 2 nd to n+1 th first network cards of the host are respectively allocated to the n virtual network spaces, and each virtual network space obtains a first network card. It should be noted that, n is a positive integer greater than or equal to 2, and its specific value is related to the number of target devices with the same IP address of the data to be collected, and specifically is the same as the number of target devices with the same IP address of the data to be collected. As a possible implementation manner, since the virtual network spaces are independent network spaces isolated from each other, the first network card allocated for each virtual network space may be a physical network card or a virtual vlan network card created based on vlan technology, which is not limited by the embodiment of the present invention. The physical network card specifically refers to a network interface device actually existing on the host, and the virtual vlan network card is not an actually existing network interface device, which is a vlan virtual network card generated by adding the physical network card to a different vlan. In a specific application, by adding one physical network card into a plurality of vlans, a plurality of virtual vlan network cards can be generated, so that the number of the physical network cards required by a host is reduced, and the hardware cost and the deployment and maintenance cost of the host are reduced. The specific generation mode of the virtual vlan-card can be realized by referring to the prior art, and the embodiments of the present invention are not described herein in detail. It should be noted that, the host in the embodiment of the present invention specifically refers to an electronic device capable of executing the network configuration method of the embodiment of the present invention, which is applicable to data collection of n target devices with the same IP address.
In step S12, a pair of virtual network cards that are in one-to-one communication may be created by using Linux Veth technology (a virtual network device technology provided by a Linux operating system), where each set of virtual network card pairs includes two virtual network cards (referred to as a first virtual network card and a second virtual network card in the embodiment of the present invention), and the two virtual network cards are mutually communicated. Preferably, n groups of virtual network card pairs are created in the embodiment of the present invention, that is, the number of pairs of created virtual network card pairs is the same as the number of virtual network spaces. Therefore, each virtual network space can be correspondingly connected with a group of virtual network card pairs respectively, so that an access path between the host machine network naming space and each virtual network space is constructed by utilizing the virtual network card pairs, and the access path between the host machine network naming space and each virtual network space cannot cause route coverage because the IP address fields of target devices to be accessed are the same, namely, only one target device can be actually accessed at the same time.
Specifically, in step S13, the first virtual network card of the virtual network card pair may be connected to the host network namespace, and the second virtual network card of the virtual network card pair may be connected to the virtual network space, because there are n groups of virtual network card pairs, there are n first virtual network cards actually connected to the host network namespace, and each of the opposite ends of the first virtual network cards, that is, the second virtual network card interconnected with the opposite ends of the first virtual network card, is respectively connected to one virtual network card, thereby forming n total access paths from the host network namespace to the virtual network space, and each access path is defined by the host network namespace, a group of virtual network cards and one virtual network space, so that each access path is isolated by not only one virtual network space network, but also access paths without route conflicts can be constructed, that is, based on the virtual network pairs and the virtual network space, the routes of the access paths isolated from each other are also isolated from each other, and do not conflict, so that the data acquisition of the same target device using one data acquisition device to n IP devices can be achieved.
Preferably, in order to construct an access path where no routing conflict exists, the IP address segment of the first network card may be set to be completely misaligned with the IP address segments of the first virtual network card and the second virtual network card. For the first network cards, since they are allocated to the respective virtual network spaces, i.e. network isolation is performed via the virtual network spaces, the IP address segments (even IP addresses) of all the first network cards may be set to be the same, i.e. the n first network cards isolated via the virtual network spaces have the same IP address segment or the same IP address, and the IP address segment of each first network card is also set to be the same as the IP address segment of the target device directly connected to the virtual network space where it is located, thereby enabling the respective virtual network spaces to be directly connected to the respective target devices having the same IP address, so as to achieve respective network accesses to the respective target devices. For the first virtual network card and the second virtual network card, in order to realize normal network communication of the first virtual network card and the second virtual network card in the same group of virtual network card pairs, in a specific configuration, the first virtual network card and the second virtual network card in the same group of virtual network card pairs are set to have the same IP address segment but different IP addresses, and in order to realize constructing access paths with non-conflict routes, the IP address segments between the first virtual network cards in different groups of virtual network card pairs are required to be set to be different. In step S14, it is assumed that the IP addresses of all the target devices to be collected are 192.168.0.1/24, the IP address of the first network card may be set to 192.168.0.n/24, the IP address of the first virtual network card may be set to 192.168.n.1/24, the IP address of the second virtual network card may be set to 192.168.n/24, so that each of the first network card, the first virtual network card and the second virtual network card may be set in the corresponding IP address, the IP addresses set for the n first virtual network card and the n second virtual network card are different, for example, the IP addresses of the first virtual network card may be set to 192.168.1.1/24, the IP address of the second first virtual network card may be set to 192.168.2.1/24, and so on, the IP address of the second virtual network card may be set to 192.168.1/24, the first virtual network card may be set to 192.168.1/24, the second virtual network card may be set to the second virtual network card, the second virtual network card may be set to the same as the second virtual network card, and the second virtual network card may have a different virtual network card may have a virtual network interface between the same virtual network interface. In some embodiments, taking the numbers #2 to #n+1 of the n virtual network spaces as examples, the IP address of the first network card of each virtual network space may be set according to the number of the virtual network space, for example, for the virtual network space numbered #2, the IP address of the corresponding first network card may be set to 192.168.0.2/24, and for the virtual network space numbered #n, the IP address of the corresponding first network card may be set to 192.168.0.n/24. Because the first network cards are isolated by the virtual network space, the network environments and the routing information of the first network cards are isolated and do not interfere with each other, in other embodiments, the first network cards of the n virtual network spaces may be set to the same IP address, for example, all set to 192.168.0.2/24. Therefore, since the virtual network space isolates the network configuration of the first network card, each virtual network space is connected to the host network naming space through a group of virtual network card pairs with different IP addresses, the IP address segments of the first network card and the second virtual network card in each group of virtual network card pairs are completely misaligned, and the IP address segments between the first virtual network card in the different groups of virtual network card pairs are also completely misaligned, n access paths with completely non-conflicting routes are formed between the host network naming space and the virtual network space, so that the n access paths can be used for respectively carrying out data acquisition on n target devices with the same IP address. More preferably, in order to form n access paths with completely non-conflicting routes between the host network naming space and the virtual network space, in a specific implementation, the IP address segment of the first network card and the IP address segments of the first virtual network card and the second virtual network card in each set of virtual network card pairs are also set to be non-coincident with the IP address segment of the host network card, that is, the IP address segment of the first network card is non-coincident with the IP address segment of the host network card, and the IP address segments of the first virtual network card and the second virtual network card in each set of virtual network card pairs are also non-coincident with the IP address segment of the host network card.
In step S15, each virtual network space is connected to one target device in a one-to-one correspondence manner, so that each access path is communicated with n target devices in a one-to-one correspondence manner, and therefore, each target device realizes network and route isolation through one virtual network space and a first network card allocated to the virtual network space, and each virtual network space is connected to a host network naming space through an independent access path with completely non-conflicting routes, therefore, the host network naming space can be connected to corresponding target devices with the same IP addresses by using n access paths, and synchronous and real-time data acquisition of the target devices is realized.
In a specific application, the network configuration can be performed on the host machine, so that data acquisition can be performed on n target devices with the same IP address at the same time by using one data acquisition device. Specifically, the host may provide proxy service for the data acquisition device performing data acquisition in a proxy gateway manner, or the host may be further configured as a data acquirer capable of performing data acquisition on n target devices having the same IP address at the same time. Two possible embodiments will be described in detail below.
First, taking a host machine as an example of providing a proxy service for a data acquisition device performing data acquisition in a proxy gateway manner, fig. 2 schematically shows a method flow of data acquisition applicable to n target devices with the same IP address, and as shown in fig. 2, the implementation includes:
step S21: performing network configuration on a host;
step S22: mapping the ports to be acquired of the n target devices to second virtual network cards corresponding to virtual network spaces connected with the corresponding target devices one by one respectively so as to form first mapping ports on the second virtual network cards, wherein the first mapping ports correspond to the ports to be acquired of the corresponding target devices one by one;
step S23: the first mapping ports mapped to the second virtual network cards are respectively mapped to the host network cards of the host network namespaces through the first virtual network cards communicated with the corresponding second virtual network cards one by one so as to form second mapping ports corresponding to the first mapping ports one by one on the host network cards, wherein the second mapping ports are set to be different from the ports to be acquired and the second mapping ports are different from each other;
step S24: and respectively carrying out data acquisition on the corresponding target equipment on the data acquisition equipment through each second mapping port of the host network card.
In step S21, specifically, the network configuration method shown in fig. 1 and suitable for data collection of n target devices with the same IP address is used to perform network configuration on the host, so as to create n virtual network spaces and n virtual network card pairs on the host, and form n access paths corresponding to and communicating with the n target devices one by one respectively.
In the embodiment of the invention, the host is taken as an agent to realize the data acquisition of n target devices with the same IP addresses, in the mode, the data acquisition device directly sends a data acquisition request to the host, the host needs to forward the data request from the data acquisition device to the target device, and the host also needs to feed back the data packet returned by the target device to the data acquisition device through the host. However, for the data acquisition device located outside the host, the data interaction between the data acquisition device and the host, that is, sending a data acquisition request to the host and receiving an acquisition data packet fed back by the host, are realized based on the host network card, and since only one host network card, that is, only one host network card has an IP address, and the IP address field of the host network card is different from that of each group of first virtual network cards, in order to realize data acquisition of the external data acquisition device on n pieces of target devices with the same IP address, that is, in order to enable the external data acquisition device to utilize multiple access paths inside the host, multiple access ports are provided for the data acquisition device in a port mapping manner. Based on this, the embodiment of the present invention needs to form, through the processing in step S23, a second mapping port corresponding to the ports to be collected of the target devices on the host network card, so that the external data collection device can send a data collection request to the host through the second mapping port and receive the collected data packet fed back by the host through the first virtual network card, thereby realizing data collection of multiple target devices. Meanwhile, for the host, as the first network card allocated to each virtual network space is respectively connected with one target device through the processing of step S21, and each virtual network space is connected to the host network card of the host network naming space through a group of virtual network card pairs, and thus n mutually independent and mutually noninterfere access paths are created inside the host, but in the mutually noninterfere access paths, the virtual network card pairs and the first network card of each access path are in different IP address fields, which can cause the phenomenon that when the host acting as an agent uses the same access path to forward data, the virtual network card pairs and the target devices in the same virtual network space cannot be routed to each other.
In step S22, the ports to be collected of n target devices connected to the virtual network space may be mapped onto the second virtual network cards correspondingly connected to the corresponding virtual network space one by one, so as to realize network isolation of access ports of n target devices with the same IP address. In the example, assuming that n target devices have n to-be-acquired ports, the numbers of the to-be-acquired ports are #1 to #n, the numbers of the virtual network space are #2 to #n+1, the target device #1 is connected to the virtual network space #2, the target device #2 is connected to the virtual network space #3, and so on, in step S22, the to-be-acquired ports of the target device #1 are mapped onto the second virtual network card of the virtual network card pair connected to the virtual network space #2, and so on, the to-be-acquired ports of the n target devices are mapped onto the second virtual network card connected to the corresponding virtual network space, so that first mapping ports corresponding to the to-be-acquired ports are formed on each second virtual network card, and thus, isolation and access address conversion of the to-be-acquired ports of the n target devices are realized through the network isolation characteristic of the virtual network space and the network communication function provided by the virtual network card pair, so that independent network communication can be performed with the host network card through the virtual network space and the virtual pair. Because the network isolation is performed, and the target device, the virtual network space and the virtual network card pair respectively have different network cards, the first mapping port mapped to the second virtual network card may be set to be the same as the port to be acquired of the corresponding target device, and, for example, assuming that the port to be acquired of n target devices is 8080, the first mapping port of n target devices on n second virtual network cards may still be set to 8080, so that the external device, such as the data collector, can access the port to be acquired of n target devices without distinction, but because the first mapping port performs network isolation through the virtual network space, route conflict is avoided while the external device performs non-differential access to the target devices with the same IP address. Of course, it will be understood by those skilled in the art that, in other possible embodiments, the first mapping port may be set to be different from the port to be acquired of the corresponding target device, so long as it is satisfied that the port number is not repeatedly set on the monolithic network card, which is not limited by the embodiment of the present invention. As a possible implementation manner, in step S22, port mapping is specifically performed in each virtual network space by using one iptables dnat+snat isolated from each other, that is, in each virtual network space, one iptables dnat+snat is used to map the ports to be acquired of the target devices connected to the virtual network space to the connected second virtual network cards, so that the ports to be acquired of the n target devices are mapped to the n second virtual network cards in a one-to-one correspondence manner by using the n iptables dnat+snat isolated from each other, so that first mapping ports corresponding to the ports to be acquired are formed on the second virtual network cards in a one-to-one correspondence manner. In a specific application, the number of the ports to be collected on each target device may be arbitrary, and not only one, but also two or more ports to be collected on each target device may be mapped onto the second virtual network cards corresponding to the virtual network spaces to which the target device is connected, where the difference is that, in a scenario that two or more ports to be collected are provided on the target device, two or more first mapping ports are provided on the corresponding second virtual network cards, that is, the number of the mapping ports is the same as the number of the ports to be collected and corresponds to one. It should be noted that iptables is a component tool for setting, maintaining and checking IP packet filtering rules of Linux kernels, and implements filtering and matching of IP packets by defining different tables and setting different rule links in the tables. The snat and the dnat in the iptables are used for performing destination network address conversion, which can rewrite the destination IP address of the IP packet, based on the network address conversion of the snat and the dnat, if one IP packet is matched in the corresponding link, all packets belonging to the same stream are automatically converted and then can be routed to the correct host or network, therefore, the embodiment of the invention creates an IP address conversion rule belonging to the corresponding virtual network space under each virtual network space by the snat and the dnat in the iptables respectively, can realize the mutually isolated mapping of the ports to be acquired of n target devices, enables the IP of the target devices in different access paths to be converted to different second virtual network cards, and each conversion is mutually isolated through the virtual network space, thereby realizing the mutually isolated IP packet rewriting of n target devices with the same IP address, enabling the data request pointing to the corresponding second virtual network space to be connected with the corresponding virtual network space and enabling the data request to be connected with the corresponding virtual network card of the target device. In the embodiment of the invention, the port mapping is performed by using the iptables DNAT+SNAT, so that the IP rewriting of the source address and the target address of the data request can be simultaneously realized, and the external data acquisition equipment can perform data acquisition on n target equipment with the same IP address through the proxy and the port mapping of the host.
In step S23, in the embodiment of the present invention, the first mapping port mapped to the second virtual network card is mapped to the host network card of the host network naming space, so as to realize access to the first mapping port on each second virtual network card by the host network card, and further forward the data acquisition request received by the host network card to the corresponding second virtual network card. Specifically, each first mapping port may be mapped to a host network card of the host network naming space through a first virtual network card in one-to-one communication with a corresponding second virtual network card, for example, by creating n iptables dnat+snat in the host network naming space to map first mapping ports of n second virtual network cards in one-to-one correspondence with each other to the host network card, so as to form second mapping ports in one-to-one correspondence with the first mapping ports in the host network naming space, that is, each first mapping port mapped to the second virtual network card will correspond to a second mapping port on the host network card respectively, so that the external device may access the first mapping ports on the corresponding second virtual network card through accessing the second mapping ports of the host network card, thereby implementing access to the ports to be acquired of the corresponding target device, and simultaneously enabling the external device to receive the feedback data packet from the first virtual network card through the host. Preferably, the second mapping ports on the host network card mapped to the host network namespace are set to be different from the ports to be acquired, and each second mapping port is different from each other, so that the ports from different virtual network cards can be mapped to the same network card, and the external device can reach the ports to be acquired of the corresponding target device through accessing the different second mapping ports on the same host network card. Taking n to-be-acquired ports as an example, the port numbers of each first mapping port and to-be-acquired port are 8080, and after mapping the n to-be-acquired ports onto a host network card, the formed n second mapping ports may be respectively set as 8180, 8280, …, 8n80, or may be set as other non-repeated n port numbers. It should be noted that, in the embodiment of the present invention, the number of the first mapping ports and the number of the second mapping ports are both corresponding to the number of the ports to be acquired on the target device, so it can be understood that, in the case that the number of the ports to be acquired on the target device is other numbers, such as 2n, the number of the second mapping ports formed after mapping onto the host network card is the same as the number of the ports to be acquired, such as 2 n.
Because the processing in steps S22 and S23 is performed, the x to-be-acquired ports of the n target devices with the same IP address are isolated and mapped in the virtual network space to x first mapping ports, the x first mapping ports are isolated and do not conflict with each other, the first mapping ports are mapped to the host network card in the host network naming space through the network link formed by the pair of virtual network cards, and the second mapping ports formed on the host network card are set to be different from each other, so that n routes with different isolated and destination addresses can be formed on the host to access the n target devices with the same IP address at the same time, where x can be any positive integer. Therefore, in step S24, data may be acquired from the data acquisition device through each second mapping port of the host network card, and the data acquisition device may direct different access ports when accessing each second mapping port because each second mapping port is different from each other and is not repeated, and simultaneously, since the IP address fields between each group of virtual network card pairs and the host network card are completely misaligned, and the IP address fields between each group of virtual network card pairs and the first network card are also completely misaligned, the internal routing forwarding is implemented through the rule of mapping from the first mapping port to the second mapping port, that is, iptables dnat+snat, so when reaching the first mapping port via the second mapping port, the routing inside the host is misaligned and non-conflicting, and since the networks of the first mapping port are isolated from each other, the routing conflict does not occur when reaching the to-be-acquired port of the target device via the first mapping port. Based on the method, the data acquisition equipment can simultaneously acquire data of n target equipment with the same IP address through the proxy of the host, so that synchronous and real-time data acquisition of the n target equipment with the same IP address based on one data acquisition equipment is realized, the data acquisition efficiency is improved, and the data acquisition cost is reduced. It should be noted that, in the implementation mode taking the host as the proxy, the adopted data acquisition device may be any mature existing product for data acquisition in the prior art, and the data acquisition of n target devices with the same IP address can be realized only by accessing x second mapping ports of the host network card of the host, and the task of solving the routing conflict is completely borne by the host through the internal network configuration and port mapping thereof.
Next, a method of data collection applied to n target devices having the same IP address will be described in detail, taking the host itself as an example of a data collector capable of simultaneously collecting data for n target devices having the same IP address. In which, fig. 3 schematically shows a method flow of data collection of n target devices with the same IP address according to an embodiment, and as shown in fig. 3, the implementation includes:
step S31: performing network configuration on a host;
step S32: a first program unit for data acquisition is respectively installed in each virtual network space;
step S33: and operating a first program unit in each virtual network space to acquire data of the corresponding target device, and outputting the acquired data to the target storage module through a corresponding first virtual network card communicated with the corresponding virtual network space.
In step S31, specifically, the network configuration method shown in fig. 1 and suitable for data collection of n target devices with the same IP address is used to perform network configuration on the host, so as to create n virtual network spaces and n virtual network card pairs on the host, and form n access paths corresponding to and communicating with the n target devices one by one respectively. Unlike the embodiment shown in fig. 2, in the embodiment shown in fig. 3, in step S32 and step S33, data collection is performed on n target devices with the same IP address directly by using the data collection program installed on the host and n independent access paths created in step S31. In order to realize data acquisition of n target devices with the same IP addresses by directly using n independent access paths on a host, in the embodiment of the invention, a first program unit for data acquisition is respectively installed in each virtual network space to realize network isolation of each first program unit, so that each first program unit can respectively and correspondingly acquire data of the target devices connected with the corresponding virtual network space under each virtual network space, namely, n first program units are installed in n virtual network spaces, data acquisition can be respectively performed on n target devices with the same IP addresses, wherein the first program units can be used for acquiring data of any port on the target devices. After the data of each target device is collected, in the mode of the embodiment of the invention, each first program unit is a second virtual network card and a first virtual network card which are connected through corresponding virtual network spaces, and the collected data is output to the target storage module. The target storage module may be an external storage module or a storage module located in a host network namespace. For the target storage module located outside the host, after the first program unit transmits the collected data to the first virtual network card, the first virtual network card will send a network request to the host network card in the host network naming space, after the host network naming space receives the network request of the first virtual network card, the host network naming space can use iptables SNAT to change the source address of the network request from the first virtual network card into the host network card address, and then forward the request with the source address changed to the external storage module. In the embodiment in which the target storage module is a storage module located in the host network namespace, the first virtual network cards of each group are respectively connected to the host network namespace, so that the collected data of the corresponding target device can be directly stored in the storage module of the host network namespace through the first virtual network cards. Therefore, in the embodiment of the invention, the host machine can be directly utilized to synchronously and real-time data acquisition of n target devices with the same IP address by carrying out network configuration on the host machine and directly installing a first program unit in each virtual network space, thereby reducing the data acquisition cost and improving the data acquisition efficiency. It should be noted that, the first program unit installed in the virtual network space may be any program product for data acquisition in the prior art, and the implementation manner of storing the acquired data acquired by the first program unit into the corresponding storage module may also be implemented by installing an existing storage program on the target storage module, which is not limited in the embodiment of the present invention.
In practical application, the above network configuration method may be applied to a specific electronic device, so as to obtain an electronic device that can be used for data acquisition on n target devices with the same IP address. Wherein fig. 4 and 5 show schematic block diagrams of the electronic device in different embodiments.
As shown in fig. 4, taking an example that an electronic device only includes one physical network card and a first network card is a virtual vlan network card, when the electronic device is configured by using the method shown in fig. 1, specifically, n virtual vlan network cards are divided from the physical network card of the electronic device by using vlan technology, n virtual vlan network cards 101 are respectively allocated to virtual network spaces one by one, and a unique physical network card 10 of the electronic device is allocated to a host network naming space 20 of the electronic device, where the host network naming space refers to a default network naming space of the electronic device, and the vlan technology may be 802.1qvlan technology. Thus, as shown in fig. 4, taking n as a value of 2 as an example, in the electronic device 100, two mutually isolated access paths are defined between the host network namespace 20 and the virtual network space 30 through the two virtual network spaces 30 and the two virtual network card pairs 40. Each virtual network card pair 40 includes a first virtual network card 401 and a second virtual network card 402, the first virtual network card 401 and the second virtual network card 402 are correspondingly communicated, the first virtual network card 401 in each virtual network card pair 40 is connected to the host network naming space 20, the second virtual network card 402 in each virtual network card pair 40 is respectively connected to one virtual network space 30 in a one-to-one correspondence manner, and each virtual network space 30 is respectively connected to one target device 200 in a one-to-one correspondence manner, so that the electronic device 100 is respectively connected to n target devices with the same IP address through each access path in a network isolation manner, that is, the electronic device realizes access isolation of n target devices with the same IP address through n access paths. It should be noted that, in the vlan network card in the embodiment of the present invention, the virtual network card is generated by adding a physical network card to different vlan, and a plurality of virtual vlan network cards can be obtained by adding one physical network card to different multiple vlan through vlan technology (Virtual Local Area Network technology, virtual lan technology).
As a possible implementation, the virtual network card pair is created based on virtual network device technology. In order to avoid the routing conflict of n access paths, the n target devices with the same IP address can be used for synchronous and real-time data acquisition, the IP address segment of the first network card is not overlapped with the IP address segments of the first virtual network card and the second virtual network card in each group of virtual network card pairs, the IP address segment of the first network card and the IP address segments of the first virtual network card and the second virtual network card in each group of virtual network card pairs are also not overlapped with the IP address segment of the host network card, namely, the IP address segment of the first network card is not overlapped with the IP address segment of the first virtual network card in each group of virtual network card pairs, the IP address segment of the first network card is not overlapped with the IP address segment of the host machine, and the IP address segment of the first virtual network card in each group of virtual network card pairs is not overlapped with the IP address segment of the host machine. In order to realize interconnection of the first virtual network card and the second virtual network card in the same group of virtual network card pairs, the first virtual network card and the second virtual network card in the same group of virtual network card pairs are set to have the same IP address segment but different IP addresses. Preferably, in order to achieve direct interconnection between the target device and the virtual network space, the IP address field of the first network card of each virtual network space is set to be the same as the IP address field of the target device, and the IP address of the first network card of each virtual network space may be set to be the same or different according to the requirement because each virtual network space is logically isolated.
As shown in fig. 5, taking an example that the electronic device includes n+1 physical network cards, when the network configuration is performed on the electronic device by the method shown in fig. 1, specifically, n physical network cards 102 in the n+1 physical network cards of the electronic device are respectively allocated to each virtual network space 30 one by one to serve as the first network card of each virtual network space 30, and the remaining physical network cards 103 of the electronic device are host network cards allocated to the host network namespaces 20 to serve as host network namespaces of the host network namespaces, where the host network namespaces refer to default network namespaces of the electronic device. Thus, as shown in fig. 5, taking n as a value of 3 as an example, in the electronic device 100, three mutually isolated access paths are defined between the host network naming space 20 and the virtual network space 30 through the three virtual network spaces 30 and the three virtual network card pairs 40, and each access path is defined by the host network naming space 20, the set of virtual network cards 40 and one virtual network space 30. Each virtual network card pair 40 includes a first virtual network card 401 and a second virtual network card 402, the first virtual network card 401 and the second virtual network card 402 are correspondingly communicated, the first virtual network card 401 in each virtual network card pair 40 is connected to the host network naming space 20, the second virtual network card 402 in each virtual network card pair 40 is respectively connected to one virtual network space 30 in a one-to-one correspondence manner, and each virtual network space 30 is respectively connected to one target device 200 in a one-to-one correspondence manner, so that the electronic device 100 is respectively connected to n target devices with the same IP address through each access path in a network isolation manner, that is, the electronic device realizes access isolation of n target devices with the same IP address through n access paths. In order to avoid routing collision of n access paths, the n access paths can be used for synchronous and real-time data acquisition of n target devices with the same IP address, in the embodiment of the present invention, the IP address segment of the first network card is not coincident with the IP address segments of the first virtual network card and the second virtual network card in each set of virtual network card pairs, the IP address segment of the first network card, and the IP address segments of the first virtual network card and the second virtual network card in each set of virtual network card pairs are also not coincident with the IP address segment of the host network card, that is, the IP address segment of the first network card is not coincident with the IP address segment of the first virtual network card in each set of virtual network card pairs, and the IP address segment of the first network card is not coincident with the IP address segment of the host machine. In order to realize interconnection of the first virtual network card and the second virtual network card in the same group of virtual network card pairs, the first virtual network card and the second virtual network card in the same group of virtual network card pairs are set to have the same IP address segment but different IP addresses. Preferably, in order to achieve direct interconnection between the target device and the virtual network space, the IP address field of the first network card of each virtual network space is set to be the same as the IP address field of the target device, and the IP address of the first network card of each virtual network space may be set to be the same or different according to the requirement because each virtual network space is logically isolated.
It should be noted that, as shown in fig. 4 and 5, connecting the first virtual network card to the host network naming space means that the first virtual network card of the virtual network card pair is set in the host network naming space, connecting the second virtual network card to the virtual network space means that the second virtual network card of the virtual network card pair is set in the virtual network space, and connecting the target device to the virtual network space means that network connection between the target device and the first network card allocated for the virtual network space is established.
A specific application manner of the electronic device in data acquisition of n target devices with the same IP address will be described below. As described in the foregoing method section, in a specific application, the electronic device may be selected to be used as a proxy gateway, so as to implement data collection of n target devices with the same IP address in a manner of combining with the data collection device, or the electronic device may be selected to be configured as a data collector, so that data collection of n target devices with the same IP address is implemented by using the electronic device itself. Fig. 6 to 12 show schematic block diagrams of the electronic device in different application modes.
Taking the electronic device as a proxy gateway as shown in fig. 6 as an example, the method described in fig. 2 may be used to map and proxy the port to be acquired of the target device in the electronic device to form a first mapped port 60 located in the virtual network space and a second mapped port 70 located in the host network namespace, and redirect the received data acquisition access request to the second mapped port 20 to the corresponding first mapped port 60 through n iptables dnat+snat rules created in the host network namespace, and further redirect the data acquisition access request received by the first mapped port 60 to the port to be acquired of the corresponding target device through n iptables dnat+snat rules created in the virtual network space, so as to provide access proxy and route to n target devices with the same IP address for the data acquisition device. In this embodiment, as shown in fig. 6, a physical network card is selected as the first network card of the electronic device, so as to form a data acquisition system including a data acquisition device 300 and an electronic device 100, where, in the data acquisition system, the electronic device 100 may be connected to one of the target devices with the same IP address through the first network card 101, and the data acquisition device 300 may access and acquire data to the n target devices through n access paths of the electronic device through the host network card and the second mapping port of the electronic device, specifically, the data acquisition device 300 may establish a network connection with the host network card 10 of the electronic device through the physical network card thereof, and may access the second mapping port of the electronic device to acquire data to the n target devices. The number of the first mapping ports 60 located in the virtual network space and the number of the second mapping ports 70 located in the host network naming space are the same as and correspond to the number of the ports to be collected of the target device one by one, and the second mapping ports are also set to have different port numbers from the ports to be collected, and the port numbers of the second mapping ports are different from each other.
In other possible embodiments, when the electronic device is used as the proxy gateway, the network management switch may be used to construct the data acquisition system, and in an embodiment in which the network management switch is used to construct the data acquisition system, the electronic device may be implemented as shown in fig. 8, that is, different from the electronic device shown in fig. 6, in that the first network card of the electronic device is implemented as a vlan network card. Thus, as shown in fig. 9, the data acquisition system may be constructed, and includes a network management switch 400, an electronic device 100 and a data acquisition device 300, where the electronic device is also a proxy service that serves as a proxy to provide access to n target devices with the same IP address in a proxy gateway manner. In this embodiment, unlike the architecture of the data acquisition system shown in fig. 7, the data acquisition device 300 and the target devices in the embodiment shown in fig. 9 are both access interfaces connected to the network management switch, and the electronic device 100 is a trunk interface connected to the network management switch 400, so that the data acquisition device 300 only needs to send a request to the electronic device 100 connected to the trunk interface, and can access each target device via the host network card and the second mapping port of the electronic device 100, and the route and access path from the second mapping port to the target device are completely provided by the electronic device. In this embodiment, the first network card of the electronic device is a vlan network card, the network management switch adopted by the data acquisition system is a network management switch supporting the 802.1q vlan technology, the network interface of the network management switch comprises a trunk interface and an access interface, the vlan network card of the electronic device is converted into an entity network interface, namely the access interface, through the network management switch, under the system architecture, only one physical network card is required to be arranged in the electronic device, so that the hardware cost of the electronic device is further reduced, and when the target device is increased, only the vlan network card is required to be newly added in the electronic device, and the vlan id and the access interface are required to be newly added on the network management switch, so that the hardware shutdown of the electronic device serving as an agent is not required to be performed for new physical insertion or line connection, the network management switch can directly, simply and uniformly convert the vlan network of the electronic device into an entity network input/output interface, the network topology structure is clear, the deployment and maintenance are simpler and more convenient, and the data acquisition cost can be further reduced. In the embodiment shown in fig. 7 and fig. 9, the data acquisition device 300 is exemplified by a data acquisition device integrating data acquisition and storage, it may be understood that in a specific application, the data acquisition device 300 may be replaced by an external storage device including a data acquisition device having only an acquisition function and a target storage module, where in the embodiment of fig. 7, only the external storage device needs to be connected to the data acquisition device, and in the embodiment of fig. 9, only the external storage device needs to be connected to the access interface of the network management switch. It should be further noted that, the data acquisition device 300 used in the embodiments of fig. 7 and 9 may be any device having a data acquisition function in the prior art, and the data acquisition manner and the storage manner of the acquired data may be configured and used according to the existing functions provided by the existing data acquisition device 300, which is not limited in this embodiment of the present invention.
As shown in fig. 10, taking an electronic device as a data collector as an example, the electronic device may be configured by using the method described in fig. 3, so as to install a first program unit 90 for data collection in a virtual network space and create n iptables SNAT rules in a host network naming space, so as to directly collect data on a target device directly connected to a corresponding virtual network space by starting each first program unit 90, push the collected data to a first virtual network card 401 directly connected to the host network naming space through a second virtual network card 402, redirect a source address of a collected data packet to the host network card through the n iptables SNAT rules created in the host network naming space by the first virtual network card 401, and send the redirected data packet to a target storage module through the host network card by the first virtual network card 401, so as to realize data collection and storage of n target devices with the same IP address. In this embodiment, each first program unit 90 in the virtual network space of the electronic device may directly access the port to be collected of the corresponding target device through the first network card of the virtual network space where the first program unit 90 is located, so as to collect data of the corresponding target device, while the host network naming space communicates with each first program unit 90 through the first virtual network card serving as the NAT gateway, and the collected data is redirected by using the iptables SNAT rule and then output to the target storage module through the host network card. The first network card of the electronic device shown in fig. 10 adopts a physical network card, thus, as shown in fig. 11 and 12, taking the target storage module 500 as an external storage device as an example, a data collection system including the electronic device 100 and the storage device 500 may be formed, under the data collection system, the target device is directly connected with a virtual network space of the electronic device 100 via the first network card, the electronic device 100 performs data collection on the target device through a first program unit in the virtual network space, and forwards the collected data to the external storage device 500 via the virtual network card pair and the host network card, thereby realizing data collection on n target devices with the same IP address, where the target storage module 500 establishes a network connection with the electronic device through the host network card, and the electronic device 100 modifies a source address of the collected data through a NAT gateway (i.e. the first virtual network card) creating n iptables SNAT rules in the host network naming space, and then sends the modified source address to a designated access port of the target storage module 500, so as to realize data storage on the target storage module 500. In other embodiments, the target storage module may also be directly disposed in a host network namespace of the electronic device, where the formed data acquisition system only needs one electronic device and directly connects the electronic device to n target devices with the same IP address.
In other embodiments, the electronic device as the data collector shown in fig. 13 may also be combined with a network management switch to form a data collection system of another embodiment, as shown in fig. 13, where in this embodiment, a vlan network card is adopted as a first network card of the electronic device in fig. 13, where the data collection system needs to be built by means of the network management switch, and taking an example that the target storage module is directly set in a host network naming space of the electronic device, where the built data collection system is shown in fig. 14, where the data collection system includes a network management switch 400 supporting vlan technology and an electronic device 100 connected to a trunk interface of the network management switch, and n target devices 200 are respectively in communication with n access paths of the electronic device through corresponding access interfaces of the network management switch. It should be noted that, in a specific application, when the electronic device as the data collector is combined with the network management switch to construct the data collection system, in a scenario that the target storage module is an external storage device, only the external storage device is required to be connected to the access interface of the network management switch, so that the data collection system conforming to the corresponding modification can be constructed.
It should be noted that, in other possible embodiments, when the data acquisition system is constructed, the data acquisition system may be constructed by not only the foregoing embodiments, but also any combination of a switch in the prior art, a data acquisition device in the prior art (may optionally use a data acquisition device that collects and stores the data together, or may use a data acquisition device that only includes a collection function and an external storage module), an electronic device and a target storage module mentioned in any embodiment (may be built in the data acquisition device, or may be built in the electronic device, or may be separately provided on a separate external device), where, for example, when a physical network card is used as a first network card of the electronic device, a switch (where the switch may be a normal switch, that is, another type of switch other than a network management switch that supports vlan technology) may also be used to construct a data acquisition system that meets the requirements; for another example, the electronic device may be configured as a data collector provided with the target storage module (i.e. the electronic device with the built-in target storage module is formed by the configuration of fig. 3), or may be configured as a data collector without the target storage module (in this case, the target storage module may be provided on an external device, and the construction of the data acquisition system may be implemented by connecting the external device to a host network card), etc., and it is understood that, when the electronic device is changed according to the foregoing embodiment, only the architecture of the data acquisition system needs to be adjusted accordingly to obtain the data acquisition system with different modifications.
In addition, it should be further noted that, because the n target devices with the same IP address and the n target devices with the same IP address segment but different IP addresses have similar problems of data acquisition and access, it is not easy to understand for those skilled in the art that the above scheme of the embodiment of the present invention is applicable to data acquisition of the n target devices with the same IP address, and simultaneously, the scheme is also applicable to data acquisition of the n target devices with the same IP address segment, so that the meaning of "the n target devices with the same IP address" mentioned in the embodiment of the present invention may be interpreted as including both the n target devices with the same IP address and the n target devices with the same IP address segment.
Fig. 15 schematically illustrates an electronic device according to another embodiment of the present invention, which is implemented as shown in the figure to include:
a memory 600 for storing executable instructions; and
a processor 700 for executing executable instructions stored in a memory, which when executed by the processor implement the steps of the network configuration method for data acquisition of n target devices with identical IP addresses or the data acquisition method for n target devices with identical IP addresses described in any of the foregoing embodiments.
In specific practice, the above electronic device may be combined with a data acquisition device, or with a data acquisition device and a switch, or by a single use manner, to achieve synchronous and real-time data acquisition of n target devices with the same IP address, and in particular, the above electronic device may be implemented as a computer, a PC, a tablet, a data acquisition box, or the like.
In some embodiments, embodiments of the present invention provide a non-transitory computer readable storage medium having stored therein one or more programs including execution instructions that can be read and executed by an electronic device (including, but not limited to, a computer, a server, or a network device, etc.) for performing the network configuration method of the present invention applicable to data collection of n target devices with the same IP address or the data collection method of n target devices with the same IP address according to any of the above embodiments of the present invention.
In some embodiments, embodiments of the present invention also provide a computer program product comprising a computer program stored on a non-volatile computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, cause the computer to perform the network configuration method for data acquisition of n target devices of the same IP address or the data acquisition method for n target devices of the same IP address of any of the embodiments above.
In some embodiments, the present invention further provides an electronic device, including: the system comprises at least one processor and a memory communicatively connected with the at least one processor, wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the network configuration method applicable to data collection of n target devices with the same IP address or the data collection method applicable to n target devices with the same IP address of any of the above embodiments.
In some embodiments, the embodiments of the present invention further provide a storage medium having stored thereon a computer program which, when executed by a processor, implements the network configuration method of any of the above embodiments adapted for data collection of n target devices of the same IP address or the data collection method for n target devices of the same IP address.
Fig. 16 is a schematic hardware structure of an electronic device according to another embodiment of the present invention, where the electronic device may be implemented by using the structure shown in the drawing, and as shown in fig. 16, the electronic device includes:
one or more processors 610, and a memory 620, one processor 610 being illustrated in fig. 16.
The electronic device may further include: an input device 630 and an output device 640.
The processor 610, memory 620, input devices 630, and output devices 640 may be connected by a bus or other means, for example in fig. 16.
The memory 620 is used as a non-volatile computer readable storage medium, and may be used to store a non-volatile software program, a non-volatile computer executable program, and a module, such as a network configuration method applicable to data collection of n target devices with the same IP address or program instructions/modules corresponding to a data collection method for n target devices with the same IP address in an embodiment of the present invention. The processor 610 executes various functional applications of the server and data processing by running nonvolatile software programs, instructions and modules stored in the memory 620, that is, implements the network configuration method applicable to data collection of n target devices with the same IP address or the data collection method for n target devices with the same IP address in the above-described method embodiment.
Memory 620 may include a storage program area that may store an operating system, at least one application program required for functionality, and a storage data area; the storage data area may store data created according to a network configuration method applicable to data collection of n target devices of the same IP address or the use of a data collection method for n target devices of the same IP address, or the like. In addition, memory 620 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 620 optionally includes memory remotely located relative to processor 610, which may be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the internet of vehicles, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 630 may receive input digital or character information and generate signals related to user settings and function control of the image processing apparatus. The output device 640 may include a display device such as a display screen.
The one or more modules are stored in the memory 620, which when executed by the one or more processors 610, perform the network configuration method applicable to data collection of n target devices of the same IP address or the data collection method for n target devices of the same IP address in any of the method embodiments described above.
The product can execute the method provided by the embodiment of the application, and has the corresponding functional modules and beneficial effects of the execution method. Technical details not described in detail in this embodiment may be found in the methods provided in the embodiments of the present application.
The electronic device of the embodiments of the present application exists in a variety of forms including, but not limited to:
(1) Mobile communication devices, which are characterized by mobile communication functionality and are aimed at providing voice, data communication. Such terminals include smart phones (e.g., iPhone), multimedia phones, functional phones, and low-end phones, among others.
(2) Ultra mobile personal computer equipment, which belongs to the category of personal computers, has the functions of calculation and processing and generally has the characteristic of mobile internet surfing. Such terminals include PDA, MID and UMPC devices, etc., such as iPad.
(3) Portable entertainment devices such devices can display and play multimedia content. Such devices include audio, video players (e.g., iPod), palm game consoles, electronic books, and smart toys and portable car navigation devices.
(4) The server is similar to a general computer architecture in that the server is provided with high-reliability services, and therefore, the server has high requirements on processing capacity, stability, reliability, safety, expandability, manageability and the like.
(5) Other electronic devices with data interaction function.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
From the above description of embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus a general purpose hardware platform, or may be implemented by hardware. Based on such understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the related art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims (14)

1. The electronic equipment is characterized in that the electronic equipment can be used for data acquisition of n pieces of target equipment, wherein the n pieces of target equipment have the same IP address, and n is a positive integer greater than or equal to 2;
the electronic equipment defines n access paths which are communicated with n target devices in a one-to-one correspondence manner between a host network naming space of the electronic equipment and the n virtual network spaces through n virtual network spaces and n groups of virtual network card pairs arranged in the electronic equipment;
each access path is defined by a host network naming space, a group of virtual network card pairs and a virtual network space;
each access path is in one-to-one communication with one of the target devices having the same IP address via the virtual network space defining the access path.
2. The electronic device of claim 1, wherein each set of virtual network card pairs includes a first virtual network card and a second virtual network card that are in communication with each other, the first virtual network card in each set of virtual network card pairs is connected to the host network namespace, and the second virtual network card in each set of virtual network card pairs is connected to one virtual network space in one-to-one correspondence;
each virtual network space is connected with one target device in a one-to-one correspondence mode.
3. The electronic device of claim 2, wherein each virtual network space is assigned a first network card and the host network namespaces are assigned host network cards, wherein,
the first network card is set to have the same IP address section with the target equipment connected with the virtual network space where the first network card is located, the IP address section of the first network card is set to be misaligned with the IP address sections of the first virtual network card and the second virtual network card in each group of virtual network card pairs, the first virtual network card and the second virtual network card in the same group of virtual network card pairs are set to have the same IP address section, and the IP address section of the first network card and the IP address section of the first virtual network card and the second virtual network card in each group of virtual network card pairs are also set to be misaligned with the IP address section of the host network card.
4. The electronic device of claim 3, wherein the first network card is a physical network card or a virtual vlan network card.
5. The electronic device according to any one of claims 1 to 4, wherein the ports to be acquired of the n target devices are mapped onto second virtual network cards corresponding to the virtual network spaces to which they are connected, respectively, so as to form first mapping ports corresponding to the ports to be acquired of the target devices on the second virtual network cards;
the first mapping ports are respectively mapped to the host network cards of the host network namespaces one by one through the corresponding communicated first virtual network cards so as to form second mapping ports which are in one-to-one correspondence with the first mapping ports on the host network cards, wherein the second mapping ports are set to be different from the ports to be acquired, and the second mapping ports are set to be different from each other.
6. The electronic device according to any one of claims 1 to 4, wherein a first program unit for data acquisition is installed in each virtual network space;
and each first program unit outputs the collected data of the target equipment through a first virtual network card communicated with the host network naming space.
7. The data acquisition system is characterized in that the system can be used for acquiring data of n pieces of target equipment, wherein the n pieces of target equipment have the same IP address, and n is a positive integer greater than or equal to 2; the system comprises:
a switch; and
an agent connected to a corresponding network interface of the switch, wherein the agent is the electronic device of claim 5, and the n target devices are respectively communicated with n access paths of the electronic device in a one-to-one correspondence manner through the corresponding network interface of the switch;
and the data acquisition equipment is connected to the corresponding network interface of the switch and is used for acquiring data of the n target devices through the electronic equipment.
8. The data acquisition system is characterized in that the system can be used for acquiring data of n pieces of target equipment, wherein the n pieces of target equipment have the same IP address, and n is a positive integer greater than or equal to 2; the system comprises:
a switch; and
a data collector connected to a corresponding network interface of the switch, wherein the data collector is the electronic device of claim 6, and the n target devices are respectively communicated with n access paths of the electronic device in a one-to-one correspondence manner through the corresponding network interface of the switch.
9. The network configuration method suitable for data acquisition of n target devices with the same IP address is characterized by comprising the following steps:
creating n virtual network spaces, and respectively distributing a first network card for each virtual network space;
respectively creating n groups of virtual network card pairs, wherein each group of virtual network card pairs comprises a first virtual network card and a second virtual network card which are mutually communicated;
respectively connecting a first virtual network card in each group of virtual network card pairs to a host network naming space, and respectively connecting a second virtual network card in each group of virtual network card pairs with one virtual network space in a one-to-one correspondence manner so as to define n access paths by the host network naming space, n groups of virtual network cards and n virtual network spaces, wherein each access path is defined by the host network naming space, one group of virtual network cards and one virtual network space;
setting IP addresses for each first network card, each first virtual network card and each second virtual network card respectively, wherein the first network card is set to have the same IP address section with the target equipment connected with the virtual network space where the first network card is positioned, the IP address section of the first network card is set to be misaligned with the IP address sections of the first virtual network card and the second virtual network card in each group of virtual network card pairs, the first virtual network card and the second virtual network card in the same group of virtual network card pairs have the same IP address section, and the IP address section of the first network card and the IP address section of the first virtual network card and the second virtual network card in each group of virtual network card pairs are also set to be misaligned with the IP address section of the host network card;
And connecting each virtual network space to one target device in a one-to-one correspondence manner, so as to communicate each access path with n target devices in a one-to-one correspondence manner.
10. The data acquisition method suitable for n target devices with the same IP address is characterized by comprising the following steps:
configuring a network based on the method of claim 9;
mapping the ports to be acquired of the n target devices to second virtual network cards corresponding to virtual network spaces connected with the corresponding target devices one by one respectively so as to form first mapping ports corresponding to the ports to be acquired one by one on the second virtual network cards;
the first mapping ports are mapped to host network cards of the host network namespaces one by one through the first virtual network cards which are communicated with the corresponding second virtual network cards one by one respectively so as to form second mapping ports which are in one-to-one correspondence with the first mapping ports on the host network cards, wherein the second mapping ports are different from the ports to be acquired and are different from each other;
and respectively carrying out data acquisition on the corresponding target equipment on the data acquisition equipment through each second mapping port of the host network card.
11. The data acquisition method suitable for n target devices with the same IP address is characterized by comprising the following steps:
configuring a network based on the method of claim 9;
a first program unit for data acquisition is respectively installed in each virtual network space;
and operating a first program unit in each virtual network space to acquire data of the corresponding target device, and outputting the acquired data to the target storage module through a corresponding first virtual network card communicated with the corresponding virtual network space.
12. An electronic device, comprising:
a memory for storing executable instructions; and
a processor for executing executable instructions stored in a memory, which when executed by the processor implement the steps of the method of any one of claims 9 to 11.
13. A storage medium having stored thereon a computer program, which when executed by a processor performs the steps of the method according to any of claims 9-11.
14. A computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, cause the computer to perform the method of any of claims 9-11.
CN202310480535.2A 2023-04-28 Data acquisition method and network configuration method suitable for n target devices with same IP addresses, electronic device and data acquisition system Active CN116827777B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310480535.2A CN116827777B (en) 2023-04-28 Data acquisition method and network configuration method suitable for n target devices with same IP addresses, electronic device and data acquisition system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310480535.2A CN116827777B (en) 2023-04-28 Data acquisition method and network configuration method suitable for n target devices with same IP addresses, electronic device and data acquisition system

Publications (2)

Publication Number Publication Date
CN116827777A true CN116827777A (en) 2023-09-29
CN116827777B CN116827777B (en) 2024-05-14

Family

ID=

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107566541A (en) * 2017-08-03 2018-01-09 携程旅游信息技术(上海)有限公司 Capacitor network resource allocation methods, system, storage medium and electronic equipment
CN112260925A (en) * 2020-09-30 2021-01-22 厦门汉印电子技术有限公司 Electronic scale data transmission method, device, equipment and storage medium of virtual network
CN114615109A (en) * 2020-11-23 2022-06-10 北京达佳互联信息技术有限公司 Container network creating method and device, electronic equipment and storage medium
CN114629844A (en) * 2022-02-28 2022-06-14 浙江大华技术股份有限公司 Message forwarding method and device and electronic equipment
CN115168198A (en) * 2022-06-30 2022-10-11 苏州浪潮智能科技有限公司 GDR test environment deployment method, system and server

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107566541A (en) * 2017-08-03 2018-01-09 携程旅游信息技术(上海)有限公司 Capacitor network resource allocation methods, system, storage medium and electronic equipment
CN112260925A (en) * 2020-09-30 2021-01-22 厦门汉印电子技术有限公司 Electronic scale data transmission method, device, equipment and storage medium of virtual network
CN114615109A (en) * 2020-11-23 2022-06-10 北京达佳互联信息技术有限公司 Container network creating method and device, electronic equipment and storage medium
CN114629844A (en) * 2022-02-28 2022-06-14 浙江大华技术股份有限公司 Message forwarding method and device and electronic equipment
CN115168198A (en) * 2022-06-30 2022-10-11 苏州浪潮智能科技有限公司 GDR test environment deployment method, system and server

Similar Documents

Publication Publication Date Title
CN106953788B (en) virtual network controller and control method
CN107465590A (en) Network infrastructure system, the method for route network traffic and computer-readable medium
JP5594552B2 (en) Network system and route control method
US9819574B2 (en) Concerted multi-destination forwarding in a joint TRILL fabric and VXLAN/IP fabric data center
CN107070691A (en) Docker containers across host communication method and system
CN100521663C (en) Method for crossing network address conversion in point-to-point communication
CN103650424A (en) Implementation method and server of home gateway service function
CN103931144B (en) A kind of method, apparatus and system communicated in virtual Domain
CN109547354B (en) Load balancing method, device, system, core layer switch and storage medium
CN103441932A (en) Host routing table entry generating method and device
CN104486589A (en) Assess method and device of GVRP-based video monitoring system
CN105227466A (en) Communication processing method and device
CN105635335B (en) Social resources cut-in method, apparatus and system
CN115189920A (en) Cross-network domain communication method and related device
CN104202398A (en) Remote control method, device and system
CN104734930B (en) Method and device for realizing access of Virtual Local Area Network (VLAN) to Variable Frequency (VF) network and Fiber Channel Frequency (FCF)
CN110391919A (en) Flux of multicast retransmission method, device, electronic equipment
CN109379292A (en) A kind of method of multicasting, virtual switch, SDN controller and storage medium
CN116827777B (en) Data acquisition method and network configuration method suitable for n target devices with same IP addresses, electronic device and data acquisition system
CN103986714A (en) Implementation method and device for connecting bus control network into agent of AVB network
CN116827777A (en) Data acquisition method and network configuration method suitable for n target devices with same IP addresses, electronic device and data acquisition system
CN114157632B (en) Network isolation method, device, equipment and storage medium
CN113676544A (en) Cloud storage network and method for realizing service isolation in entity server
CN116982306A (en) Extending IP addresses in overlay networks
CN114221895A (en) Data transmission method, device and network equipment

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
GR01 Patent grant