Method and device for scheduling configuration resources

文档序号:750544 发布日期:2021-04-02 浏览:13次 中文

阅读说明:本技术 一种配置资源调度方法及装置 (Method and device for scheduling configuration resources ) 是由 刘世贞 于 2020-12-02 设计创作,主要内容包括:本说明书提供一种配置资源调度方法及装置,所述方法包括:解除了相关技术中,配置资源组和内网设备的一一对应的绑定关系,并预先配置了数量小于内网设备数量的配置资源组。网关设备在接收到某一内网设备请求新建首个会话的报文时,为该内网设备分配一个配置资源组,基于该配置资源组对该请求新建首个会话的报文进行NAT处理。如果网关设备接收到该内网设备请求新建下一个会话的报文时,依然基于该配置资源组对请求新建下一个会话的报文进行NAT处理。如果该内网设备的全部会话都已经老化,则收回分配给该内网设备的配置资源组。可以使用少于内网设备的配置资源组进行动态调度,减少了每个配置资源组的闲置时间,减少了资源浪费。(The present specification provides a method and an apparatus for scheduling configuration resources, where the method includes: the binding relationship of the configuration resource groups and the intranet equipment in one-to-one correspondence in the related technology is eliminated, and the configuration resource groups with the quantity smaller than that of the intranet equipment are configured in advance. When receiving a message of a certain intranet device requesting to establish a new first session, the gateway device allocates a configuration resource group for the intranet device, and performs NAT processing on the message requesting to establish the new first session based on the configuration resource group. And if the gateway equipment receives the message of the next session requested to be established by the intranet equipment, the NAT processing is still carried out on the message of the next session requested to be established on the basis of the configuration resource group. And if all the sessions of the intranet equipment are aged, recovering the configuration resource group allocated to the intranet equipment. The dynamic scheduling can be performed by using the configuration resource groups less than the intranet equipment, so that the idle time of each configuration resource group is reduced, and the resource waste is reduced.)

1. A method for scheduling configuration resources is characterized in that the method is applied to gateway equipment, and the gateway equipment corresponds to S intranet equipment;

pre-configuring a resource pool of the gateway device, so that the resource pool comprises M public network addresses and a port range consisting of N ports, the port range is divided into a plurality of port blocks, the number of the ports of each port block is Q, and each port block and the public network address form a configuration resource group aiming at each public network address; wherein M N/Q < S;

the method comprises the following steps:

under the condition that a message of any intranet equipment requesting to establish a new session is received, if a configuration resource group occupied by the intranet equipment exists, performing Network Address Translation (NAT) processing on the message based on the configuration resource group occupied by the intranet equipment; if the configuration resource group occupied by the intranet equipment does not exist, enabling the intranet equipment to occupy an unoccupied configuration resource group, and carrying out NAT processing on the message based on the configuration resource group occupied by the intranet equipment;

and under the condition that all the sessions of the intranet equipment are monitored to be aged, recovering the configuration resource group occupied by the intranet equipment.

2. The method according to claim 1, wherein determining whether there is a configuration resource group that the intranet device is occupying specifically comprises:

if the configuration resource group used by the intranet equipment exists or the aging configuration resource group of the intranet equipment exists, determining that the configuration resource group occupied by the intranet equipment exists;

if it is determined that the configuration resource group used by the intranet equipment does not exist and the aging configuration resource group of the intranet equipment does not exist, determining that the configuration resource group occupied by the intranet equipment does not exist;

for any configuration resource group, when the condition that the aging condition corresponding to the configuration resource group is met is monitored, the configuration resource group begins to age; the aging condition corresponding to the configuration resource group is that the last unaged session of the intranet equipment starts to age;

if it is determined that the aging configuration resource group of the intranet device exists, before performing the NAT processing on the message, the method further includes:

and stopping aging the configuration resource group, and enabling the intranet equipment to reuse the configuration resource group.

3. The method according to claim 1, wherein performing NAT processing on the message based on the set of configuration resources being occupied by the intranet device comprises:

judging whether the resources of the configuration resource group occupied by the intranet equipment are used up or not;

if the message is used up, performing NAT processing on the message based on the configuration resource group occupied by the intranet equipment;

the method further comprises the following steps:

if not, refusing to carry out NAT treatment on the message.

4. The method according to claim 3, wherein determining whether the set of configuration resources being occupied by the intranet device is exhausted comprises:

judging whether the value of a counting variable corresponding to the configuration resource group occupied by the intranet equipment reaches Q;

if yes, determining that the resources of the configuration resource group occupied by the intranet equipment are used up;

if not, determining that the resources of the configuration resource group occupied by the intranet equipment are not used up;

adding 1 to the value of the counting variable every time NAT processing is carried out on a message based on a configuration resource group occupied by the intranet equipment; and subtracting 1 from the value of the counting variable every time one session of the intranet equipment finishes aging.

5. The method according to claim 1, wherein a node in a pre-created hash chain table is used to record a correspondence between the intranet address hash of the intranet device and the configuration resource group being occupied by the intranet device.

6. The method according to claim 2, wherein a node in a pre-created first hash chain table is used to record a correspondence between an intranet address hash of the intranet device and a configuration resource group being used by the intranet device; and recording the corresponding relation between the intranet address hash of the intranet equipment and the aging configuration resource group of the intranet equipment by using one node in the pre-created second hash chain table.

7. A configuration resource scheduling device is applied to gateway equipment, wherein the gateway equipment corresponds to S intranet equipment;

pre-configuring a resource pool of the gateway device, so that the resource pool comprises M public network addresses and a port range consisting of N ports, the port range is divided into a plurality of port blocks, the number of the ports of each port block is Q, and each port block and the public network address form a configuration resource group aiming at each public network address; wherein M N/Q < S;

the device comprises:

the NAT processing unit is used for carrying out NAT processing on the message based on the configuration resource group occupied by the intranet equipment if the configuration resource group occupied by the intranet equipment exists under the condition that the message of requesting to establish a new session by any intranet equipment is received; if the configuration resource group occupied by the intranet equipment does not exist, enabling the intranet equipment to occupy an unoccupied configuration resource group, and carrying out NAT processing on the message based on the configuration resource group occupied by the intranet equipment;

and the resource group withdrawing unit is used for withdrawing the configuration resource group occupied by the intranet equipment under the condition that all the sessions of the intranet equipment are monitored to be aged.

8. The apparatus according to claim 7, wherein the determining, in the NAT processing unit, whether there is a configuration resource group that the intranet device is occupying specifically includes:

if the configuration resource group used by the intranet equipment exists or the aging configuration resource group of the intranet equipment exists, determining that the configuration resource group occupied by the intranet equipment exists;

if it is determined that the configuration resource group used by the intranet equipment does not exist and the aging configuration resource group of the intranet equipment does not exist, determining that the configuration resource group occupied by the intranet equipment does not exist;

for any configuration resource group, when the condition that the aging condition corresponding to the configuration resource group is met is monitored, the configuration resource group begins to age; the aging condition corresponding to the configuration resource group is that the last unaged session of the intranet equipment starts to age;

if it is determined that the aging configuration resource group of the intranet device exists, the NAT processing unit further includes, before performing NAT processing on the message:

and the aging stopping unit is used for stopping aging the configuration resource group and enabling the intranet equipment to reuse the configuration resource group.

9. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method of scheduling configuration resources according to any one of claims 1 to 6.

10. A gateway device, characterized in that the gateway device comprises:

one or more processors;

a memory for storing one or more programs;

when executed by the one or more processors, cause the one or more processors to implement the method of configuring resource scheduling according to any one of claims 1 to 6.

Technical Field

The present disclosure relates to the field of computer application technologies, and in particular, to a method and an apparatus for scheduling configuration resources.

Background

The gateway device between the intranet and the public Network realizes a new session between the intranet device and the public Network device based on a Network Address Translation (NAT) protocol (the session herein refers to a session between the intranet device and the public Network device).

The gateway device maintains a resource pool, and resources in the resource pool include a plurality of public network addresses and port ranges. In practical applications, the resources in the resource pool are generally configured as follows: dividing a port range into a plurality of port blocks, wherein the number of ports of each port block is the same; and aiming at each public network address, forming a configuration resource group by each port block and the public network address respectively.

The gateway device allocates different configuration resource groups to different intranet devices in advance. For each intranet device, when receiving a message requesting a new session from the intranet device, the gateway device configures a source address and a source port of the message of the new session by using a configuration resource (a combination of a public network address and a port) in a configuration resource group corresponding to the intranet device, and one configuration resource can only be used for creating a new session.

It should be noted that the same intranet device may request to create a plurality of sessions, and ports bound to different sessions are different. Therefore, the number of ports of the port block in the configuration resource group corresponding to any intranet device determines the upper limit of the number of sessions that can be newly created by the intranet device.

However, the implementation manner of allocating one configuration resource group to each intranet device in advance has the technical problem of resource waste.

Disclosure of Invention

In order to overcome the problem of resource waste in the related art, the present specification provides a method and an apparatus for scheduling configuration resources.

According to a first aspect of an embodiment of the present specification, a method for scheduling configuration resources is provided, which is applied to a gateway device, where the gateway device corresponds to S pieces of intranet equipment; pre-configuring a resource pool of the gateway device, so that the resource pool comprises M public network addresses and a port range consisting of N ports, the port range is divided into a plurality of port blocks, the number of the ports of each port block is Q, and each port block and the public network address form a configuration resource group aiming at each public network address; wherein M N/Q < S; the method comprises the following steps:

under the condition that a message of any intranet equipment requesting to establish a new session is received, if a configuration resource group occupied by the intranet equipment exists, performing NAT (network address translation) processing on the message based on the configuration resource group occupied by the intranet equipment; if the configuration resource group occupied by the intranet equipment does not exist, enabling the intranet equipment to occupy an unoccupied configuration resource group, and carrying out NAT processing on the message based on the configuration resource group occupied by the intranet equipment;

and under the condition that all the sessions of the intranet equipment are monitored to be aged, recovering the configuration resource group occupied by the intranet equipment.

According to a second aspect of the embodiments of the present specification, there is provided a configuration resource scheduling apparatus, which is applied to a gateway device, where the gateway device corresponds to S intranet devices; pre-configuring a resource pool of the gateway device, so that the resource pool comprises M public network addresses and a port range consisting of N ports, the port range is divided into a plurality of port blocks, the number of the ports of each port block is Q, and each port block and the public network address form a configuration resource group aiming at each public network address; wherein M N/Q < S; the device comprises:

the NAT processing unit is used for carrying out NAT processing on the message based on the configuration resource group occupied by the intranet equipment if the configuration resource group occupied by the intranet equipment exists under the condition that the message of requesting to establish a new session by any intranet equipment is received; if the configuration resource group occupied by the intranet equipment does not exist, enabling the intranet equipment to occupy an unoccupied configuration resource group, and carrying out NAT processing on the message based on the configuration resource group occupied by the intranet equipment;

and the resource group withdrawing unit is used for withdrawing the configuration resource group occupied by the intranet equipment under the condition that all the sessions of the intranet equipment are monitored to be aged.

According to a third aspect of embodiments herein, there is provided a gateway apparatus comprising:

one or more processors;

a memory for storing one or more programs;

when the one or more programs are executed by the one or more processors, the one or more processors implement the method for scheduling configuration resources according to any embodiment of the first aspect of the embodiments of the present specification.

According to a fourth aspect of the present specification, there is provided a computer-readable storage medium, on which a computer program is stored, which when executed by a processor, implements the method for scheduling configuration resources according to any one of the embodiments of the first aspect of the present specification.

The technical solution provided in the embodiments of the present description removes the one-to-one binding relationship between configuration resource groups and intranet equipment in the related art, and pre-configures configuration resource groups whose number is smaller than the number of intranet equipment. When receiving a message of a certain intranet device requesting to establish a new first session (that is, there is no session of the intranet device in a current session table), the gateway device allocates a configuration resource group to the intranet device, and performs NAT processing on the message requesting to establish the new first session based on the configuration resource group. And if the gateway equipment receives the message of the next session requested to be established by the intranet equipment, the NAT processing is still carried out on the message of the next session requested to be established on the basis of the configuration resource group. And if all the sessions of the intranet equipment are aged, reclaiming the configuration resource group allocated to the intranet equipment so that the configuration resource group can be allocated to other intranet equipment.

Through the technical scheme provided by the embodiment of the specification, the dynamic scheduling can be performed by using the configuration resource groups less than the intranet equipment, so that the idle time of each configuration resource group is reduced, and the resource waste is reduced.

It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the specification.

Drawings

The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present specification and together with the description, serve to explain the principles of the specification.

Fig. 1 is a flowchart of a method of NAT processing shown in this specification.

Fig. 2 is a flowchart illustrating a method for scheduling configuration resources according to an exemplary embodiment.

Fig. 3 is a flow diagram illustrating another method for scheduling configuration resources according to an embodiment of the present disclosure.

Fig. 4 is a block diagram illustrating a configuration resource scheduling apparatus according to an example embodiment.

Fig. 5 is a hardware configuration diagram of a gateway device in which the resource scheduling apparatus is configured in the present specification.

Detailed Description

The NAT is a network address translation protocol applied to the gateway device, and is used to translate a source address and a source port of a message into a combination of a public network address and a port, so that the message can be recognized by the public network device, and thus, an intranet device sending the message can communicate with the public network device. When the session is newly established, a configuration resource, that is, a combination of an IP address and a port, needs to be allocated to the session. The number of sessions that an intranet device may establish is large, in order to avoid that an intranet device occupies configuration resources without control, and thus other intranet devices cannot establish a new session, generally, the number of combinations of public network addresses and ports used by an intranet device needs to be limited, the limiting method generally is to enable an intranet device to only occupy one configuration resource group, the configuration method of the configuration resource group generally is to divide a port range into a plurality of port blocks, and each port block and the public network address form one configuration resource group for each public network address. For example, assuming that the resources in the resource pool include M public network addresses and a port range of N ports, and the number of ports of each port block is designated as S, the configured resource pool includes M × N/S configuration resource groups.

Based on this, in the related art, generally, when configuring resource groups, the number of the configuration resource groups is limited to be not less than the number of the intranet devices, one configuration resource group is reserved for all the intranet devices, a repeated configuration resource group cannot be reserved for different intranet devices, and only one configuration resource group is reserved for one intranet device, that is, the intranet devices and the configuration resource groups reserved for the intranet devices are in one-to-one correspondence. Thus, when the NAT processing is required, the IP address and the port range in the configuration resource group reserved for the intranet device are obtained through calculation, so that the intranet device can use the configuration resource group reserved for the intranet device, and the gateway device can perform NAT conversion on the message in the session based on the configuration resource group.

Although this method can avoid one intranet device from occupying configuration resources without restriction, at a certain time, the probability that all intranet devices have sessions is low, which results in many configuration resources being idle, and resource waste is caused.

Based on this, the present specification provides a configuration resource scheduling method, which removes the one-to-one binding relationship between configuration resource groups and intranet equipment in the related art, and pre-configures configuration resource groups of which the number is smaller than that of the intranet equipment. When receiving a message of a certain intranet device requesting to establish a new first session (that is, there is no session of the intranet device in a current session table), the gateway device allocates a configuration resource group to the intranet device, and performs NAT processing on the message requesting to establish the new first session based on the configuration resource group. And if the gateway equipment receives the message of the next session requested to be established by the intranet equipment, the NAT processing is still carried out on the message of the next session requested to be established on the basis of the configuration resource group. And if all the sessions of the intranet equipment are aged, reclaiming the configuration resource group allocated to the intranet equipment so that the configuration resource group can be allocated to other intranet equipment. Through the technical scheme provided by the embodiment of the specification, the dynamic scheduling can be performed by using the configuration resource groups less than the intranet equipment, so that the idle time of each configuration resource group is reduced, and the resource waste is reduced.

Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present specification. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the specification, as detailed in the appended claims.

The terminology used in the description herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the description. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.

It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, the first information may also be referred to as second information, and similarly, the second information may also be referred to as first information, without departing from the scope of the present specification. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.

The following provides a detailed description of examples of the present specification.

As shown in fig. 1, fig. 1 is a flowchart of a method for processing a gateway device NAT shown in this specification. The NAT processing method comprises the following steps:

step 101, receiving a message of an intranet device requesting to establish a new session.

And 102, matching the NAT strategy to obtain a resource pool.

The NAT strategy may determine whether the message needs to be subjected to NAT conversion, and whether resources need to be allocated to the message. After the NAT policy is matched, the resource pool identifier can be obtained to find the corresponding resource pool, and NAT conversion is performed on the message, so that a new session is established between the intranet device and the public network device.

Step 103, acquiring a configuration resource group according to the configuration resource scheduling method, and using the public network address of the configuration resource group as the source address of the message.

The method for configuring resource scheduling is a method in the first aspect of the embodiment of this specification, and a specific method may refer to a flowchart shown in fig. 2. And one configuration resource group comprises a combination of a public network address and a section of port range, and after the configuration resource group is obtained, the public network address of the configuration resource group is used as a message source address to carry out conversion.

And 104, judging whether the network port in the message is in the port range of the configuration resource group, if so, executing 105a, and if not, executing 105 b.

The source port of the message before NAT conversion, namely the intranet port corresponding to the message, can be judged whether in the port range of the configuration resource group, if the port is in the port range, and the port is not used by the message in other sessions of the intranet equipment, the port can be used as the source port of the message, so that the process of port conversion is reduced, the CPU burden is lightened, and the time is saved.

And 105a, taking the intranet port of the message as a source port of the message.

And step 105b, taking the initial port of the configuration resource group as a message source port.

In order to facilitate traversal of whether all ports in the configuration resource group are used, a search may be started from a first port, that is, an initial port is selected as a source port of a message, and whether a conflicting session exists in a session table is searched, if so, a second port is continuously used as the source port of the message, and the search is performed until no conflicting session exists, and if not, the source port of the message is converted into the port.

And step 106, searching a session table, judging whether a conflict exists, if so, executing step 107, and if not, executing step 109.

The conflict is whether a session corresponding to a message using the public network address as a message source address and the port as a message source port exists in the session table, in other words, whether other messages sent by the intranet device use the port as a message source port is determined. If there is a conflict, the message needs to use the other port as the source port of the message. In order to facilitate searching, the sessions of the same intranet device can be stored in one session table, so that under the condition that the source addresses of the sessions of the same intranet device are the same, when whether the currently selected port conflicts or not is searched, the session table can be searched, and whether the current port conflicts or not can be judged only by searching whether the ports are the same or not, which is more convenient.

Step 107, judging whether the configuration resource group has other unused ports, if so, executing 108, and if not, executing 110.

The unused port is a port that is not used as a source port when the IP address is used as a source address. The method for determining whether there are other unused ports may be to look up a session table, and see whether there are unused ports, that is, for a combination of an IP address corresponding to the configuration resource group and each port, there is a session using the combination, if each combination is used, it indicates that there is no unused port, and if there is an unused combination, it indicates that there is an unused port.

And step 110, packet loss.

In order to prevent that one intranet device occupies all resources, which causes that other intranet devices cannot surf the internet normally, the number of configuration resources used by each intranet device needs to be limited, so that the number of configuration resources occupied by one intranet device is limited to one configuration resource group, and when no residual resources exist in the resource group, a new message requesting a new session is lost. In use, the occurrence frequency of the packet loss situation can be reduced by reasonably configuring the size of the resource pool.

Step 108, the message source port is converted into an unused port.

And if the unused port is found, modifying the source port of the message into the unused port.

Step 109, the message of the source address and the source port after being converted is obtained.

After the conversion, the message with the source address and the source port converted is obtained, and information such as the quintuple, the source port before conversion and the like is recorded and stored in the session table, so that other messages subsequent to the session can normally transmit the message through the session table.

In order to implement dynamic scheduling of configured resources when performing NAT processing, one or more embodiments in this specification provide a method for scheduling configured resources, where the method is applied to a gateway device, and the gateway device corresponds to S intranet devices, that is, the gateway device may establish a new session between S intranet devices connected to an intranet and a public network device. The method for scheduling the configured resources comprises two stages, namely a pre-configuration stage and a dynamic scheduling stage of the configured resources.

Next, the scheme will be described in terms of both pre-configuring and configuring the dynamic scheduling of resources.

In the pre-configuration phase: pre-configuring a resource pool of the gateway device, so that the resource pool comprises M public network addresses and a port range consisting of N ports, the port range is divided into a plurality of port blocks, the number of the ports of each port block is Q, and each port block and the public network address form a configuration resource group aiming at each public network address; wherein M N/Q < S.

In the related art, in order to enable intranet devices and configuration resource groups to correspond to each other one by one during configuration, a condition that the number of the configuration resource groups is not less than the number of the intranet devices must be satisfied during configuration of a resource pool. Under the condition of limited resources, in order to satisfy the condition that the number of configuration resource groups is not less than the number of intranet devices, the number of resources in each configuration resource group may be made smaller. Thus, when the flow of a certain intranet device is large, more sessions need to be established, and packet loss may occur. Therefore, at a certain moment, due to the limitation of the quantity condition of the configuration resource groups, the configured resource groups cannot meet the use requirement, but simultaneously, a plurality of limited configuration resource groups exist, so that the configuration resources cannot be fully utilized.

Thus, in one or more embodiments of the present description, in order to make the configuration resources fully utilized, it is necessary to reasonably configure the resources in the resource pool. During configuration, in order to increase the utilization rate of the configuration resource groups and reduce the number of idle configuration resource groups, the number of the configuration resource groups needs to be smaller than the number of intranet devices during configuration. In order to make the number of configuration resource groups smaller than the number of intranet devices, an appropriate value of M, N, Q may be selected according to actual requirements. For example, the number of sessions that each intranet device needs to exist at the same time is large, the value of the number Q of ports of each port block can be increased, and other values are unchanged, so that the utilization rate of the configuration resource group is increased. Or the number of intranet devices needing to be connected with the public network at the same time in the intranet is small, and the number M of public network addresses or the size N of a port range can be reduced under the condition that other conditions are not changed, so that the number of configuration resources is reduced, and the utilization rate of configuration resource groups is improved. Of course, according to the actual situation, M, N and Q may both be changed to achieve a better configuration effect, so as to improve the utilization rate of the limited configuration resources.

In the dynamic scheduling stage of the configuration resources: as shown in fig. 2, fig. 2 is a flowchart illustrating a method for scheduling configuration resources according to an exemplary embodiment, where the method includes the following steps:

step 202, under the condition that a message of any intranet equipment requesting to establish a new session is received, if a configuration resource group occupied by the intranet equipment exists, performing NAT (network address translation) processing on the message based on the configuration resource group occupied by the intranet equipment; and if the configuration resource group occupied by the intranet equipment does not exist, enabling the intranet equipment to occupy an unoccupied configuration resource group, and carrying out NAT processing on the message based on the configuration resource group occupied by the intranet equipment.

The configuration resource group occupied by the intranet device may be a configuration resource group being used by the intranet device, that is, the intranet device has a session that uses resources in the configuration resource group as a message source address and a message source port. Performing NAT processing on the message includes converting the source address and the source address of the message into a public network address and a public network port, and after performing NAT processing, it is necessary to record the correspondence between the internal network address and the port and the public network address and the port in a session table, and send the message to the destination address of the message.

Further, considering that a session has no message passing through for a long time, the session should be aged, so that the configuration resources occupied by the session are available for other sessions. In order to avoid allocating multiple configuration resource groups to an intranet device in the case of deleting relevant information in a gateway device in consideration of the time required for session aging, the configuration resource groups that the intranet device is occupying include the configuration resource group that the intranet device is using and the configuration resource group that the intranet device is aging. The intranet equipment comprises aging configuration resources and configuration resources which are aged and unused in the aging configuration resource group. After the configuration resource group is set to be in an aging state, timing is started, and after a preset aging time threshold (which is generally smaller) is reached, the aging-completed configuration resource group is deleted from the aging linked list so that other intranet equipment can use the configuration resource group. Therefore, the situation that one intranet device corresponds to a plurality of configuration resource groups due to the fact that the configuration resource groups are not aged due to accidents in the aging process is prevented.

Under the above circumstances, determining whether there is a configuration resource group that the intranet device is occupying specifically includes: if the configuration resource group used by the intranet equipment exists or the aging configuration resource group of the intranet equipment exists, determining that the configuration resource group occupied by the intranet equipment exists; if it is determined that the configuration resource group currently used by the intranet equipment does not exist and it is determined that the aging configuration resource group of the intranet equipment does not exist, it is determined that the configuration resource group currently occupied by the intranet equipment does not exist.

That is to say, it is determined whether the intranet device has an occupied configuration resource group, and it is necessary to check whether the intranet device corresponds to an aged configuration resource group or a currently used configuration resource group, so as to prevent two configuration resource groups from being allocated to one intranet device.

For any configuration resource group, when the condition that the aging condition corresponding to the configuration resource group is met is monitored, the configuration resource group begins to age; the aging condition corresponding to the configuration resource group is that the last unaged session of the intranet equipment starts to age. In this way, the binding relationship between the configuration resource group and the intranet device can be released, so that the rest intranet devices can reuse the configuration resource group to newly establish a session with the public network device.

If it is determined that the aging configuration resource group of the intranet device exists, before performing the NAT processing on the message, the method further includes: and stopping aging the configuration resource group, and enabling the intranet equipment to reuse the configuration resource group. That is, if the configuration resource group is aging, and at this time, if an intranet device corresponding to the configuration resource group needs to create a new session, in order to prevent multiple configuration resource groups from being allocated to one intranet device, it is necessary to make the intranet device preferentially use the configuration resource group as the configuration resource group of the new session.

And 204, under the condition that all the sessions of the intranet equipment are monitored to be aged, recovering the configuration resource group occupied by the intranet equipment.

After all the sessions corresponding to the intranet device are aged, the session table corresponding to the intranet device is emptied, the session table may not be an actual session table, and refers to a logical session table, all the sessions corresponding to the intranet device are stored in the session table, and no session of another intranet device exists. For convenience of management, a plurality of session tables may be generated, each session table corresponding to one intranet device, and session information of all the intranet devices may be recorded in the session table. At this time, in order to enable the configuration resource group to be used by other intranet devices, it is necessary to release the binding relationship between the intranet device and the configuration resource group, and reset the configuration resource group to an unoccupied state, that is, to withdraw the configuration resource group that the intranet device is occupying, so that when a new session request of other intranet devices that do not occupy the configuration resource group comes, the gateway device may perform NAT processing on the message according to the configuration resource group.

Further, in the case that the configuration resources are limited, even if one configuration resource group can include more ports after improvement, there is still a possibility of packet loss, so to save time of step 107 shown in fig. 1, when the configuration resource group is dynamically allocated, when the intranet device does not have an occupied configuration resource group, the packet needs to be lost, and the number of steps 107 is reduced. Specifically, performing NAT processing on the packet based on the configuration resource group that the intranet device is occupying includes: judging whether the resources of the configuration resource group occupied by the intranet equipment are used up or not; and if the message is used up, performing NAT processing on the message based on the configuration resource group occupied by the intranet equipment. The method further comprises the following steps: if not, refusing to carry out NAT treatment on the message.

The searching for whether the resources of the configuration resource group that the intranet device is occupying are used up may be to search a session table to find whether there are unused resources in the intranet device. Further, in order to reduce the time for dynamically scheduling the configuration resources and improve the efficiency of dynamic scheduling as much as possible, a counting variable may be used to record the resource usage in each configuration resource group. Specifically, the determining whether the set of configuration resources that the intranet device is occupying is used up includes: judging whether the value of a counting variable corresponding to the configuration resource group occupied by the intranet equipment reaches Q; if yes, determining that the resources of the configuration resource group occupied by the intranet equipment are used up; if not, determining that the resources of the configuration resource group occupied by the intranet equipment are not used up; adding 1 to the value of the counting variable every time NAT processing is carried out on a message based on a configuration resource group occupied by the intranet equipment; and subtracting 1 from the value of the counting variable every time one session of the intranet equipment finishes aging. That is to say, a counting variable is added to record the occupation situation of the current configuration resource group, so that whether the resources of the configuration resource group are used up can be quickly obtained by judging whether the value of the counting variable reaches the port number Q of each port block.

When the aging of the session is considered, the counting variable may be processed differently according to different requirements, for example, the value of the counting variable may be changed when the aging of the session is completed, or the value of the technical variable may be changed when the aging of the session is started. In the case where it is considered that there is an aging configuration resource group, if the count variable changes its value until the aging is completed, but at the time of starting the aging, it is possible to set the configuration resource group to be in an aging state, the configuration resource group may have both an in-use state and an aging state.

Further, in order to improve efficiency of searching whether the intranet device has an occupied configuration resource group, the method may include: and recording the corresponding relation between the intranet address hash of the intranet equipment and the configuration resource group occupied by the intranet equipment by utilizing one node in the pre-created hash chain table. Compared with other linked lists, the hash linked list is higher in efficiency of accessing, and the hash linked list can be used for a plurality of inquiry processes to simultaneously search the corresponding relation between intranet equipment and configuration resource groups. Specifically, the hash chain table is equivalent to a chain table formed by a plurality of arrays, when searching, the array in which the hash value is stored is searched from the chain table in a matching manner, and after the specific array is determined, other information such as a counting variable and the like can be obtained from the array. The Hash chain table comprises a plurality of arrays, so that a plurality of processes can access the chain table at the same time, and the query efficiency is improved.

Further, when the existence of the aging linked list is considered, two hash linked lists can be used to respectively store the corresponding relationship between the intranet equipment and the configuration resource group being used by the intranet equipment or the configuration resource group being aged. In particular. Recording the corresponding relation between the intranet address hash of the intranet equipment and the configuration resource group which is used by the intranet equipment by using one node in a pre-created first hash chain table; and recording the corresponding relation between the intranet address hash of the intranet equipment and the aging configuration resource group of the intranet equipment by using one node in the pre-created second hash chain table.

Under the condition that whether a certain node in the first hash chain table needs to be deleted or not is determined by the counting variable and is added into the second hash chain table, if the counting variable changes when the session starts to age, the node in the first hash chain table should be deleted and added into the second hash chain table when the counting variable is 0, which indicates that the configured resource group represented by the node starts to age; and when the node is added into the second hash chain table, timing should be started, when a time threshold is reached, the configuration resource group is represented to be aged, the node should be deleted from the second hash chain table, and the configuration resource group is marked as an unused state again. If the count variable changes when the session aging is complete, then when the count variable is 1 and the last session begins to age, the node in the first hash chain should be deleted and added to the second hash chain. The unused configuration resource groups can also be stored in a linked list, so that the scheduling and the use are convenient.

According to the one or more embodiments, the pre-binding relationship between the configuration resource group and the intranet equipment is released, the resources in the resource pool are reasonably configured, the configuration resources are dynamically scheduled, so that the idle configuration resource group is reduced, and the utilization rate of the limited configuration resources is improved. In addition, by reasonably configuring the resources in the resource pool, the configuration resources in each configuration resource group can be increased, and the occurrence of packet loss caused by insufficient configuration resources in the configuration resource groups is reduced.

In the related art, the resources in the resource pool include M public network addresses, the port range of N ports specifies that the number of ports of each port block is S, and then the method for calculating the configuration resources reserved for the intranet device is as follows: the method for calculating the IP address and the port range of the reserved configuration resource group can comprise the following steps: calculating the number of configuration resource groups corresponding to 1 IP address, wherein the number is N/S; calculating the intranet address offset of the intranet equipment, and subtracting the initial address of the intranet from the intranet source address of the message; calculating a public network source address of a configuration resource group reserved for the intranet equipment, and a quotient of an available public network starting address of the resource pool and the quantity of the configuration resource groups corresponding to the intranet address offset and the 1 IP address; calculating the starting port of the configuration resource group reserved for the intranet equipment, and adding the product of the surplus value of the intranet address offset and the number of the configuration resource groups corresponding to 1 IP address and S to the starting port available for the resource pool; and calculating an ending port of the configuration resource group reserved for the intranet equipment, and adding S-1 to a starting port of the reserved configuration resource group. Thus, the configuration resource group can be obtained and used through the calculated public network source address, the starting port and the ending port of the configuration resource group reserved for the intranet equipment.

The method will be described below with reference to a specific embodiment. Assuming that resources in the resource pool are reasonably configured in advance to obtain a plurality of configuration resource groups, and the number of the configuration resource groups is smaller than the number of the intranet devices, as shown in fig. 3, fig. 3 is a flowchart of another configuration resource scheduling method shown in this specification according to an embodiment, and includes the following steps:

step 301, a hash value of a network source address in a message is obtained.

And hashing the source address in the message to obtain the hash value.

And step 302, using whether the hash chain table has the node of the hash value, if so, executing step 303, and if not, executing step 306.

In the embodiment, the efficiency of dynamic scheduling is improved by using the hash chain table and the aged hash chain table. In the method, the first hash chain table is a hash chain table, the second hash chain table is a second hash chain table in the embodiment, and the two hash chain tables both store the corresponding relationship between the configuration resource group represented by the node and the intranet equipment. And judging whether a node using the hash value exists in the hash chain table, namely whether a configuration resource group which is used by the intranet equipment exists.

Step 303, whether the counting variable of the node reaches the port number Q of each port block, if so, the execution is 305, and if not, the execution is 304.

In both hash chain tables there is also a count variable to record how many resources in the set of configuration resources are used, wherein in this embodiment the count variable changes as the session starts to age. And when the last unaged session in the configuration resource group starts to age, deleting the configuration resource group from the used hash chain table, adding the configuration resource group to the aged hash chain table, and recording the counting variable as 0. And judging whether the counting variable reaches Q, namely judging whether all the resources in the configuration resource group are occupied.

And 304, performing NAT processing on the message based on the configuration resource group, and adding 1 to the counting variable.

And step 305, packet loss.

And step 306, whether the aged hash chain table has the node of the hash value or not is judged, if the aged hash chain table has the node of the hash value, the step 307 is executed, and if the aged hash chain table does not have the node of the hash value, the step 308 is executed.

If the configuration resource group exists in the aging hash chain table, the configuration resource group only exists in the resources which are not used at the moment and the resources which are aging. In order to prevent multiple configuration resource groups from being allocated to an intranet device, when there is an aging configuration resource corresponding to the intranet device, the aging process of the configuration resource group should be stopped, and the intranet device should reuse the configuration resource group to perform message transmission and reception.

And 307, adding the configuration resource group from the aging linked list to the used hash linked list again, performing NAT processing on the message based on the configuration resource group, and recording a counting variable as 1.

And 308, allocating an unoccupied configuration resource group for the intranet equipment from an unused linked list, performing NAT processing on the message based on the configuration resource group, and recording a counting variable as 1.

When the intranet device is found not to have a corresponding configuration resource group, when configuration is correct, when there are remaining configuration resource groups, an unused or not aging configuration resource group should be allocated for the intranet device to communicate with the public network.

In addition, in order to release an unoccupied configuration resource group, when the last session in the configuration resource group is aged, the last session should be deleted from the aged hash chain table and added to the unused chain table, so that other intranet devices without configuration resource groups can perform NAT processing on a packet requesting a new session based on the configuration resource group when the new session is required.

Through the embodiment, the binding relationship between the configuration resource group and the intranet equipment is released through reasonably configuring the resources in the resource pool, and the configuration resource group is scheduled through a reasonable dynamic allocation process, so that the configuration resource group is fully utilized and multiplexed. Therefore, the number of idle configuration resource groups is reduced at the same time, and the utilization rate of limited configuration resources is improved.

Corresponding to the embodiments of the foregoing method, the present specification also provides embodiments of an apparatus and a gateway device applied thereto.

As shown in fig. 4, fig. 4 is a block diagram of a configuration resource scheduling apparatus, which is applied to a gateway device corresponding to S intranet devices, according to an exemplary embodiment shown in this specification; pre-configuring a resource pool of the gateway device, so that the resource pool comprises M public network addresses and a port range consisting of N ports, the port range is divided into a plurality of port blocks, the number of the ports of each port block is Q, and each port block and the public network address form a configuration resource group aiming at each public network address; wherein M N/Q < S; the device comprises:

the NAT processing unit 410 is configured to, in a case where a message requesting a new session is received from any intranet device, perform NAT processing on the message based on a configuration resource group that the intranet device is occupying if the configuration resource group that the intranet device is occupying exists; if the configuration resource group occupied by the intranet equipment does not exist, enabling the intranet equipment to occupy an unoccupied configuration resource group, and carrying out NAT processing on the message based on the configuration resource group occupied by the intranet equipment;

and the resource group withdrawing unit 420 is configured to withdraw the configuration resource group that the intranet device is occupying under the condition that it is monitored that all sessions of the intranet device are aged.

Further, the determining, in the NAT processing unit, whether there is a configuration resource group that the intranet device is occupying includes: if the configuration resource group used by the intranet equipment exists or the aging configuration resource group of the intranet equipment exists, determining that the configuration resource group occupied by the intranet equipment exists; if it is determined that the configuration resource group used by the intranet equipment does not exist and the aging configuration resource group of the intranet equipment does not exist, determining that the configuration resource group occupied by the intranet equipment does not exist; for any configuration resource group, when the condition that the aging condition corresponding to the configuration resource group is met is monitored, the configuration resource group begins to age; the aging condition corresponding to the configuration resource group is that the last unaged session of the intranet equipment starts to age; if it is determined that the aging configuration resource group of the intranet device exists, the NAT processing unit further includes, before performing NAT processing on the message: and the aging stopping unit is used for stopping aging the configuration resource group and enabling the intranet equipment to reuse the configuration resource group.

Further, in the NAT processing unit, performing NAT processing on the packet based on the configuration resource group that the intranet device is occupying, including: judging whether the resources of the configuration resource group occupied by the intranet equipment are used up or not; if the message is used up, performing NAT processing on the message based on the configuration resource group occupied by the intranet equipment; the device further comprises: and the NAT processing rejection unit is used for rejecting the NAT processing of the message if the message is not used up.

Further, the NAT processing unit determining whether the set of configuration resources occupied by the intranet device is used up includes: judging whether the value of a counting variable corresponding to the configuration resource group occupied by the intranet equipment reaches Q; if yes, determining that the resources of the configuration resource group occupied by the intranet equipment are used up; if not, determining that the resources of the configuration resource group occupied by the intranet equipment are not used up; adding 1 to the value of the counting variable every time NAT processing is carried out on a message based on a configuration resource group occupied by the intranet equipment; and subtracting 1 from the value of the counting variable every time one session of the intranet equipment finishes aging.

Further, a node in a pre-created hash chain table may be used to record a correspondence between the intranet address hash of the intranet device and the configuration resource group that the intranet device is occupying.

Further, a node in a pre-created first hash chain table can be used for recording the corresponding relation between the intranet address hash of the intranet equipment and the configuration resource group which is used by the intranet equipment; and recording the corresponding relation between the intranet address hash of the intranet equipment and the aging configuration resource group of the intranet equipment by using one node in the pre-created second hash chain table.

The implementation process of the functions and actions of each module in the above device is specifically described in the implementation process of the corresponding step in the above method, and is not described herein again.

For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, wherein the modules described as separate parts may or may not be physically separate, and the parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution in the specification. One of ordinary skill in the art can understand and implement it without inventive effort.

As shown in fig. 5, fig. 5 is a hardware structure diagram of a gateway device in which a resource scheduling apparatus is configured in the embodiment, where the gateway device includes one or more processors; a memory for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the aforementioned method of scheduling configuration resources. The apparatus may include: a processor 1010, a memory 1020, an input/output interface 1030, a communication interface 1040, and a bus 1050. Wherein the processor 1010, memory 1020, input/output interface 1030, and communication interface 1040 are communicatively coupled to each other within the device via bus 1050.

The processor 1010 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits, and is configured to execute related programs to implement the technical solutions provided in the embodiments of the present disclosure.

The Memory 1020 may be implemented in the form of a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, or the like. The memory 1020 may store an operating system and other application programs, and when the technical solution provided by the embodiments of the present specification is implemented by software or firmware, the relevant program codes are stored in the memory 1020 and called to be executed by the processor 1010.

The input/output interface 1030 is used for connecting an input/output module to input and output information. The i/o module may be configured as a component in a device (not shown) or may be external to the device to provide a corresponding function. The input devices may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output devices may include a display, a speaker, a vibrator, an indicator light, etc.

The communication interface 1040 is used for connecting a communication module (not shown in the drawings) to implement communication interaction between the present apparatus and other apparatuses. The communication module can realize communication in a wired mode (such as USB, network cable and the like) and also can realize communication in a wireless mode (such as mobile network, WIFI, Bluetooth and the like).

Bus 1050 includes a path that transfers information between various components of the device, such as processor 1010, memory 1020, input/output interface 1030, and communication interface 1040.

It should be noted that although the above-mentioned device only shows the processor 1010, the memory 1020, the input/output interface 1030, the communication interface 1040 and the bus 1050, in a specific implementation, the device may also include other components necessary for normal operation. In addition, those skilled in the art will appreciate that the above-described apparatus may also include only those components necessary to implement the embodiments of the present description, and not necessarily all of the components shown in the figures.

Embodiments of the present specification further provide a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the foregoing method for scheduling configuration resources.

Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.

The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.

Other embodiments of the present description will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This specification is intended to cover any variations, uses, or adaptations of the specification following, in general, the principles of the specification and including such departures from the present disclosure as come within known or customary practice within the art to which the specification pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the specification being indicated by the following claims.

It will be understood that the present description is not limited to the precise arrangements described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.

The above description is only a preferred embodiment of the present disclosure, and should not be taken as limiting the present disclosure, and any modifications, equivalents, improvements, etc. made within the spirit and principle of the present disclosure should be included in the scope of the present disclosure.

18页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种网络工程用具有分布式混合结构的交换机

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!