This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Are there any jar to check whether two ip address is in same network segment

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"IP_A" and its prefix length of subnet mask is known , and there is a "IP_B" , I want to check whether "IP_A" is in the same netwoek segment with "IP_B", is there any jar JAVA has provided?

If there isn't any jar could finish the job.I have to finish by myself.

My way is like this. First make a binary notation according to the prefix length called "subnet" and then use the "subnet" to do AND operation with the "IP_A" ,then get the "network number" , do the same thing using "IP_B" and "subnet" and get another network number(network number2).
Finally compare the "network number" and the "network number2" to see whether they're the same.

If I merely know the prefix length of subnet mask , how can I get the subnet mask in binary or demical notation?
Thanks a lot!
jun
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try Apache Commons Net library's SubnetUtils and SubnetInfo.isInRange()
 
Marshal
Posts: 78708
374
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not a "beginning" question. Moving.
 
ken jun
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Karthik Shiraly wrote:Try Apache Commons Net library's SubnetUtils and SubnetInfo.isInRange()



Thanks a lot I will try it after class.... going to have class

Could you give me some tips helping me finish this?
" If I merely know the prefix length of subnet mask , how can I get the subnet mask in binary or demical notation? "
 
ken jun
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Not a "beginning" question. Moving.



ah...I am sorry , how careless I was.. anyway thanks
 
Campbell Ritchie
Marshal
Posts: 78708
374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem ; many people do that. Apology accepted.
 
ken jun
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:No problem ; many people do that. Apology accepted.



you are so nice .
By the way Could you give me some tips helping me finish this?
" If I merely know the prefix length of subnet mask , how can I get the subnet mask in binary or demical notation? "
 
ken jun
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ken jun wrote:

Campbell Ritchie wrote:No problem ; many people do that. Apology accepted.



you are so nice .
By the way Could you give me some tips helping me finish this?
" If I merely know the prefix length of subnet mask , how can I get the subnet mask in binary or demical notation? "



how foolish I was ,the jar SubnetUtils has a constainer that using CIDR, it means I can just know the ip and the prefix.
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic