[go: up one dir, main page]

CN107465771B - A kind of network address segment division method and system - Google Patents

A kind of network address segment division 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
order
current
mask
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

本申请公开了一种网络地址段划分方法及系统,包括:接收用户输入的IP地址、掩码、划分子网数和子网的所需IP数;利用子网的所需IP数,得到子网的实际所需IP数;计算出大于等于子网的实际所需IP数最小的2的M[i]次方的偶数,得到子网的分配IP数;利用掩码的总位数和子网的M[i],得到子网掩码长度和子网掩码;依照子网的实际所需IP数从大到小的顺序,生成子网的次序;利用起始IP、子网的分配IP数,计算出当前子网的广播地址;利用子网的广播地址和IP地址,计算出子网的开始地址。本申请仅需用户输入IP地址、掩码、划分子网数和子网的所需IP数,便可计算出子网的网段地址和子网掩码,从而快速、精准和自动的完成对网络地址段的非均匀划分。

Figure 201710854749

The present application discloses a method and system for dividing a network address segment, including: receiving an IP address, a mask, the number of divided subnets, and the required IP number of the subnet entered by a user; and obtaining the subnet by using the required IP number of the subnet Calculate the actual required IP number of the subnet; calculate the even number of the minimum 2 to the M [i] power of the actual required IP number of the subnet, and obtain the allocated IP number of the subnet; use the total number of bits of the mask and the number of subnets M [i] , get the subnet mask length and subnet mask; according to the actual required IP number of the subnet from large to small, the order of the subnet is generated; using the starting IP and the allocated IP number of the subnet, Calculate the broadcast address of the current subnet; use the broadcast address and IP address of the subnet to calculate the start address of the subnet. This application only needs the user to input the IP address, mask, the number of subnets and the required IP number of the subnet, and then the network segment address and subnet mask of the subnet can be calculated, so that the network address can be quickly, accurately and automatically completed. Non-uniform division of segments.

Figure 201710854749

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.一种网络地址段划分方法,其特征在于,包括:1. a network address segment division method, is characterized in that, comprises: 接收用户输入的IP地址、掩码、划分子网数和每个子网各自对应的所需IP数;Receive the IP address, mask, number of subnets and the corresponding required IP number for each subnet entered by the user; 对每个子网各自对应的所需IP数加2,得到每个子网各自对应的实际所需IP数;Add 2 to the number of required IPs corresponding to each subnet to obtain the actual number of required IPs corresponding to each subnet; 分别计算出大于等于每个子网各自对应的实际所需IP数最小的2的M[i]次方的偶数,得到每个子网各自对应的分配IP数;Calculate the even number of the M [i] power of 2 that is greater than or equal to the actual required IP number corresponding to each subnet respectively, and obtain the corresponding allocated IP number of each subnet; 利用掩码的总位数减去每个子网各自对应的M[i],得到每个子网各自对应的子网掩码长度和子网掩码;Subtract the corresponding M [i] of each subnet from the total number of bits of the mask to obtain the corresponding subnet mask length and subnet mask of each subnet; 利用每个子网各自对应的实际所需IP数,依照实际所需IP数从大到小的顺序,对每个子网进行排序,生成各个子网的次序;Using the actual required IP number corresponding to each subnet, sort each subnet according to the actual required IP number in descending order, and generate the order of each subnet; 利用所述IP地址和所述掩码相与,计算出起始IP,利用所述起始IP、当前子网和当前子网次序前所有子网的分配IP数,计算出当前子网的广播地址;Using the sum of the IP address and the mask to calculate the starting IP, and using the starting IP, the current subnet and the allocated IP numbers of all subnets before the current subnet order, calculate the broadcast of the current subnet address; 判断当前子网的次序是否为1,如果是,则当前子网的开始地址等于所述IP地址,如果否,则当前子网的开始地址等于前一个子网的广播地址加1;Judging whether the order of the current subnet is 1, if so, the start address of the current subnet is equal to the IP address, if not, the start address of the current subnet is equal to the broadcast address of the previous subnet plus 1; 其中,划分子网数用n表示。Among them, the number of divided subnets is represented by n. 2.根据权利要求1所述的网络地址段划分方法,其特征在于,还包括:2. The network address segment division method according to claim 1, characterized in that, further comprising: 将每个子网各自对应的分配IP数和所需IP数,代入未用IP数计算公式,计算出每个子网各自对应的未用IP数;Substitute the corresponding allocated IP numbers and required IP numbers for each subnet into the calculation formula for the number of unused IPs, and calculate the number of unused IPs corresponding to each subnet; 其中,所述未用IP数计算公式为:
Figure FDA0002382790800000011
Wherein, the calculation formula of the number of unused IPs is:
Figure FDA0002382790800000011
式中,F[i]表示次序为i的子网的未用IP数,
Figure FDA0002382790800000012
表示次序为i的子网的分配IP数,Ui表示次序为i的子网的所需IP数,1<i<n。
In the formula, F [i] represents the number of unused IPs of the subnet in order i,
Figure FDA0002382790800000012
Represents the allocated IP number of the subnet in the order i, U i represents the required IP number of the subnet in the order i, 1<i<n.
3.根据权利要求1所述的网络地址段划分方法,其特征在于,还包括:3. The network address segment division method according to claim 1, characterized in that, further comprising: 依据各个子网的次序,将IP可分配地址总数和各子网已分配的分配IP数之和,代入剩余IP地址数计算公式,计算出各子网对应的剩余IP地址数;According to the order of each subnet, the total number of IP addresses that can be allocated and the total number of allocated IP addresses allocated by each subnet are substituted into the calculation formula for the number of remaining IP addresses to calculate the number of remaining IP addresses corresponding to each subnet; 其中,所述剩余IP地址数计算公式为:
Figure FDA0002382790800000013
The formula for calculating the number of remaining IP addresses is:
Figure FDA0002382790800000013
式中,G[i]表示次序为i的子网的剩余IP地址数,Y表示所述掩码的长度。In the formula, G [i] represents the number of remaining IP addresses of the subnet in order i, and Y represents the length of the mask.
4.根据权利要求1所述的网络地址段划分方法,其特征在于,还包括:4. The network address segment division method according to claim 1, characterized in that, further comprising: 利用每个子网各自对应的开始地址和子网掩码长度,得到每个子网各自对应的网段地址。Using the corresponding start address and subnet mask length of each subnet, the corresponding network segment address of each subnet is obtained. 5.根据权利要求1所述的网络地址段划分方法,其特征在于,还包括:5. The network address segment division method according to claim 1, characterized in that, further comprising: 利用终止IP计算公式计算出终止IP;Use the termination IP calculation formula to calculate the termination IP; 其中,所述终止IP计算公式为:H=X+232-Y-1;Wherein, the termination IP calculation formula is: H=X+2 32-Y -1; 式中,H表示所述终止IP,X表示所述起始地址,Y表示所述掩码的长度。In the formula, H represents the termination IP, X represents the start address, and Y represents the length of the mask. 6.根据权利要求1所述的网络地址段划分方法,其特征在于,还包括:6. The network address segment division method according to claim 1, characterized in that, further comprising: 利用每个子网各自对应的开始地址和广播地址,得到每个子网各自对应的可分配IP地址范围。Using the corresponding start address and broadcast address of each subnet, the corresponding assignable IP address range of each subnet is obtained. 7.根据权利要求1所述的网络地址段划分方法,其特征在于,还包括:7. The network address segment division method according to claim 1, characterized in that, further comprising: 利用默认网关计算公式和每个子网各自对应的开始地址,计算出每个子网各自对应的默认网关;Use the default gateway calculation formula and the corresponding start address of each subnet to calculate the default gateway corresponding to each subnet; 其中,所述默认网关计算公式为:E[i]=A[i]+1;Wherein, the default gateway calculation formula is: E [i] =A [i] +1; 式中,E[i]表示次序为i的子网的默认网关,A[i]表示次序为i的子网的开始地址。In the formula, E [i] represents the default gateway of the subnet in the order i, and A [i] represents the start address of the subnet in the order i. 8.根据权利要求1至7任一项所述的网络地址段划分方法,其特征在于,所述利用所述起始IP、当前子网和当前子网次序前所有子网的分配IP数,计算出当前子网的广播地址的过程,包括:8. the network address segment dividing method according to any one of claims 1 to 7, is characterized in that, described utilizing the distribution IP number of all subnets before described starting IP, current subnet and current subnet order, The process of calculating the broadcast address of the current subnet, including: 将所述起始IP、当前子网和当前子网次序前所有子网的分配IP数,均代入至广播地址计算公式,计算出当前子网的广播地址;The distribution IP numbers of all the subnets before the described starting IP, the current subnet and the current subnet order are all substituted into the broadcast address calculation formula, and the broadcast address of the current subnet is calculated; 其中,所述广播地址计算公式为:
Figure FDA0002382790800000021
Wherein, the calculation formula of the broadcast address is:
Figure FDA0002382790800000021
式中,B[i]表示次序为i的子网的广播地址,X表示所述起始IP,
Figure FDA0002382790800000022
表示 次序为i的子网的分配IP数。
In the formula, B [i] represents the broadcast address of the subnet in order i, X represents the starting IP,
Figure FDA0002382790800000022
Indicates the number of assigned IPs for the subnet in order i.
9.根据权利要求1至7任一项所述的网络地址段划分方法,其特征在于,所述判断当前子网的次序是否为1,如果是,则当前子网的开始地址等于所述IP地址,如果否,则当前子网的开始地址等于前一个子网的广播地址加1的过程,包括:9. The method for dividing a network address segment according to any one of claims 1 to 7, wherein the judging order of the current subnet is 1, and if so, the start address of the current subnet is equal to the IP If not, the start address of the current subnet is equal to the broadcast address of the previous subnet plus 1, including: 利用开始地址计算公式,判断当前子网的次序是否为1,如果是,则当前子网的开始地址等于所述IP地址,如果否,则当前子网的开始地址等于前一个子网的广播地址加1;Use the starting address calculation formula to determine whether the order of the current subnet is 1. If so, the starting address of the current subnet is equal to the IP address. If not, the starting address of the current subnet is equal to the broadcast address of the previous subnet. plus 1; 其中,所述开始地址计算公式为:
Figure FDA0002382790800000031
Wherein, the starting address calculation formula is:
Figure FDA0002382790800000031
式中,IP表示所述IP地址,B[i-1]表示次序为i-1的子网的广播地址。In the formula, IP represents the IP address, and B [i-1] represents the broadcast address of the subnet whose order is i-1.
10.一种网络地址段划分系统,其特征在于,包括:10. A network address segment division system, comprising: 接收模块,用于接收用户输入的IP地址、掩码、划分子网数和每个子网各自对应的所需IP数;The receiving module is used to receive the IP address, mask, the number of divided subnets and the required IP number corresponding to each subnet entered by the user; 实际IP计算模块,用于对每个子网各自对应的所需IP数加2,得到每个子网各自对应的实际所需IP数;The actual IP calculation module is used to add 2 to the required IP number corresponding to each subnet to obtain the actual required IP number corresponding to each subnet; 分配IP计算模块,用于分别计算出大于等于每个子网各自对应的实际所需IP数最小的2的M[i]次方的偶数,得到每个子网各自对应的分配IP数;The allocation IP calculation module is used to calculate the even number of the M [i] power of 2 that is greater than or equal to the minimum actual required IP number corresponding to each subnet, and obtain the corresponding allocated IP number of each subnet; 子网掩码计算模块,用于利用掩码的总位数减去每个子网各自对应的M[i],得到每个子网各自对应的子网掩码长度和子网掩码;The subnet mask calculation module is used to subtract the corresponding M [i] of each subnet from the total number of bits of the mask to obtain the corresponding subnet mask length and subnet mask of each subnet; 子网次序计算模块,用于利用每个子网各自对应的实际所需IP数,依照实际所需IP数从大到小的顺序,对每个子网进行排序,生成各个子网的次序;The subnet order calculation module is used to sort each subnet according to the actual required IP number corresponding to each subnet, according to the order of the actual required IP number from large to small, and generate the order of each subnet; 广播地址计算模块,用于利用所述IP地址和所述掩码相与,计算出起始IP,利用所述起始IP、当前子网和当前子网次序前所有子网的分配IP数,计算出当前子网的广播地址;The broadcast address calculation module is used to calculate the starting IP using the IP address and the mask, and use the starting IP, the current subnet and the distribution IP number of all subnets before the current subnet sequence, Calculate the broadcast address of the current subnet; 开始地址计算模块,用于判断当前子网的次序是否为1,如果是,则当前子网的开始地址等于所述IP地址,如果否,则当前子网的开始地址等于前一个子网的广播地址加1;The starting address calculation module is used to judge whether the order of the current subnet is 1. If so, the starting address of the current subnet is equal to the IP address. If not, the starting address of the current subnet is equal to the broadcast of the previous subnet. add 1 to the address; 其中,划分子网数用n表示。Among them, the number of divided subnets is represented by n.
CN201710854749.6A 2017-09-20 2017-09-20 A kind of network address segment division 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 A kind of network address segment division method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710854749.6A CN107465771B (en) 2017-09-20 2017-09-20 A kind of network address segment division 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 A kind of network address segment division method and system

Country Status (1)

Country Link
CN (1) CN107465771B (en)

Families Citing this family (6)

* 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
CN118175140B (en) * 2024-05-13 2024-09-13 中移(苏州)软件技术有限公司 Network address allocation method and device 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) A kind of network address segment division method and system
CN107431637B (en) Network service deployment method and device
CN105809323A (en) Task allocation method and system
CN109447820B (en) Data processing method, device, computer equipment and storage medium
CN108307318B (en) User information acquisition method and device and electronic equipment
US20190182341A1 (en) Global provisioning of millions of users with deployment units
CN111200665B (en) User source tracing method and device and computer readable storage medium
CN112967032B (en) Sales bill of materials management method, system, equipment and storage medium
CN104317738B (en) A Method of Incremental Computing Based on MapReduce
CN106204122B (en) Contact point value measurement method and device
CN107885913B (en) Feasibility judgment method and device for radiation field shielding scheme, computer equipment and storage medium
CN110334103B (en) Recommendation service updating method, providing device, access device and recommendation system
CN105430115B (en) A kind of method, apparatus and calculating equipment in the optimization library IP
CN105761713B (en) Chord transformation processing method and device
CN113689074B (en) Client distribution method, device, equipment and medium
CN104735103A (en) Method and device for managing distributed data and method and device for receiving distributed data
CN105100117A (en) Method and device for accessing combined services
CN109783777A (en) List deriving method, device, readable storage medium storing program for executing and electronic equipment
CN110401709A (en) Processing method, device and the storage medium of session in a kind of instant messaging application
CN111026929B (en) Text approval method, device and storage medium
CN113472551B (en) Network flow prediction method, device and storage medium
CN106600327A (en) iOS advertisement unique identifier generation method
CN109858723A (en) A method of integrating the service of more service providers
CN108446125A (en) Application program installation kit generation method, device, equipment and system
CN111836274B (en) Service processing method and device

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