CN107465771B - Network address segment dividing method and system - Google Patents

Network address segment dividing method and system Download PDF

Info

Publication number
CN107465771B
CN107465771B CN201710854749.6A CN201710854749A CN107465771B CN 107465771 B CN107465771 B CN 107465771B CN 201710854749 A CN201710854749 A CN 201710854749A CN 107465771 B CN107465771 B CN 107465771B
Authority
CN
China
Prior art keywords
subnet
address
current
mask
calculating
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.)
Active
Application number
CN201710854749.6A
Other languages
Chinese (zh)
Other versions
CN107465771A (en
Inventor
王明仪
王文彦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong University of Technology
Original Assignee
Guangdong University of Technology
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 Guangdong University of Technology filed Critical Guangdong University of Technology
Priority to CN201710854749.6A priority Critical patent/CN107465771B/en
Publication of CN107465771A publication Critical patent/CN107465771A/en
Application granted granted Critical
Publication of CN107465771B publication Critical patent/CN107465771B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2101/00Indexing scheme associated with group H04L61/00
    • H04L2101/60Types of network addresses
    • H04L2101/668Internet protocol [IP] address subnets
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application discloses a network address segment partitioning partyA method and system comprising: receiving an IP address, a mask code, a dividing subnet number and a required IP number of a subnet which are input by a user; obtaining the actual IP number of the subnet by using the IP number required by the subnet; calculating M of 2 with the minimum number of the actually required IP of the sub-networks[i]Obtaining the distributed IP number of the subnet according to the even number of the power; m of total number of bits and subnet using mask[i]Obtaining subnet mask length and subnet mask; generating the sequence of the subnets according to the sequence of the actual required IP numbers of the subnets from large to small; calculating the broadcast address of the current subnet by using the initial IP and the number of the distributed IPs of the subnet; and calculating the starting address of the subnet by using the broadcast address and the IP address of the subnet. According to the method and the device, the network segment address and the subnet mask of the subnet can be calculated only by inputting the IP address, the mask, the subnet dividing number and the required IP number of the subnet by a user, so that the non-uniform division of the network address segment can be rapidly, accurately and automatically completed.

Description

Network address segment dividing method and system
Technical Field
The invention relates to the field of internet, in particular to a network address segment dividing method and a network address segment dividing system.
Background
In the modern society with more and more developed communication, the network construction becomes more and more rapid, wherein the network address planning is also an indispensable part in the network construction design, and the automatic network address planning can reduce the time and accuracy of the network planning construction.
The algorithm and software in the prior art can only carry out uniform subnet division, but cannot carry out non-uniform subnet division.
Therefore, how to rapidly and accurately perform the non-uniform subnet division is a problem to be solved by those skilled in the art.
Disclosure of Invention
In view of the above, the present invention provides a method and a system for dividing a network address segment, so as to quickly, accurately and automatically calculate a network address of each subnet, and complete non-uniform division of the network address segment. The specific scheme is as follows:
a method of network address segment partitioning, comprising:
receiving an IP address, a mask code, a dividing subnet number and a required IP number corresponding to each subnet input by a user;
adding 2 to the required IP number corresponding to each subnet to obtain the actual required IP number corresponding to each subnet;
respectively calculating M which is more than or equal to 2 with minimum actual required IP number corresponding to each subnet[i]Obtaining the distribution IP number corresponding to each subnet by the even number of the power;
subtracting M corresponding to each subnet by using total bits of mask[i]Obtaining the subnet mask length and the subnet mask corresponding to each subnet;
sequencing each subnet according to the sequence of the actual required IP numbers from large to small by using the actual required IP numbers corresponding to each subnet, and generating the sequence of each subnet;
calculating an initial IP by utilizing the IP address and the mask phase, and calculating a broadcast address of the current subnet by utilizing the initial IP, the current subnet and the distributed IP number of all subnets before the current subnet;
and judging whether the sequence of the current subnet is 1, if so, the starting address of the current subnet is equal to the IP address, and if not, the starting address of the current subnet is equal to the broadcasting address of the previous subnet plus 1.
Optionally, the method further includes:
substituting the distributed IP number and the required IP number corresponding to each subnet into an unused IP number calculation formula to calculate the unused IP number corresponding to each subnet;
wherein, the unused IP number calculation formula is as follows:
Figure BDA0001413958370000021
in the formula, F[n]Representing the number of unused IPs for subnets in order n,
Figure BDA0001413958370000022
indicating the allocated IP number, U, of the subnets in order nnRepresenting the required number of IPs for the subnet in order n.
Optionally, the method further includes:
substituting the sum of the total number of the IP allocable addresses and the allocated IP number allocated to each subnet into a residual IP address number calculation formula according to the sequence of each subnet, and calculating the residual IP address number corresponding to each subnet;
wherein, the remaining IP address number calculation formula is as follows:
Figure BDA0001413958370000023
in the formula, G[i]Denotes the number of remaining IP addresses of the subnet in order i, and Y denotes the length of the mask.
Optionally, the method further includes:
and obtaining the network segment address corresponding to each subnet by using the starting address and the subnet mask length corresponding to each subnet.
Optionally, the method further includes:
calculating a termination IP by using a termination IP calculation formula;
wherein, the terminating IP calculation formula is: h + X232-Y-1;
Wherein H represents the terminating IP.
Optionally, the method further includes:
and obtaining the assignable IP address range corresponding to each subnet by using the starting address and the broadcast address corresponding to each subnet.
Optionally, the method further includes:
calculating the default gateway corresponding to each subnet by utilizing a default gateway calculation formula and the start address corresponding to each subnet;
wherein the default gateway calculation formula is: e[i]=A[i]+1;
In the formula, E[i]Default gateway, A, representing subnets of order i[i]Indicating the start address of the subnet in order i.
Optionally, the calculating the broadcast address of the current subnet by using the initial IP, the current subnet, and the number of allocated IPs of all subnets before the current subnet, includes:
substituting the initial IP, the current subnet and the distributed IP numbers of all the subnets before the current subnet into a broadcast address calculation formula to calculate the broadcast address of the current subnet;
wherein, the broadcast address calculation formula is:
Figure BDA0001413958370000031
in the formula, B[i]Denotes the broadcast address of the subnet in order i, X denotes the starting IP,
Figure BDA0001413958370000032
the assigned IP number for the subnet with order i.
Optionally, the determining whether the order of the current subnet is 1, if yes, the start address of the current subnet is equal to the IP address, and if no, the start address of the current subnet is equal to the broadcast address of the previous subnet plus 1 includes:
judging whether the sequence of the current subnet is 1 or not by using a starting address calculation formula, if so, the starting address of the current subnet is equal to the IP address, and if not, the starting address of the current subnet is equal to the broadcast address of the previous subnet plus 1;
wherein, the starting address calculation formula is as follows:
Figure BDA0001413958370000033
in the formula, A[i]Representing the start address of the subnet in order i, IP representing said IP address, B[i-1]Indicating the broadcast addresses of the subnets in order i-1.
The invention also discloses a network address segment dividing system, which comprises:
the receiving module is used for receiving the IP address, the mask code, the divided sub-network number and the required IP number corresponding to each sub-network input by the user;
the actual IP calculating module is used for adding 2 to the required IP number corresponding to each subnet to obtain the actual required IP number corresponding to each subnet;
an IP allocation calculation module for calculating M which is more than or equal to 2 with minimum actual required IP number corresponding to each subnet respectively[i]Obtaining the distribution IP number corresponding to each subnet by the even number of the power;
a subnet mask calculation module for subtracting M corresponding to each subnet by the total number of bits of the mask[i]Obtaining the subnet mask length and the subnet mask corresponding to each subnet;
the subnet order calculation module is used for sequencing each subnet according to the sequence of the actual required IP numbers from large to small by utilizing the actual required IP numbers corresponding to each subnet to generate the order of each subnet;
the broadcast address calculation module is used for calculating an initial IP by utilizing the IP address and the mask phase, and calculating the broadcast address of the current subnet by utilizing the initial IP, the current subnet and the distributed IP number of all subnets before the current subnet;
and the starting address calculation module is used for judging whether the sequence of the current subnet is 1, if so, the starting address of the current subnet is equal to the IP address, and if not, the starting address of the current subnet is equal to the broadcast address of the previous subnet plus 1.
The invention relates to a network address field dividing method, which comprises the following steps: receiving an IP address, a mask code, a dividing subnet number and a required IP number corresponding to each subnet input by a user; adding 2 to the required IP number corresponding to each subnet to obtain the actual required IP number corresponding to each subnet; respectively calculating M which is more than or equal to 2 with minimum actual required IP number corresponding to each subnet[i]Obtaining the distribution IP number corresponding to each subnet by the even number of the power; subtracting M corresponding to each subnet by using total bits of mask[i]Obtaining the subnet mask length and the subnet mask corresponding to each subnet; sequencing each subnet according to the sequence of the actual required IP numbers from large to small by using the actual required IP numbers corresponding to each subnet, and generating the sequence of each subnet; calculating initial IP by using IP address and mask AND, and calculating all sub-networks before current sub-network and current sub-network by using initial IPThe number of distributed IP is calculated, and the broadcast address of the current subnet is calculated; and judging whether the sequence of the current subnet is 1, if so, the starting address of the current subnet is equal to the IP address, and if not, the starting address of the current subnet is equal to the broadcasting address of the previous subnet plus 1.
The invention can obtain the actual required IP number of the subnet through the required IP number of the subnet only by inputting the IP address, the mask, the dividing subnet number and the required IP number respectively corresponding to each subnet by a user, and the minimum 2M of the actual required IP number corresponding to the subnet or more is calculated[i]Obtaining the distributed IP numbers corresponding to the subnets by the even number of the power, and utilizing the total number of the mask and M[i]The method comprises the steps of obtaining the subnet mask length and the subnet mask corresponding to each subnet, generating an order of the subnets according to the actual required IP number from large to small, calculating the broadcast address of the subnet by using the initial IP and the distributed IP number of the subnets, and finally obtaining the start address of the subnet by using the broadcast address and the IP address to finish the division of the network address field of the subnet, thereby realizing the rapid, accurate and automatic calculation of the network address of each subnet and finishing the non-uniform division of the network address field.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flow chart illustrating a network address segment partitioning method disclosed in the embodiments of the present invention;
FIG. 2 is a schematic diagram of a network address segment partitioning system according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention discloses a network address field dividing method, which comprises the following steps that as shown in figure 1:
step S11: and receiving the IP address, the mask, the divided subnet number and the required IP number corresponding to each subnet input by a user.
For example, the user inputs the IP address of 202.12.3.0, the mask of/24, the number of divided subnets of 5, the number of required IPs for the first subnet of 23, the number of required IPs for the second subnet of 16, the number of required IPs for the third subnet of 56, the number of required IPs for the fourth subnet of 9, and the number of required IPs for the fifth subnet of 13.
It will be appreciated that the initial number of subnets may be generated automatically, in accordance with the user creation order.
Step S12: and adding 2 to the required IP number corresponding to each subnet to obtain the actual required IP number corresponding to each subnet.
Specifically, each subnet needs a broadcast address and a start address, which cannot be directly utilized by the subnet, so that to satisfy the required IP number corresponding to each subnet, 2 needs to be added to the required IP number to represent the broadcast address and the start address of the subnet, and the actual required IP number corresponding to each subnet is obtained, for example, the required IP number of the subnet is 56, and the actual required IP number of the subnet is 58.
Step S13: respectively calculating M which is more than or equal to 2 with minimum actual required IP number corresponding to each subnet[i]And obtaining the distributed IP number corresponding to each subnet by the even number of the power.
It will be appreciated that since the IP address is allocated in 2, if the actual required IP number of the subnet is not a power of 2, the allocated IP number of the subnet will be greater than the actual required IP number of the subnet.
Specifically, after the actual required IP number of the subnet is obtained, the IP number to be allocated to each subnet is calculatedThe number of distributed IP of each subnet is calculated to be more than or equal to M of 2 with the minimum number of actual required IP corresponding to each subnet[i]Even to the power of the power, the respective allocated IP number of each subnet is obtained, for example, the actual required IP number of the subnet is 58, which is at 25And 26I.e., 32 ≦ 58 ≦ 64, so the subnet's assigned IP number is 64, M[i]The value is 6.
Step S14: subtracting M corresponding to each subnet by using total bits of mask[i]And obtaining the subnet mask length and the subnet mask corresponding to each subnet.
Specifically, the total number of bits of the mask, that is, the total length is 32 bits, and the subnet mask of the subnet can be calculated after the subnet mask length of the subnet is known, so that M corresponding to each subnet is subtracted by the total number of bits of the mask[i]Obtaining the subnet mask length and subnet mask corresponding to each subnet, e.g. M of subnet[i]A value of 6, the total number of bits of the mask 32 is used to subtract M of the subnet[i]The subnet mask length of the subnet is 26, and the subnet mask is 255.255.255.192.
Wherein the subnet mask length may be j[i]=32-M[i]Is represented by the formula, wherein j[i]The subnet mask length of the subnet in order i is indicated, and 32 indicates the total number of bits of the mask.
Step S15: and sequencing each subnet according to the sequence of the actual required IP numbers from large to small by using the actual required IP numbers corresponding to each subnet, and generating the sequence of each subnet.
Specifically, since the numbers of the subnets are determined according to the input sequence of the user, it is difficult to ensure that the sequence of the numbers is arranged from large to small according to the actually required IP numbers, and therefore, the actually required IP numbers corresponding to the subnets are utilized to sort the subnets according to the order from large to small of the actually required IP numbers, so as to generate the sequence of the subnets, and avoid the situation that the IP allocation is wasted due to the allocation not according to the sequence, for example, the number of the required IPs for the first subnet is 23, the number of the required IPs for the second subnet is 16, the number of the required IPs for the third subnet is 56, the number of the required IPs for the fourth subnet is 9, and the number of the required IPs for the fifth subnet is 13, the sequence of the third subnet is 1, the sequence of the first subnet is 2, the sequence of the second subnet is 3, the sequence of the fifth subnet is 4, and the sequence of the fourth subnet is 5.
Step S16: and calculating an initial IP by utilizing the IP address and the mask phase, and calculating the broadcast address of the current subnet by utilizing the initial IP, the current subnet and the distributed IP number of all subnets before the current subnet.
Specifically, an IP address and a mask are used to sum up, calculate a starting IP, for example, the IP address is 202.12.3.0, the mask is 255.255.255.0, convert both the IP address and the mask into 2-ary system, sum up 8 bits each, calculate the starting IP to be 202.12.3.0, obtain the starting IP, and then use the starting IP, the current subnet and the allocated IP number of all subnets before the current subnet order, for example, the starting IP is 202.12.3.0, the subnet with the order of 3 is the current subnet, the allocated IP number of the current subnet is 32, the allocated IP number of the subnet with the order of 2 is 32, the allocated IP number of the subnet with the order of 1 is 64, and calculate the broadcast address of the current subnet.
It will be appreciated that the remaining subnets are computed in a manner consistent with the current subnet, thereby computing the broadcast address for each subnet.
Step S17: and judging whether the sequence of the current subnet is 1, if so, the starting address of the current subnet is equal to the IP address, and if not, the starting address of the current subnet is equal to the broadcasting address of the previous subnet plus 1.
Therefore, the embodiment of the invention can obtain the actual required IP number of the subnet through the required IP number of the subnet by only inputting the IP address, the mask, the divided subnet number and the required IP number corresponding to each subnet by the user, and calculate the M [ i ] with the minimum value of 2 which is more than or equal to the actual required IP number corresponding to the subnet]Obtaining the distributed IP numbers corresponding to the subnets by the even number of the power, and utilizing the total number of the mask and M[i]Obtaining the subnet mask length and subnet mask corresponding to each subnet, generating the order of each subnet according to the actual required IP number from large to small, calculating the broadcast address of the subnet by using the initial IP and the distributed IP number of the subnet, and finally using the broadcast placeAnd the address and the IP address are used for obtaining the starting address of the subnet and completing the division of the network address field of the subnet, thereby realizing the rapid, accurate and automatic calculation of the network address of each subnet and completing the non-uniform division of the network address field.
The embodiment of the invention discloses a specific network address field division method, and compared with the previous embodiment, the embodiment further explains and optimizes the technical scheme. Specifically, the method comprises the following steps:
in the embodiment of the present invention, in order to further improve the user experience, the related content of network address segment division may be more comprehensively calculated, and the following steps S21 to S28 may be included; in particular, the method comprises the following steps of,
step S21: and substituting the distributed IP number and the required IP number corresponding to each subnet into an unused IP number calculation formula to calculate the unused IP number corresponding to each subnet.
Wherein, the unused IP number calculation formula is as follows:
Figure BDA0001413958370000081
in the formula, F[n]Representing the number of unused IPs for subnets in order n,
Figure BDA0001413958370000082
indicating the allocated IP number, U, of the subnets in order nnRepresenting the required number of IPs for the subnet in order n.
E.g. subnets in order of 2, M[n]Is equal to 5, UnEqual to 23 and the unused IP number equal to 7.
Step S22: and substituting the sum of the total number of the IP allocable addresses and the allocated IP number allocated to each subnet into a residual IP address number calculation formula according to the sequence of each subnet, and calculating the residual IP address number corresponding to each subnet.
Wherein, the calculation formula of the residual IP address number is as follows:
Figure BDA0001413958370000083
in the formula, G[i]Indicating the number of remaining IP addresses of the subnet in order i, YIndicating the length of the mask.
For example, the number of allocated IPs for the subnet in the order of 1 is 64, the number of allocated IPs for the subnet in the order of 2 is 32, the subnet in the order of 3 is the current subnet, the length of the mask is 24, and the remaining IP addresses 128 after the subnet in the order of 3 are obtained by substituting the remaining IP address number calculation formula.
Step S23: and obtaining the network segment address corresponding to each subnet by using the starting address and the subnet mask length corresponding to each subnet.
For example, the subnet has a start address of 202.12.3.0, a subnet mask length of 26, and a segment address of 202.12.3.0/26, i.e., A[i]/j。
Step S24: and calculating the termination IP by using a termination IP calculation formula.
Wherein, the formula for terminating the IP calculation is as follows: h + X232-Y-1;
In the formula, H represents a terminating IP.
For example, the start IP is 202.12.3.0, the mask length is 24, and the stop IP is 202.12.3.255.
Step S27: and obtaining the assignable IP address range corresponding to each subnet by using the starting address and the broadcast address corresponding to each subnet.
Specifically, the assignable IP address range of each subnet is between the start address and the broadcast address corresponding to each subnet, and can be expressed as (a) by using a calculation formula[i]+1 to (B)[i]-1), for example, the subnet has a start address of 202.12.3.0 and the subnet has a broadcast address of 202.12.3.63, the subnet has an allocable IP address range of 202.12.3.1 to 202.12.3.62.
Step S28: and calculating the default gateway corresponding to each subnet by utilizing a default gateway calculation formula and the starting address corresponding to each subnet.
The default gateway calculation formula is as follows: e[i]=A[i]+1;
In the formula, E[i]Default gateway, A, representing subnets of order i[i]Indicating the start address of the subnet in order i.
For example, the start address of a subnet is 202.12.3.64, then the default gateway for that subnet is 202.12.3.65.
In the embodiment of the present invention, the process of calculating the broadcast address of the current subnet by using the initial IP, the current subnet, and the allocated IP numbers of all subnets before the current subnet in sequence described in the previous embodiment may specifically be:
substituting the initial IP, the current subnet and the distributed IP numbers of all the subnets before the current subnet into a broadcast address calculation formula to calculate the broadcast address of the current subnet;
the broadcast address calculation formula is as follows:
Figure BDA0001413958370000091
in the formula, B[i]Indicating the broadcast address of the subnet in order i, X indicating the starting IP,
Figure BDA0001413958370000092
the assigned IP number for the subnet with order i.
In the previous embodiment, the step of determining whether the order of the current subnet is 1, if yes, the start address of the current subnet is equal to the IP address, and if no, the start address of the current subnet is equal to the broadcast address of the previous subnet plus 1 may specifically be:
judging whether the sequence of the current subnet is 1 or not by using a starting address calculation formula, if so, the starting address of the current subnet is equal to the IP address, and if not, the starting address of the current subnet is equal to the broadcast address of the previous subnet plus 1;
wherein, the starting address calculation formula is as follows:
Figure BDA0001413958370000093
in the formula, A[i]Denotes the start address of the subnet in order i, IP denotes the IP address, B[i-1]Indicating the broadcast addresses of the subnets in order i-1.
Furthermore, in order to facilitate the user to look up the calculation result and improve the user experience, various data can be exported and stored in a form of a table for the user to look up, as shown in the address planning description table in table 1.
TABLE 1
Figure BDA0001413958370000101
Correspondingly, the embodiment of the present invention also discloses a network address segment dividing system, as shown in fig. 2, the system includes:
a receiving module 11, configured to receive an IP address, a mask, a divided subnet number, and a required IP number corresponding to each subnet, which are input by a user;
an actual IP calculation module 12, configured to add 2 to the required IP number corresponding to each subnet, to obtain an actual required IP number corresponding to each subnet;
an IP allocation calculation module 13 for calculating M which is greater than or equal to 2 with the minimum number of the actual required IP corresponding to each subnet respectively[i]Obtaining the distribution IP number corresponding to each subnet by the even number of the power;
a subnet mask calculating module 14 for subtracting M corresponding to each subnet by the total number of bits of the mask[i]Obtaining the subnet mask length and the subnet mask corresponding to each subnet;
a subnet order calculating module 15, configured to sort each subnet according to a sequence of actual required IP numbers from large to small by using the actual required IP numbers corresponding to each subnet, and generate an order of each subnet;
a broadcast address calculation module 16, configured to calculate an initial IP by using the IP address and the mask phase, and calculate a broadcast address of the current subnet by using the initial IP, the current subnet, and the allocated IP number of all subnets before the current subnet order;
and a start address calculation module 17, configured to determine whether the order of the current subnet is 1, if yes, the start address of the current subnet is equal to the IP address, and if no, the start address of the current subnet is equal to the broadcast address of the previous subnet plus 1.
Therefore, the embodiment of the invention only needs user inputThe IP address, the mask, the dividing subnet number and the required IP number corresponding to each subnet respectively can obtain the actual required IP number of the subnet according to the required IP number of the subnet, and the M which is more than or equal to 2 and has the minimum actual required IP number corresponding to the subnet is calculated[i]Obtaining the distributed IP numbers corresponding to the subnets by the even number of the power, and utilizing the total number of the mask and M[i]The method comprises the steps of obtaining the subnet mask length and the subnet mask corresponding to each subnet, generating an order of the subnets according to the actual required IP number from large to small, calculating the broadcast address of the subnet by using the initial IP and the distributed IP number of the subnets, and finally obtaining the start address of the subnet by using the broadcast address and the IP address to finish the division of the network address field of the subnet, thereby realizing the rapid, accurate and automatic calculation of the network address of each subnet and finishing the non-uniform division of the network address field.
The embodiment of the invention can also comprise:
the unused IP calculation module is used for substituting the distributed IP number and the required IP number which respectively correspond to each subnet into an unused IP number calculation formula to calculate the unused IP number which respectively corresponds to each subnet;
wherein, the unused IP number calculation formula is as follows:
Figure BDA0001413958370000111
in the formula, F[n]Representing the number of unused IPs for subnets in order n,
Figure BDA0001413958370000112
indicating the allocated IP number, U, of the subnets in order nnRepresenting the required number of IPs for the subnet in order n.
The residual IP calculating module is used for substituting the sum of the total number of the IP allocable addresses and the allocated IP number of each subnet into a residual IP address number calculating formula according to the sequence of each subnet to calculate the residual IP address number corresponding to each subnet;
wherein, the calculation formula of the residual IP address number is as follows:
Figure BDA0001413958370000113
in the formula, G[i]Denotes the number of remaining IP addresses of the subnet in order i, and Y denotes the length of the mask.
And the network segment address calculation module is used for obtaining the network segment address corresponding to each subnet by utilizing the start address and the subnet mask length corresponding to each subnet.
The terminal IP calculation module is used for calculating a terminal IP by using a terminal IP calculation formula;
wherein, the formula for terminating the IP calculation is as follows: h + X232-Y-1;
In the formula, H represents a terminating IP.
And the address range calculation module is used for obtaining the assignable IP address range corresponding to each subnet by using the starting address and the broadcast address corresponding to each subnet.
In this embodiment of the present invention, the broadcast address module 16 may be specifically configured to substitute the initial IP, the current subnet, and the number of allocated IPs of all subnets before the current subnet order into a broadcast address calculation formula, so as to calculate the broadcast address of the current subnet;
the broadcast address calculation formula is as follows:
Figure BDA0001413958370000121
in the formula, B[i]Indicating the broadcast address of the subnet in order i, X indicating the starting IP,
Figure BDA0001413958370000122
the assigned IP number for the subnet with order i.
The start address calculation module 17 may be specifically configured to determine, by using a start address calculation formula, whether the order of the current subnet is 1, if yes, the start address of the current subnet is equal to the IP address, and if no, the start address of the current subnet is equal to the broadcast address of the previous subnet plus 1;
wherein, the starting address calculation formula is as follows:
Figure BDA0001413958370000123
in the formula, A[i]Denotes the start address of the subnet in order i, IP denotes the IP address, B[i-1]Indicating the broadcast addresses of the subnets in order i-1.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The method and system for dividing the network address field provided by the present invention are described in detail above, and the principle and the implementation of the present invention are explained in the present document by applying specific examples, and the description of the above embodiments is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A method for partitioning a network address field, comprising:
receiving an IP address, a mask code, a dividing subnet number and a required IP number corresponding to each subnet input by a user;
adding 2 to the required IP number corresponding to each subnet to obtain the actual required IP number corresponding to each subnet;
respectively calculating M which is more than or equal to 2 with minimum actual required IP number corresponding to each subnet[i]Obtaining the distribution IP number corresponding to each subnet by the even number of the power;
subtracting M corresponding to each subnet by using total bits of mask[i]Obtaining the subnet mask length and the subnet mask corresponding to each subnet;
sequencing each subnet according to the sequence of the actual required IP numbers from large to small by using the actual required IP numbers corresponding to each subnet, and generating the sequence of each subnet;
calculating an initial IP by utilizing the IP address and the mask phase, and calculating a broadcast address of the current subnet by utilizing the initial IP, the current subnet and the distributed IP number of all subnets before the current subnet;
judging whether the sequence of the current subnet is 1, if so, the starting address of the current subnet is equal to the IP address, and if not, the starting address of the current subnet is equal to the broadcast address of the previous subnet plus 1;
wherein, the number of the divided subnets is represented by n.
2. The method of claim 1, further comprising:
substituting the distributed IP number and the required IP number corresponding to each subnet into an unused IP number calculation formula to calculate the unused IP number corresponding to each subnet;
wherein, the unused IP number calculation formula is as follows:
Figure FDA0002382790800000011
in the formula, F[i]Representing the number of unused IPs for subnets in order i,
Figure FDA0002382790800000012
indicating the allocated IP number, U, of the subnet in order iiRepresenting the required number of IPs for a subnet in order i, 1<i<n。
3. The method of claim 1, further comprising:
substituting the sum of the total number of the IP allocable addresses and the allocated IP number allocated to each subnet into a residual IP address number calculation formula according to the sequence of each subnet, and calculating the residual IP address number corresponding to each subnet;
wherein, the remaining IP address number calculation formula is as follows:
Figure FDA0002382790800000013
in the formula, G[i]Denotes the number of remaining IP addresses of the subnet in order i, and Y denotes the length of the mask.
4. The method of claim 1, further comprising:
and obtaining the network segment address corresponding to each subnet by using the starting address and the subnet mask length corresponding to each subnet.
5. The method of claim 1, further comprising:
calculating a termination IP by using a termination IP calculation formula;
wherein, the terminating IP calculation formula is: h + X232-Y-1;
Where H denotes the terminating IP, X denotes the start address, and Y denotes the length of the mask.
6. The method of claim 1, further comprising:
and obtaining the assignable IP address range corresponding to each subnet by using the starting address and the broadcast address corresponding to each subnet.
7. The method of claim 1, further comprising:
calculating the default gateway corresponding to each subnet by using a default gateway calculation formula and the start address corresponding to each subnet;
wherein the default gateway calculation formula is: e[i]=A[i]+1;
In the formula, E[i]Default gateway, A, representing subnets of order i[i]Indicating the start address of the subnet in order i.
8. The method according to any one of claims 1 to 7, wherein the step of calculating the broadcast address of the current subnet by using the allocated IP numbers of the initial IP, the current subnet and all subnets before the current subnet comprises:
substituting the initial IP, the current subnet and the distributed IP numbers of all the subnets before the current subnet into a broadcast address calculation formula to calculate the broadcast address of the current subnet;
wherein, the broadcast address calculation formula is:
Figure FDA0002382790800000021
in the formula, B[i]Denotes the broadcast address of the subnet in order i, X denotes the starting IP,
Figure FDA0002382790800000022
to representThe assigned IP number for the subnet with order i.
9. The method according to any one of claims 1 to 7, wherein the step of determining whether the order of the current subnet is 1, if yes, the start address of the current subnet is equal to the IP address, and if no, the start address of the current subnet is equal to the broadcast address of the previous subnet plus 1 comprises:
judging whether the sequence of the current subnet is 1 or not by using a starting address calculation formula, if so, the starting address of the current subnet is equal to the IP address, and if not, the starting address of the current subnet is equal to the broadcast address of the previous subnet plus 1;
wherein, the starting address calculation formula is as follows:
Figure FDA0002382790800000031
wherein IP represents the IP address, B[i-1]Indicating the broadcast addresses of the subnets in order i-1.
10. A network address fragment partitioning system, comprising:
the receiving module is used for receiving the IP address, the mask code, the divided sub-network number and the required IP number corresponding to each sub-network input by the user;
the actual IP calculating module is used for adding 2 to the required IP number corresponding to each subnet to obtain the actual required IP number corresponding to each subnet;
an IP allocation calculation module for calculating M which is more than or equal to 2 with minimum actual required IP number corresponding to each subnet respectively[i]Obtaining the distribution IP number corresponding to each subnet by the even number of the power;
a subnet mask calculation module for subtracting M corresponding to each subnet by the total number of bits of the mask[i]Obtaining the subnet mask length and the subnet mask corresponding to each subnet;
the subnet order calculation module is used for sequencing each subnet according to the sequence of the actual required IP numbers from large to small by utilizing the actual required IP numbers corresponding to each subnet to generate the order of each subnet;
the broadcast address calculation module is used for calculating an initial IP by utilizing the IP address and the mask phase, and calculating the broadcast address of the current subnet by utilizing the initial IP, the current subnet and the distributed IP number of all subnets before the current subnet;
the starting address calculation module is used for judging whether the sequence of the current subnet is 1, if so, the starting address of the current subnet is equal to the IP address, and if not, the starting address of the current subnet is equal to the broadcast address of the previous subnet plus 1;
wherein, the number of the divided subnets is represented by n.
CN201710854749.6A 2017-09-20 2017-09-20 Network address segment dividing method and system Active CN107465771B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710854749.6A CN107465771B (en) 2017-09-20 2017-09-20 Network address segment dividing method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710854749.6A CN107465771B (en) 2017-09-20 2017-09-20 Network address segment dividing method and system

Publications (2)

Publication Number Publication Date
CN107465771A CN107465771A (en) 2017-12-12
CN107465771B true CN107465771B (en) 2020-05-19

Family

ID=60552709

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710854749.6A Active CN107465771B (en) 2017-09-20 2017-09-20 Network address segment dividing method and system

Country Status (1)

Country Link
CN (1) CN107465771B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111163188B (en) * 2020-01-02 2022-07-29 北京同有飞骥科技股份有限公司 Subnet mask conversion method and system
CN111510441B (en) * 2020-04-08 2021-02-05 中山大学 Legal and efficient method for collecting common intranet IP address
CN112437167B (en) * 2020-11-11 2023-03-24 北京天融信网络安全技术有限公司 Method and device for creating transmission channel, storage medium and electronic equipment
CN113472911B (en) * 2021-06-10 2023-05-16 新华三信息安全技术有限公司 Subnet dividing method and device
CN114301840B (en) * 2021-12-16 2024-02-13 山石网科通信技术股份有限公司 Method and device for loading geographic information base and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1325209A (en) * 2000-08-25 2001-12-05 深圳市中兴通讯股份有限公司 IP address allocation method for access server
CN1645825A (en) * 2005-01-11 2005-07-27 东南大学 Terminal to terminal running performance monitoring method based on sampling measurement
EP2779089A2 (en) * 2010-07-30 2014-09-17 Fundação D. Anna Sommer Champalimaud E Dr. Carlos Montez Champalimaud Systems and methods for segmentation and processing of tissue images and feature extraction from same for treating, diagnosing, or predicting medical conditions

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1325209A (en) * 2000-08-25 2001-12-05 深圳市中兴通讯股份有限公司 IP address allocation method for access server
CN1645825A (en) * 2005-01-11 2005-07-27 东南大学 Terminal to terminal running performance monitoring method based on sampling measurement
EP2779089A2 (en) * 2010-07-30 2014-09-17 Fundação D. Anna Sommer Champalimaud E Dr. Carlos Montez Champalimaud Systems and methods for segmentation and processing of tissue images and feature extraction from same for treating, diagnosing, or predicting medical conditions

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
《IP 地址管理系统的研究与实现》;韩军浩;《中国优秀硕士学位论文全文数据库 信息科技辑》;20081115(第11期);全文 *

Also Published As

Publication number Publication date
CN107465771A (en) 2017-12-12

Similar Documents

Publication Publication Date Title
CN107465771B (en) Network address segment dividing method and system
CN107431637B (en) Network service deployment method and device
CN105809323A (en) Task allocation method and system
US10567265B2 (en) Solution test method and server
CN112491564B (en) Method, device, equipment and medium for detecting bandwidth charging value of network equipment
CN108401290A (en) A kind of paging method and base station
MY181230A (en) Method and apparatus for realizing communication between web page and native application, and electronic device
CN111897605A (en) Data processing method and device based on micro-service architecture and readable storage medium
CN106301772A (en) Cipher set-up method, device and for arranging the device of password
CN101655803A (en) Method and mobile terminal for implementing mathematical model simulation
CN108520329B (en) Accurate automatic allocation method and device for second-hand house clients based on broker portrait
CN105761713B (en) Chord transformation processing method and device
CN105100117A (en) Method and device for accessing combined services
CN111741109A (en) Access method, device, equipment and storage medium based on proxy
CN109842482B (en) Information synchronization method, system and terminal equipment
CN111026929B (en) Text approval method, device and storage medium
CN108366136B (en) Domain name resolution method and device
CN105867922A (en) Differential upgrade method and system
CN106600327A (en) iOS advertisement unique identifier generation method
CN114329554A (en) Method, device, equipment and medium for managing key file of baseboard management controller
CN109783777B (en) Form export method and device, readable storage medium and electronic equipment
CN109729223A (en) Call service processing method, device, number changing service platform and storage medium
CN112749958A (en) Resource transfer method, device, equipment and storage medium
CN107295641A (en) RNTI distribution methods and device
CN103560979B (en) A kind of resource allocation methods and equipment

Legal Events

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