项目上有个需求,要求计算cidr,网上perl和php,python很多,java的很少,呵呵,虽说懂点那个,毕竟还是会这个。
所以查了一下:
https://foo.cs.ucsb.edu/cs56/issues/0000414/IP_Calculator/browse/src/edu/ucsb/cs56/w12/choice/issue0000414/IPCalc.java
http://apache-mina.10907.n7.nabble.com/Converting-an-IP-range-to-CIDR-notation-td29392.html
这里有个支持IPV6的:
http://stackoverflow.com/questions/2942299/converting-cidr-address-to-subnet-mask-and-network-address
http://social.technet.microsoft.com/Forums/en-US/beacba14-b313-4d6c-9f7f-ff9d98b8331b/what-is-the-calculation-for-converting-an-ip-address-to-cidr
来几个对比工具:
http://www.webboar.com/tools/ip2cidr/
http://www.magic-cookie.co.uk/iplist.html
http://share-foo.com/SubnetCalc.php
http://www.ipaddressguide.com/cidr#range
文章很多:
http://stackoverflow.com/questions/5020317/in-java-given-an-ip-address-range-return-the-minimum-list-of-cidr-blocks-that
http://www.codeproject.com/Tips/49522/Convert-CIDR-formatted-string-to-its-IPAddress-Ran
http://stackoverflow.com/questions/18608165/cidr-notation-and-ip-range-validator-pattern
http://www.daniweb.com/software-development/c/code/387352/given-a-cidr-notation-print-the-range-of-the-possible-ip-addresses
http://gallery.technet.microsoft.com/scriptcenter/List-the-IP-addresses-in-a-60c5bb6b
http://stackoverflow.com/questions/6708272/list-of-ip-addresses-in-python-to-a-list-of-cidr
http://www.java3z.com/cwbwebhome/article/article5/51078.html?id=2609
http://serverfault.com/questions/12854/cidr-for-dummies
http://www.softpanorama.org/Net/Internet_layer/subnetting_and_cidr.shtml
http://wenku.baidu.com/view/40d44aebb8f67c1cfad6b846.html
http://www.luyouqiwang.net/a/pics/2013/0617/1162.html
http://tw.myblog.yahoo.com/wawayu0511/article?mid=1446&prev=1449&next=-1
http://backdrift.org/ip-subnet-netmask-cidr-cheat-sheet
http://doc.m0n0.ch/quickstartpc/intro-CIDR.html
http://www.pudn.com/downloads148/sourcecode/java/detail641420.html