CN115996183A - Flow determination method and equipment - Google Patents

Flow determination method and equipment Download PDF

Info

Publication number
CN115996183A
CN115996183A CN202111205260.9A CN202111205260A CN115996183A CN 115996183 A CN115996183 A CN 115996183A CN 202111205260 A CN202111205260 A CN 202111205260A CN 115996183 A CN115996183 A CN 115996183A
Authority
CN
China
Prior art keywords
virtual machine
data packet
external network
address
packet belongs
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111205260.9A
Other languages
Chinese (zh)
Inventor
王利
朱子凡
陈晓明
林雪峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China United Network Communications Group Co Ltd
Unicom Cloud Data Co Ltd
Original Assignee
China United Network Communications Group Co Ltd
Unicom Cloud Data 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 China United Network Communications Group Co Ltd, Unicom Cloud Data Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN202111205260.9A priority Critical patent/CN115996183A/en
Publication of CN115996183A publication Critical patent/CN115996183A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides a flow determination method and equipment, wherein the method comprises the following steps: when a data packet is acquired, acquiring key equipment information in the data packet; determining a virtual machine to which the data packet belongs according to the key equipment information; and acquiring the size of the data packet, determining a flow value corresponding to the virtual machine to which the data packet belongs according to the size of the data packet, and realizing automatic statistics of the external network flow used by the virtual machine so as to charge the virtual machine according to the external network flow used by the virtual machine and ensure the charging accuracy.

Description

Flow determination method and equipment
Technical Field
The embodiment of the invention relates to the technical field of cloud computing, in particular to a flow determination method and flow determination equipment.
Background
The cloud platform is also called a cloud computing platform, which is a service based on hardware resources and software resources, provides computing, network and storage capabilities, and is a management system specially oriented to mass servers.
At present, when a cloud platform is used, a virtual machine is often required to be built, and after the virtual machine is built successfully, the virtual machine can communicate with a terminal in an external network, so that a method for determining the external network traffic used by the virtual machine is needed to charge the virtual machine according to the external network traffic used by the virtual machine.
Disclosure of Invention
The invention provides a flow determination method and equipment for realizing statistics of external network flow.
In a first aspect, the present invention provides a flow determination method, including:
when a data packet is acquired, acquiring key equipment information in the data packet;
determining a virtual machine to which the data packet belongs according to the key equipment information;
and acquiring the size of the data packet, and determining a flow value corresponding to the virtual machine to which the data packet belongs according to the size of the data packet.
In one possible design, the critical device information includes a source address and a destination address;
the determining, according to the key device information, the virtual machine to which the data packet belongs, includes:
obtaining a mapping relation table of the virtual machine and the external network address;
judging whether the source address or the destination address exists in the mapping relation table of the virtual machine and the external network address;
and if the source address or the destination address exists, determining the virtual machine to which the data packet belongs according to the source address or the destination address.
In one possible design, the critical device information further includes a hardware address;
and if the source address or the destination address exists, determining the virtual machine to which the data packet belongs according to the source address or the destination address, including:
if the destination address exists, a virtual machine identifier corresponding to the destination address is obtained from the virtual machine and external network address mapping relation table, and the virtual machine corresponding to the virtual machine identifier corresponding to the destination address is determined to be the virtual machine to which the data packet belongs;
if the source address exists, virtual machine identifiers corresponding to the source address and the hardware address are obtained from the virtual machine and external network address mapping relation table, and the virtual machine corresponding to the virtual machine identifiers corresponding to the source address and the hardware address is determined to be the virtual machine to which the data packet belongs.
In one possible design, the determining, according to the size of the data packet, a flow value corresponding to a virtual machine to which the data packet belongs includes:
if the destination address exists, determining a downlink flow value corresponding to a virtual machine to which the data packet belongs according to the size of the data packet;
if the source address exists, determining an uplink flow value corresponding to the virtual machine to which the data packet belongs according to the size of the data packet.
In one possible design, the method further comprises:
and storing the flow value corresponding to the virtual machine to which the data packet belongs to a database.
In one possible design, the method further comprises:
and acquiring the latest information of the external network mapping pair of the virtual machine, and updating the mapping relation table of the virtual machine and the external network address according to the latest information of the external network mapping pair of the virtual machine.
In one possible design, the storing, in a database, the flow value corresponding to the virtual machine to which the data packet belongs includes:
and storing the flow value corresponding to the virtual machine to which the data packet belongs to a database through a middleware.
In a second aspect, the present invention provides a flow rate determination apparatus comprising:
the information acquisition module is used for acquiring key equipment information in the data packet when the data packet is acquired;
the processing module is used for determining the virtual machine to which the data packet belongs according to the key equipment information;
the processing module is further configured to obtain a size of the data packet, and determine a flow value corresponding to a virtual machine to which the data packet belongs according to the size of the data packet.
In one possible design, the critical device information includes a source address and a destination address;
the processing module is further configured to:
obtaining a mapping relation table of the virtual machine and the external network address;
judging whether the source address or the destination address exists in the mapping relation table of the virtual machine and the external network address;
and if the source address or the destination address exists, determining the virtual machine to which the data packet belongs according to the source address or the destination address.
In one possible design, the critical device information further includes a hardware address;
the processing module is further configured to:
if the destination address exists, a virtual machine identifier corresponding to the destination address is obtained from the virtual machine and external network address mapping relation table, and the virtual machine corresponding to the virtual machine identifier corresponding to the destination address is determined to be the virtual machine to which the data packet belongs;
if the source address exists, virtual machine identifiers corresponding to the source address and the hardware address are obtained from the virtual machine and external network address mapping relation table, and the virtual machine corresponding to the virtual machine identifiers corresponding to the source address and the hardware address is determined to be the virtual machine to which the data packet belongs.
In one possible design, the processing module is further configured to:
if the destination address exists, determining a downlink flow value corresponding to a virtual machine to which the data packet belongs according to the size of the data packet;
if the source address exists, determining an uplink flow value corresponding to the virtual machine to which the data packet belongs according to the size of the data packet.
In one possible design, the processing module is further configured to: and storing the flow value corresponding to the virtual machine to which the data packet belongs to a database.
In one possible design, the processing module is further configured to:
and acquiring the latest information of the external network mapping pair of the virtual machine, and updating the mapping relation table of the virtual machine and the external network address according to the latest information of the external network mapping pair of the virtual machine.
In one possible design, the processing module is further configured to:
and storing the flow value corresponding to the virtual machine to which the data packet belongs to a database through a middleware.
In a third aspect, the present invention provides an electronic device comprising: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executes computer-executable instructions stored in the memory, causing the at least one processor to perform the flow determination method as described above in the first aspect and the various possible designs of the first aspect.
In a fourth aspect, the present invention provides a computer readable storage medium having stored therein computer executable instructions which, when executed by a processor, implement the flow determination method according to the first aspect and the various possible designs of the first aspect.
In a fifth aspect, the present invention provides a computer program product comprising a computer program which, when executed by a processor, implements the flow determination method according to the first aspect and the various possible designs of the first aspect.
The invention provides a flow determination method and equipment, which are used for extracting related information in a data packet, namely key equipment information, to determine a virtual machine related to the data packet, namely a virtual machine to which the external network flow consumed by the data packet belongs, when the data packet is acquired, so as to obtain the virtual machine to which the data packet belongs. After the virtual machine to which the data packet belongs is obtained, the consumed external network flow is determined by utilizing the size of the data packet so as to obtain a flow value corresponding to the virtual machine to which the data packet belongs, and the automatic statistics of the external network flow used by the virtual machine is realized, so that the external network flow used by the virtual machine is conveniently charged according to the external network flow used by the virtual machine, and the charging accuracy is ensured.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, a brief description will be given below of the drawings required for the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the present invention, and that other drawings can be obtained according to these drawings without inventive effort to a person skilled in the art.
Fig. 1 is a schematic view of a scenario of a flow determination method according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of a flow determination method according to an embodiment of the present invention;
fig. 3 is a second flow chart of a flow determination method according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a flow rate determining device according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present 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 one of ordinary skill in the art without undue burden on the person of ordinary skill in the art based on the embodiments of the present invention, are within the scope of the present invention.
When the cloud platform is used, a virtual machine is often required to be built, and after the virtual machine is built successfully, the virtual machine can communicate with a terminal in an external network. When the virtual machine communicates with the public network, i.e. the terminal in the external network, the external network traffic needs to be consumed, so that the external network traffic consumed by the virtual machine needs to be counted, so that traffic charging is performed according to the external network traffic consumed by the virtual machine. However, there are few methods for counting the external network traffic of the virtual machine at present, so there is a need for a method for counting the external network traffic used by the virtual machine so as to charge for the external network traffic used by the virtual machine.
Therefore, the technical idea of the present invention is to provide a method for counting the external network traffic used by a virtual machine, namely, constructing an openvswitch bridge, configuring an uplink and downlink flow table statistics rule on the openvswitch bridge, and determining the virtual machine to which the data packet belongs when the received data packet is matched with the uplink and downlink flow table statistics rule, thereby obtaining the traffic value corresponding to the virtual machine to which the data packet belongs, and realizing automatic and rapid statistics of the external network traffic used by the virtual machine, so as to charge the virtual machine according to the external network traffic used by the virtual machine, and ensure the charging accuracy.
The technical solutions of the present disclosure and how the technical solutions of the present disclosure solve the above technical problems are described in detail below with specific examples. The following specific examples may be combined with each other, and the same or similar concepts or processes may not be described in detail in some examples. Examples of the present disclosure will be described below with reference to the accompanying drawings.
Fig. 1 is a schematic diagram of a scenario of a traffic determination method according to an embodiment of the present invention, as shown in fig. 1, when an electronic device 101 receives a data packet sent by a terminal 102 in an external network, it determines a virtual machine 103 to which the data packet belongs, so as to obtain an external network traffic consumed by the virtual machine 103.
Alternatively, the electronic device 101 may be a computer, a server, or the like. Specifically, the electronic device 101 may be a computing node, which manages at least one virtual machine, i.e. a virtual machine managed by the electronic device, i.e. a corresponding virtual machine, through which the electronic device passes when communicating with a terminal in an external network.
It will be appreciated that the number of virtual machines corresponding to the electronic device shown in fig. 1 is merely an example, which is not limited by the present disclosure.
Alternatively, the terminal 102 may be a computer, server, mobile terminal (e.g., cell phone, tablet, wearable device), etc.
Fig. 2 is a schematic flow chart of a flow determining method according to an embodiment of the present invention, where an execution body of the embodiment may be an electronic device, and specifically may be a computing node. As shown in fig. 2, the method includes:
s201, when a data packet is acquired, acquiring key equipment information in the data packet.
In this embodiment, when the data packet is received, indicating that the virtual machine may need to use the external network traffic, the relevant information in the data packet, that is, the key device information, is extracted, so as to determine the traffic used by the relevant virtual machine by using the key device information.
Optionally, when other terminals send data packets to the virtual machines, the data packets need to be determined according to the data packets when the data packets sent by other terminals are received through an openvswitch bridge on the computing node, and the data packets are forwarded to the corresponding virtual machines; when the virtual machine sends a data packet to other terminals, the data packet is required to pass through the openvswitch bridge, namely, when the openvswitch bridge receives the data packet sent by the virtual machine, the flow is determined according to the data packet, the data packet is forwarded to the corresponding terminal, namely, the flow determination is only carried out by using the openvswitch bridge, and the action is released.
Specifically, when the openvswitch bridge on the computing node receives a data packet, key equipment information in the data packet is extracted.
In addition, the openvswitch bridge is constructed by an Agent end.
Optionally, the key device information includes one or more of the following: source address, destination address, and hardware address.
The source address is the network address of the terminal sending the data packet, the destination address is the network address of the terminal receiving the data packet, for example, if the terminal 1 sends the data packet to the virtual machine 1, the source address is the network address of the terminal 1, and the destination address is the network address of the virtual machine 1.
When the source address in the data packet is the network address of the virtual machine, the data packet is indicated to be an uplink data packet, and the hardware address in the data packet is the hardware (Media Access Control, MAC) address of the virtual machine. Optionally, when the virtual machine accesses the external network, address conversion is performed, that is, the hardware address is converted into the hardware address of the external network gateway bound by the virtual router, that is, the hardware address in the data packet is the hardware address of the external network gateway.
Specifically, the virtual router is a router used by the virtual machine to access the external network.
Optionally, the network address comprises an internet protocol (Internet Protocol, IP) address. Specifically, it is an external network address.
S202, determining the virtual machine to which the data packet belongs according to the key equipment information.
In this embodiment, after obtaining the key device information in the data packet, whether the terminal corresponding to the source address or the destination address of the data packet is a certain virtual machine is determined according to the key device information, that is, the virtual machine to which the data packet belongs is determined by using the key device information in the data packet, where the virtual machine to which the data packet belongs represents the virtual machine that receives or sends the data packet, that is, the virtual machine that needs to use the external network traffic.
Specifically, when the virtual machine sends a data packet to other terminals in the external network, the data packet is an uplink data packet, and uplink traffic of the virtual machine needs to be consumed, and then the source address in the data packet is an external network address corresponding to the virtual machine, that is, the data packet belongs to the virtual machine. When other terminals in the external network access the virtual machine, namely, send data packets to the virtual machine, the data packets are downlink data packets, downlink flow of the virtual machine needs to be consumed, and then the destination address in the data packets is the external network address corresponding to the virtual machine, namely, the data packets belong to the virtual machine.
S203, the size of the data packet is obtained, and a flow value corresponding to the virtual machine to which the data packet belongs is determined according to the size of the data packet.
In this embodiment, after determining the virtual machine to which the data packet belongs, that is, after determining the virtual machine to which the external network traffic to which the data packet needs to consume belongs, the traffic to which the data packet needs to be consumed is determined based on the size of the data packet, so as to obtain the traffic value corresponding to the virtual machine to which the data packet belongs, that is, the external network traffic to which the virtual machine needs to consume is counted, thereby realizing traffic statistics.
Wherein the size of the data packet is actually the number of bytes. The process of determining the traffic that needs to be consumed by a data packet based on the size of the data packet is an existing process.
In this embodiment, when a data packet is received, key device information in the data packet is extracted, and when a source address or a destination address of the data packet is determined to be a virtual machine according to the key device information, that is, after the virtual machine to which the data packet belongs is determined, the external network traffic consumed by the virtual machine is determined based on the size of the data packet, so as to implement accurate statistics of the external network traffic.
As can be seen from the above description, when a data packet is acquired, relevant information in the data packet, that is, key device information, is extracted to determine a virtual machine related to the data packet, that is, determine a virtual machine to which an external network traffic consumed by the data packet belongs, so as to obtain the virtual machine to which the data packet belongs. After the virtual machine to which the data packet belongs is obtained, the consumed external network flow is determined by utilizing the size of the data packet so as to obtain a flow value corresponding to the virtual machine to which the data packet belongs, and automatic statistics of the external network flow used by the virtual machine is realized, so that the external network flow used by the virtual machine is conveniently charged according to the external network flow used by the virtual machine, and the charging accuracy is ensured.
Fig. 3 is a second flow chart of a flow determination method according to an embodiment of the present invention, where, based on the embodiment of fig. 2, when determining a virtual machine to which a data packet belongs, the flow determination method may be determined according to a source address and/or a destination address in the data packet, and this process will be described with reference to a specific embodiment. As shown in fig. 3, the method includes:
s301, when a data packet is acquired, acquiring key equipment information in the data packet.
S302, a mapping relation table of the virtual machine and the external network address is obtained.
In this embodiment, when a data packet is received, the latest mapping relation table of the virtual machine and the external network address is obtained, so as to obtain the mapping pair information of the external network of the virtual machine from the mapping relation table of the virtual machine and the external network address, and the virtual machine to which the virtual machine belongs is determined by using the mapping pair information of the external network of the virtual machine.
Optionally, the mapping relation table of the virtual machine and the external network address stores a plurality of pieces of information of external network mapping pairs of the virtual machine, and the information of the external network mapping pairs of the virtual machine represents a binding relation between the virtual machine and the external network address, and includes a virtual machine identifier and a corresponding virtual machine internal network address, external network address and hardware address.
The hardware address comprises a hardware address of the virtual machine and/or a hardware address of an external network gateway corresponding to the virtual machine.
In this embodiment, optionally, the computing node obtains the latest external network mapping pair information of the virtual machine from the control node at regular intervals, and updates the mapping relationship table of the virtual machine and the external network address according to the latest external network mapping pair information of the virtual machine.
Specifically, the computing node, namely the Agent end, starts a timer task, sends a binding relation acquisition request to the control node, and the control node returns the binding relation between the virtual machine and the external network address which are currently existing, namely the latest virtual machine external network mapping pair information to the computing node, and the computing node updates the virtual machine and the external network address mapping relation table by utilizing the latest virtual machine external network mapping pair information.
Specifically, on the premise that the virtual router binds the external network gateway and the tenant internal network, when the external network address binds the virtual port of the virtual machine, when the external network address and the internal network address of the virtual machine are mapped, the external network address and the internal network address of the virtual machine are set up to be NAT (Network Address Translation ) mapping, which indicates that the virtual machine can access the public network through the external network address, the control node triggers the parameter dictionary for constructing statistics, and thus, the external network mapping pair information of the virtual machine is generated.
Further, optionally, when updating the mapping relation table of the virtual machine and the external network address by using the latest external network mapping relation information of the virtual machine, deleting the binding relation between the virtual machine which is unbinding and the external network address, and adding the binding relation between the newly-bound virtual machine and the external network address, namely, the external network address mapping relation table comprises the latest external network mapping relation information of the virtual machine, namely, the binding relation between the virtual machine which exists currently and the external network address, so as to obtain the latest external network address mapping relation table.
Specifically, the Agent node compares the latest external network mapping pair information of the virtual machine with the current external network address mapping relation table, and if the external network address is unbound with the virtual port of the virtual machine, deletes the external network mapping pair information of the virtual machine corresponding to the virtual machine from the virtual machine and external network address mapping relation table. If the newly added external network address is bound with the virtual interface of the virtual machine, the external network mapping pair information of the virtual machine corresponding to the virtual machine is added in the mapping relation table of the virtual machine and the external network address.
S303, judging whether a source address or a destination address exists in the mapping relation table of the virtual machine and the external network address.
In this embodiment, after extracting the source address or the destination address from the received data packet, it is determined whether the source address or the destination address exists in the mapping relationship table between the virtual machine and the external network address, so as to determine whether the data packet is related to the virtual machine, that is, whether the external network traffic of the virtual machine is consumed.
S304, if the source address or the destination address exists, determining the virtual machine to which the data packet belongs according to the source address or the destination address.
In this embodiment, when the source address or the destination address in the data packet exists in the mapping relationship table of the virtual machine and the external network address, it is indicated that the data packet is related to the virtual machine, that is, the external network traffic of the virtual machine is consumed, and then the virtual machine to which the data packet belongs is determined based on the source address or the destination address, that is, the virtual machine to which the consumed external network traffic belongs is determined.
Optionally, when determining the virtual machine to which the data packet belongs based on the source address or the destination address, if the destination address exists, acquiring a virtual machine identifier corresponding to the destination address from a mapping relationship table of the virtual machine and the external network address, and determining the virtual machine corresponding to the virtual machine identifier corresponding to the destination address as the virtual machine to which the data packet belongs. If the source address exists, virtual machine identifiers corresponding to the source address and the hardware address are obtained from a mapping relation table of the virtual machine and the external network address, and the virtual machine corresponding to the virtual machine identifiers corresponding to the source address and the hardware address is determined to be the virtual machine to which the data packet belongs.
Specifically, when the destination address in the data packet exists in the mapping relation table of the virtual machine and the external network address, it indicates that corresponding mapping pair information of the virtual machine and the external network exists in the mapping relation table of the virtual machine and the external network address, and the data packet is a downlink data packet, that is, the data packet is a data packet sent to the virtual machine by other terminals in the external network, then a virtual machine identifier corresponding to the destination address is obtained from the mapping relation table of the virtual machine and the external network address, and the virtual machine corresponding to the virtual machine identifier is the virtual machine to which the data packet belongs, that is, when the virtual machine receives the data packet, the corresponding external network flow needs to be consumed.
When the source address in the data packet exists in the mapping relation table of the virtual machine and the external network address, it indicates that corresponding mapping pair information of the external network of the virtual machine exists in the mapping relation table of the virtual machine and the external network address, and the data packet is an uplink data packet, that is, the data packet is a data packet sent by the virtual machine to other terminals in the external network, then the virtual machine identification corresponding to the source address and the hardware identification is obtained from the mapping relation table of the virtual machine and the external network address, and the virtual machine corresponding to the virtual machine identification is the virtual machine to which the data packet belongs, that is, when the virtual machine sends the data packet, the corresponding external network flow is required to be consumed.
In addition, optionally, when the source address in the data packet exists in the mapping relationship table of the virtual machine and the external network address, the virtual machine identifier corresponding to the source address may be directly obtained from the mapping relationship table of the virtual machine and the external network address, and the virtual machine corresponding to the virtual machine identifier corresponding to the source address may be determined as the virtual machine to which the data packet belongs.
It can be understood that when the source address in the data packet exists in the mapping relation table of the virtual machine and the external network address, the destination address of the data packet is the network address of a certain terminal in the external network; when the destination address in the data packet exists in the mapping relation table of the virtual machine and the external network address, the source address of the data packet is the network address of a certain terminal in the external network, namely the data packet is generated when the virtual machine communicates with the terminal in the external network.
S305, acquiring the size of the data packet, and determining a flow value corresponding to the virtual machine to which the data packet belongs according to the size of the data packet.
In this embodiment, the flow value corresponding to the virtual machine includes an upstream flow value and a downstream flow value. If the destination address exists in the mapping relation table of the virtual machine and the external network address, determining a downlink flow value corresponding to the virtual machine to which the data packet belongs according to the size of the data packet. If the source address exists in the mapping relation table of the virtual machine and the external network address, determining an uplink flow value corresponding to the virtual machine to which the data packet belongs according to the size of the data packet.
Specifically, when a destination address exists in the mapping relation table of the virtual machine and the external network address, the data packet is indicated to be a downlink data packet, namely, the downlink flow of the virtual machine to which the data packet belongs needs to be consumed, namely, the data packet is indicated to be matched with the statistics rule of the uplink and downlink flow tables on the openvswitch bridge, and then the downlink flow value corresponding to the virtual machine to which the data packet belongs is obtained according to the size of the data packet; when the source address exists in the mapping relation table of the virtual machine and the external network address, the data packet is indicated to be an uplink data packet, namely the uplink flow of the virtual machine to which the data packet belongs needs to be consumed, namely the data packet is indicated to be matched with the statistics rule of the uplink flow table and the downlink flow table on the openvswitch bridge, and the uplink flow value corresponding to the virtual machine to which the data packet belongs is obtained according to the size of the data packet.
In any embodiment, optionally, after the external network traffic consumed by the virtual machine is obtained through statistics, the traffic value corresponding to the virtual machine to which the data packet belongs is stored in the database, that is, the external network traffic consumed by the virtual machine is stored in the database.
Further, optionally, when the flow value corresponding to the virtual machine is stored in the database, the flow value corresponding to the virtual machine to which the data packet belongs may be stored in the database through the middleware.
Specifically, the middleware includes Kafka.
S306, if the source address and the destination address do not exist, the data packet is sent to the target end.
In this embodiment, when the mapping relationship table between the virtual machine and the external network address does not have the source address and the destination address in the data packet, it indicates that neither the sender nor the receiver of the data packet is the virtual machine, i.e., the data packet is irrelevant to the virtual machine, and the data packet can be directly sent to the corresponding terminal, i.e., the destination terminal without traffic statistics.
In this embodiment, an uplink flow value or a downlink flow value of a virtual machine to which the data packet belongs is determined according to relevant information of the data packet, that is, a source address or a destination address, so as to implement accurate statistics of uplink and downlink flows of the virtual machine.
In this embodiment, when a data packet is received, key device information in the data packet is extracted, and whether a source address or a destination address in the key device information exists in a mapping relation table of a virtual machine and an external network address is determined, that is, whether the data packet is related to a certain virtual machine is determined, that is, whether the data packet belongs to a certain virtual machine is determined, so that when the data packet is determined to belong to a certain virtual machine, the external network traffic consumed by the virtual machine is determined, and statistics of the external network traffic corresponding to the virtual machine is realized.
Fig. 4 is a schematic structural diagram of a flow rate determining device according to an embodiment of the present invention, and as shown in fig. 4, the flow rate determining device 400 includes: an information acquisition module 401 and a processing module 402.
The information obtaining module 401 is configured to obtain, when a data packet is obtained, key device information in the data packet.
And the processing module 402 is configured to determine, according to the key device information, a virtual machine to which the data packet belongs.
The processing module 402 is further configured to obtain a size of the data packet, and determine a flow value corresponding to the virtual machine to which the data packet belongs according to the size of the data packet.
In any embodiment, optionally, the critical device information includes a source address and a destination address.
Optionally, the critical device information further includes a hardware address.
In another embodiment of the present invention, based on the embodiment shown in fig. 4, the processing module 402 is further configured to:
and obtaining a mapping relation table of the virtual machine and the external network address.
And judging whether a source address or a destination address exists in the mapping relation table of the virtual machine and the external network address.
If the source address or the destination address exists, determining the virtual machine to which the data packet belongs according to the source address or the destination address.
In this embodiment, optionally, the processing module 402 is further configured to:
if the destination address exists, a virtual machine identifier corresponding to the destination address is obtained from a mapping relation table of the virtual machine and the external network address, and the virtual machine corresponding to the virtual machine identifier corresponding to the destination address is determined to be the virtual machine to which the data packet belongs.
If the source address exists, virtual machine identifiers corresponding to the source address and the hardware address are obtained from a mapping relation table of the virtual machine and the external network address, and the virtual machine corresponding to the virtual machine identifiers corresponding to the source address and the hardware address is determined to be the virtual machine to which the data packet belongs.
In this embodiment, optionally, the processing module 402 is further configured to:
if the destination address exists, determining a downlink flow value corresponding to the virtual machine to which the data packet belongs according to the size of the data packet.
If the source address exists, determining an uplink flow value corresponding to the virtual machine to which the data packet belongs according to the size of the data packet.
In this embodiment, optionally, the processing module 402 is further configured to:
and acquiring the latest information of the external network mapping pair of the virtual machine, and updating the mapping relation table of the virtual machine and the external network address according to the latest information of the external network mapping pair of the virtual machine.
In any embodiment, optionally, the processing module 402 is further configured to:
and saving the flow value corresponding to the virtual machine to which the data packet belongs to a database.
Further, optionally, the processing module 402 is further configured to:
and storing the flow value corresponding to the virtual machine to which the data packet belongs to a database through the middleware.
The ticket processing device provided by the embodiment of the invention can realize the ticket processing method of the embodiment, and the implementation principle and the technical effect are similar, and are not repeated here.
Fig. 5 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention. As shown in fig. 5, the electronic apparatus 500 of the present embodiment includes: a processor 501 and a memory 502;
wherein, the memory 502 is used for storing computer execution instructions;
the processor 501 is configured to execute computer-executable instructions stored in the memory to implement the steps performed by the receiving device in the above-described embodiment. Reference may be made in particular to the description of the embodiments of the method described above.
Alternatively, the memory 502 may be separate or integrated with the processor 501.
When the memory 502 is provided separately, the electronic device further comprises a bus 503 for connecting said memory 502 and the processor 501.
The embodiment of the invention also provides a computer readable storage medium, wherein computer executable instructions are stored in the computer readable storage medium, and when a processor executes the computer executable instructions, the flow determination method is realized.
The embodiments of the present invention also provide a computer program product comprising a computer program which, when executed by a processor, implements a flow determination method as described above.
In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, the division of the modules is merely a logical function division, and there may be other manners of division in actual implementation, for example, multiple modules may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interface, device or module indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical units, may be located in one place, or may be distributed over multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the embodiment.
In addition, each functional module in the embodiments of the present invention may be integrated in one processing unit, or each module may exist alone physically, or two or more modules may be integrated in one unit. The units formed by the modules can be realized in a hardware mode or a hardware and software functional unit mode.
The integrated modules, which are implemented in the form of software functional modules, may be stored in a computer readable storage medium. The software functional module is stored in a storage medium, and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (english: processor) to perform some of the steps of the methods described in the embodiments of the present application.
It should be understood that the above processor may be a central processing unit (english: central Processing Unit, abbreviated as CPU), or may be other general purpose processors, digital signal processors (english: digital Signal Processor, abbreviated as DSP), application specific integrated circuits (english: application Specific Integrated Circuit, abbreviated as ASIC), or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor for execution, or in a combination of hardware and software modules in a processor for execution.
The memory may comprise a high-speed RAM memory, and may further comprise a non-volatile memory NVM, such as at least one magnetic disk memory, and may also be a U-disk, a removable hard disk, a read-only memory, a magnetic disk or optical disk, etc.
The bus may be an industry standard architecture (Industry Standard Architecture, ISA) bus, an external device interconnect (Peripheral Component, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, the buses in the drawings of the present application are not limited to only one bus or one type of bus.
The storage medium may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.
An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an application specific integrated circuit (Application Specific Integrated Circuits, ASIC for short). It is also possible that the processor and the storage medium reside as discrete components in an electronic device or a master device.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the method embodiments described above may be performed by hardware associated with program instructions. The foregoing program may be stored in a computer readable storage medium. The program, when executed, performs steps including the method embodiments described above; and the aforementioned storage medium includes: various media that can store program code, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention 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 or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the invention.

Claims (10)

1. A flow determination method, comprising:
when a data packet is acquired, acquiring key equipment information in the data packet;
determining a virtual machine to which the data packet belongs according to the key equipment information;
and acquiring the size of the data packet, and determining a flow value corresponding to the virtual machine to which the data packet belongs according to the size of the data packet.
2. The method of claim 1, wherein the critical device information includes a source address and a destination address;
the determining, according to the key device information, the virtual machine to which the data packet belongs, includes:
obtaining a mapping relation table of the virtual machine and the external network address;
judging whether the source address or the destination address exists in the mapping relation table of the virtual machine and the external network address;
and if the source address or the destination address exists, determining the virtual machine to which the data packet belongs according to the source address or the destination address.
3. The method of claim 2, wherein the critical device information further comprises a hardware address;
and if the source address or the destination address exists, determining the virtual machine to which the data packet belongs according to the source address or the destination address, including:
if the destination address exists, a virtual machine identifier corresponding to the destination address is obtained from the virtual machine and external network address mapping relation table, and the virtual machine corresponding to the virtual machine identifier corresponding to the destination address is determined to be the virtual machine to which the data packet belongs;
if the source address exists, virtual machine identifiers corresponding to the source address and the hardware address are obtained from the virtual machine and external network address mapping relation table, and the virtual machine corresponding to the virtual machine identifiers corresponding to the source address and the hardware address is determined to be the virtual machine to which the data packet belongs.
4. The method of claim 3, wherein determining a traffic value corresponding to a virtual machine to which the data packet belongs according to the size of the data packet comprises:
if the destination address exists, determining a downlink flow value corresponding to a virtual machine to which the data packet belongs according to the size of the data packet;
if the source address exists, determining an uplink flow value corresponding to the virtual machine to which the data packet belongs according to the size of the data packet.
5. The method according to any one of claims 1 to 4, further comprising:
and storing the flow value corresponding to the virtual machine to which the data packet belongs to a database.
6. The method according to claim 2, wherein the method further comprises:
and acquiring the latest external network mapping pair information of the virtual machine, and updating the mapping relation table of the virtual machine and the external network address according to the latest external network mapping pair information of the virtual machine.
7. A flow rate determination apparatus, comprising:
the information acquisition module is used for acquiring key equipment information in the data packet when the data packet is acquired;
the processing module is used for determining the virtual machine to which the data packet belongs according to the key equipment information;
the processing module is further configured to obtain a size of the data packet, and determine a flow value corresponding to a virtual machine to which the data packet belongs according to the size of the data packet.
8. An electronic device, comprising: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executing computer-executable instructions stored in the memory causes the at least one processor to perform the flow determination method of any one of claims 1 to 6.
9. A computer readable storage medium having stored therein computer executable instructions which, when executed by a processor, implement the flow determination method of any one of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program, when executed by a processor, implements the flow determination method of any one of claims 1 to 6.
CN202111205260.9A 2021-10-15 2021-10-15 Flow determination method and equipment Pending CN115996183A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111205260.9A CN115996183A (en) 2021-10-15 2021-10-15 Flow determination method and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111205260.9A CN115996183A (en) 2021-10-15 2021-10-15 Flow determination method and equipment

Publications (1)

Publication Number Publication Date
CN115996183A true CN115996183A (en) 2023-04-21

Family

ID=85992588

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111205260.9A Pending CN115996183A (en) 2021-10-15 2021-10-15 Flow determination method and equipment

Country Status (1)

Country Link
CN (1) CN115996183A (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101132375A (en) * 2007-09-28 2008-02-27 杭州华三通信技术有限公司 Network flux statistical method and device
CN102082692A (en) * 2011-01-24 2011-06-01 华为技术有限公司 Method and equipment for migrating virtual machines based on network data flow direction, and cluster system
CN105681125A (en) * 2015-12-28 2016-06-15 国云科技股份有限公司 Method for counting traffic of virtual machine extranet of cloud platform
CN106330585A (en) * 2015-06-29 2017-01-11 中兴通讯股份有限公司 Flow monitoring method, device and system
CN107395508A (en) * 2016-05-17 2017-11-24 华为技术有限公司 The method and apparatus to E-Packet
CN107547439A (en) * 2017-09-08 2018-01-05 ***股份有限公司 A kind of method for controlling network flow and calculate node
CN108293022A (en) * 2015-12-30 2018-07-17 华为技术有限公司 A kind of methods, devices and systems of message transmissions
CN108600415A (en) * 2018-05-28 2018-09-28 郑州云海信息技术有限公司 A kind of virtual network accesses method, system and the SDN controllers of outer net
EP3382959A2 (en) * 2017-03-31 2018-10-03 Juniper Networks, Inc. Session-based traffic statistics logging for virtual routers
CN108777646A (en) * 2018-05-02 2018-11-09 新华三技术有限公司 Flux monitoring method and device
CN112052075A (en) * 2020-09-30 2020-12-08 中移(杭州)信息技术有限公司 Cloud desktop virtual machine live migration method, server and storage medium

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101132375A (en) * 2007-09-28 2008-02-27 杭州华三通信技术有限公司 Network flux statistical method and device
CN102082692A (en) * 2011-01-24 2011-06-01 华为技术有限公司 Method and equipment for migrating virtual machines based on network data flow direction, and cluster system
CN106330585A (en) * 2015-06-29 2017-01-11 中兴通讯股份有限公司 Flow monitoring method, device and system
CN105681125A (en) * 2015-12-28 2016-06-15 国云科技股份有限公司 Method for counting traffic of virtual machine extranet of cloud platform
CN108293022A (en) * 2015-12-30 2018-07-17 华为技术有限公司 A kind of methods, devices and systems of message transmissions
CN107395508A (en) * 2016-05-17 2017-11-24 华为技术有限公司 The method and apparatus to E-Packet
EP3382959A2 (en) * 2017-03-31 2018-10-03 Juniper Networks, Inc. Session-based traffic statistics logging for virtual routers
CN107547439A (en) * 2017-09-08 2018-01-05 ***股份有限公司 A kind of method for controlling network flow and calculate node
CN108777646A (en) * 2018-05-02 2018-11-09 新华三技术有限公司 Flux monitoring method and device
CN108600415A (en) * 2018-05-28 2018-09-28 郑州云海信息技术有限公司 A kind of virtual network accesses method, system and the SDN controllers of outer net
CN112052075A (en) * 2020-09-30 2020-12-08 中移(杭州)信息技术有限公司 Cloud desktop virtual machine live migration method, server and storage medium

Similar Documents

Publication Publication Date Title
CN109981493B (en) Method and device for configuring virtual machine network
CN106921578B (en) Method and device for generating forwarding table item
CN108429739B (en) Method, system and terminal equipment for identifying honeypots
CN111885216B (en) DNS query method, device, equipment and storage medium
CN113746692A (en) Network flow statistical method, electronic equipment and storage medium
CN111064786B (en) Account identifier management method and device
CN112015575A (en) Message processing method, device and related equipment
CN113645140B (en) Message statistical method, device, storage medium and network equipment
CN108460044B (en) Data processing method and device
CN112491794A (en) Port forwarding method, device and related equipment
CN115996183A (en) Flow determination method and equipment
CN107005433B (en) Flow table entry timing processing method and device
CN115150171B (en) Flow statistics method and device, electronic equipment and storage medium
CN110995881A (en) Domain name storage method and device
CN114978897B (en) Network control method and system based on eBPF and application identification technology
CN114071448B (en) Data transmission method, related network node and storage medium
CN113507394B (en) Network performance detection method and device, electronic equipment and storage medium
CN112565018B (en) Flow statistical method, device, gateway equipment and storage medium
CN114793325A (en) Short message charging method and device for VoLTE terminal user and electronic equipment
CN114697440B (en) Network management method and mobile terminal
CN113132273B (en) Data forwarding method and device
CN105072047A (en) Message transmitting and processing method
CN115665042B (en) Data processing method, device, user plane functional entity and storage medium
CN116366534B (en) Multicast traffic replication method based on hardware offloading and related device
CN115242733B (en) Message multicast method, multicast gateway, electronic device and storage medium

Legal Events

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